Skip to content

Commit

Permalink
set page items limit to RESULT_PER_PAGE_LIMIT
Browse files Browse the repository at this point in the history
  • Loading branch information
rajku-dev committed Feb 3, 2025
1 parent e205f00 commit febc096
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Separator } from "@/components/ui/separator";
import PaginationComponent from "@/components/Common/Pagination";
import { CardListSkeleton } from "@/components/Common/SkeletonLoading";

import { RESULTS_PER_PAGE_LIMIT } from "@/common/constants";

import routes from "@/Utils/request/api";
import query from "@/Utils/request/query";
import { formatDateTime, properCase } from "@/Utils/utils";
Expand Down Expand Up @@ -287,8 +289,8 @@ export default function QuestionnaireResponsesList({
pathParams: { patientId },
queryParams: {
encounter: encounter?.id,
limit: 15,
offset: ((qParams.page ?? 1) - 1) * 15,
limit: RESULTS_PER_PAGE_LIMIT,
offset: ((qParams.page ?? 1) - 1) * RESULTS_PER_PAGE_LIMIT,
},
}),
});
Expand All @@ -298,7 +300,7 @@ export default function QuestionnaireResponsesList({
<div className="max-w-full">
{isLoading ? (
<div className="grid gap-5">
<CardListSkeleton count={15} />
<CardListSkeleton count={RESULTS_PER_PAGE_LIMIT} />
</div>
) : (
<div>
Expand All @@ -321,14 +323,15 @@ export default function QuestionnaireResponsesList({
<div
className={cn(
"flex w-full justify-center",
(questionnarieResponses?.count ?? 0) > 15
(questionnarieResponses?.count ?? 0) >
RESULTS_PER_PAGE_LIMIT
? "visible"
: "invisible",
)}
>
<PaginationComponent
cPage={qParams.page ?? 1}
defaultPerPage={15}
defaultPerPage={RESULTS_PER_PAGE_LIMIT}
data={{ totalCount: questionnarieResponses?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
/>
Expand Down
13 changes: 8 additions & 5 deletions src/components/Patient/PatientDetailsTab/patientUpdates.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import { Card } from "@/components/ui/card";
import PaginationComponent from "@/components/Common/Pagination";
import { CardListSkeleton } from "@/components/Common/SkeletonLoading";

import { RESULTS_PER_PAGE_LIMIT } from "@/common/constants";

import routes from "@/Utils/request/api";
import query from "@/Utils/request/query";
import { formatDateTime, properCase } from "@/Utils/utils";
Expand All @@ -29,8 +31,8 @@ export const Updates = (props: PatientProps) => {
queryKey: ["patientUpdates", patientId, qParams],
queryFn: query(routes.getQuestionnaireResponses, {
queryParams: {
limit: 7,
offset: ((qParams.page ?? 1) - 1) * 7,
limit: RESULTS_PER_PAGE_LIMIT,
offset: ((qParams.page ?? 1) - 1) * RESULTS_PER_PAGE_LIMIT,
},
pathParams: { patientId },
}),
Expand All @@ -53,7 +55,7 @@ export const Updates = (props: PatientProps) => {
<div className="flex flex-col gap-4">
{isLoading ? (
<div className="grid gap-4">
<CardListSkeleton count={7} />
<CardListSkeleton count={RESULTS_PER_PAGE_LIMIT} />
</div>
) : (
<div>
Expand Down Expand Up @@ -111,14 +113,15 @@ export const Updates = (props: PatientProps) => {
<div
className={cn(
"flex w-full justify-center",
(patientUpdatesData?.count ?? 0) > 7
(patientUpdatesData?.count ?? 0) >
RESULTS_PER_PAGE_LIMIT
? "visible"
: "invisible",
)}
>
<PaginationComponent
cPage={qParams.page ?? 1}
defaultPerPage={7}
defaultPerPage={RESULTS_PER_PAGE_LIMIT}
data={{ totalCount: patientUpdatesData?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
/>
Expand Down
12 changes: 7 additions & 5 deletions src/components/Resource/ResourceCommentSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ import { Avatar } from "@/components/Common/Avatar";
import PaginationComponent from "@/components/Common/Pagination";
import { CardListSkeleton } from "@/components/Common/SkeletonLoading";

import { RESULTS_PER_PAGE_LIMIT } from "@/common/constants";

import routes from "@/Utils/request/api";
import mutate from "@/Utils/request/mutate";
import query from "@/Utils/request/query";
Expand All @@ -30,8 +32,8 @@ const CommentSection = (props: { id: string }) => {
queryKey: ["resourceComments", id, qParams],
queryFn: query(routes.getResourceComments, {
queryParams: {
limit: 15,
offset: ((qParams.page ?? 1) - 1) * 15,
limit: RESULTS_PER_PAGE_LIMIT,
offset: ((qParams.page ?? 1) - 1) * RESULTS_PER_PAGE_LIMIT,
},
pathParams: { id },
}),
Expand Down Expand Up @@ -78,7 +80,7 @@ const CommentSection = (props: { id: string }) => {
{isLoading ? (
<div>
<div className="grid gap-5">
<CardListSkeleton count={15} />
<CardListSkeleton count={RESULTS_PER_PAGE_LIMIT} />
</div>
</div>
) : (
Expand All @@ -98,14 +100,14 @@ const CommentSection = (props: { id: string }) => {
<div
className={cn(
"flex w-full justify-center",
(resourceComments?.count ?? 0) > 15
(resourceComments?.count ?? 0) > RESULTS_PER_PAGE_LIMIT
? "visible"
: "invisible",
)}
>
<PaginationComponent
cPage={qParams.page ?? 1}
defaultPerPage={15}
defaultPerPage={RESULTS_PER_PAGE_LIMIT}
data={{ totalCount: resourceComments?.count ?? 0 }}
onChange={(page) => setQueryParams({ page })}
/>
Expand Down

0 comments on commit febc096

Please sign in to comment.