-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(fe): show modal when leaving create and edit page (#2031)
* feat(fe): show modal in admin contest * feat(fe): add contest create modal * feat(fe): add alert to contest create and edit * feat(be): add get-contest-submission-informations api (#1894) * feat(be): add contest-submission-result model * chore(be): rename contest-submission-result to contest-submission-information * chore(be): set nullability of fields in contest-submission-information * feat(be): add get-contest-submission-informations api * chore(be): rename * test(be): add test * docs(be): add docs * chore(be): rename files and add fields on contest-submission-summary-for-one * feat(be): implement combine score summary and submissions * chore(be): comment test * feat(be): add problem-id option * fix(be): fix wrong type * docs(be): rename files * docs(be): rename file * docs(be): rename files * fix(be): fix ContestSubmissionSummaryForOne model * docs(be): remove resolved todo * chore(be): lint contest.service.spec * fix(be): don't throw error when no submission --------- Co-authored-by: 강민석 <min.seok@g.skku.edu> Co-authored-by: jimin9038 <jimin9038@g.skku.edu> * fix(fe): redirect to home when user logged out (#2027) * feat(infra): add capacity provider strategy to ecs cluster (#2026) * feat(infra): add capacity provider strategy to ecs cluster * feat(infra): modify weight of capacity provider strategy to 1 * feat(fe): edit create problem page (#1923) * feat(fe): edit popover text and padding * chore(fe): add space between title and visible, add left margin to angleleft * chore(fe): add color to radio button, adjust gaps * feat(fe): change checkbox design, delete tag select, change box order * chore(fe): change toggle color, move template field * chore(fe): move title, add space between title and visible, move template up hint and source * fix(fe): comment out tags and get tag * chore(fe): delete comment about tag feature * chore(fe): delete comments * chore(fe): delete comments --------- Co-authored-by: Jiho Park <59248080+jihorobert@users.noreply.github.com> * chore(fe): hide test button (#2028) Co-authored-by: Jiho Park <59248080+jihorobert@users.noreply.github.com> * chore(fe): edit admin contest toggle title text (#2030) * feat(be): implement getContestScoreSummaries api (#2029) * feat(be): implement getContestScoreSummaries * fix(be): make userContestScoreSummaryWithUserInfo model to return user * docs(be): getcontestscoresummaries * fix(be): rename get contest score api * feat(be): sperate testcases into sample or hidden (#2000) * feat(be): delete example-io and add is-hidden-testcase field * feat(be): modify get-problem api to return testcases * docs(be): add is-hidden-testcase * fix(be): rename variable name of problem-response * docs(be): add problem-testcase field * docs(be): add todo on create-testcases - TODO: 테스트케이스 저장 방식 S3 => DB 직접 저장으로 변경 시 함수 삭제 * chore(be): change is-hidden-testcase to is-hidden * fix(fe): erase sample in admin, change samples to problem testcase in client --------- Co-authored-by: b0xercat <seojin3154@naver.com> Co-authored-by: jimin9038 <jimin9038@g.skku.edu> * feat(fe): add contest create modal * feat(fe): add modal to problem create and edit * feat(fe): make confirmnavigation reusable * fix(fe): disable confirm when creating --------- Co-authored-by: Jaehyeon Kim <kjhkk1020@naver.com> Co-authored-by: 강민석 <min.seok@g.skku.edu> Co-authored-by: jimin9038 <jimin9038@g.skku.edu> Co-authored-by: YooJin Lee <113789141+youznn@users.noreply.github.com> Co-authored-by: Eunsu Kang <56429615+ssupecial@users.noreply.github.com> Co-authored-by: 박주형 <80684730+juhyeong0505@users.noreply.github.com> Co-authored-by: Jiho Park <59248080+jihorobert@users.noreply.github.com> Co-authored-by: Kwon Seo Jin <97675977+B0XERCAT@users.noreply.github.com> Co-authored-by: b0xercat <seojin3154@naver.com>
- Loading branch information
1 parent
07f38e1
commit b806a31
Showing
5 changed files
with
146 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { useRouter } from 'next/navigation' | ||
import type { MutableRefObject } from 'react' | ||
import { useEffect } from 'react' | ||
|
||
export const useConfirmNavigation = ( | ||
shouldSkipWarningRef: MutableRefObject<boolean> | ||
) => { | ||
const router = useRouter() | ||
const handleBeforeUnload = (event: BeforeUnloadEvent) => { | ||
event.preventDefault() | ||
event.returnValue = '' | ||
} | ||
|
||
useEffect(() => { | ||
window.addEventListener('beforeunload', handleBeforeUnload) | ||
|
||
const originalPush = router.push | ||
|
||
router.push = (href, ...args) => { | ||
if (shouldSkipWarningRef.current) { | ||
originalPush(href, ...args) | ||
return | ||
} | ||
const shouldWarn = window.confirm( | ||
'Are you sure you want to leave this page? Changes you made may not be saved.' | ||
) | ||
if (shouldWarn) { | ||
originalPush(href, ...args) | ||
} | ||
} | ||
|
||
return () => { | ||
window.removeEventListener('beforeunload', handleBeforeUnload) | ||
router.push = originalPush | ||
} | ||
}, [router, shouldSkipWarningRef.current]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters