Skip to content
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

Feature/meetingroom qa #43

Merged
merged 3 commits into from
Jun 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 20 additions & 5 deletions src/components/map/BranchInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ import { getSelectedOfficeInfo } from '@/api/map/getSelectedOffice';
import { getOfficeMeetingRoomCount } from '@/api/map/getAvailableOffice';
import TabSection from './TapSection';

const getBranchImage = (imageName: string): string => {
return `/branch/${imageName}`;
};

const BranchInfo: React.FC = () => {
const router = useRouter();
const { setReservedBranch } = useBranchStore2();
Expand All @@ -27,14 +31,25 @@ const BranchInfo: React.FC = () => {
const roadFromStation = router.query.roadFromStation as string;
const stationToBranch = router.query.stationToBranch as string;
const branchId = router.query.branchId;
const branchImage = router.query.image as string;

const imagePairs = [
['branch1-1.png', 'branch1-2.png'],
['branch2-1.png', 'branch2-2.png'],
['branch3-1.png', 'branch3-2.png']
];

const hash = Array.from(branchName).reduce((acc: number, char: string) => acc + char.charCodeAt(0), 0);
const pairIndex = hash % imagePairs.length;

const selectedImagePair = imagePairs[pairIndex];

const branchImage1 = getBranchImage(selectedImagePair[0]);
const branchImage2 = getBranchImage(selectedImagePair[1]);

const numericBranchId = Array.isArray(branchId) ? parseInt(branchId[0], 10) : parseInt(branchId as string, 10);

const [activeTab, setActiveTab] = useState('meetingRoom');

const imagePrefix = (branchImage || '').replace('.png', '');

console.log(branchId);
console.log(numericBranchId)

Expand Down Expand Up @@ -155,7 +170,7 @@ const BranchInfo: React.FC = () => {
onSlideChange={(swiper) => setCurrentSlide(swiper.realIndex + 1)}>
<SwiperSlide className="flex justify-center items-center h-full relative">
<Image
src={`${imagePrefix}-1.png`}
src={branchImage1}
alt="Office Image 1"
width={500}
height={246}
Expand All @@ -167,7 +182,7 @@ const BranchInfo: React.FC = () => {
</SwiperSlide>
<SwiperSlide className="flex justify-center items-center h-full relative">
<Image
src={`${imagePrefix}-2.png`}
src={branchImage2}
alt="Office Image 2"
width={500}
height={246}
Expand Down
1 change: 0 additions & 1 deletion src/components/map/BranchModal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ const BranchModal: React.FC<ModalProps> = ({ isOpen, onClose, branchName, branch
roadFromStation: officeInfo.roadFromStation,
stationToBranch: officeInfo.stationToBranch.join(','),
branchId: officeInfo.branchId as number,
image: getBranchImage(branchName),
}
}, `/branches/${encodeURIComponent(branchName)}`);
} catch (error) {
Expand Down
14 changes: 8 additions & 6 deletions src/components/reservation/meetingRoom/MeetingRoomIndex.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,22 @@ const formatDisplayDate = (startDate: Date, endDate: Date): string => {

const setInitialDateTime = (): [Date, Date, string] => {
const now = new Date();
let startAt: Date;
const roundedMinutes = Math.ceil(now.getMinutes() / 30) * 30;
const startAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), roundedMinutes, 0);

if (now.getMinutes() > 30) {
startAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours() + 1, 0, 0);
let endAt: Date;
if (startAt.getHours() === 23 && startAt.getMinutes() === 30) {
endAt = new Date(startAt.getTime() + 30 * 60 * 1000);
} else {
startAt = new Date(now.getFullYear(), now.getMonth(), now.getDate(), now.getHours(), 30, 0);
endAt = new Date(startAt.getTime() + 60 * 60 * 1000);
}

const endAt = new Date(startAt.getTime() + 60 * 60 * 1000);
const currentTime = formatDisplayDate(startAt, endAt);

return [startAt, endAt, currentTime];
};


const setInitialParams = (startAt: Date, endAt: Date, branchName: string): GetMeetingRoomsParams => {
const formattedStartAt = formatDateToCustomString(startAt);
const formattedEndAt = formatDateToCustomString(endAt);
Expand Down Expand Up @@ -382,7 +384,7 @@ const MeetingRoomIndex: React.FC = () => {
</div>
<div className="flex mt-[4px] items-center">
<Image src={'/floor.svg'} width={14} height={14} alt="floor" className="mr-[6px]" />
<div className="text-stone-500 text-xs font-normal font-['Pretendard'] mr-[12px] my-auto">
<div className="text-stone-500 text-xs font-normal font-['Pretendard'] mr-[12px] mt-auto">
{room.meetingRoomFloor < 0 ? `B${Math.abs(room.meetingRoomFloor)}` : `${room.meetingRoomFloor}`}층
</div>
<Image src={'/capacity.svg'} width={14} height={14} alt="capacity" className="mr-[6px]" />
Expand Down
2 changes: 1 addition & 1 deletion src/components/reservation/meetingRoom/MeetingRoomInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,7 @@ const MeetingRoomInfo = () => {
<div className="text-black/opacity-20 text-lg font-bold font-['Pretendard']">{meetingRoom.meetingRoomName}</div>
<div className="flex flex-row items-center">
<Image src={'/floor.svg'} width={14} height={14} alt="floor" className="mr-[6px]" />
<div className="text-stone-500 text-xs font-normal font-['Pretendard'] mr-[12px] my-auto">
<div className="text-stone-500 text-xs font-normal font-['Pretendard'] mr-[12px] mt-auto">
{meetingRoom.meetingRoomFloor < 0 ? `B${Math.abs(meetingRoom.meetingRoomFloor)}` : `${meetingRoom.meetingRoomFloor}`}층
</div>
<Image src={'/capacity.svg'} width={14} height={14} alt="capacity" className="mr-[6px]" />
Expand Down
Loading