From 90b4d95dfb7a8f5a926d6a4f1ca1ed4b15e1b5c3 Mon Sep 17 00:00:00 2001 From: wlren Date: Sat, 8 Oct 2022 16:28:08 +0800 Subject: [PATCH] [questions][ui] Add DiscardDraftModal --- .../questions/ContributeQuestionModal.tsx | 153 ++++++++++-------- .../questions/DisacrdDraftModal.tsx | 82 ++++++++++ 2 files changed, 167 insertions(+), 68 deletions(-) create mode 100644 apps/portal/src/components/questions/DisacrdDraftModal.tsx diff --git a/apps/portal/src/components/questions/ContributeQuestionModal.tsx b/apps/portal/src/components/questions/ContributeQuestionModal.tsx index 1da146e8..c878e0a9 100644 --- a/apps/portal/src/components/questions/ContributeQuestionModal.tsx +++ b/apps/portal/src/components/questions/ContributeQuestionModal.tsx @@ -2,6 +2,7 @@ import type { Dispatch, SetStateAction } from 'react'; import { Fragment, useState } from 'react'; import { Dialog, Transition } from '@headlessui/react'; +import DiscardDraftModal from './DisacrdDraftModal'; import Checkbox from './ui-patch/Checkbox'; export type ContributeQuestionModalProps = { @@ -14,83 +15,99 @@ export default function ContributeQuestionModal({ setContributeState, }: ContributeQuestionModalProps) { const [canSubmit, setCanSubmit] = useState(false); - + const [isDiscardOpen, setIsDiscardOpen] = useState(false); const handleCheckSimilarQuestions = (checked: boolean) => { setCanSubmit(checked); }; - return ( - - setContributeState(false)}> - -
- + const handleDiscardDraft = () => { + // eslint-disable-next-line no-console + console.log('discarded draft'); + setContributeState(false); + setIsDiscardOpen(false); + }; + + const handleCancelDiscard = () => { + setIsDiscardOpen(false); + }; -
-
- - -
-
-
- - Question Draft - -
-

- Question Contribution form -

+ return ( +
+ + setContributeState(false)}> + +
+ +
+
+ + +
+
+
+ + Question Draft + +
+

+ Question Contribution form +

+
-
-
-
- -
-
- - +
+
+ +
+
+ + +
-
- - + + +
-
-
-
+
+
+ + ); } diff --git a/apps/portal/src/components/questions/DisacrdDraftModal.tsx b/apps/portal/src/components/questions/DisacrdDraftModal.tsx new file mode 100644 index 00000000..053c7986 --- /dev/null +++ b/apps/portal/src/components/questions/DisacrdDraftModal.tsx @@ -0,0 +1,82 @@ +import { Fragment } from 'react'; +import { Dialog, Transition } from '@headlessui/react'; +import { ExclamationTriangleIcon } from '@heroicons/react/24/outline'; + +export type DiscardDraftModalProps = { + handleCancelDiscard: () => void; + handleDiscardDraft: () => void; + isDiscardOpen: boolean; +}; +export default function DiscardDraftModal({ + isDiscardOpen, + handleCancelDiscard, + handleDiscardDraft, +}: DiscardDraftModalProps) { + return ( + + + +
+ + +
+
+ + +
+
+
+
+ + Discard Question Draft + +
+

+ Are you sure you want to discard the current draft? This + action cannot be undone. +

+
+
+
+
+ + +
+
+
+
+
+
+
+ ); +}