Skip to content

Commit 503e19e

Browse files
authored
πŸ‘½ Apply API changes on 24 Jan (#38)
### πŸ“ μž‘μ—… λ‚΄μš© - 1μ›” 24일(ν† ) νšŒμ˜μ—μ„œ μžˆμ—ˆλ˜ API 변경사항을 λ°˜μ˜ν•˜μ˜€μŠ΅λ‹ˆλ‹€. - 기타 μ†Œμ†Œν•œ λ¦¬νŒ©ν† λ§ μž‘μ—…μ„ μ§„ν–‰ν•˜μ˜€μŠ΅λ‹ˆλ‹€. ### πŸ“Έ μŠ€ν¬λ¦°μƒ· μ—†μŒ ### πŸš€ 리뷰 μš”κ΅¬μ‚¬ν•­ - API에 μžˆλŠ” λͺ¨λ“  μš”μ²­Β·μ‘λ‹΅ ν˜•μ‹μ„ νƒ€μž…μœΌλ‘œ κ·œμ •ν•˜μ˜€μŠ΅λ‹ˆλ‹€. 이 νƒ€μž… μ€‘μ—μ„œλŠ” μ‹€μ œλ‘œ 쓰이지 μ•Šμ€ 것도 μžˆλŠ”μ§€λΌ, CIλ₯Ό ν†΅κ³Όν•˜μ§€ λͺ»ν•  κ²ƒμž…λ‹ˆλ‹€. 이 점 κ°μ•ˆν•˜μ—¬ μ£Όμ‹œκΈ° λ°”λžλ‹ˆλ‹€.
1 parent d2e5174 commit 503e19e

26 files changed

+498
-420
lines changed

β€Žsrc/api/auth/signup.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import apiClient from '@/api/apiClient';
22
import type { SignUpRequest, SignUpResponse } from '@/types/auth';
33

4-
export default async function signup(
4+
export default async function signUp(
55
data: SignUpRequest
66
): Promise<SignUpResponse> {
77
const formData = new FormData();

β€Žsrc/api/event.tsβ€Ž

Lines changed: 0 additions & 50 deletions
This file was deleted.

β€Žsrc/api/events/event.tsβ€Ž

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import type {
2+
CreateEventRequest,
3+
EventDetailResponse,
4+
UpdateEventRequest,
5+
UpdateEventResponse,
6+
} from '@/types/events';
7+
import apiClient from '../apiClient';
8+
9+
// 일정 생성 (POST /api/events)
10+
export async function createEvent(data: CreateEventRequest) {
11+
const response = await apiClient.post(`/events`, data);
12+
13+
return {
14+
data: response.data,
15+
status: response.status,
16+
};
17+
}
18+
19+
// 일정 상세 응닡 (GET /api/events/:id)
20+
export async function getEventDetail(id: string) {
21+
const response = await apiClient.get<EventDetailResponse>(`/events/${id}`);
22+
23+
return {
24+
data: response.data,
25+
status: response.status,
26+
};
27+
}
28+
29+
// 일정 μˆ˜μ • (PUT /api/events/:id)
30+
export async function updateEvent(id: string, data: UpdateEventRequest) {
31+
const response = await apiClient.put<UpdateEventResponse>(
32+
`/events/${id}`,
33+
data
34+
);
35+
36+
return {
37+
data: response.data,
38+
status: response.status,
39+
};
40+
}
41+
42+
// TODO: 일정 μ‚­μ œ (DELETE /api/events/:id)

β€Žsrc/api/events/me.tsβ€Ž

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { MyEventsResponse } from '@/types/events';
2+
import apiClient from '../apiClient';
3+
4+
// λ‚΄κ°€ μƒμ„±ν•œ 일정 λͺ©λ‘ (GET /api/events/me)
5+
export default async function getMyEvents() {
6+
const response = await apiClient.get<MyEventsResponse>(`/events/me`);
7+
8+
return {
9+
data: response.data,
10+
status: response.status,
11+
};
12+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
import type {
2+
GuestsParams,
3+
GuestsResponse,
4+
JoinEventRequest,
5+
JoinEventResponse,
6+
} from '@/types/events';
7+
import apiClient from '../apiClient';
8+
9+
// μ°Έμ—¬μž λͺ…단 (GET /api/events/:id/registrations)
10+
export async function getGuests(id: string, params?: GuestsParams) {
11+
const response = await apiClient.get<GuestsResponse>(
12+
`/events/${id}/registrations`,
13+
{ params }
14+
);
15+
16+
return {
17+
data: response.data,
18+
status: response.status,
19+
};
20+
}
21+
22+
// μ°Έμ—¬ μ‹ μ²­ (POST /api/events/:id/registrations)
23+
export async function joinEvent(id: string, data: JoinEventRequest) {
24+
const response = await apiClient.post<JoinEventResponse>(
25+
`/events/${id}/registrations`,
26+
data
27+
);
28+
29+
return {
30+
data: response.data,
31+
status: response.status,
32+
};
33+
}

β€Žsrc/api/registrations/me.tsβ€Ž

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import apiClient from '@/api/apiClient';
2+
import type { MyRegistrationsResponse } from '@/types/registrations';
3+
4+
// λ‚΄κ°€ μ‹ μ²­ν•œ 일정 쑰회 (GET /api/registrations/me)
5+
export default async function getMyRegistrations(): Promise<MyRegistrationsResponse> {
6+
const response = await apiClient.get('/registrations/me');
7+
return response.data;
8+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import apiClient from '@/api/apiClient';
2+
import type {
3+
PatchRegistrationRequest,
4+
PatchRegistrationResponse,
5+
} from '@/types/registrations';
6+
7+
// μ‹ μ²­ μƒνƒœ μˆ˜μ • (PATCH /api/registrations/:id)
8+
export default async function patchRegistration(
9+
id: string,
10+
data: PatchRegistrationRequest
11+
): Promise<PatchRegistrationResponse> {
12+
const response = await apiClient.patch(`/registrations/${id}`, data);
13+
return response.data;
14+
}

β€Žsrc/api/users/me.tsβ€Ž

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
11
import apiClient from '@/api/apiClient';
2-
import type { GetMeResponse } from '@/types/users';
2+
import type {
3+
GetMeResponse,
4+
PatchMeRequest,
5+
PatchMeResponse,
6+
} from '@/types/users';
37

4-
export default async function getMe(token?: string): Promise<GetMeResponse> {
8+
// λ‚˜μ˜ 정보 쑰회 (GET /api/users/me)
9+
export async function getMe(token?: string): Promise<GetMeResponse> {
510
// token이 인자둜 λ“€μ–΄μ˜€λ©΄ 헀더에 λͺ…μ‹œμ μœΌλ‘œ λ„£μ–΄μ£Όκ³ , μ—†μœΌλ©΄ 인터셉터가 처리
6-
const response = await apiClient.get('/users/me', {
11+
const headers = {
712
headers: token ? { Authorization: `Bearer ${token}` } : {},
8-
});
13+
};
14+
const response = await apiClient.get('/users/me', headers);
915
return response.data;
1016
}
17+
18+
// λ‚˜μ˜ 정보 μˆ˜μ • (PATCH /api/users/me)
19+
export async function patchMe(data: PatchMeRequest): Promise<PatchMeResponse> {
20+
const response = await apiClient.patch('/users/me', data);
21+
return response.data;
22+
}
23+
24+
// TODO: νšŒμ› νƒˆν‡΄ (DELETE /api/users/me)

β€Žsrc/components/EventCardView.tsxβ€Ž

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,35 +7,35 @@ import {
77
ItemMedia,
88
ItemTitle,
99
} from '@/components/ui/item';
10-
import type { Event } from '@/types/schemas';
10+
import type { MyEvent } from '@/types/events';
1111
import { getShortenedDate } from '@/utils/date';
1212
import { ChevronRightIcon, Plus } from 'lucide-react';
1313
import { Link } from 'react-router';
1414
import { Button } from './ui/button';
1515

1616
function getDateLabel(
17-
startEpoch: number | undefined,
18-
endEpoch: number | undefined
17+
startISODate: string | undefined,
18+
endISODate: string | undefined
1919
) {
20-
if (!endEpoch) {
20+
if (!endISODate) {
2121
return 'μƒμ‹œ λͺ¨μ§‘ 쀑';
2222
}
2323

2424
const now = new Date();
25-
const endDate = new Date(endEpoch);
25+
const endDate = new Date(endISODate);
2626

27-
if (startEpoch && now < new Date(startEpoch)) {
28-
return `${getShortenedDate(startEpoch)}λΆ€ν„° λͺ¨μ§‘`;
27+
if (startISODate && now < new Date(startISODate)) {
28+
return `${getShortenedDate(startISODate)}λΆ€ν„° λͺ¨μ§‘`;
2929
}
3030

3131
if (now <= endDate) {
32-
return `${getShortenedDate(endEpoch)}κΉŒμ§€ λͺ¨μ§‘`;
32+
return `${getShortenedDate(endISODate)}κΉŒμ§€ λͺ¨μ§‘`;
3333
}
3434

3535
return 'λͺ¨μ§‘ 마감';
3636
}
3737

38-
export default function EventCardView({ events }: { events: Event[] }) {
38+
export default function EventCardView({ events }: { events: MyEvent[] }) {
3939
if (events.length === 0) {
4040
return (
4141
<div className="flex-1 flex items-center justify-center">
@@ -73,16 +73,16 @@ export default function EventCardView({ events }: { events: Event[] }) {
7373
</Link>
7474
</Item>
7575
{events.map((event) => (
76-
<Item key={event.id} variant="outline" asChild role="listitem">
77-
<Link to={`/event/${event.id}`}>
76+
<Item key={event.publicId} variant="outline" asChild role="listitem">
77+
<Link to={`/event/${event.publicId}`}>
7878
<ItemContent>
7979
<ItemTitle>
8080
<h2 className="text-lg font-semibold line-clamp-1">
8181
{event.title}
8282
</h2>
8383
</ItemTitle>
8484
<ItemDescription>
85-
{getDateLabel(undefined, event.registrationDeadline)}
85+
{getDateLabel(undefined, event.registrationEndsAt)}
8686
</ItemDescription>
8787
</ItemContent>
8888
<ItemActions>

β€Žsrc/components/EventDetailContent.tsxβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { ScrollArea } from '@/components/ui/scroll-area';
2-
import type { Event } from '@/types/schemas';
2+
import type { DetailedEvent } from '@/types/events';
33
import { useNavigate } from 'react-router';
44
import { formatEventDate } from '../utils/date';
55

66
interface EventDetailContentProps {
7-
schedule: Event;
7+
schedule: DetailedEvent;
88
currentParticipants: number;
99
}
1010

@@ -35,7 +35,7 @@ export default function EventDetailContent({
3535
{/* 1. μΌμ‹œ 및 μž₯μ†Œ */}
3636
<div className="text-left space-y-3 w-full">
3737
<p className="text-lg sm:text-xl font-bold text-black">
38-
μΌμ‹œ {formatEventDate(schedule.startAt)}
38+
μΌμ‹œ {formatEventDate(schedule.startsAt)}
3939
</p>
4040
<p className="text-lg sm:text-xl font-bold text-black">
4141
μž₯μ†Œ {schedule.location || 'λ―Έμ •'}
@@ -44,7 +44,7 @@ export default function EventDetailContent({
4444

4545
{/* 2. μ‹ μ²­ ν˜„ν™© λ²„νŠΌ */}
4646
<button
47-
onClick={() => navigate(`/event/${schedule.id}/guests`)}
47+
onClick={() => navigate(`/event/${schedule.publicId}/guests`)}
4848
className="flex items-center text-lg font-bold group hover:opacity-70 transition-opacity"
4949
>
5050
{schedule.capacity}λͺ… 쀑{' '}
@@ -65,8 +65,8 @@ export default function EventDetailContent({
6565

6666
{/* 4. 마감 정보 (λ²„νŠΌ 상단 문ꡬ) */}
6767
<p className="text-lg font-bold text-black">
68-
{schedule.registrationDeadline
69-
? `${formatEventDate(schedule.registrationDeadline)} λͺ¨μ§‘ 마감`
68+
{schedule.registrationEndsAt
69+
? `${formatEventDate(schedule.registrationEndsAt)} λͺ¨μ§‘ 마감`
7070
: 'μƒμ‹œ λͺ¨μ§‘'}
7171
</p>
7272
</div>

0 commit comments

Comments
Β (0)