Skip to content

Commit

Permalink
fixed discharge patients list not using state mgmt provided by useFil…
Browse files Browse the repository at this point in the history
…ters for pagination
  • Loading branch information
rithviknishad committed Oct 15, 2024
1 parent 31e14e4 commit 32bb8eb
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 10 deletions.
9 changes: 8 additions & 1 deletion src/CAREUI/misc/PaginatedList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ function useContextualized<TItem>() {
interface Props<TItem> extends QueryOptions<PaginatedResponse<TItem>> {
route: QueryRoute<PaginatedResponse<TItem>>;
perPage?: number;
onPageChange?: (page: number) => void;
queryCB?: (
query: ReturnType<typeof useQuery<PaginatedResponse<TItem>>>,
) => void;
Expand All @@ -49,7 +50,13 @@ export default function PaginatedList<TItem extends object>({
queryCB,
...queryOptions
}: Props<TItem>) {
const [currentPage, setPage] = useState(1);
const [currentPage, _setPage] = useState(1);

const setPage = (page: number) => {
_setPage(page);
queryOptions.onPageChange?.(page);
};

const query = useQuery(route, {
...queryOptions,
query: {
Expand Down
20 changes: 11 additions & 9 deletions src/Components/Facility/DischargedPatientsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,15 +47,16 @@ const DischargedPatientsList = ({
pathParams: { id: facility_external_id },
});

const { qParams, updateQuery, advancedFilter, FilterBadges } = useFilters({
limit: 12,
cacheBlacklist: [
"name",
"patient_no",
"phone_number",
"emergency_phone_number",
],
});
const { qParams, updateQuery, advancedFilter, FilterBadges, updatePage } =
useFilters({
limit: 12,
cacheBlacklist: [
"name",
"patient_no",
"phone_number",
"emergency_phone_number",
],
});

useEffect(() => {
if (!qParams.phone_number && phone_number.length >= 13) {
Expand Down Expand Up @@ -438,6 +439,7 @@ const DischargedPatientsList = ({
setCount(query.data?.count || 0);
console.log(query.data?.count);
}}
onPageChange={updatePage}
>
{() => (
<div className="flex flex-col gap-4">
Expand Down

0 comments on commit 32bb8eb

Please sign in to comment.