From 4d0a5537b6cbef10b64076907e16eb57ef47533a Mon Sep 17 00:00:00 2001 From: Shaurya Gupta Date: Mon, 2 Dec 2024 23:12:21 +0530 Subject: [PATCH] resolved coderabbitai comments --- src/Utils/request/api.tsx | 7 +++++-- src/Utils/request/types.ts | 3 +++ src/components/Common/Pagination.tsx | 6 +++--- src/components/Facility/FacilityStaffList.tsx | 6 ++---- 4 files changed, 13 insertions(+), 9 deletions(-) diff --git a/src/Utils/request/api.tsx b/src/Utils/request/api.tsx index 40021007773..8018a958757 100644 --- a/src/Utils/request/api.tsx +++ b/src/Utils/request/api.tsx @@ -89,7 +89,10 @@ import { UserModel, } from "@/components/Users/models"; -import { PaginatedResponse } from "@/Utils/request/types"; +import { + DoctorPaginatedResponse, + PaginatedResponse, +} from "@/Utils/request/types"; /** * A fake function that returns an empty object casted to type T @@ -671,7 +674,7 @@ const routes = { listDoctor: { path: "/api/v1/facility/{facilityId}/hospital_doctor/", - TRes: Type>(), + TRes: Type>(), }, getDoctor: { path: "/api/v1/facility/{facilityId}/hospital_doctor/{id}/", diff --git a/src/Utils/request/types.ts b/src/Utils/request/types.ts index be15c4dbe45..aa121557398 100644 --- a/src/Utils/request/types.ts +++ b/src/Utils/request/types.ts @@ -41,5 +41,8 @@ export interface PaginatedResponse { next: string | null; previous: string | null; results: TItem[]; +} + +export interface DoctorPaginatedResponse extends PaginatedResponse { total_doctors: number; } diff --git a/src/components/Common/Pagination.tsx b/src/components/Common/Pagination.tsx index e11da1e8aae..e33200b17b4 100644 --- a/src/components/Common/Pagination.tsx +++ b/src/components/Common/Pagination.tsx @@ -12,7 +12,7 @@ interface PaginationProps { defaultPerPage: number; cPage: number; className?: string; - ScrollToTop?: boolean; + scrollToTop?: boolean; } const Pagination = ({ className = "mx-auto my-4", @@ -20,7 +20,7 @@ const Pagination = ({ onChange, defaultPerPage, cPage, - ScrollToTop = true, + scrollToTop = true, }: PaginationProps) => { const [rowsPerPage, setRowsPerPage] = useState(3); const [currentPage, setCurrentPage] = useState(1); @@ -83,7 +83,7 @@ const Pagination = ({ setCurrentPage(page); onChange(page, rowsPerPage); const pageContainer = window.document.getElementById("pages"); - if (ScrollToTop) { + if (scrollToTop) { pageContainer?.scroll({ top: 0, left: 0, diff --git a/src/components/Facility/FacilityStaffList.tsx b/src/components/Facility/FacilityStaffList.tsx index b9eabbb7eac..5cc67927a4c 100644 --- a/src/components/Facility/FacilityStaffList.tsx +++ b/src/components/Facility/FacilityStaffList.tsx @@ -41,9 +41,7 @@ export const FacilityStaffList = (props: any) => { const handlePageChange = (page: number) => { updatePage(page); const staffCapacityElement = document.getElementById("staff_capacity"); - if (staffCapacityElement) { - staffCapacityElement.scrollIntoView({ behavior: "smooth" }); - } + staffCapacityElement?.scrollIntoView({ behavior: "smooth" }); }; let doctorList: any = null; @@ -133,7 +131,7 @@ export const FacilityStaffList = (props: any) => { cPage={qParams.page} defaultPerPage={resultsPerPage} data={{ totalCount: doctorsList?.count ?? 0 }} - ScrollToTop={false} + scrollToTop={false} onChange={(page: number) => handlePageChange(page)} />