Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

search by typing in symptoms #7551

Merged
merged 21 commits into from
Apr 24, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/Components/Common/SymptomsSelect.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import CareIcon from "../../CAREUI/icons/CareIcon";
import { SYMPTOM_CHOICES } from "../../Common/constants";
import { AutocompleteMutliSelect } from "../Form/FormFields/AutocompleteMultiselect";
import FormField from "../Form/FormFields/FormField";
import {
FormFieldBaseProps,
useFormFieldPropsResolver,
} from "../Form/FormFields/Utils";
import MultiSelectMenuV2 from "../Form/MultiSelectMenuV2";

const ASYMPTOMATIC_ID = 1;

Expand Down Expand Up @@ -69,15 +69,15 @@ export const SymptomsSelect = (props: FormFieldBaseProps<number[]>) => {

return (
<FormField field={field}>
<MultiSelectMenuV2
<AutocompleteMutliSelect
id={field.id}
options={SYMPTOM_CHOICES}
disabled={props.disabled}
placeholder="Select symptoms"
optionLabel={(option) => option.text}
optionValue={(option) => option.id}
value={props.value || []}
optionDescription={getDescription}
value={props.value}
onChange={updateSelection}
/>
</FormField>
Expand Down
27 changes: 20 additions & 7 deletions src/Components/Form/FormFields/AutocompleteMultiselect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import {
MultiSelectOptionChip,
dropdownOptionClassNames,
} from "../MultiSelectMenuV2";
import { useEffect, useState } from "react";
import { ReactNode, useEffect, useState } from "react";
import CareIcon from "../../../CAREUI/icons/CareIcon";
import { Combobox } from "@headlessui/react";
import { DropdownTransition } from "../../Common/components/HelperComponents";
Expand Down Expand Up @@ -47,6 +47,7 @@ type AutocompleteMutliSelectProps<T, V = T> = {
disabled?: boolean | undefined;
value: V[];
placeholder?: string;
optionDescription?: OptionCallback<T, ReactNode>;
optionLabel: OptionCallback<T, string>;
optionValue?: OptionCallback<T, V>;
className?: string;
Expand Down Expand Up @@ -77,6 +78,7 @@ export const AutocompleteMutliSelect = <T, V>(
const label = props.optionLabel(option);
return {
label,
description: props.optionDescription && props.optionDescription(option),
search: label.toLowerCase(),
value: (props.optionValue ? props.optionValue(option) : option) as V,
};
Expand Down Expand Up @@ -114,7 +116,7 @@ export const AutocompleteMutliSelect = <T, V>(
placeholder={
value.length
? `${value.length} item(s) selected`
: props.placeholder || "Select"
: props.placeholder ?? "Select"
}
onChange={(event) => setQuery(event.target.value.toLowerCase())}
autoComplete="off"
Expand Down Expand Up @@ -175,12 +177,23 @@ export const AutocompleteMutliSelect = <T, V>(
value={option}
>
{({ selected }) => (
<div className="flex justify-between">
{option.label}
{selected && (
<CareIcon icon="l-check" className="text-lg" />
<>
<div className="flex justify-between">
{option.label}
{selected && (
<CareIcon icon="l-check" className="text-lg" />
)}
</div>
{option.description && (
<p
className={`font-normal ${
selected ? "text-primary-200" : "text-gray-700"
}`}
>
{option.description}
</p>
)}
</div>
</>
)}
</Combobox.Option>
))}
Expand Down
Loading