Skip to content

Commit

Permalink
Merge pull request #1251 from innovationacademy-kr/fe/dev/fix_totalPage/
Browse files Browse the repository at this point in the history
#1241

[COMMON] FIX: totalPage 를 totalLength 로 수정 #1241
  • Loading branch information
seong-hui authored Jul 19, 2023
2 parents e787fdb + e03dd47 commit fe5e55d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AdminCabinetLentLog from "@/components/LentLog/AdminCabinetLentLog";
import { LentLogResponseType } from "@/types/dto/lent.dto";
import { axiosGetCabinetLentLog } from "@/api/axios/axios.custom";
import useMenu from "@/hooks/useMenu";
import { getTotalPage } from "@/utils/dateUtils";
import { STATUS_400_BAD_REQUEST } from "@/constants/StatusCode";

const AdminCabinetLentLogContainer = () => {
Expand All @@ -17,7 +18,7 @@ const AdminCabinetLentLogContainer = () => {
async function getData(page: number) {
try {
const result = await axiosGetCabinetLentLog(currentCabinetId, page);
setTotalPage(result.data.totalPage);
setTotalPage(getTotalPage(result.data.totalLength, 10));
setLogs(result.data.result);
} catch {
setLogs(STATUS_400_BAD_REQUEST);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import AdminUserLentLog from "@/components/LentLog/AdminUserLentLog";
import { LentLogResponseType } from "@/types/dto/lent.dto";
import { axiosGetUserLentLog } from "@/api/axios/axios.custom";
import useMenu from "@/hooks/useMenu";
import { getTotalPage } from "@/utils/dateUtils";
import { STATUS_400_BAD_REQUEST } from "@/constants/StatusCode";


Expand All @@ -18,7 +19,7 @@ const AdminUserLentLogContainer = () => {
async function getData(page: number) {
try {
const result = await axiosGetUserLentLog(targetUserInfo.userId, page);
setTotalPage(result.data.totalPage);
setTotalPage(getTotalPage(result.data.totalLength, 10));
setLogs(result.data.result);
} catch {
setLogs(STATUS_400_BAD_REQUEST);
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/components/LentLog/LentLog.container.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import LentLog from "@/components/LentLog/LentLog";
import { LentLogResponseType } from "@/types/dto/lent.dto";
import { axiosMyLentLog } from "@/api/axios/axios.custom";
import useMenu from "@/hooks/useMenu";
import { getTotalPage } from "@/utils/dateUtils";
import { STATUS_400_BAD_REQUEST } from "@/constants/StatusCode";


Expand All @@ -14,7 +15,7 @@ const LentLogContainer = () => {
async function getData(page: number) {
try {
const result = await axiosMyLentLog(0);
setTotalPage(Math.floor(result.data.total_length / 10) + 1);
setTotalPage(getTotalPage(result.data.totalLength, 10));
setLogs(result.data.result);
} catch {
setLogs(STATUS_400_BAD_REQUEST);
Expand Down
5 changes: 3 additions & 2 deletions frontend/src/pages/admin/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
axiosSearchByCabinetNum,
axiosSearchDetailByIntraId,
} from "@/api/axios/axios.custom";
import { getTotalPage } from "@/utils/dateUtils";

interface ISearchDetail {
name: string;
Expand Down Expand Up @@ -61,7 +62,7 @@ const SearchPage = () => {
currentPage.current
);
setSearchListByIntraId(searchResult.data.result ?? []);
setTotalSearchList(searchResult.data.totalPage ?? 0);
setTotalSearchList(getTotalPage(searchResult.data.totalLength, 10) ?? 0);
setTimeout(() => {
setIsLoading(false);
}, 500);
Expand All @@ -80,7 +81,7 @@ const SearchPage = () => {
);
}
setSearchListByNum(searchResultData ?? []);
setTotalSearchList(searchResult.data.totalPage ?? 0);
setTotalSearchList(getTotalPage(searchResult.data.totalLength, 10) ?? 0);
setTimeout(() => {
setIsLoading(false);
}, 500);
Expand Down
4 changes: 4 additions & 0 deletions frontend/src/utils/dateUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ export const getExpireDateString = (

return formatDate(expireDate);
};

export const getTotalPage = (totalLength: number, size: number) => {
return Math.ceil(totalLength / size);
};

0 comments on commit fe5e55d

Please sign in to comment.