diff --git a/apps/jonogon-web-next/src/app/petition/draft/_page.tsx b/apps/jonogon-web-next/src/app/petition/draft/_page.tsx index 9dbaf96f..52b9067b 100644 --- a/apps/jonogon-web-next/src/app/petition/draft/_page.tsx +++ b/apps/jonogon-web-next/src/app/petition/draft/_page.tsx @@ -11,16 +11,17 @@ import {Input} from '@/components/ui/input'; import {Button} from '@/components/ui/button'; import {AutoCompleteInput} from '@/components/ui/input-autocomplete'; import {petitionLocations, petitionTargets} from '@/lib/constants'; -import { useAuthState } from '@/auth/token-manager'; +import {useAuthState} from '@/auth/token-manager'; import SimilarPetitionsSuggestions from '@/components/custom/SimilarPetitionsSuggestions'; +import RegulationsModal from '@/components/custom/RegulationsModal'; function storeDraftPetition(data: T) { localStorage.setItem('draft-petition', JSON.stringify(data)); } export default function EditLoggedOutDraftPetition() { - const isAuthenticated = useAuthState() + const isAuthenticated = useAuthState(); const [isLoading, setIsLoading] = useState(false); const [showSimilarPetitions, setShowSimilarPetitions] = useState(true); @@ -57,14 +58,14 @@ export default function EditLoggedOutDraftPetition() { const redirectToLogin = () => { setIsLoading(true); - - const hasPetitionDraftData = Object.values(petitionData).some((v) => v && v.length > 0); + const hasPetitionDraftData = Object.values(petitionData).some( + (v) => v && v.length > 0, + ); if (hasPetitionDraftData) { storeDraftPetition(petitionData); } - router.push(`/login?next=${encodeURIComponent('/petition/draft')}`); - } + }; useEffect(() => { if (isAuthenticated) { @@ -102,8 +103,8 @@ export default function EditLoggedOutDraftPetition() { {showSimilarPetitions && ( setShowSimilarPetitions(false)} + title={petitionData.title ?? ''} + onClose={() => setShowSimilarPetitions(false)} /> )}
@@ -217,6 +218,7 @@ export default function EditLoggedOutDraftPetition() {
+ router.push('/')} /> ); } diff --git a/apps/jonogon-web-next/src/app/petitions/[id]/edit/page.tsx b/apps/jonogon-web-next/src/app/petitions/[id]/edit/page.tsx index c33f7e91..caf9789e 100644 --- a/apps/jonogon-web-next/src/app/petitions/[id]/edit/page.tsx +++ b/apps/jonogon-web-next/src/app/petitions/[id]/edit/page.tsx @@ -30,6 +30,7 @@ import { } from '@/components/ui/alert-dialog'; import PetitionFileUploader from '@/components/custom/PetitionFileUploader'; import SimilarPetitionsSuggestions from '@/components/custom/SimilarPetitionsSuggestions'; +import RegulationsModal from '@/components/custom/RegulationsModal'; // import {AutoCompleteInput} from '@/components/ui/input-autocomplete'; // import {petitionLocations, petitionTargets} from '@/lib/constants'; @@ -45,9 +46,10 @@ export default function EditPetition() { const [showSimilarPetitions, setShowSimilarPetitions] = useState(true); - const {data: selfResponse, isLoading: isLoadingSelf} = trpc.users.getSelf.useQuery(undefined, { - enabled: !!isAuthenticated, - }); + const {data: selfResponse, isLoading: isLoadingSelf} = + trpc.users.getSelf.useQuery(undefined, { + enabled: !!isAuthenticated, + }); const freshValue = params.get('fresh'); @@ -171,7 +173,10 @@ export default function EditPetition() { }, }); - const handleAttachmentUpload = (attachment: { type: 'image' | 'file', file: File }) => { + const handleAttachmentUpload = (attachment: { + type: 'image' | 'file'; + file: File; + }) => { uploadAttachment({ type: attachment.type, file: attachment.file, @@ -289,8 +294,8 @@ export default function EditPetition() { {freshValue && showSimilarPetitions && ( setShowSimilarPetitions(false)} + title={petitionData.title ?? ''} + onClose={() => setShowSimilarPetitions(false)} /> )}
@@ -338,8 +343,12 @@ export default function EditPetition() { banglaLabel="ছবি" fileType="image" files={petitionRemoteData?.data?.attachments || []} - onAttachmentsChange={(attachment) => handleAttachmentUpload(attachment)} - removeAttachment={(attachment) => removeAttachment(attachment)} + onAttachmentsChange={(attachment) => + handleAttachmentUpload(attachment) + } + removeAttachment={(attachment) => + removeAttachment(attachment) + } petitionId={Number(petition_id)} /> handleAttachmentUpload(attachment)} - removeAttachment={(attachment) => removeAttachment(attachment)} + onAttachmentsChange={(attachment) => + handleAttachmentUpload(attachment) + } + removeAttachment={(attachment) => + removeAttachment(attachment) + } petitionId={Number(petition_id)} />
@@ -384,6 +397,14 @@ export default function EditPetition() {
+ { + if (freshValue) { + router.push('/'); + } + }} + /> ); } diff --git a/apps/jonogon-web-next/src/components/custom/RegulationsModal.tsx b/apps/jonogon-web-next/src/components/custom/RegulationsModal.tsx new file mode 100644 index 00000000..8ff508f1 --- /dev/null +++ b/apps/jonogon-web-next/src/components/custom/RegulationsModal.tsx @@ -0,0 +1,120 @@ +import React, {useState, useEffect} from 'react'; +import { + Dialog, + DialogContent, + DialogDescription, + DialogHeader, + DialogTitle, +} from '@/components/ui/dialog'; +import {Button} from '@/components/ui/button'; + +interface RegulationsModalProps { + onClose?: () => void; + onAccept?: () => void; + shouldShow?: boolean; +} + +const RegulationsModal: React.FC = ({ + onClose, + onAccept, + shouldShow = true, +}: RegulationsModalProps) => { + const [isOpen, setIsOpen] = useState(shouldShow); + + useEffect(() => { + setIsOpen(shouldShow); + }, [shouldShow]); + + const handleClose = () => { + setIsOpen(false); + onClose?.(); + }; + + const handleAccept = () => { + setIsOpen(false); + onAccept?.(); + }; + + return ( + + +
+ + + Rules & regulations for filing দাবিs + + +
+ {[ + { + title: 'No bullying', + description: + 'Keep interactions constructive. Intimidation or harassment of any kind is not tolerated.', + }, + { + title: 'No Hate Speech', + description: + 'Express your views respectfully. Language that promotes hatred against individuals or groups is prohibited.', + }, + { + title: 'No Discrimination', + description: + 'Treat everyone equally. Discrimination based on race, gender, religion, or any other characteristic is unacceptable.', + }, + { + title: 'No Profanity', + description: + 'Maintain a civil tone. Use of offensive language or explicit content is not allowed.', + }, + { + title: 'No Racism', + description: + 'Embrace diversity. Racist comments or content promoting racial superiority are strictly forbidden.', + }, + ].map((rule, index) => ( +
+
+ {index + 1} +
+
+

+ {rule.title} +

+ + {rule.description} + +
+
+ ))} +
+
+ +

+ By accepting our rules and regulations you're + accepting our{' '} + + Terms & Conditions + {' '} + for behaving and acting accordingly in our platform. +

+
+
+
+
+ ); +}; + +export default RegulationsModal; diff --git a/apps/jonogon-web-next/src/components/ui/dialog.tsx b/apps/jonogon-web-next/src/components/ui/dialog.tsx index a89b95d4..0f1c72d9 100644 --- a/apps/jonogon-web-next/src/components/ui/dialog.tsx +++ b/apps/jonogon-web-next/src/components/ui/dialog.tsx @@ -29,8 +29,8 @@ DialogOverlay.displayName = DialogPrimitive.Overlay.displayName; const DialogContent = React.forwardRef< React.ElementRef, - React.ComponentPropsWithoutRef ->(({className, children, ...props}, ref) => ( + React.ComponentPropsWithoutRef & { closeButton?: boolean } +>(({ className, children, closeButton = true, ...props }, ref) => ( {children} - - - Close - + {closeButton && ( + + + Close + + )} ));