Skip to content

Commit

Permalink
Feature/#212 마일스톤 반려 이유 확인할 수 있도록 수정 (#213)
Browse files Browse the repository at this point in the history
* refactor: error message class 명으로 수정

#212

* feat: 마일스톤 불러오기 에러 날 경우, 로그아웃 페이지으로 이동

#212

* feat: 마일스톤 불러오기 에러 헨들링 추가할 수있도록 수정

#212

* feat: 페이지로 들어갈 경우, 반려 이유 확인할 수 있도록 수정

#212
  • Loading branch information
llddang authored Sep 20, 2024
1 parent 6511884 commit 6d8fe26
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 7 deletions.
6 changes: 6 additions & 0 deletions frontend/src/app/admin/milestone/list/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,12 @@ const Page = async ({ params: { slug } }: MilestoneHistoryDetailPageProps) => {
<span className="w-[8em]">승인 상태</span>
<span className="flex-grow">{convertMilestoneHistoryStatus(history.status)}</span>
</p>
{history.rejectReason && (
<p className="flex">
<span className="w-[8em]">반려 이유</span>
<span className="flex-grow">{history.rejectReason}</span>
</p>
)}
<MilestoneHistoryStatusChangeButton historyId={history.id} status={history.status} />
</div>
</div>
Expand Down
9 changes: 8 additions & 1 deletion frontend/src/app/admin/milestone/list/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ import MilestoneHistoryTable from './components/MilestoneHistoryTable';
import MilestoneHistoryExcelFileDownloadButton from './components/MilestoneHistoryTable/MilestoneHistoryExcelFileDownloadButton.tsx';
import { AuthSliceState } from '@/store/auth.slice';
import { getAuthFromCookie } from '@/lib/utils/auth';
import { BusinessError } from '@/types/error';
import { redirect } from 'next/navigation';

const Page = async ({ searchParams }: { searchParams?: { [key: string]: string | undefined } }) => {
const headersList = headers();
Expand All @@ -21,7 +23,12 @@ const Page = async ({ searchParams }: { searchParams?: { [key: string]: string |
const field = searchParams?.field ? parseInt(searchParams.field, 10) : 0;
const keyword = searchParams?.keyword ? searchParams.keyword : '';

const milestoneHistories = await getMilestoneHistories(auth.token, field, keyword, page - 1);
let milestoneHistories;
try {
milestoneHistories = await getMilestoneHistories(auth.token, field, keyword, page - 1);
} catch (err) {
// TODO: server api error handling...
}

return (
<div>
Expand Down
6 changes: 5 additions & 1 deletion frontend/src/lib/api/server.api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { MilestoneHistorySortCriteria, SortDirection } from '@/types/milestone';

import { mockHackathonPrize } from '@/mocks/hackathon';
import { removeEmptyField } from '../utils/utils';
import { BusinessError } from '@/types/error';

export async function getMilestoneHistoriesOfStudent(
token: string,
Expand Down Expand Up @@ -60,7 +61,10 @@ export async function getMilestoneHistories(
}),
})
.then((res) => res.data)
.catch((err) => Promise.reject(err));
.catch((err) => {
location.replace('/sign-out');
return Promise.reject(err);
});
}

export async function getMilestoneHistory(historyId: number, token: string) {
Expand Down
10 changes: 5 additions & 5 deletions frontend/src/types/error.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,39 +20,39 @@ export class BusinessError extends Error {
super();
this.originalError = error;
this.name = 'BusinessError';
this.message = message ? message : 'MemberRoleNotMatchedError';
this.message = message ? message : 'BusinessError';
}
}

export class AuthError extends BusinessError {
constructor(error?: AxiosError, message?: string) {
super(error, message);
this.name = 'AuthError';
this.message = message ? message : 'MemberRoleNotMatchedError';
this.message = message ? message : 'AuthError';
}
}

export class NotFoundError extends AuthError {
constructor(error?: AxiosError, message?: string) {
super(error, message);
this.name = 'NotFoundError';
this.message = message ? message : 'MemberRoleNotMatchedError';
this.message = message ? message : 'NotFoundError';
}
}

export class AccessDeniedError extends AuthError {
constructor(error?: AxiosError, message?: string) {
super(error, message);
this.name = 'AccessDeniedError';
this.message = message ? message : 'MemberRoleNotMatchedError';
this.message = message ? message : 'AccessDeniedError';
}
}

export class UnauthorizedError extends AuthError {
constructor(error?: AxiosError, message?: string) {
super(error, message);
this.name = 'UnauthorizedError';
this.message = message ? message : 'MemberRoleNotMatchedError';
this.message = message ? message : 'UnauthorizedError';
}
}

Expand Down

0 comments on commit 6d8fe26

Please sign in to comment.