diff --git a/apps/admin/app/studies/detail-info/[studyId]/@modal/default.tsx b/apps/admin/app/studies/detail-info/[studyId]/@modal/default.tsx deleted file mode 100644 index 395785b9..00000000 --- a/apps/admin/app/studies/detail-info/[studyId]/@modal/default.tsx +++ /dev/null @@ -1,5 +0,0 @@ -const Default = () => { - return null; -}; - -export default Default; diff --git a/apps/admin/app/studies/detail-info/[studyId]/_components/CreateStudyDetailInfo.tsx b/apps/admin/app/studies/detail-info/[studyId]/_components/CreateStudyDetailInfo.tsx index 54fc682f..fba95d7e 100644 --- a/apps/admin/app/studies/detail-info/[studyId]/_components/CreateStudyDetailInfo.tsx +++ b/apps/admin/app/studies/detail-info/[studyId]/_components/CreateStudyDetailInfo.tsx @@ -2,13 +2,11 @@ import { zodResolver } from "@hookform/resolvers/zod"; import { Flex } from "@styled-system/jsx"; import { Space, Text } from "@wow-class/ui"; -import { routerPath } from "constants/router/routerPath"; -import { useRouter } from "next/navigation"; +import { useOpenState } from "@wow-class/ui/hooks"; import type { CSSProperties, MouseEvent } from "react"; -import { Suspense, useEffect } from "react"; +import { Suspense, useEffect, useState } from "react"; import { FormProvider, useForm } from "react-hook-form"; import type { CreateStudyDetailInfoApiRequestDto } from "types/dtos/studyDetailInfo"; -import createQueryString from "utils/createQueryString"; import { studyDetailInfoSchema } from "utils/validate/studyDetailInfo"; import Button from "wowds-ui/Button"; @@ -17,10 +15,11 @@ import Header from "@/studies/[studyId]/_components/header/Header"; import usePrefillStudyDetailInfo from "../_hooks/usePrefillStudyDetailInfo"; import StudyCurriculum from "./StudyCurriculum"; import StudyDescription from "./StudyDescription"; +import StudyDetailInfoCheckModal from "./StudyDetailInfoCheckModal"; const CreateStudyDetailInfo = ({ params }: { params: { studyId: string } }) => { const { studyId } = params; - const router = useRouter(); + const { open, setOpen, onClose } = useOpenState(); const prefillStudyInfo = usePrefillStudyDetailInfo(parseInt(studyId, 10)); const methods = useForm({ resolver: zodResolver(studyDetailInfoSchema), @@ -32,15 +31,18 @@ const CreateStudyDetailInfo = ({ params }: { params: { studyId: string } }) => { const handleSubmit = (e: MouseEvent) => { e.preventDefault(); - const formData = methods.getValues(); - const route = createQueryString( - `${studyId}${routerPath["detail-info-check"].href}?studyId=${studyId}`, - formData - ); - router.push(route); + setOpen(true); }; + return ( + {open && ( + + )} { +const StudyDetailInfoCheckModal = ({ + formData, + studyId, + onClose, +}: { + formData: CreateStudyDetailInfoApiRequestDto; + studyId: string; + onClose: () => void; +}) => { const [studyName, setStudyName] = useState(""); - const { onClose } = useModalRoute(); - const { parseQueryString } = useParseSearchParams(); - const searchParams = useSearchParams(); - const { studyId, ...formData } = parseQueryString< - CreateStudyDetailInfoApiRequestDto & { studyId: string } - >(searchParams.toString()); const { isSuccess, handleSubmitDetailInfo } = useSubmitStudyDetailInfo( parseInt(studyId, 10), @@ -35,7 +33,7 @@ const StudyDetailInfoCheckModal = () => { }, [studyId]); return ( - + { - return null; -}; - -export default Default; diff --git a/apps/admin/app/studies/detail-info/[studyId]/layout.tsx b/apps/admin/app/studies/detail-info/[studyId]/layout.tsx index d7907bbe..8e5b133f 100644 --- a/apps/admin/app/studies/detail-info/[studyId]/layout.tsx +++ b/apps/admin/app/studies/detail-info/[studyId]/layout.tsx @@ -1,16 +1,9 @@ const StudyDetailInfoLayout = ({ children, - modal, }: Readonly<{ children: React.ReactNode; - modal: React.ReactNode; }>) => { - return ( -
- {children} - {modal} -
- ); + return
{children}
; }; const MainLayoutStyle = {