-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* chore: 테스트를 위한 mock데이터 수정 * feat: 캘린더 현재 날짜 적용 및 날짜 선택 기능 추가 * feat: 날짜별 roomDetail 데이터 mock handler 추가 * feat: 날짜별 상세 데이터 options * feat: getRoomDetail에 date 옵션 추가 * feat: 캘린더 UI 및 캘린더 선택시 데이터 업데이트 기능 추가 * fix: 변수명 수정 및 캘린더 로직 수정 * feat: serverTime props 추가 및 타입 정의 * feat: API 요청 경로 수정 * feat: detailByDate API 다시 수정 * style: roomDetail provider 분리 * fix: PR리뷰 적용 * fix: 테스트용 주석 제거
- Loading branch information
1 parent
1cb8d42
commit 9498858
Showing
11 changed files
with
267 additions
and
79 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { useContext } from 'react'; | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { roomOptions } from '@/core/api/options'; | ||
import { DateRoomDetailContext } from './RoomDetailProvider'; | ||
import { RoomInfo, RoomWorkspace } from '@/RoomDetail'; | ||
import { RoomInfo as RoomInfoType } from '@/core/types/Room'; | ||
interface RoomDetailContainerProps { | ||
roomDetailData: RoomInfoType; | ||
serverTime: Date; | ||
} | ||
|
||
const RoomDetailContainer = ({ | ||
roomDetailData, | ||
serverTime | ||
}: RoomDetailContainerProps) => { | ||
const { date } = useContext(DateRoomDetailContext); | ||
const roomId = '1234'; | ||
const chooseDate = `${date.getFullYear()}-${date.getMonth()}-${date.getDate()}`; | ||
|
||
const { data: roomDetailDataByDate, status } = useQuery({ | ||
...roomOptions.detailByDate(roomId, chooseDate) | ||
}); | ||
|
||
if (roomDetailDataByDate) { | ||
roomDetailData = roomDetailDataByDate; | ||
} | ||
|
||
return ( | ||
<> | ||
<div className="h-[20.56rem] bg-[url('/level1.png')] bg-cover bg-no-repeat text-white"> | ||
<RoomInfo | ||
{...roomDetailData} | ||
status={status} | ||
/> | ||
</div> | ||
<div className="px-[1.81rem] pb-[1.62rem] pt-[1.88rem]"> | ||
<RoomWorkspace | ||
{...roomDetailData} | ||
status={status} | ||
serverTime={serverTime} | ||
/> | ||
</div> | ||
</> | ||
); | ||
}; | ||
|
||
export default RoomDetailContainer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import { ReactNode, useState, createContext } from 'react'; | ||
|
||
export const DateRoomDetailContext = createContext<{ | ||
date: Date; | ||
selectDate: (value: Date) => void; | ||
}>({ | ||
date: new Date(), | ||
selectDate: (value: Date) => { | ||
return value; | ||
} | ||
}); | ||
|
||
interface RoomDetailProviderProps { | ||
children: ReactNode; | ||
serverTime: Date; | ||
} | ||
|
||
const RoomDetailProvider = ({ | ||
children, | ||
serverTime | ||
}: RoomDetailProviderProps) => { | ||
const [changedDate, setChangeDate] = useState<Date>(serverTime); | ||
|
||
return ( | ||
<DateRoomDetailContext.Provider | ||
value={{ | ||
date: changedDate, | ||
selectDate: (dateValue: Date) => { | ||
setChangeDate(dateValue); | ||
} | ||
}} | ||
> | ||
{children} | ||
</DateRoomDetailContext.Provider> | ||
); | ||
}; | ||
|
||
export default RoomDetailProvider; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export const DAY_OF_THE_WEEK = ['일', '월', '화', '수', '목', '금', '토']; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
export const makeWeekCalendar = (serverTime: Date) => { | ||
const weekArray: Date[] = Array.from({ length: 7 }); | ||
|
||
const todayDate = serverTime.getDate(); | ||
const todayDay = serverTime.getDay(); | ||
|
||
for (let i = 0; i < 7; i++) { | ||
const mondayDate = todayDate - todayDay + 1; | ||
const newDate = new Date(serverTime); | ||
|
||
newDate.setFullYear(newDate.getFullYear()); | ||
newDate.setMonth(newDate.getMonth()); | ||
newDate.setDate(mondayDate + i); | ||
|
||
weekArray[i] = newDate; | ||
} | ||
|
||
return { thisWeekTimestamp: weekArray }; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.