diff --git a/apps/portal/src/components/questions/ContributeQuestionDialog.tsx b/apps/portal/src/components/questions/ContributeQuestionDialog.tsx index 4115a2db..ed31837d 100644 --- a/apps/portal/src/components/questions/ContributeQuestionDialog.tsx +++ b/apps/portal/src/components/questions/ContributeQuestionDialog.tsx @@ -1,6 +1,6 @@ import { Fragment, useState } from 'react'; import { Dialog, Transition } from '@headlessui/react'; -import { HorizontalDivider } from '@tih/ui'; +import { HorizontalDivider, useToast } from '@tih/ui'; import DiscardDraftDialog from './DiscardDraftDialog'; import type { ContributeQuestionFormProps } from './forms/ContributeQuestionForm'; @@ -21,6 +21,8 @@ export default function ContributeQuestionDialog({ }: ContributeQuestionDialogProps) { const [showDiscardDialog, setShowDiscardDialog] = useState(false); + const { showToast } = useToast(); + const handleDraftDiscard = () => { setShowDiscardDialog(false); onCancel(); @@ -75,6 +77,14 @@ export default function ContributeQuestionDialog({
setShowDiscardDialog(true)} + onSimilarQuestionFound={() => { + onCancel(); + showToast({ + title: + 'Your response has been recorded. Draft discarded.', + variant: 'success', + }); + }} onSubmit={(data) => { onSubmit(data); onCancel(); diff --git a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx index 4d8059e6..b183b012 100644 --- a/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx +++ b/apps/portal/src/components/questions/card/question/BaseQuestionCard.tsx @@ -88,10 +88,12 @@ type ReceivedStatisticsProps = type CreateEncounterProps = | { + createEncounterButtonText: string; onReceivedSubmit: (data: CreateQuestionEncounterData) => void; showCreateEncounterButton: true; } | { + createEncounterButtonText?: never; onReceivedSubmit?: never; showCreateEncounterButton?: false; }; @@ -132,6 +134,7 @@ export default function BaseQuestionCard({ showAnswerStatistics, showReceivedStatistics, showCreateEncounterButton, + createEncounterButtonText, showActionButton, actionButtonLabel, onActionButtonClick, @@ -238,7 +241,7 @@ export default function BaseQuestionCard({