diff --git a/.vscode/extensions.json b/.vscode/extensions.json index f02cc327..b9e06b2a 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -9,6 +9,7 @@ "formulahendry.auto-rename-tag", "pkief.material-icon-theme", "equinusocio.vsc-material-theme", - "wix.vscode-import-cost" + "wix.vscode-import-cost", + "streetsidesoftware.code-spell-checker" ] } diff --git a/src/assets/calendar.svg b/src/assets/calendar.svg new file mode 100644 index 00000000..606052b5 --- /dev/null +++ b/src/assets/calendar.svg @@ -0,0 +1,6 @@ + + + + + + diff --git a/src/components/common/DuplicationCheckInput.tsx b/src/components/common/DuplicationCheckInput.tsx new file mode 100644 index 00000000..31f21855 --- /dev/null +++ b/src/components/common/DuplicationCheckInput.tsx @@ -0,0 +1,46 @@ +import { UseFormRegisterReturn } from 'react-hook-form'; +import { GiCheckMark } from 'react-icons/gi'; +import { RiProhibited2Line } from 'react-icons/ri'; + +type DuplicationCheckInputProp = { + id: string; + label?: string; + value: string; + placeholder?: string; + errors?: string; + register?: UseFormRegisterReturn; +}; + +export default function DuplicationCheckInput({ + id, + label, + value, + placeholder, + errors, + register, +}: DuplicationCheckInputProp) { + return ( + + ); +} diff --git a/src/components/common/ToggleButton.tsx b/src/components/common/ToggleButton.tsx new file mode 100644 index 00000000..4a540da4 --- /dev/null +++ b/src/components/common/ToggleButton.tsx @@ -0,0 +1,26 @@ +type ToggleButtonProps = { + id: string; + checked: boolean; + onChange: (e: React.ChangeEvent) => void; +}; + +export default function ToggleButton({ id, checked, onChange: handleChange }: ToggleButtonProps) { + return ( + + ); +} diff --git a/src/components/modal/ModaFormButton.tsx b/src/components/modal/ModalFormButton.tsx similarity index 76% rename from src/components/modal/ModaFormButton.tsx rename to src/components/modal/ModalFormButton.tsx index 6a0807ad..7cd99faa 100644 --- a/src/components/modal/ModaFormButton.tsx +++ b/src/components/modal/ModalFormButton.tsx @@ -4,9 +4,9 @@ type ModalFormButtonProps = { onClose: () => void; }; -export default function ModaFormButton({ formId, isCreate, onClose }: ModalFormButtonProps) { +export default function ModalFormButton({ formId, isCreate, onClose }: ModalFormButtonProps) { return ( -
+
diff --git a/src/components/modal/project-status/CreateModalProjectStatus.tsx b/src/components/modal/project-status/CreateModalProjectStatus.tsx index aea32a96..853e41ec 100644 --- a/src/components/modal/project-status/CreateModalProjectStatus.tsx +++ b/src/components/modal/project-status/CreateModalProjectStatus.tsx @@ -2,7 +2,7 @@ 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 ModaFormButton from '@components/modal/ModaFormButton'; +import ModalFormButton from '@components/modal/ModalFormButton'; import { ProjectStatusForm } from '@/types/ProjectStatusType'; type CreateModalProjectStatusProps = { @@ -19,10 +19,8 @@ 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 6febcb2e..c9a78088 100644 --- a/src/components/modal/project-status/ModalProjectStatusForm.tsx +++ b/src/components/modal/project-status/ModalProjectStatusForm.tsx @@ -1,8 +1,8 @@ import { SubmitHandler, useForm } from 'react-hook-form'; import { STATUS_VALIDATION_RULES } from '@constants/formValidationRules'; import useProjectStatusQuery from '@hooks/query/useProjectStatusQuery'; -import { GiCheckMark } from 'react-icons/gi'; -import { RiProhibited2Fill, RiProhibited2Line } from 'react-icons/ri'; +import DuplicationCheckInput from '@components/common/DuplicationCheckInput'; +import { RiProhibited2Fill } from 'react-icons/ri'; import type { ProjectStatus, ProjectStatusForm } from '@/types/ProjectStatusType'; type ModalProjectStatusFormProps = { @@ -27,28 +27,14 @@ export default function ModalProjectStatusForm({ formId, statusId, onSubmit }: M return (
- +

색상

{usableColorList.map(({ color, isUsable }, index) => ( diff --git a/src/components/modal/project-status/UpdateModalProjectStatus.tsx b/src/components/modal/project-status/UpdateModalProjectStatus.tsx index ae0a1256..acdf4296 100644 --- a/src/components/modal/project-status/UpdateModalProjectStatus.tsx +++ b/src/components/modal/project-status/UpdateModalProjectStatus.tsx @@ -2,7 +2,7 @@ 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 ModaFormButton from '@components/modal/ModaFormButton'; +import ModalFormButton from '@components/modal/ModalFormButton'; import { ProjectStatus, ProjectStatusForm } from '@/types/ProjectStatusType'; type UpdateModalProjectStatusProps = { @@ -21,10 +21,8 @@ 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 ad29c6be..7707e734 100644 --- a/src/components/modal/task/CreateModalTask.tsx +++ b/src/components/modal/task/CreateModalTask.tsx @@ -2,14 +2,16 @@ 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 ModaFormButton from '@components/modal/ModaFormButton'; +import ModalFormButton from '@components/modal/ModalFormButton'; import { TaskForm } from '@/types/TaskType'; +import { Project } from '@/types/ProjectType'; type CreateModalTaskProps = { + project: Project; onClose: () => void; }; -export default function CreateModalTask({ onClose: handleClose }: CreateModalTaskProps) { +export default function CreateModalTask({ project, onClose: handleClose }: CreateModalTaskProps) { // ToDo: 상태 생성을 위한 네트워크 로직 추가 const handleSubmit: SubmitHandler = async (data) => { console.log('생성 폼 제출'); @@ -19,11 +21,8 @@ export default function CreateModalTask({ onClose: handleClose }: CreateModalTas return ( -
- {/* ToDo: Task 생성 모달 작성시 수정할 것 */} - - -
+ +
); diff --git a/src/components/modal/task/ModalTaskForm.tsx b/src/components/modal/task/ModalTaskForm.tsx index 8eb50e21..b6c940a2 100644 --- a/src/components/modal/task/ModalTaskForm.tsx +++ b/src/components/modal/task/ModalTaskForm.tsx @@ -1,21 +1,119 @@ +import { useState } from 'react'; +import { DateTime } from 'luxon'; +import { IoSearch } from 'react-icons/io5'; import { SubmitHandler, 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'; -type ModalTaskFromProps = { +type ModalTaskFormProps = { formId: string; + project: Project; taskId?: Task['taskId']; onSubmit: SubmitHandler; }; -// ToDo: Task 모달 작성시 Task Form 만들기 -export default function ModalTaskForm({ formId, taskId, onSubmit }: ModalTaskFromProps) { - const { register, handleSubmit } = useForm({ +export default function ModalTaskForm({ formId, project, taskId, onSubmit }: ModalTaskFormProps) { + const [hasDeadline, setHasDeadline] = useState(false); + const { taskNameList } = useTaskQuery(project.projectId); + const { + register, + watch, + setValue, + getValues, + clearErrors, + handleSubmit, + formState: { errors }, + } = useForm({ mode: 'onChange', - defaultValues: {}, + defaultValues: { + name: '', + content: '', + startDate: DateTime.fromJSDate(new Date()).toFormat('yyyy-LL-dd'), + endDate: DateTime.fromJSDate(new Date()).toFormat('yyyy-LL-dd'), + }, }); + + const handleDeadlineToggle = () => { + setValue('endDate', getValues('startDate')); + clearErrors('endDate'); + setHasDeadline((prev) => !prev); + }; + return ( - -
{taskId}
+ + + +
+ + +
+ + + +