Skip to content

Commit

Permalink
RoomSearchContext 통합
Browse files Browse the repository at this point in the history
  • Loading branch information
honeyyyoon committed Jan 23, 2025
1 parent 6cac439 commit 7aecfd1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 87 deletions.
9 changes: 8 additions & 1 deletion src/components/home/context/RoomSearchContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,14 @@ import type {
RoomSearchParams,
} from '@/types/roomSearch';

type ModalType = 'location' | 'calendar' | 'guests' | 'filter' | null;
type ModalType =
| 'location'
| 'calendar'
| 'guests'
| 'filter'
| 'roomCalendar'
| 'roomGuests'
| null;

type Location = {
sido?: string;
Expand Down
76 changes: 0 additions & 76 deletions src/components/home/context/SearchContext.tsx

This file was deleted.

6 changes: 3 additions & 3 deletions src/components/roomdetail/Reservation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useState } from 'react';

import clock from '@/assets/icons/reservation/clock.svg';
import BaseModal from '@/components/common/Modal/BaseModal';
import { useSearch } from '@/components/home/context/SearchContext';
import { useRoomSearch } from '@/components/home/context/RoomSearchContext';
import RoomGuestsModal from '@/components/roomdetail/RoomGuestsModal';
import type { roomType } from '@/types/roomType';

Expand All @@ -21,7 +21,7 @@ const Reservation = ({ data }: InfoProps) => {
const [isLoading, setIsLoading] = useState(false);
const [error, setError] = useState<string | null>(null);
const { checkIn, checkOut, guests, currentModal, openModal, closeModal } =
useSearch();
useRoomSearch();

const handleReservation = async () => {
try {
Expand Down Expand Up @@ -194,4 +194,4 @@ const Reservation = ({ data }: InfoProps) => {
);
};

export default Reservation;
export default Reservation;
2 changes: 1 addition & 1 deletion src/components/roomdetail/ReviewModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,4 @@ const ReviewModal = ({ onClose, data }: ReviewProps) => {
);
};

export default ReviewModal;
export default ReviewModal;
6 changes: 3 additions & 3 deletions src/components/roomdetail/RoomGuestsModal.tsx
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import ErrorIcon from '@mui/icons-material/Error';
import { useState } from 'react';

import { useSearch } from '@/components/home/context/SearchContext';
import { useRoomSearch } from '@/components/home/context/RoomSearchContext';

type GuestsModalProps = {
onClose: () => void;
maxOccupancy: number;
};

const GuestsModal = ({ onClose, maxOccupancy }: GuestsModalProps) => {
const { setGuests } = useSearch();
const { setGuests } = useRoomSearch();
const [guestCount, setGuestCount] = useState(0);

const handleIncrement = () => {
Expand Down Expand Up @@ -76,4 +76,4 @@ const GuestsModal = ({ onClose, maxOccupancy }: GuestsModalProps) => {
);
};

export default GuestsModal;
export default GuestsModal;
6 changes: 3 additions & 3 deletions src/components/roomdetail/roomCalendarModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import dayjs from 'dayjs';
import { useEffect, useState } from 'react';
import { useCallback } from 'react';

import { useSearch } from '@/components/home/context/SearchContext';
import { useRoomSearch } from '@/components/home/context/RoomSearchContext';

type AvailabilityResponse = {
availableDates: string[];
Expand All @@ -15,7 +15,7 @@ type CalendarModalProps = {
};

const RoomCalendarModal = ({ onClose, id }: CalendarModalProps) => {
const { checkIn, checkOut, setCheckIn, setCheckOut } = useSearch();
const { checkIn, checkOut, setCheckIn, setCheckOut } = useRoomSearch();
const [currentMonth, setCurrentMonth] = useState(dayjs());
const [selecting, setSelecting] = useState<'checkIn' | 'checkOut'>('checkIn');
const [availableDates, setAvailableDates] = useState<string[]>([]);
Expand Down Expand Up @@ -239,4 +239,4 @@ const RoomCalendarModal = ({ onClose, id }: CalendarModalProps) => {
);
};

export default RoomCalendarModal;
export default RoomCalendarModal;

0 comments on commit 7aecfd1

Please sign in to comment.