|
3 | 3 | import { useEffect, useState } from 'react'; |
4 | 4 | import Image from 'next/image'; |
5 | 5 | import { useTranslations } from 'next-intl'; |
6 | | -import { cn } from '@gitanimals/ui-tailwind'; |
| 6 | +import { Button, cn, Dialog } from '@gitanimals/ui-tailwind'; |
7 | 7 | import { wrap } from '@suspensive/react'; |
8 | 8 |
|
9 | 9 | import { Background } from '@/app/[locale]/game/quiz/_components/BackGround'; |
10 | | -import CompleteAlertDialog from '@/app/[locale]/game/quiz/solve/_components/done/CompleteAlertDialog'; |
11 | | -import FailAlertDialog from '@/app/[locale]/game/quiz/solve/_components/fail/FailAlertDialog'; |
12 | 10 | import QuizProgressBar from '@/app/[locale]/game/quiz/solve/_components/solving/QuizProgressBar'; |
13 | | -import CorrectConfirmDialog from '@/app/[locale]/game/quiz/solve/_components/success/CorrectConfirmDialog'; |
14 | 11 | import { QUIZ_ANSWER } from '@/app/[locale]/game/quiz/solve/_constants/solveQuiz.constants'; |
15 | 12 | import { customScrollStyle } from '@/styles/scrollStyle'; |
16 | 13 |
|
| 14 | +import { customT } from '../../../_utils/quiz.intl'; |
17 | 15 | import useQuizAction from '../../_hooks/useQuizAction'; |
18 | 16 | import useQuizData from '../../_hooks/useQuizData'; |
19 | 17 | import useQuizDialogStatus from '../../_hooks/useQuizDialogStatus'; |
@@ -90,18 +88,106 @@ const SolvingQuizSection = wrap |
90 | 88 | </div> |
91 | 89 | </div> |
92 | 90 | </div> |
93 | | - <CorrectConfirmDialog |
94 | | - isOpen={correctDialog.isOpen} |
95 | | - onClose={correctDialog.close} |
96 | | - onStop={async () => { |
97 | | - await stopQuiz(); |
98 | | - await terminateQuiz(); |
99 | | - }} |
100 | | - onConfirm={moveToNextStage} |
101 | | - correctPoint={prize} |
102 | | - /> |
103 | | - <FailAlertDialog isOpen={failDialog.isOpen} onClose={moveToQuizMain} /> |
104 | | - <CompleteAlertDialog isOpen={completeDialog.isOpen} onClose={terminateQuiz} completePoint={prize} /> |
| 91 | + <Dialog open={correctDialog.isOpen} onOpenChange={(open) => !open && stopQuiz().then(() => terminateQuiz())}> |
| 92 | + <Dialog.Content |
| 93 | + className="flex w-full flex-col items-center gap-[12px]" |
| 94 | + isShowClose={false} |
| 95 | + onEscapeKeyDown={(e) => e.preventDefault()} |
| 96 | + onPointerDownOutside={(e) => e.preventDefault()} |
| 97 | + > |
| 98 | + <div className="flex w-full flex-col items-center gap-[12px]"> |
| 99 | + <Dialog.Title className="!glyph24-bold !text-center [font-family:'Product_Sans'] font-bold"> |
| 100 | + {t('correct-dialog.title')} |
| 101 | + </Dialog.Title> |
| 102 | + <Dialog.Description className="glyph16-regular text-center [font-family:'Product_Sans'] font-normal text-white-75 [word-break:keep-all]"> |
| 103 | + {t('correct-dialog.description')} |
| 104 | + </Dialog.Description> |
| 105 | + </div> |
| 106 | + <Image |
| 107 | + className="my-[4px]" |
| 108 | + src="/assets/game/quiz/quiz-coin.svg" |
| 109 | + alt="quiz-coin" |
| 110 | + width={160} |
| 111 | + height={160} |
| 112 | + draggable={false} |
| 113 | + /> |
| 114 | + <div className="flex w-full flex-col gap-[8px]"> |
| 115 | + <Button className="w-full" onClick={moveToNextStage} variant="primary" size="m"> |
| 116 | + {t('correct-dialog.challenge-button')} |
| 117 | + </Button> |
| 118 | + <Button |
| 119 | + className="w-full" |
| 120 | + onClick={() => stopQuiz().then(() => terminateQuiz())} |
| 121 | + variant="secondary" |
| 122 | + size="m" |
| 123 | + > |
| 124 | + {customT(t('correct-dialog.stop-button'), { point: prize })} |
| 125 | + </Button> |
| 126 | + </div> |
| 127 | + </Dialog.Content> |
| 128 | + </Dialog> |
| 129 | + <Dialog open={failDialog.isOpen} onOpenChange={(open) => !open && moveToQuizMain()}> |
| 130 | + <Dialog.Content |
| 131 | + className="flex w-full flex-col items-center gap-[12px]" |
| 132 | + isShowClose={false} |
| 133 | + onEscapeKeyDown={(e) => e.preventDefault()} |
| 134 | + onPointerDownOutside={(e) => e.preventDefault()} |
| 135 | + > |
| 136 | + <div className="flex w-full flex-col items-center gap-[12px]"> |
| 137 | + <Dialog.Title className="!glyph24-bold !text-center [font-family:'Product_Sans'] font-bold"> |
| 138 | + {t('fail-dialog.title')} |
| 139 | + </Dialog.Title> |
| 140 | + <Dialog.Description className="glyph16-regular text-center [font-family:'Product_Sans'] font-normal text-white-75 [word-break:keep-all]"> |
| 141 | + {t('fail-dialog.description')} |
| 142 | + </Dialog.Description> |
| 143 | + </div> |
| 144 | + <div className="my-[4px] flex h-[160px] w-[160px] items-center justify-center"> |
| 145 | + <Image |
| 146 | + src="/assets/game/quiz/cursor-unchoiced.webp" |
| 147 | + alt="quiz-failed" |
| 148 | + width={100} |
| 149 | + height={100} |
| 150 | + draggable={false} |
| 151 | + /> |
| 152 | + </div> |
| 153 | + <div className="flex w-full"> |
| 154 | + <Button className="w-full" onClick={moveToQuizMain} variant="secondary" size="m"> |
| 155 | + {t('fail-dialog.close-button')} |
| 156 | + </Button> |
| 157 | + </div> |
| 158 | + </Dialog.Content> |
| 159 | + </Dialog> |
| 160 | + <Dialog open={completeDialog.isOpen} onOpenChange={(open) => !open && terminateQuiz()}> |
| 161 | + <Dialog.Content |
| 162 | + className="flex w-full flex-col items-center gap-[12px]" |
| 163 | + isShowClose={false} |
| 164 | + onEscapeKeyDown={(e) => e.preventDefault()} |
| 165 | + onPointerDownOutside={(e) => e.preventDefault()} |
| 166 | + > |
| 167 | + <div className="flex w-full flex-col items-center gap-[12px]"> |
| 168 | + <Dialog.Title className="!glyph24-bold !text-center [font-family:'Product_Sans'] font-bold"> |
| 169 | + {t('complete-dialog.title')} |
| 170 | + </Dialog.Title> |
| 171 | + <Dialog.Description className="glyph16-regular text-center [font-family:'Product_Sans'] font-normal text-white-75 [word-break:keep-all]"> |
| 172 | + {customT(t('complete-dialog.description'), { point: prize })} |
| 173 | + </Dialog.Description> |
| 174 | + </div> |
| 175 | + <div className="my-[4px] flex h-[160px] w-[160px] items-center justify-center"> |
| 176 | + <Image |
| 177 | + src="/assets/game/quiz/quiz-double-coin.webp" |
| 178 | + alt="quiz-complete" |
| 179 | + width={204} |
| 180 | + height={184} |
| 181 | + draggable={false} |
| 182 | + /> |
| 183 | + </div> |
| 184 | + <div className="flex w-full"> |
| 185 | + <Button className="w-full" onClick={terminateQuiz} variant="secondary" size="m"> |
| 186 | + {t('complete-dialog.close-button')} |
| 187 | + </Button> |
| 188 | + </div> |
| 189 | + </Dialog.Content> |
| 190 | + </Dialog> |
105 | 191 | </> |
106 | 192 | ); |
107 | 193 | }); |
|
0 commit comments