Skip to content

Commit 32bb662

Browse files
committed
feat(domain/enrollment-check): 등록확인 API 연동
1 parent 4f482eb commit 32bb662

File tree

6 files changed

+51
-126
lines changed

6 files changed

+51
-126
lines changed

api/arts/index.ts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { ResponseForm } from "@/types";
2+
import type { Art } from "@/types/arts";
3+
import httpClient from "../core";
4+
5+
export const getCheckList = async (): Promise<ResponseForm<Art[]>> => {
6+
return httpClient.get("/arts/check-list");
7+
};

api/index.ts

+1
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ export * from "./detail";
33
export * from "./comment";
44
export * from "./reserve";
55
export * from "./landing";
6+
export * from "./arts";

app/login/page.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import OAuthLogin from "@/components/domains/oauth/login";
44

55
const authUri = process.env.NEXT_PUBLIC_NAVER_AUTH_URI as string;
66
const clientId = process.env.NEXT_PUBLIC_NAVER_CLIENT_ID as string;
7+
const clientState = process.env.NEXT_PUBLIC_AUTH_CLIENT_STATE as string;
78
const redirectUri = process.env.NEXT_PUBLIC_NAVER_REDIRECT_URI as string;
89

910
export default function LoginPage() {
@@ -13,7 +14,7 @@ export default function LoginPage() {
1314
authUri={authUri}
1415
clientId={clientId}
1516
redirectUri={redirectUri}
16-
state="test"
17+
state={clientState}
1718
style={{ backgroundColor: "#03c75A", width: "350px" }}
1819
>
1920
네이버 로그인

components/domains/enrollment-check/data.ts

-106
Original file line numberDiff line numberDiff line change
@@ -1,109 +1,3 @@
1-
export const mockRes = {
2-
message: "등록확인 리스트 페이지 조회에 성공했습니다..",
3-
data: [
4-
{
5-
id: 33,
6-
createdAt: "2024-01-30T14:28:38.045106+09:00",
7-
genre: "test",
8-
title: "test",
9-
status: "APPROVED",
10-
createdBy: "test",
11-
schedules: [
12-
{
13-
id: 57,
14-
leftSeatCount: 48,
15-
seatMaxCount: 100,
16-
},
17-
{
18-
id: 58,
19-
leftSeatCount: 1,
20-
seatMaxCount: 100,
21-
},
22-
],
23-
},
24-
{
25-
id: 32,
26-
createdAt: "2024-01-30T14:27:02.689494+09:00",
27-
genre: "test",
28-
title: "test",
29-
status: "APPROVED",
30-
createdBy: "test",
31-
schedules: [
32-
{
33-
id: 55,
34-
leftSeatCount: 99,
35-
seatMaxCount: 100,
36-
},
37-
{
38-
id: 56,
39-
leftSeatCount: 99,
40-
seatMaxCount: 100,
41-
},
42-
],
43-
},
44-
{
45-
id: 30,
46-
createdAt: "2024-01-30T14:20:29.129058+09:00",
47-
genre: "test",
48-
title: "test",
49-
status: "APPROVED",
50-
createdBy: "test",
51-
schedules: [
52-
{
53-
id: 51,
54-
leftSeatCount: 68,
55-
seatMaxCount: 0,
56-
},
57-
{
58-
id: 52,
59-
leftSeatCount: 119,
60-
seatMaxCount: 0,
61-
},
62-
],
63-
},
64-
{
65-
id: 5,
66-
createdAt: "2023-12-19T20:13:59.079114+09:00",
67-
genre: "test",
68-
title: "test",
69-
status: "APPROVED",
70-
createdBy: "test",
71-
schedules: [
72-
{
73-
id: 10,
74-
leftSeatCount: 0,
75-
seatMaxCount: 0,
76-
},
77-
{
78-
id: 9,
79-
leftSeatCount: 0,
80-
seatMaxCount: 0,
81-
},
82-
],
83-
},
84-
{
85-
id: 1,
86-
createdAt: "2023-11-18T18:01:33.129115+09:00",
87-
genre: "test",
88-
title: "test",
89-
status: "APPROVED",
90-
createdBy: "test",
91-
schedules: [
92-
{
93-
id: 1,
94-
leftSeatCount: 0,
95-
seatMaxCount: 0,
96-
},
97-
{
98-
id: 2,
99-
leftSeatCount: 0,
100-
seatMaxCount: 0,
101-
},
102-
],
103-
},
104-
],
105-
};
106-
1071
export const displayedStatus: { [key: string]: string } = {
1082
APPROVED: "승인",
1093
REJECTED: "반려",

components/domains/enrollment-check/table/index.tsx

+26-19
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import { useEffect, useState } from "react";
22
import type { ColumnDef } from "@tanstack/react-table";
33
import dayjs from "dayjs";
44
import styled from "styled-components";
5+
import { getCheckList } from "@/api";
56
import { SpacerSkleton } from "@/components/common/spacer";
67
import { Table } from "@/components/common/table";
78
import Typography from "@/components/common/text/Typography";
89
import { DeleteAdmin } from "./deleteAdmin";
9-
import { mockRes, displayedStatus } from "../data";
10+
import { displayedStatus } from "../data";
1011

1112
const column: ColumnDef<any>[] = [
1213
{ id: "id", header: "번호", accessorFn: (row) => row.id, size: 28 },
@@ -53,31 +54,37 @@ export function EnrollmentCheckTable() {
5354
useEffect(() => {
5455
const updated: any[] = [];
5556

56-
const { data } = mockRes;
57+
(async () => {
58+
const { data } = await getCheckList();
5759

58-
data.forEach((work) => {
59-
const { schedules, ...rest } = work;
60+
data.forEach((work) => {
61+
const { schedules, ...rest } = work;
6062

61-
schedules.forEach((schedule) => {
62-
const { id, leftSeatCount, seatMaxCount } = schedule;
63+
schedules.forEach((schedule) => {
64+
const { id, leftSeatCount, seatMaxCount } = schedule;
6365

64-
const row = {
65-
id,
66-
created_at: dayjs(rest.createdAt).format("YYYY.MM.DD"),
67-
genre: rest.genre,
68-
title: rest.title,
69-
createdBy: rest.createdBy,
70-
status: displayedStatus[rest.status],
71-
selling: `${leftSeatCount}/${seatMaxCount}`,
72-
};
66+
const row = {
67+
id,
68+
created_at: dayjs(rest.createdAt).format("YYYY.MM.DD"),
69+
genre: rest.genre,
70+
title: rest.title,
71+
createdBy: rest.createdBy,
72+
status: displayedStatus[rest.status],
73+
selling: `${leftSeatCount}/${seatMaxCount}`,
74+
};
7375

74-
updated.push(row);
75-
});
76+
updated.push(row);
77+
});
7678

77-
setList(updated);
78-
});
79+
setList(updated);
80+
});
81+
})();
7982
}, []);
8083

84+
if (list.length === 0) {
85+
return;
86+
}
87+
8188
return (
8289
<SpacerSkleton id="main-content" type="vertical" gap={44}>
8390
<div>

types/arts/index.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
export interface Art {
2+
id: number;
3+
createdAt: Date;
4+
genre: string;
5+
title: string;
6+
status: string;
7+
createdBy: string;
8+
schedules: Schedule[];
9+
}
10+
11+
export interface Schedule {
12+
id: number;
13+
leftSeatCount: number;
14+
seatMaxCount: number;
15+
}

0 commit comments

Comments
 (0)