Skip to content

Commit 21cadb0

Browse files
authored
Merge pull request #179 from GDSC-DGU/refactor/#178
[Refactor] 부스 관련 API 및 좋아요 기능 구조 개선
2 parents ab1f237 + 27f0eb4 commit 21cadb0

35 files changed

+408
-344
lines changed

src/api/booth/admin/adminBooth.ts

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { adminInstance } from "@/api/instance";
2+
import { sendRequest } from "@/api/request";
3+
import type {
4+
AdminPubStatus,
5+
ReserveListResponse,
6+
} from "../shared/sharedBoothTypes";
7+
8+
// 1. 예약 목록 조회 (/pub)
9+
export const fetchReserveListAPI = () =>
10+
sendRequest<ReserveListResponse>(adminInstance, "GET", "/pub");
11+
12+
// 2. 부스 호출 (/pub/call)
13+
export const callBoothAPI = (reserveId: string) =>
14+
sendRequest(adminInstance, "POST", "/pub/call", { reserveId });
15+
16+
// 3. 방문 처리 (/pub/reserve)
17+
export const completeVisitAPI = (reserveId: string) =>
18+
sendRequest(adminInstance, "PATCH", "/pub/reserve", { reserveId });
19+
20+
// 4. 부스 상태 변경 (/pub?pubsStatus=)
21+
export const updateBoothStatusAPI = (
22+
status: AdminPubStatus["status"] // "AVAILABLE" | "FULL" | "END"
23+
) => {
24+
const url = `/pub?pubsStatus=${status}`;
25+
return sendRequest<boolean>(adminInstance, "PATCH", url);
26+
};
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
import { useMutation, useQueryClient } from "@tanstack/react-query";
2+
import {
3+
callBoothAPI,
4+
completeVisitAPI,
5+
updateBoothStatusAPI,
6+
} from "@/api/booth/admin/adminBooth";
7+
import { withDelayedGlobalLoading } from "@/utils/delayedGlobalLoading";
8+
import type { BoothStatus } from "@/types/booth";
9+
10+
/**
11+
* 특정 예약 팀에게 호출(Call) 처리하는 mutation 훅
12+
* - 사용처: 어드민 화면에서 사용자가 대기 중일 때 "호출" 버튼 클릭 시
13+
* - API: POST /pub/call
14+
* - 성공 시: ["admin", "reserveList"] 캐시 무효화
15+
*/
16+
17+
export const useCallBooth = () => {
18+
const queryClient = useQueryClient();
19+
return useMutation({
20+
mutationFn: (reserveId: string) =>
21+
withDelayedGlobalLoading(callBoothAPI(reserveId)),
22+
onSuccess: () => {
23+
queryClient.invalidateQueries({ queryKey: ["admin", "reserveList"] });
24+
},
25+
});
26+
};
27+
28+
/**
29+
* 특정 예약 팀의 방문 완료 처리 mutation 훅
30+
* - 사용처: 어드민 화면에서 사용자가 입장 완료 시 "입장 확인" 클릭
31+
* - API: PATCH /pub/reserve
32+
* - 성공 시: ["admin", "reserveList"] 캐시 무효화
33+
*/
34+
35+
export const useCompleteVisit = () => {
36+
const queryClient = useQueryClient();
37+
return useMutation({
38+
mutationFn: (reserveId: string) =>
39+
withDelayedGlobalLoading(completeVisitAPI(reserveId)),
40+
onSuccess: () => {
41+
queryClient.invalidateQueries({ queryKey: ["admin", "reserveList"] });
42+
},
43+
});
44+
};
45+
46+
/**
47+
* 부스 전체 상태(AVAILABLE | FULL | END) 변경 mutation 훅
48+
* - 사용처: 어드민이 부스 운영 상태를 변경할 때 사용
49+
* - API: PATCH /pub?pubsStatus=...
50+
* - 성공 후 캐시 무효화 없음 (필요시 수동 refetch 필요)
51+
*/
52+
53+
export const useUpdateBoothStatus = () => {
54+
return useMutation({
55+
mutationFn: (status: BoothStatus) =>
56+
withDelayedGlobalLoading(updateBoothStatusAPI(status)),
57+
});
58+
};
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
/**
2+
* 어드민 대시보드에서 예약 목록(ReserveList)을 주기적으로 조회하는 React Query 훅
3+
* - 사용처: 어드민 화면의 부스 대기 팀 리스트
4+
* - API: GET /pub
5+
* - 반환값: { reserveList[], waitingTotalCount, lateTotalCount, pubStatus }
6+
*/
7+
8+
import { useQuery } from "@tanstack/react-query";
9+
import { fetchReserveListAPI } from "@/api/booth/admin/adminBooth";
10+
import { withDelayedGlobalLoading } from "@/utils/delayedGlobalLoading";
11+
12+
export const useReserveList = () =>
13+
useQuery({
14+
queryKey: ["admin", "reserveList"],
15+
queryFn: () => withDelayedGlobalLoading(fetchReserveListAPI()),
16+
refetchInterval: 10000,
17+
refetchOnWindowFocus: true,
18+
staleTime: 0,
19+
});

src/api/booth/adminBooth.ts

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

src/api/booth/boothAdmin.ts

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

src/api/booth/callBooth.ts

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

src/api/booth/completeVisit.ts

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

src/api/booth/fetchBoothList.ts

Lines changed: 0 additions & 19 deletions
This file was deleted.
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
// 예약 상태 (공통)
2+
export type ReserveStatus = "WAITING" | "CALLED" | "LATE" | "VISITED" | "CANCELLED";
3+
4+
// 사용자 예약 정보
5+
export interface ReservationInfo {
6+
waitTeam: number;
7+
reserveStatus: "WAITING" | "DONE" | "CANCELLED";
8+
}
9+
10+
// 사용자 부스 상태
11+
export interface PubStatus {
12+
pubsId: number;
13+
waitTeam: number;
14+
status: "AVAILABLE" | "FULL" | "PREPARING" | "END";
15+
}
16+
17+
// 관리자 부스 상태 (name 포함됨)
18+
export interface AdminPubStatus {
19+
pubsId: number;
20+
name: string;
21+
status: "AVAILABLE" | "FULL" | "PREPARING" | "END";
22+
}
23+
24+
// 관리자 예약 리스트 항목
25+
export interface Reserve {
26+
reserveId: string;
27+
reserveName: string;
28+
phoneNumber: string;
29+
reserveMembers: number;
30+
status: ReserveStatus;
31+
elapsedTime: number | string | null;
32+
}
33+
34+
// 예약 리스트 전체 응답 타입
35+
export interface ReserveListResponse {
36+
reserveList: Reserve[];
37+
waitingTotalCount: number;
38+
lateTotalCount: number;
39+
pubStatus?: AdminPubStatus;
40+
}

0 commit comments

Comments
 (0)