Skip to content

Commit

Permalink
fix: roomType 타입 및 params 수정 (#211)
Browse files Browse the repository at this point in the history
  • Loading branch information
chasj0326 authored Nov 22, 2023
1 parent 0d9151c commit f73a29f
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 8 deletions.
8 changes: 4 additions & 4 deletions src/RoomSearch/components/Selection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ interface SelectionProps {
setRoomType: React.Dispatch<React.SetStateAction<RoomSelectType>>;
}

const TYPES = ['all', 'morning', 'night'] as const;
const TYPES = ['ALL', 'MORNING', 'NIGHT'] as const;
const typeMap = {
all: '전체',
morning: '아침',
night: '밤'
ALL: '전체',
MORNING: '아침',
NIGHT: '밤'
};

const Selection = ({ currentRoomType, setRoomType }: SelectionProps) => {
Expand Down
1 change: 0 additions & 1 deletion src/core/api/functions/roomAPI.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ const roomAPI = {
},

getRoomsAll: async (params?: RoomsRequestParams) => {
console.log(params);
return await baseInstance.get<TotalRooms>('/rooms', { params });
}
};
Expand Down
5 changes: 4 additions & 1 deletion src/core/api/queries/useSearchRooms.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ const useSearchRooms = ({
queryKey: ['rooms', roomType, keyword],

queryFn: ({ pageParam }) => {
const params: RoomsRequestParams = { roomType };
const params: RoomsRequestParams = {};
if (roomType !== 'ALL') {
params.roomType = roomType;
}
if (pageParam > 0) {
params.roomId = pageParam;
}
Expand Down
2 changes: 1 addition & 1 deletion src/core/types/TotalRooms.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { DayType } from '.';

export type RoomSelectType = 'morning' | 'night' | 'all';
export type RoomSelectType = 'ALL' | 'MORNING' | 'NIGHT';

export interface Room {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion src/pages/SearchPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import ResultListFallback from '@/RoomSearch/components/ResultListFallback';
import { NetworkFallback } from '@/shared/ErrorBoundary';

const SearchPage = () => {
const [roomType, setRoomType] = useState<RoomSelectType>('all');
const [roomType, setRoomType] = useState<RoomSelectType>('ALL');
const [keyword, setKeyword] = useState('');

return (
Expand Down

0 comments on commit f73a29f

Please sign in to comment.