Skip to content

Commit

Permalink
feat: 추천 api 연결
Browse files Browse the repository at this point in the history
  • Loading branch information
jiohjung98 committed Jun 10, 2024
1 parent acbb702 commit 3ad8dda
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 19 deletions.
File renamed without changes.
40 changes: 21 additions & 19 deletions src/components/reservation/meetingRoom/MeetingRoomIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import Image from 'next/image';
import DatePickerModal from './DatePickerModal';
import { useRouter } from 'next/router';
import { useBranchStore } from '@/store/branch.store';
import { getBranchesByDistance } from '@/api/reservation/getBranchesByDistance';

const formatDateToCustomString = (date: Date): string => {
const year = date.getFullYear();
Expand Down Expand Up @@ -148,6 +149,7 @@ const MeetingRoomIndex: React.FC = () => {

useEffect(() => {
}, [meetingRooms]);


const roomTypeMap: { [key: string]: string } = {
'MINI': '미니(1-4인)',
Expand Down Expand Up @@ -263,25 +265,25 @@ const MeetingRoomIndex: React.FC = () => {
setActiveTabState(tab);
setShowModal(true);
};
// const getCapacityText = (capacity: number) => {
// if (capacity === 1 || capacity === 5 || capacity === 9 || capacity === 13) {
// return `${capacity}명`;
// }
// if (capacity > 1 && capacity < 5) {
// return `1~${capacity}명`;
// }
// if (capacity > 5 && capacity < 9) {
// return `5~${capacity}명`;
// }
// if (capacity > 9 && capacity < 13) {
// return `9~${capacity}명`;
// }
// if (capacity === 14 || capacity === 15) {
// return `13~${capacity}명`;
// }
// return `${capacity}명`;
// };

const fetchBranchesByDistance = async (latitude: number, longitude: number) => {
try {
const branches = await getBranchesByDistance(latitude, longitude);
console.log('Branches by distance:', branches);
} catch (error) {
console.error('Error fetching branches by distance:', error);
}
};

useEffect(() => {
if (meetingRooms.length === 0) {
const latitude = currentBranch!.branchLatitude
const longitude = currentBranch!.branchLongitude
fetchBranchesByDistance(latitude, longitude);
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [meetingRooms]);


return (
<div className="p-4 h-screen">
Expand Down

0 comments on commit 3ad8dda

Please sign in to comment.