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

Moves Ordering Filter out of Advanced Filters #4622

Merged
merged 2 commits into from
Jan 23, 2023
Merged
Show file tree
Hide file tree
Changes from all 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
40 changes: 36 additions & 4 deletions src/Components/Patient/ManagePatients.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ import {
ADMITTED_TO,
GENDER_TYPES,
PATIENT_CATEGORIES,
PATIENT_FILTER_ORDER,
TELEMEDICINE_ACTIONS,
} from "../../Common/constants";
import { make as SlideOver } from "../Common/SlideOver.gen";
Expand All @@ -35,6 +36,7 @@ import ButtonV2 from "../Common/components/ButtonV2";
import { ExportMenu } from "../Common/Export";
import PhoneNumberFormField from "../Form/FormFields/PhoneNumberFormField";
import { FieldChangeEvent } from "../Form/FormFields/Utils";
import DropdownMenu, { DropdownItem } from "../Common/components/Menu";

const Loading = loadable(() => import("../Common/Loading"));
const PageTitle = loadable(() => import("../Common/PageTitle"));
Expand Down Expand Up @@ -648,7 +650,6 @@ export const PatientManager = () => {
<PageTitle title="Patients" hideBack={true} breadcrumbs={false} />
<div className="flex flex-col gap-2 lg:gap-3 lg:flex-row justify-end">
<ButtonV2
className="flex gap-2 items-center font-semibold"
onClick={() => {
qParams.facility
? navigate(`/facility/${qParams.facility}/patient`)
Expand All @@ -658,8 +659,10 @@ export const PatientManager = () => {
<CareIcon className="care-l-plus text-lg" />
<p>Add Patient Details</p>
</ButtonV2>
<button
className="btn btn-primary-ghost w-full lg:w-fit"
<ButtonV2
ghost
border
className="bg-white"
onClick={() => advancedFilter.setShow(true)}
>
<svg
Expand Down Expand Up @@ -692,7 +695,36 @@ export const PatientManager = () => {
</line>
</svg>
<span>Advanced Filters</span>
</button>
</ButtonV2>
<DropdownMenu
title="Sort by"
variant="secondary"
className="border border-primary-500 bg-white"
icon={<CareIcon className="care-l-sort" />}
>
{PATIENT_FILTER_ORDER.map((ordering) => {
return (
<DropdownItem
key={ordering.text}
onClick={() => updateQuery({ ordering: ordering.text })}
icon={
<CareIcon
className={
ordering.order === "Ascending"
? "care-l-sort-amount-up"
: "care-l-sort-amount-down"
}
/>
}
>
<span>{ordering.desc}</span>
<span className="text-gray-600 text-sm">
{ordering.order}
</span>
</DropdownItem>
);
})}
</DropdownMenu>
<div className="tooltip">
<ExportMenu
disabled={!isExportAllowed}
Expand Down
31 changes: 1 addition & 30 deletions src/Components/Patient/PatientFilterV2.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { useEffect, useCallback } from "react";
import { FacilitySelect } from "../Common/FacilitySelect";
import AutoCompleteAsync from "../Form/AutoCompleteAsync";
import {
PATIENT_FILTER_ORDER,
GENDER_TYPES,
FACILITY_TYPES,
DISEASE_STATUS,
Expand Down Expand Up @@ -56,7 +55,6 @@ export default function PatientFilterV2(props: any) {
created_date_after: filter.created_date_after || null,
modified_date_before: filter.modified_date_before || null,
modified_date_after: filter.modified_date_after || null,
ordering: filter.ordering,
category: filter.category || null,
gender: filter.gender || null,
disease_status: filter.disease_status || null,
Expand Down Expand Up @@ -109,7 +107,6 @@ export default function PatientFilterV2(props: any) {
created_date_after: "",
modified_date_before: "",
modified_date_after: "",
ordering: "",
category: null,
gender: null,
disease_status: null,
Expand Down Expand Up @@ -211,7 +208,6 @@ export default function PatientFilterV2(props: any) {
created_date_after,
modified_date_before,
modified_date_after,
ordering,
category,
gender,
disease_status,
Expand Down Expand Up @@ -298,7 +294,6 @@ export default function PatientFilterV2(props: any) {
moment(last_consultation_discharge_date_after).isValid()
? moment(last_consultation_discharge_date_after).format("YYYY-MM-DD")
: "",
ordering: ordering || "",
category: category || "",
gender: gender || "",
disease_status:
Expand Down Expand Up @@ -364,31 +359,7 @@ export default function PatientFilterV2(props: any) {
closeFilter();
}}
/>
<div className="w-full flex-none pt-20">
<div className="mb-3 text-md flex items-center text-gray-700 gap-2">
<CareIcon className="care-l-sort text-lg" />
<p>Ordering</p>
</div>
<SelectMenuV2
options={PATIENT_FILTER_ORDER}
optionLabel={(o) => o.desc}
optionSelectedLabel={(option) => `${option.desc} (${option.order})`}
optionDescription={(o) => o.order}
optionIcon={(option) => (
<CareIcon
className={`${
option.order === "Ascending"
? "care-l-sort-amount-up"
: "care-l-sort-amount-down"
}`}
/>
)}
value={filterState.ordering || undefined}
optionValue={(o) => o.text}
onChange={(v) => setFilterState({ ...filterState, ordering: v })}
/>
</div>
<div className="text-md my-6 flex items-center text-gray-700 gap-2">
<div className="text-md pt-20 py-6 flex items-center text-gray-700 gap-2">
<CareIcon className="care-l-filter text-lg" />
<p>Filter by</p>
</div>
Expand Down