diff --git a/src/components/common/ToggleButton.tsx b/src/components/common/ToggleButton.tsx index 4a540da4..7c99bc3a 100644 --- a/src/components/common/ToggleButton.tsx +++ b/src/components/common/ToggleButton.tsx @@ -16,11 +16,11 @@ export default function ToggleButton({ id, checked, onChange: handleChange }: To /> {/* prettier-ignore */} + absolute bottom-0 left-0 right-0 top-0 cursor-pointer rounded-full bg-disable transition duration-300 + before:content-[''] before:absolute before:left-2 before:top-1/2 before:-translate-y-1/2 before:size-7 + before:rounded-full before:bg-white before:transition before:duration-300 + peer-checked:bg-main peer-checked:before:translate-x-9 + "/> ); } diff --git a/src/components/modal/project-status/CreateModalProjectStatus.tsx b/src/components/modal/project-status/CreateModalProjectStatus.tsx index 853e41ec..669ecf1e 100644 --- a/src/components/modal/project-status/CreateModalProjectStatus.tsx +++ b/src/components/modal/project-status/CreateModalProjectStatus.tsx @@ -1,15 +1,18 @@ -import { SubmitHandler } from 'react-hook-form'; import ModalLayout from '@layouts/ModalLayout'; import ModalPortal from '@components/modal/ModalPortal'; import ModalProjectStatusForm from '@components/modal/project-status/ModalProjectStatusForm'; import ModalFormButton from '@components/modal/ModalFormButton'; -import { ProjectStatusForm } from '@/types/ProjectStatusType'; + +import type { SubmitHandler } from 'react-hook-form'; +import type { Project } from '@/types/ProjectType'; +import type { ProjectStatusForm } from '@/types/ProjectStatusType'; type CreateModalProjectStatusProps = { + project: Project; onClose: () => void; }; -export default function CreateModalProjectStatus({ onClose: handleClose }: CreateModalProjectStatusProps) { +export default function CreateModalProjectStatus({ project, onClose: handleClose }: CreateModalProjectStatusProps) { // ToDo: 상태 생성을 위한 네트워크 로직 추가 const handleSubmit: SubmitHandler = async (data) => { console.log('생성 폼 제출'); @@ -19,7 +22,7 @@ export default function CreateModalProjectStatus({ onClose: handleClose }: Creat return ( - + diff --git a/src/components/modal/project-status/ModalProjectStatusForm.tsx b/src/components/modal/project-status/ModalProjectStatusForm.tsx index c9a78088..2e1afed8 100644 --- a/src/components/modal/project-status/ModalProjectStatusForm.tsx +++ b/src/components/modal/project-status/ModalProjectStatusForm.tsx @@ -1,18 +1,22 @@ -import { SubmitHandler, useForm } from 'react-hook-form'; +import { useForm } from 'react-hook-form'; +import { RiProhibited2Fill } from 'react-icons/ri'; import { STATUS_VALIDATION_RULES } from '@constants/formValidationRules'; -import useProjectStatusQuery from '@hooks/query/useProjectStatusQuery'; import DuplicationCheckInput from '@components/common/DuplicationCheckInput'; -import { RiProhibited2Fill } from 'react-icons/ri'; +import useStatusQuery from '@hooks/query/useStatusQuery'; + +import type { SubmitHandler } from 'react-hook-form'; import type { ProjectStatus, ProjectStatusForm } from '@/types/ProjectStatusType'; +import type { Project } from '@/types/ProjectType'; type ModalProjectStatusFormProps = { formId: string; + project: Project; statusId?: ProjectStatus['statusId']; onSubmit: SubmitHandler; }; -export default function ModalProjectStatusForm({ formId, statusId, onSubmit }: ModalProjectStatusFormProps) { - const { initialValue, nameList, colorList, usableColorList } = useProjectStatusQuery(statusId); +export default function ModalProjectStatusForm({ formId, project, statusId, onSubmit }: ModalProjectStatusFormProps) { + const { initialValue, nameList, colorList, usableColorList } = useStatusQuery(project.projectId, statusId); const { register, watch, @@ -20,17 +24,15 @@ export default function ModalProjectStatusForm({ formId, statusId, onSubmit }: M formState: { errors }, } = useForm({ mode: 'onChange', - defaultValues: initialValue || { name: '', color: '' }, + defaultValues: initialValue, }); - const statusName = watch('name'); - const selectedColor = watch('color'); return (
void; }; -export default function UpdateModalProjectStatus({ statusId, onClose: handleClose }: UpdateModalProjectStatusProps) { +export default function UpdateModalProjectStatus({ + project, + statusId, + onClose: handleClose, +}: UpdateModalProjectStatusProps) { // ToDo: 상태 수정을 위한 네트워크 로직 추가 const handleSubmit: SubmitHandler = async (data) => { console.log(statusId, '수정 폼 제출'); @@ -21,7 +28,12 @@ export default function UpdateModalProjectStatus({ statusId, onClose: handleClos return ( - + diff --git a/src/components/modal/task/CreateModalTask.tsx b/src/components/modal/task/CreateModalTask.tsx index 7707e734..c5342da2 100644 --- a/src/components/modal/task/CreateModalTask.tsx +++ b/src/components/modal/task/CreateModalTask.tsx @@ -1,10 +1,11 @@ -import { SubmitHandler } from 'react-hook-form'; import ModalLayout from '@layouts/ModalLayout'; import ModalPortal from '@components/modal/ModalPortal'; import ModalTaskForm from '@components/modal/task/ModalTaskForm'; import ModalFormButton from '@components/modal/ModalFormButton'; -import { TaskForm } from '@/types/TaskType'; -import { Project } from '@/types/ProjectType'; + +import type { SubmitHandler } from 'react-hook-form'; +import type { TaskForm } from '@/types/TaskType'; +import type { Project } from '@/types/ProjectType'; type CreateModalTaskProps = { project: Project; diff --git a/src/components/modal/task/ModalTaskForm.tsx b/src/components/modal/task/ModalTaskForm.tsx index b6c940a2..4ffe4ff6 100644 --- a/src/components/modal/task/ModalTaskForm.tsx +++ b/src/components/modal/task/ModalTaskForm.tsx @@ -1,13 +1,16 @@ import { useState } from 'react'; import { DateTime } from 'luxon'; import { IoSearch } from 'react-icons/io5'; -import { SubmitHandler, useForm } from 'react-hook-form'; +import { useForm } from 'react-hook-form'; import { TASK_VALIDATION_RULES } from '@constants/formValidationRules'; import ToggleButton from '@components/common/ToggleButton'; import DuplicationCheckInput from '@components/common/DuplicationCheckInput'; import useTaskQuery from '@hooks/query/useTaskQuery'; -import { Project } from '@/types/ProjectType'; -import { Task, TaskForm } from '@/types/TaskType'; +import useStatusQuery from '@hooks/query/useStatusQuery'; + +import type { SubmitHandler } from 'react-hook-form'; +import type { Project } from '@/types/ProjectType'; +import type { Task, TaskForm } from '@/types/TaskType'; type ModalTaskFormProps = { formId: string; @@ -18,7 +21,9 @@ type ModalTaskFormProps = { export default function ModalTaskForm({ formId, project, taskId, onSubmit }: ModalTaskFormProps) { const [hasDeadline, setHasDeadline] = useState(false); + const { statusList } = useStatusQuery(project.projectId, taskId); const { taskNameList } = useTaskQuery(project.projectId); + // ToDo: 상태 수정 모달 작성시 기본값 설정 방식 변경할 것 const { register, watch, @@ -34,6 +39,7 @@ export default function ModalTaskForm({ formId, project, taskId, onSubmit }: Mod content: '', startDate: DateTime.fromJSDate(new Date()).toFormat('yyyy-LL-dd'), endDate: DateTime.fromJSDate(new Date()).toFormat('yyyy-LL-dd'), + statusId: statusList[0].statusId, }, }); @@ -49,6 +55,35 @@ export default function ModalTaskForm({ formId, project, taskId, onSubmit }: Mod className="mb-20 flex w-4/5 max-w-375 grow flex-col justify-center" onSubmit={handleSubmit(onSubmit)} > + {/* ToDo: 상태 선택 리팩토링 할 것 */} +
+ {statusList.map((status) => { + const { statusId, name, color } = status; + const isChecked = +watch('statusId') === statusId; + return ( +