diff --git a/src/components/Diagnosis/ConditionVerificationStatusMenu.tsx b/src/components/Diagnosis/ConditionVerificationStatusMenu.tsx index 608e2d06dff..6a06d3d07f3 100644 --- a/src/components/Diagnosis/ConditionVerificationStatusMenu.tsx +++ b/src/components/Diagnosis/ConditionVerificationStatusMenu.tsx @@ -1,3 +1,4 @@ +import { useState } from "react"; import { useTranslation } from "react-i18next"; import CareIcon from "@/CAREUI/icons/CareIcon"; @@ -14,6 +15,7 @@ import { classNames } from "@/Utils/utils"; interface Props { disabled?: boolean; value?: T; + defaultValue?: T; // Added default value support placeholder?: string; options: readonly T[]; onSelect: (option: T) => void; @@ -26,48 +28,69 @@ export default function ConditionVerificationStatusMenu< T extends ConditionVerificationStatus, >(props: Props) { const { t } = useTranslation(); + const [searchTerm, setSearchTerm] = useState(""); + const [selectedValue, setSelectedValue] = useState(props.defaultValue); + + const filteredOptions = props.options.filter((status) => + t(status).toLowerCase().includes(searchTerm.toLowerCase()) + ); return ( <> - {props.options.map((status) => ( + setSearchTerm(e.target.value)} + /> + + {filteredOptions.map((status) => ( props.onSelect(status)} + onClick={() => { + setSelectedValue(status); + props.onSelect(status); + }} icon={ } className="group" - disabled={props.value === status} + disabled={selectedValue === status} >
- + {InactiveConditionVerificationStatuses.includes( status as (typeof InactiveConditionVerificationStatuses)[number], ) - ? "Remove as " + ? t("remove_as") : ""} {t(status)} @@ -78,11 +101,14 @@ export default function ConditionVerificationStatusMenu< ))} - {props.value && props.onRemove && ( + {selectedValue && props.onRemove && ( props.onRemove?.()} + onClick={() => { + setSelectedValue(undefined); + props.onRemove?.(); + }} icon={} > {t("remove")} @@ -96,22 +122,18 @@ export default function ConditionVerificationStatusMenu< export const StatusStyle = { unconfirmed: { variant: "warning", - // icon: "l-question", colors: "text-yellow-500 border-yellow-500", }, provisional: { variant: "warning", - // icon: "l-question", colors: "text-secondary-800 border-secondary-800", }, differential: { variant: "warning", - // icon: "l-question", colors: "text-secondary-800 border-secondary-800", }, confirmed: { variant: "primary", - // icon: "l-check", colors: "text-primary-500 border-primary-500", }, refuted: { @@ -121,7 +143,6 @@ export const StatusStyle = { }, "entered-in-error": { variant: "danger", - // icon: "l-ban", colors: "text-danger-500 border-danger-500", }, } as const;