-
Notifications
You must be signed in to change notification settings - Fork 0
feat: 대시보드 메인페이지 API 연동 #124
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
4a994aa
bc9e3a5
8b017f6
ddf138b
d20f779
746b969
583a25f
a8c5924
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| import { axiosClient } from '../../../shared/types/api/http-client'; | ||
| import { HostDashboardResponse } from '../model/hostDashboard'; | ||
| import { ApiResponse } from '../../../shared/types/api/apiResponse'; | ||
|
|
||
| const hostDashboard = async (eventId: number) => { | ||
| const response = await axiosClient.get<ApiResponse<HostDashboardResponse>>(`/host-channels/dashboard`, { | ||
| params: { eventId }, | ||
| }); | ||
|
|
||
| return response.data.result; | ||
| }; | ||
Yejiin21 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| export default hostDashboard; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| import { useQuery } from '@tanstack/react-query'; | ||
| import hostDashboard from '../api/hostDashboard'; | ||
| import { useParams } from 'react-router-dom'; | ||
|
|
||
| const useHostDashboard = () => { | ||
| const { id } = useParams(); | ||
|
|
||
| const eventId = Number(id); | ||
|
|
||
| const { data, refetch } = useQuery({ | ||
| queryKey: ['hostDashboard', eventId], | ||
| queryFn: () => hostDashboard(eventId), | ||
| enabled: !!eventId, | ||
| }); | ||
|
|
||
| return { data, refetch }; | ||
| }; | ||
|
|
||
| export default useHostDashboard; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| export interface HostDashboardResponse { | ||
| eventName: string; | ||
| eventStartDate: string; | ||
| eventEndDate: string; | ||
| totalTicketCnt: number; | ||
| totalPrice: number; | ||
| ticketOption: boolean; | ||
| ticket: boolean; | ||
| } |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -8,23 +8,55 @@ interface DatePickerProps { | |
| className?: string; | ||
| eventState?: FunnelState['eventState']; | ||
| setEventState?: React.Dispatch<React.SetStateAction<FunnelState['eventState']>>; | ||
| startDate?: string; | ||
| endDate?: string; | ||
| onStartDateChange?: (date: string) => void; | ||
| onEndDateChange?: (date: string) => void; | ||
| isLabel?: boolean; | ||
| } | ||
|
|
||
| const EventDatePicker = ({ className, eventState, setEventState, isLabel = false }: DatePickerProps) => { | ||
| const [startDate, setStartDate] = useState<Date | null>( | ||
| eventState?.startDate ? new Date(eventState.startDate) : new Date() | ||
| ); | ||
| const [endDate, setEndDate] = useState<Date | null>(eventState?.endDate ? new Date(eventState.endDate) : new Date()); | ||
| const EventDatePicker = ({ | ||
| className, | ||
| eventState, | ||
| setEventState, | ||
| startDate: initialStartDate, | ||
| endDate: initialEndDate, | ||
| onStartDateChange, | ||
| onEndDateChange, | ||
| isLabel = false, | ||
| }: DatePickerProps) => { | ||
| const [startDate, setStartDate] = useState<Date | null>(null); | ||
| const [endDate, setEndDate] = useState<Date | null>(null); | ||
| const [startTime, setStartTime] = useState<string>('06:00'); | ||
| const [endTime, setEndTime] = useState<string>('23:00'); | ||
|
|
||
| useEffect(() => { | ||
| const start = eventState?.startDate || initialStartDate; | ||
| const end = eventState?.endDate || initialEndDate; | ||
|
|
||
| if (start && !startDate) { | ||
| const startDate = new Date(start); | ||
| setStartDate(startDate); | ||
| const hours = startDate.getHours().toString().padStart(2, '0'); | ||
| const minutes = startDate.getMinutes().toString().padStart(2, '0'); | ||
| setStartTime(`${hours}:${minutes}`); | ||
| } | ||
|
|
||
| if (end && !endDate) { | ||
| const endDate = new Date(end); | ||
| setEndDate(endDate); | ||
| const hours = endDate.getHours().toString().padStart(2, '0'); | ||
| const minutes = endDate.getMinutes().toString().padStart(2, '0'); | ||
| setEndTime(`${hours}:${minutes}`); | ||
| } | ||
| }, [eventState, initialStartDate, initialEndDate]); | ||
|
|
||
| const generateTimeOptions = () => { | ||
| const options = []; | ||
| for (let i = 0; i < 24; i++) { | ||
| for (let j = 0; j < 4; j++) { | ||
| const hour = i.toString().padStart(2, '0'); | ||
| const minute = (j * 15).toString().padEnd(2, '0'); | ||
| const minute = (j * 15).toString().padStart(2, '0'); | ||
| options.push(`${hour}:${minute}`); | ||
| } | ||
| } | ||
|
|
@@ -34,7 +66,7 @@ const EventDatePicker = ({ className, eventState, setEventState, isLabel = false | |
| const timeOptions = generateTimeOptions(); | ||
|
|
||
| useEffect(() => { | ||
| if (setEventState && startDate && endDate) { | ||
| if (startDate && endDate) { | ||
| const [startHour, startMin] = startTime.split(':').map(Number); | ||
| const [endHour, endMin] = endTime.split(':').map(Number); | ||
|
|
||
|
|
@@ -44,13 +76,26 @@ const EventDatePicker = ({ className, eventState, setEventState, isLabel = false | |
| const end = new Date(endDate); | ||
| end.setHours(endHour, endMin, 0, 0); | ||
|
|
||
| setEventState(prev => ({ | ||
| ...prev, | ||
| startDate: start.toISOString(), | ||
| endDate: end.toISOString(), | ||
| })); | ||
| const startISO = new Date(start.getTime() + 9 * 60 * 60 * 1000).toISOString(); | ||
| const endISO = new Date(end.getTime() + 9 * 60 * 60 * 1000).toISOString(); | ||
|
Comment on lines
+79
to
+80
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🛠️ Refactor suggestion 타임존 처리 관련 고려사항 날짜에 9시간을 더하는 방식으로 타임존 처리를 하고 있는데, 이는 한국 시간(KST, UTC+9)을 위한 것으로 보입니다. 하지만 이러한 하드코딩된 시간 조정은 문제가 될 수 있습니다. 타임존 처리는 Date 객체의 메서드나 moment.js, date-fns와 같은 라이브러리를 사용하여 좀 더 명시적으로 처리하는 것이 좋습니다. 현재 방식은 다른 타임존의 사용자에게 혼란을 줄 수 있습니다. - const startISO = new Date(start.getTime() + 9 * 60 * 60 * 1000).toISOString();
- const endISO = new Date(end.getTime() + 9 * 60 * 60 * 1000).toISOString();
+ // date-fns 사용 예시
+ import { format, addHours } from 'date-fns';
+ import { zonedTimeToUtc } from 'date-fns-tz';
+
+ const startISO = zonedTimeToUtc(start, 'Asia/Seoul').toISOString();
+ const endISO = zonedTimeToUtc(end, 'Asia/Seoul').toISOString();
|
||
|
|
||
| if (setEventState) { | ||
| setEventState(prev => ({ | ||
| ...prev, | ||
| startDate: startISO, | ||
| endDate: endISO, | ||
| })); | ||
| } | ||
|
|
||
| if (onStartDateChange) { | ||
| onStartDateChange(startISO); | ||
| } | ||
|
|
||
| if (onEndDateChange) { | ||
| onEndDateChange(endISO); | ||
| } | ||
| } | ||
| }, [startDate, endDate, startTime, endTime, setEventState]); | ||
| }, [startDate, endDate, startTime, endTime, setEventState, onStartDateChange, onEndDateChange]); | ||
|
|
||
| return ( | ||
| <div className={`flex flex-col w-full ${className}`}> | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Verification agent
🧩 Analysis chain
공백 제거 변경이 잘 적용되었습니다.
이 부분의 변경은 단순 공백 제거에 불과하지만, eventDetail API 함수의 반환 구조 변경(response.data.result → response.data)과 연관되어 있습니다. 현재 이 훅 자체는 큰 수정이 필요하지 않았지만, 이 훅을 사용하는 컴포넌트들이 데이터 접근 방식을 적절히 수정했는지 확인해주세요.
🏁 Script executed:
Length of output: 130
🏁 Script executed:
Length of output: 318
🏁 Script executed:
Length of output: 2536
eventDetail 반환 구조 변경에 따른 컴포넌트 수정 필요
response.data.result→response.data로 API 반환값이 바뀌었으므로, 아직data.result를 참조하고 있는 컴포넌트들을 직접data로 참조하도록 수정해야 합니다. 다음 파일들을 점검 및 리팩토링해 주세요:data.result를 사용 중인 파일들 (rg 결과 참조)수정 예시:
위 파일들의 모든
data.result참조를data로 교체하고, 맵핑 로직이나 변수명도 일관되게 업데이트해 주세요.