Skip to content

Commit

Permalink
refactor: report api mocking 로직 수정 (#285)
Browse files Browse the repository at this point in the history
  • Loading branch information
soyoung125 authored May 7, 2024
1 parent ecf944c commit 5dc44b1
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
12 changes: 6 additions & 6 deletions src/mocks/handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,21 +357,21 @@ export const handlers = [
);
}),

http.get<MonthScheduleQuery>(`${DOMAIN}/report/month`, async ({ params }) => {
// const user_id = req.url.searchParams.get("user_id");
// const date = req.url.searchParams.get("date");
const { user_id, date } = params;
http.get(`${DOMAIN}/report/month`, async ({ request }) => {
const url = new URL(request.url);
const user_id = url.searchParams.get("user_id");
const date = url.searchParams.get("date");
const schedules = getLocalStorage<Schedule[]>(
LOCAL_STORAGE_KEY_SCHEDULES,
[]
);
const monthSchedules = schedules.filter(
(schedule) =>
schedule.user_id === user_id &&
moment(date).isSame(schedule.start_date, "month")
moment(date).isSameOrAfter(schedule.start_date, "month") &&
moment(date).isSameOrBefore(schedule.end_date, "month")
);
await delay(1000);

if (monthSchedules.length === 0) {
return HttpResponse.json(
{
Expand Down
3 changes: 2 additions & 1 deletion src/pages/reports/Report/Report.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ function Report() {
if (isPending) {
return <>loading</>;
}
if (!report?.date || isError) {

if (!report?.expenditure_this_month || isError) {
return <>소비 데이터가 없습니다.</>;
}

Expand Down

0 comments on commit 5dc44b1

Please sign in to comment.