From 9a8c481548544e9ea158f46f5985287ee5b6eb50 Mon Sep 17 00:00:00 2001 From: Shivank Kacker Date: Tue, 3 Sep 2024 22:07:46 +0530 Subject: [PATCH] added onselect to AddICD11DiagnosisProps --- .../ConsultationDiagnosisBuilder/AddICD11Diagnosis.tsx | 9 +++++---- .../ConsultationDiagnosisBuilder.tsx | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/Components/Diagnosis/ConsultationDiagnosisBuilder/AddICD11Diagnosis.tsx b/src/Components/Diagnosis/ConsultationDiagnosisBuilder/AddICD11Diagnosis.tsx index b9459d1c34e..6bc309f5716 100644 --- a/src/Components/Diagnosis/ConsultationDiagnosisBuilder/AddICD11Diagnosis.tsx +++ b/src/Components/Diagnosis/ConsultationDiagnosisBuilder/AddICD11Diagnosis.tsx @@ -18,7 +18,7 @@ interface AddICD11DiagnosisProps { disallowed: ICD11DiagnosisModel[]; disabled?: boolean; prefill?: ICD11DiagnosisModel; - setPrefill?: (prefill?: ICD11DiagnosisModel) => void; + onSelect?: (selected: ICD11DiagnosisModel) => unknown; } export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) { @@ -40,8 +40,6 @@ export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) { useEffect(() => props.prefill && setSelected(props.prefill), [props.prefill]); - useEffect(() => props.setPrefill?.(undefined), [selected]); - const handleAdd = async (status: CreateDiagnosis["verification_status"]) => { if (!selected) return; @@ -70,7 +68,10 @@ export default function AddICD11Diagnosis(props: AddICD11DiagnosisProps) { disabled={props.disabled || adding} placeholder={t("search_icd11_placeholder")} value={selected} - onChange={(e) => setSelected(e.value)} + onChange={(e) => { + setSelected(e.value); + props.onSelect?.(e.value); + }} options={mergeQueryOptions( selected ? [selected] : [], data ?? [], diff --git a/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx b/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx index 9a876b463dc..043654929a8 100644 --- a/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx +++ b/src/Components/Diagnosis/ConsultationDiagnosisBuilder/ConsultationDiagnosisBuilder.tsx @@ -144,7 +144,7 @@ export const EditDiagnosesBuilder = (props: EditDiagnosesProps) => { return false; }} prefill={prefill} - setPrefill={setPrefill} + onSelect={() => setPrefill(undefined)} /> {!!props.suggestions?.length && (