From e8ba344ecb8662cdf48df26829c93b0da3677604 Mon Sep 17 00:00:00 2001 From: Jeff Sieu Date: Fri, 21 Oct 2022 12:36:23 +0800 Subject: [PATCH] [questions][ui] updates --- .../questions/card/QuestionCard.tsx | 35 ++- .../questions/card/QuestionListCard.tsx | 2 +- .../forms/CreateQuestionEncounterForm.tsx | 201 +++++++++--------- .../questions/typeahead/ExpandedTypeahead.tsx | 2 +- .../src/utils/questions/RequireAllOrNone.ts | 1 + 5 files changed, 119 insertions(+), 122 deletions(-) create mode 100644 apps/portal/src/utils/questions/RequireAllOrNone.ts diff --git a/apps/portal/src/components/questions/card/QuestionCard.tsx b/apps/portal/src/components/questions/card/QuestionCard.tsx index 55c87957..effe2190 100644 --- a/apps/portal/src/components/questions/card/QuestionCard.tsx +++ b/apps/portal/src/components/questions/card/QuestionCard.tsx @@ -112,17 +112,7 @@ export default function QuestionCard({ const [showReceivedForm, setShowReceivedForm] = useState(false); const { handleDownvote, handleUpvote, vote } = useQuestionVote(questionId); const hoverClass = showHover ? 'hover:bg-slate-50' : ''; - const cardContent = showReceivedForm ? ( - { - setShowReceivedForm(false); - }} - onSubmit={(data) => { - onReceivedSubmit?.(data); - setShowReceivedForm(false); - }} - /> - ) : ( + const cardContent = ( <> {showVoteButtons && ( )} -
+
@@ -150,12 +140,10 @@ export default function QuestionCard({ /> )}
-
-

- {content} -

-
- {(showAnswerStatistics || showReceivedStatistics) && ( +

+ {content} +

+ {!showReceivedForm && (showAnswerStatistics || showReceivedStatistics) && (
{showAnswerStatistics && (
); diff --git a/apps/portal/src/components/questions/card/QuestionListCard.tsx b/apps/portal/src/components/questions/card/QuestionListCard.tsx index 2921a117..d340a2ea 100644 --- a/apps/portal/src/components/questions/card/QuestionListCard.tsx +++ b/apps/portal/src/components/questions/card/QuestionListCard.tsx @@ -21,7 +21,7 @@ export type QuestionListCardProps = Omit< function QuestionListCardWithoutHref(props: QuestionListCardProps) { return ( -
+ )} + {step === 1 && ( +
+ { + setSelectedLocation(location); setStep(step + 1); }} + isLabelHidden={true} + placeholder="Other location" + // eslint-disable-next-line @typescript-eslint/no-empty-function + onQueryChange={() => {}} + onSelect={({ value: location }) => { + setSelectedLocation(location); + }} /> - )} - {step === 3 && ( -
+ )} + {step === 2 && ( +
+ { + setSelectedRole(role); + setStep(step + 1); + }} + placeholder="Other role" + // eslint-disable-next-line @typescript-eslint/no-empty-function + onQueryChange={() => {}} + onSelect={({ value: role }) => { + setSelectedRole(role); }} /> - )} -
+
+ )} + {step === 3 && ( + { + setSelectedDate( + startOfMonth(new Date(value.year, value.month - 1)), + ); + }} + /> + )} + {step < 3 && ( +
); } diff --git a/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx b/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx index 05d34195..b06f49b7 100644 --- a/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx +++ b/apps/portal/src/components/questions/typeahead/ExpandedTypeahead.tsx @@ -1,7 +1,7 @@ import type { ComponentProps } from 'react'; import { Button, Typeahead } from '@tih/ui'; -type RequireAllOrNone = T | { [K in keyof T]?: never }; +import type { RequireAllOrNone } from '~/utils/questions/RequireAllOrNone'; type TypeaheadProps = ComponentProps; type TypeaheadOption = TypeaheadProps['options'][number]; diff --git a/apps/portal/src/utils/questions/RequireAllOrNone.ts b/apps/portal/src/utils/questions/RequireAllOrNone.ts new file mode 100644 index 00000000..82c8b0e5 --- /dev/null +++ b/apps/portal/src/utils/questions/RequireAllOrNone.ts @@ -0,0 +1 @@ +export type RequireAllOrNone = T | { [K in keyof T]?: never };