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

Landing Page and Facilities List: Search #9621

Closed
Closed
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
35 changes: 13 additions & 22 deletions src/pages/Facility/FacilitiesPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import { Link, navigate } from "raviger";
import { useEffect } from "react";
import { useTranslation } from "react-i18next";

import CareIcon from "@/CAREUI/icons/CareIcon";

import { Button } from "@/components/ui/button";
import { Card } from "@/components/ui/card";

Expand All @@ -30,10 +28,9 @@ const STATE_GEO_ID = careConfig.keralaGeoId;

export function FacilitiesPage() {
const { mainLogo } = careConfig;
const { qParams, updateQuery, advancedFilter, clearSearch, Pagination } =
useFilters({
limit: RESULTS_PER_PAGE_LIMIT,
});
const { qParams, updateQuery, clearSearch, Pagination } = useFilters({
limit: RESULTS_PER_PAGE_LIMIT,
});

const tokenData: TokenData = JSON.parse(
localStorage.getItem(CarePatientTokenKey) || "{}",
Expand All @@ -47,30 +44,24 @@ export function FacilitiesPage() {
queryKey: ["facilities", qParams],
queryFn: query(routes.getAllFacilities, {
queryParams: {
geo_organization: qParams.geo_organization || STATE_GEO_ID,
geo_organization: qParams.geo_organization,
name: qParams.search ? qParams.search : undefined,
page: qParams.page,
limit: RESULTS_PER_PAGE_LIMIT,
offset: (qParams.page - 1) * RESULTS_PER_PAGE_LIMIT,
...advancedFilter.filter,
},
}),
enabled: !!qParams.geo_organization || !!STATE_GEO_ID,
enabled: !!qParams.geo_organization,
});

useEffect(() => {
if (qParams.district) {
updateQuery({ geo_organization: qParams.district });
if (qParams.geo_organization) {
updateQuery({ geo_organization: qParams.geo_organization });
} else {
updateQuery({ geo_organization: STATE_GEO_ID });
}
}, [qParams.district, STATE_GEO_ID]);
}, [qParams.geo_organization, qParams.search]);

/* useEffect(() => {
if (!qParams.district && qParams.local_body) {
advancedFilter.removeFilters(["local_body"]);
}
}, [advancedFilter, qParams]);
*/
const GetLoginHeader = () => {
if (
tokenData &&
Expand Down Expand Up @@ -120,9 +111,9 @@ export function FacilitiesPage() {
id="facility-search"
options={[
{
key: "facility_district_pincode",
key: "facility_district",
type: "text" as const,
placeholder: t("facility_search_placeholder_pincode"),
placeholder: t("facility_search_placeholder"),
value: qParams.search || "",
shortcutKey: "f",
},
Expand All @@ -132,14 +123,14 @@ export function FacilitiesPage() {
clearSearch={clearSearch}
enableOptionButtons={false}
/>
<Button
{/* <Button
variant="white"
onClick={() => advancedFilter.setShow(true)}
className="flex items-center gap-2 p-5"
>
<CareIcon icon="l-filter" className="h-4 w-4 text-gray-400" />
<span className="text-sm font-medium text-gray-400">Filter</span>
</Button>
</Button> */}
</div>
{/* <FilterBadges
badges={({ badge, value }) => [
Expand Down
2 changes: 1 addition & 1 deletion src/pages/Landing/LandingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export function LandingPage() {
const handleSearch = () => {
const params = new URLSearchParams();
if (selectedDistrict) {
params.append("district", selectedDistrict.id.toString());
params.append("geo_organization", selectedDistrict.id.toString());
}
navigate(`/facilities?${params.toString()}`);
};
Expand Down
Loading