Skip to content

Commit

Permalink
Merge pull request #216 from SW-CSS/develop
Browse files Browse the repository at this point in the history
RELEASE
  • Loading branch information
llddang authored Sep 20, 2024
2 parents f01d35a + 84aecb0 commit a5a06d3
Show file tree
Hide file tree
Showing 9 changed files with 46 additions and 11 deletions.
10 changes: 10 additions & 0 deletions frontend/src/app/(client)/(withSidebar)/milestone/page.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import Image from 'next/image';

import * as S from './styled';
import Link from 'next/link';

const Page = () => (
<S.Content>
Expand All @@ -14,6 +15,15 @@ const Page = () => (
학생들은 교내외 여러 활동들을 통하여 실전적 SW역량, 글로벌 역량, 커뮤니케이션 역량을 균형있게 함양하고
SW중심대학사업단에서는 학생들의 적립된 마일스톤 점수에 따라 매년 장학생을 선발하고 있습니다.
</S.Description>
<div className="mb-10 mt-6 flex flex-col items-center">
<Link
href="/my-page/milestone/register"
className="mt-2 block w-fit rounded-sm bg-primary-main p-3 text-lg font-semibold tracking-wide text-white"
type="button"
>
마일스톤 등록하러 가기
</Link>
</div>
<S.ImageWrapper maxWidth="429px" maxHeight="208px" backgroundImage="/images/milestone/milestone_img02_bg.png">
<Image src="/images/milestone/milestone_img02.png" priority={false} alt="" fill />
</S.ImageWrapper>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ export const Title = styled.div`

export const Description = styled.div`
text-align: center;
margin-bottom: 50px;
`;

export const InformationList = styled.ul`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const MilestoneHistorySection = async () => {

return (
<div className="relative w-full min-w-[260px] flex-1 rounded-sm bg-white p-5 lg:max-w-[280px]">
<SubTitle title="실적 등록" urlText="등록하기" url="/my-page/milestone/register" />
<SubTitle title="실적 관리" urlText="전체보기" url="/my-page/milestone/register" />
<div className="mt-4">
{milestoneHistoriesOfStudent ? (
milestoneHistoriesOfStudent.content.map((milestoneHistory) => (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ import StudentInfoLabel from './StudentInfoLabel';
const StudentInfoSection = () => {
// TODO - 관리자가 로그인한 경우에 대한 처린
const auth = useAppSelector((state) => state.auth).value;
const { data: member } = useStudentMemberQuery(auth.id);
let member;
try {
member = useStudentMemberQuery(auth.id).data;
} catch (err) {
// TODO: server api error handling
}
return (
<div className="relative flex-grow rounded-sm bg-white p-5">
<SubTitle title="내 정보" urlText="수정" url="/my-page/edit" />
Expand Down
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
6 changes: 5 additions & 1 deletion frontend/src/lib/hooks/useApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,11 @@ export function useStudentMemberQuery(memberId: number, options?: { enabled?: bo
return useAxiosQuery({
...options,
queryKey: QueryKeys.STUDENT(memberId),
queryFn: async (): Promise<StudentMemberDto> => await client.get(`/members/${memberId}`),
queryFn: async (): Promise<StudentMemberDto> =>
await client
.get(`/members/${memberId}`)
.then((res) => res.data)
.catch((err) => Promise.reject(err)),
});
}

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 a5a06d3

Please sign in to comment.