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

[Fix] 제출 기한 지나면 제출 못하도록 막기 #387

Merged
merged 3 commits into from
Aug 13, 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
9 changes: 9 additions & 0 deletions src/views/ApplyPage/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import useCheckBrowser from '@hooks/useCheckBrowser';
import useDate from '@hooks/useDate';
import useScrollToHash from '@hooks/useScrollToHash';
import { DraftDialog, SubmitDialog } from 'views/dialogs';
import PreventApplyDialog from 'views/dialogs/PreventApplyDialog';
import NoMore from 'views/ErrorPage/components/NoMore';
import BigLoading from 'views/loadings/BigLoding';

Expand Down Expand Up @@ -35,6 +36,7 @@ const ApplyPage = ({ onSetComplete }: ApplyPageProps) => {
useCheckBrowser(); // 크롬 브라우저 권장 알럿

const draftDialog = useRef<HTMLDialogElement>(null);
const preventApplyDialog = useRef<HTMLDialogElement>(null);
const submitDialog = useRef<HTMLDialogElement>(null);
const sectionsRef = useRef<HTMLSelectElement[]>([]);

Expand Down Expand Up @@ -187,6 +189,12 @@ const ApplyPage = ({ onSetComplete }: ApplyPageProps) => {
const commonQuestionIds = commonQuestions?.questions.map((question) => question.id);

const handleSendData = (type: 'draft' | 'submit') => {
if (NoMoreApply) {
preventApplyDialog.current?.showModal();

return;
}

const mostRecentSeason = mostRecentSeasonValue === '해당사항 없음' ? 0 : mostRecentSeasonValue;
const leaveAbsence =
getValues('leaveAbsence') == undefined ? undefined : getValues('leaveAbsence') === '재학' ? false : true;
Expand Down Expand Up @@ -269,6 +277,7 @@ const ApplyPage = ({ onSetComplete }: ApplyPageProps) => {
return (
<FormProvider {...methods}>
<DraftDialog ref={draftDialog} />
<PreventApplyDialog ref={preventApplyDialog} />
<SubmitDialog
userInfo={{
name,
Expand Down
24 changes: 24 additions & 0 deletions src/views/dialogs/PreventApplyDialog/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { forwardRef, type KeyboardEvent } from 'react';

import Dialog from '@components/Dialog';

import { buttonInside, buttonOutside, buttonWrapper, mainText } from '../style.css';

const PreventApplyDialog = forwardRef<HTMLDialogElement>((_, ref) => {
const handlePreventESCKeyPress = (e: KeyboardEvent<HTMLDialogElement>) => {
if (e.key === 'Escape') e.preventDefault();
};

return (
<Dialog ref={ref} onKeyDown={handlePreventESCKeyPress}>
<p className={mainText}>지원서 제출 기한이 지났어요.</p>
<form method="dialog" className={`${buttonWrapper} ${buttonOutside.solid}`}>
<button className={buttonInside.solid}>확인</button>
</form>
</Dialog>
);
});

PreventApplyDialog.displayName = 'PreventApplyDialog';

export default PreventApplyDialog;