-
Notifications
You must be signed in to change notification settings - Fork 4
Feat/Fix: 예약 현황 달력 WIP, 내 체험 관리 이미지 Fix #39
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 9 commits
e7a2237
7186caa
5eb23fc
c4ecd8a
7c543ad
2665dd7
180bc45
586f8aa
6e54b37
3fea56f
948d411
82d1cf0
58708c1
a1f3791
0554ea6
c45e847
891a27d
34e625b
ff2328e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,103 @@ | ||
| 'use client'; | ||
|
|
||
| import { useEffect, useState } from 'react'; | ||
| import Dropdown from '../../primitives/Dropdown'; | ||
| import LoadingSpinner from '../../primitives/LoadingSpinner'; | ||
| import Image from 'next/image'; | ||
| import BackBtn from '../../primitives/mypage/BackBtn'; | ||
| import { Activity, IMyReservations } from '@/src/types/activityType'; | ||
| import ReservationCalendar from './ReservationCalendar'; | ||
| import { | ||
| getMyExperiences, | ||
| getMyReservationStatus, | ||
| } from '@/src/services/pages/myExperiences/api'; | ||
| import { useReservationStore } from '@/src/store/ReservationStore'; | ||
| import { format } from 'date-fns'; | ||
| import { IReservedSchedule } from '@/src/types/scheduleType'; | ||
|
|
||
| export default function MyReservationStatusPage() { | ||
| const [activities, setActivities] = useState<IMyReservations | null>(); | ||
|
|
||
| useEffect(() => { | ||
| const fn = async () => { | ||
| const activitiesList = await getMyExperiences(); | ||
| if (!activitiesList || activitiesList.totalCount === 0) | ||
| setActivities(null); | ||
| setActivities(activitiesList); | ||
| }; | ||
| fn(); | ||
|
||
| }, []); | ||
|
|
||
| console.log(activities); | ||
|
|
||
| return ( | ||
| <section className='flex flex-col items-center gap-8'> | ||
| <div className='w-full flex flex-col gap-2 md:justify-between'> | ||
| <div className='flex gap-4'> | ||
| <BackBtn /> | ||
|
Collaborator
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. 백버튼 위치를 다 합치고 나서 한번에 좀 정리를 해야할거 같네요 😅 |
||
| <h1 className='text-18 font-bold'>예약 현황</h1> | ||
| </div> | ||
| <p className='font-14 text-gray-500'> | ||
| 내 체험에 예약된 내역들을 한 눈에 확인할 수 있습니다. | ||
| </p> | ||
| </div> | ||
| {activities !== undefined ? ( | ||
| <> | ||
| {activities !== null && activities.totalCount !== 0 ? ( | ||
| <DropdownAndCalendar data={activities.activities} /> | ||
| ) : ( | ||
| <div className='space-y-8'> | ||
| <Image | ||
| src={'/images/Not_Found_Earth.png'} | ||
| alt='찾을 수 없습니다' | ||
| width={122} | ||
| height={122} | ||
| className='mx-auto' | ||
| /> | ||
| <span className='text-18 text-gray-600'> | ||
| 아직 등록한 체험이 없어요 | ||
| </span> | ||
| </div> | ||
| )} | ||
| </> | ||
| ) : ( | ||
| <LoadingSpinner /> | ||
| )} | ||
|
Collaborator
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. 분기처리가 너무 세세해서 한눈에 안들어오는거 같아요. |
||
| </section> | ||
| ); | ||
| } | ||
|
|
||
| function DropdownAndCalendar({ data }: { data: Activity[] }) { | ||
| const [selectedExperience, setSelectedExperience] = useState<string | null>( | ||
| null | ||
| ); | ||
| const [reservedSchedule, setReservedSchedule] = useState< | ||
| IReservedSchedule[] | null | ||
| >(null); | ||
|
|
||
| const calendarDisplayDate = useReservationStore( | ||
| (state) => state.displayController.dateToDisplay | ||
| ); | ||
|
|
||
| Promise.all( | ||
| data.map((el) => { | ||
| return getMyReservationStatus( | ||
| el.id, | ||
| format(calendarDisplayDate, 'yyyy'), | ||
| format(calendarDisplayDate, 'MM') | ||
| ); | ||
| }) | ||
| ).then((res) => setReservedSchedule(res)); | ||
|
||
|
|
||
| return ( | ||
| <div> | ||
| <Dropdown | ||
| label='' | ||
| items={data.map((el) => el.title)} | ||
| value={selectedExperience} | ||
| onChange={(e) => setSelectedExperience(e)} | ||
| /> | ||
| <ReservationCalendar schedule={reservedSchedule} /> | ||
| </div> | ||
| ); | ||
| } | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2,6 +2,7 @@ import { getMyReservationList } from '@/src/services/pages/myReservation/api'; | |
| import getUserInfo from '@/src/services/primitives/getUserInfo'; | ||
| import { ReservationStatus } from '@/src/types/myReservationType'; | ||
| import { infiniteQueryOptions, queryOptions } from '@tanstack/react-query'; | ||
| import { getMyExperiences } from '../pages/myExperiences/api'; | ||
|
|
||
| export const queries = { | ||
| user: () => ['user'], | ||
|
|
@@ -23,4 +24,11 @@ export const queries = { | |
| initialPageParam: 0, | ||
| getNextPageParam: (lastPage) => lastPage.cursorId, | ||
| }), | ||
| myExperiences: () => ['myExperiences'], | ||
| myExperiencesOptions: (accessToken: string | null | undefined) => | ||
| queryOptions({ | ||
| queryKey: [...queries.myExperiences()], | ||
| queryFn: () => getMyExperiences(), | ||
| enabled: !!accessToken, | ||
|
||
| }), | ||
| }; | ||
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.
const accessToken = useTokenStore(state => state.accessToken)으로 수정해주셔야 할거 같아요!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.
아 그러네요!