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

[FE] 달력 확정 페이지에서도 약속 잠금 모달을 사용할 수 있도록 수정 #430

Merged
merged 1 commit into from
Oct 25, 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
48 changes: 43 additions & 5 deletions frontend/src/components/MeetingConfirmCalendar/Viewer/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,14 @@ import {
import { Button } from '@components/_common/Buttons/Button';
import TabButton from '@components/_common/Buttons/TabButton';
import Calendar from '@components/_common/Calendar';
import MeetingLockConfirmModal from '@components/_common/Modal/MeetingLockConfirmModal';
import ScreenReaderOnly from '@components/_common/ScreenReaderOnly';
import Text from '@components/_common/Text';

import useConfirmModal from '@hooks/useConfirmModal/useConfirmModal';
import useRouter from '@hooks/useRouter/useRouter';

import { useLockMeetingMutation } from '@stores/servers/meeting/mutations';
import { useGetSchedules } from '@stores/servers/schedule/queries';

import { formatAriaTab } from '@utils/a11y';
Expand Down Expand Up @@ -52,6 +56,11 @@ export default function Viewer({
const { handleToggleIsTimePickerUpdate } = useContext(TimePickerUpdateStateContext);
const { isLoggedIn, userName } = useContext(AuthContext).state;

const { isConfirmModalOpen, onToggleConfirmModal } = useConfirmModal();
const { mutate: lockMutate } = useLockMeetingMutation();

const routerToMeetingConfirmPage = () => routeTo(`/meeting/${uuid}/confirm`);

const handleScheduleUpdate = () => {
if (!isLoggedIn) {
alert('로그인 해주세요');
Expand All @@ -78,6 +87,20 @@ export default function Viewer({
}
};

const handleConfirmPageRoute = () => {
if (!isLocked) {
onToggleConfirmModal();
return;
}

routerToMeetingConfirmPage();
};

const handleMeetingLockWithRoute = () => {
lockMutate(uuid);
routerToMeetingConfirmPage();
};

return (
meetingSchedules && (
<>
Expand Down Expand Up @@ -139,11 +162,7 @@ export default function Viewer({
<footer css={s_bottomFixedButtonContainer}>
<div css={s_fullButtonContainer}>
{hostName === userName ? (
<Button
size="full"
variant="primary"
onClick={() => routeTo(`/meeting/${uuid}/confirm`)}
>
<Button size="full" variant="primary" onClick={handleConfirmPageRoute}>
약속 시간 확정하기
</Button>
) : (
Expand All @@ -165,6 +184,25 @@ export default function Viewer({
<Pen width="28" height="28" />
</button>
</footer>

<MeetingLockConfirmModal
isOpen={isConfirmModalOpen}
onClose={onToggleConfirmModal}
onConfirm={handleMeetingLockWithRoute}
onSecondButtonClick={routerToMeetingConfirmPage}
title="약속 잠금 결정"
size="small"
position="center"
buttonPosition="column"
>
<Text variant="default" typo="captionMedium">
약속을 확정하기 위해서는 우선
<Text.Accent text=" 약속을 잠가야 합니다" />
</Text>
<Text variant="default" typo="captionMedium">
약속을 잠그고 약속 확정 페이지로 이동할까요?
</Text>
</MeetingLockConfirmModal>
</>
)
);
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/stores/servers/user/mutations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export const usePostLoginMutation = () => {

setIsLoggedIn(true);
setUserName(userName);
routeTo(`/meeting/${uuid}`);
routeTo(`/meeting/${uuid}/register`);
},
});
};
Expand Down