Skip to content

Commit

Permalink
resolved coderabbitai comments
Browse files Browse the repository at this point in the history
  • Loading branch information
shauryag2002 committed Dec 2, 2024
1 parent 2812e9c commit 4d0a553
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 9 deletions.
7 changes: 5 additions & 2 deletions src/Utils/request/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -671,7 +674,7 @@ const routes = {

listDoctor: {
path: "/api/v1/facility/{facilityId}/hospital_doctor/",
TRes: Type<PaginatedResponse<DoctorModal>>(),
TRes: Type<DoctorPaginatedResponse<DoctorModal>>(),
},
getDoctor: {
path: "/api/v1/facility/{facilityId}/hospital_doctor/{id}/",
Expand Down
3 changes: 3 additions & 0 deletions src/Utils/request/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,8 @@ export interface PaginatedResponse<TItem> {
next: string | null;
previous: string | null;
results: TItem[];
}

export interface DoctorPaginatedResponse<T> extends PaginatedResponse<T> {
total_doctors: number;
}
6 changes: 3 additions & 3 deletions src/components/Common/Pagination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ interface PaginationProps {
defaultPerPage: number;
cPage: number;
className?: string;
ScrollToTop?: boolean;
scrollToTop?: boolean;
}
const Pagination = ({
className = "mx-auto my-4",
data,
onChange,
defaultPerPage,
cPage,
ScrollToTop = true,
scrollToTop = true,
}: PaginationProps) => {
const [rowsPerPage, setRowsPerPage] = useState(3);
const [currentPage, setCurrentPage] = useState(1);
Expand Down Expand Up @@ -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,
Expand Down
6 changes: 2 additions & 4 deletions src/components/Facility/FacilityStaffList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)}
/>
</section>
Expand Down

0 comments on commit 4d0a553

Please sign in to comment.