Skip to content

Commit

Permalink
added onselect to AddICD11DiagnosisProps
Browse files Browse the repository at this point in the history
  • Loading branch information
shivankacker committed Sep 3, 2024
1 parent e4d66cb commit 9a8c481
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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;

Expand Down Expand Up @@ -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 ?? [],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const EditDiagnosesBuilder = (props: EditDiagnosesProps) => {
return false;
}}
prefill={prefill}
setPrefill={setPrefill}
onSelect={() => setPrefill(undefined)}
/>
{!!props.suggestions?.length && (
<div className="mb-4 flex flex-wrap gap-2">
Expand Down

0 comments on commit 9a8c481

Please sign in to comment.