-
Notifications
You must be signed in to change notification settings - Fork 0
[FEAT] 투두 생성 모달 및 홈 투두 카드 UI 구현 #138
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
7537042
ab714de
b5c3cb9
87c8f56
48a8cc6
97f30e1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,91 @@ | ||
| import { z } from "zod"; | ||
|
|
||
| import { apiResponseSchema } from "@/api/schema/response"; | ||
|
|
||
| export const todoIconSchema = z.enum([ | ||
| "ICON_1", | ||
| "ICON_2", | ||
| "ICON_3", | ||
| "ICON_4", | ||
| "ICON_5", | ||
| "ICON_6", | ||
| "ICON_7", | ||
| "ICON_8", | ||
| ]); | ||
|
|
||
| export const todoPrioritySchema = z.enum([ | ||
| "VERY_HIGH", | ||
| "HIGH", | ||
| "MEDIUM", | ||
| "LOW", | ||
| ]); | ||
|
|
||
| export const todoRepeatTypeSchema = z.enum([ | ||
| "NONE", | ||
| "DAILY", | ||
| "WEEKLY", | ||
| "MONTHLY", | ||
| ]); | ||
|
|
||
| export const todoRepeatWeekdaySchema = z.enum([ | ||
| "MON", | ||
| "TUE", | ||
| "WED", | ||
| "THU", | ||
| "FRI", | ||
| "SAT", | ||
| "SUN", | ||
| ]); | ||
|
|
||
| const DATE_PATTERN = /^\d{4}-\d{2}-\d{2}$/; | ||
| const DURATION_PATTERN = /^\d{1,3}:[0-5]\d$/; | ||
|
|
||
| export const createTodoRequestSchema = z | ||
| .object({ | ||
| icon: todoIconSchema.nullable(), | ||
| title: z.string().trim().min(1), | ||
| subtasks: z.array(z.string().trim().min(1)).nullable(), | ||
| date: z.string().regex(DATE_PATTERN), | ||
| duration: z.string().regex(DURATION_PATTERN), | ||
| priority: todoPrioritySchema.nullable(), | ||
| tagId: z.number().int().positive().nullable(), | ||
| repeatType: todoRepeatTypeSchema, | ||
| repeatWeekdays: z.array(todoRepeatWeekdaySchema).nullable(), | ||
| repeatDayOfMonth: z.number().int().min(1).max(31).nullable(), | ||
| memo: z.string().nullable(), | ||
| }) | ||
| .superRefine((value, ctx) => { | ||
| if ( | ||
| value.repeatType === "WEEKLY" && | ||
| (!value.repeatWeekdays || value.repeatWeekdays.length === 0) | ||
| ) { | ||
| ctx.addIssue({ | ||
| code: "custom", | ||
| path: ["repeatWeekdays"], | ||
| message: "반복할 요일을 선택해주세요.", | ||
| }); | ||
| } | ||
|
|
||
| if (value.repeatType === "MONTHLY" && !value.repeatDayOfMonth) { | ||
| ctx.addIssue({ | ||
| code: "custom", | ||
| path: ["repeatDayOfMonth"], | ||
| message: "반복할 날짜를 선택해주세요.", | ||
| }); | ||
| } | ||
| }); | ||
|
|
||
| export type CreateTodoRequest = z.infer<typeof createTodoRequestSchema>; | ||
|
|
||
| export type TodoIcon = z.infer<typeof todoIconSchema>; | ||
| export type TodoPriority = z.infer<typeof todoPrioritySchema>; | ||
| export type TodoRepeatType = z.infer<typeof todoRepeatTypeSchema>; | ||
| export type TodoRepeatWeekday = z.infer<typeof todoRepeatWeekdaySchema>; | ||
|
|
||
| export const createTodoResponseSchema = apiResponseSchema( | ||
| z.object({ | ||
| todoId: z.number(), | ||
| }), | ||
| ); | ||
|
|
||
| export type CreateTodoResponse = z.infer<typeof createTodoResponseSchema>; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import { ChevronUpIcon } from "@repo/timo-design-system/icons"; | ||
| import { IconGraphic, IconSelector } from "@repo/timo-design-system/ui"; | ||
| import { cn } from "@repo/timo-design-system/utils"; | ||
|
|
||
| import type { TodoIconValue } from "@repo/timo-design-system/ui"; | ||
|
|
||
| export interface CreateTodoIconFieldProps { | ||
| icon: TodoIconValue | null; | ||
| isIconPanelOpen: boolean; | ||
| addIconLabel: string; | ||
| onOpenPanel: () => void; | ||
| onTogglePanel: () => void; | ||
| onSelectIcon: (icon: TodoIconValue) => void; | ||
| onRemoveIcon: () => void; | ||
| } | ||
|
|
||
| export const CreateTodoIconField = ({ | ||
| icon, | ||
| isIconPanelOpen, | ||
| addIconLabel, | ||
| onOpenPanel, | ||
| onTogglePanel, | ||
| onSelectIcon, | ||
| onRemoveIcon, | ||
| }: CreateTodoIconFieldProps) => { | ||
| return ( | ||
| <div className="flex w-full flex-col items-start gap-2"> | ||
| {!isIconPanelOpen && icon ? ( | ||
| <button | ||
| type="button" | ||
| onClick={onOpenPanel} | ||
| aria-label={addIconLabel} | ||
| className="flex size-6 shrink-0 items-center justify-center rounded-[4px]" | ||
| > | ||
| <IconGraphic icon={icon} /> | ||
| </button> | ||
| ) : ( | ||
| <button | ||
| type="button" | ||
| onClick={onTogglePanel} | ||
| aria-expanded={isIconPanelOpen} | ||
| className="bg-timo-gray-200 flex items-center gap-1 rounded-[4px] px-1.5 py-0.5" | ||
| > | ||
| <ChevronUpIcon | ||
| width={18} | ||
| height={18} | ||
| className={cn( | ||
| "shrink-0 transition-transform duration-200 ease-in-out", | ||
| !isIconPanelOpen && "rotate-180", | ||
| )} | ||
| /> | ||
| <span className="typo-caption-r-10 text-timo-gray-700 whitespace-nowrap"> | ||
| {addIconLabel} | ||
| </span> | ||
| </button> | ||
| )} | ||
|
|
||
| {isIconPanelOpen && ( | ||
| <IconSelector | ||
| selected={icon} | ||
| onSelect={onSelectIcon} | ||
| onRemove={onRemoveIcon} | ||
| /> | ||
| )} | ||
| </div> | ||
| ); | ||
| }; |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,21 @@ | ||||||||||||||||||||||||||||||||||||||
| export interface CreateTodoMemoFieldProps { | ||||||||||||||||||||||||||||||||||||||
| value: string; | ||||||||||||||||||||||||||||||||||||||
| placeholder: string; | ||||||||||||||||||||||||||||||||||||||
| onChange: (value: string) => void; | ||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||
| export const CreateTodoMemoField = ({ | ||||||||||||||||||||||||||||||||||||||
| value, | ||||||||||||||||||||||||||||||||||||||
| placeholder, | ||||||||||||||||||||||||||||||||||||||
| onChange, | ||||||||||||||||||||||||||||||||||||||
| }: CreateTodoMemoFieldProps) => { | ||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||
| <textarea | ||||||||||||||||||||||||||||||||||||||
| value={value} | ||||||||||||||||||||||||||||||||||||||
| onChange={(event) => onChange(event.target.value)} | ||||||||||||||||||||||||||||||||||||||
| placeholder={placeholder} | ||||||||||||||||||||||||||||||||||||||
| rows={1} | ||||||||||||||||||||||||||||||||||||||
| className="typo-body-r-12 text-timo-gray-800 w-full resize-none outline-none" | ||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+12
to
+20
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
As per coding guidelines, " 🛡️ 포커스 스타일 추가 제안- className="typo-body-r-12 text-timo-gray-800 w-full resize-none outline-none"
+ className="typo-body-r-12 text-timo-gray-800 w-full resize-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-timo-blue-500"📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,42 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { Checkbox } from "@repo/timo-design-system/ui"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { CreateTodoRequest } from "@/api/todo/todo-schema"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import type { UseFormRegister } from "react-hook-form"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export interface CreateTodoTaskFieldsProps { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| register: UseFormRegister<CreateTodoRequest>; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| titlePlaceholder: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subtaskInput: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subtaskPlaceholder: string; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSubtaskInputChange: (value: string) => void; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export const CreateTodoTaskFields = ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| register, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| titlePlaceholder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subtaskInput, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| subtaskPlaceholder, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onSubtaskInputChange, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }: CreateTodoTaskFieldsProps) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return ( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex w-full flex-col items-start gap-1.5"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex w-full items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Checkbox checked={false} onChange={() => {}} disabled /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| {...register("title")} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placeholder={titlePlaceholder} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="typo-headline-b-14 text-timo-black min-w-0 flex-1 outline-none" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <div className="flex w-full items-center gap-2"> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <Checkbox checked={false} onChange={() => {}} disabled /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| <input | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value={subtaskInput} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| onChange={(event) => onSubtaskInputChange(event.target.value)} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| placeholder={subtaskPlaceholder} | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| className="typo-body-r-12 text-timo-gray-800 min-w-0 flex-1 outline-none" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+22
to
+39
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
title 입력(line 28)과 subtask 입력(line 37) 모두 As per coding guidelines, " 🛡️ 포커스 스타일 추가 제안 <div className="flex w-full items-center gap-2">
<Checkbox checked={false} onChange={() => {}} disabled />
<input
{...register("title")}
placeholder={titlePlaceholder}
- className="typo-headline-b-14 text-timo-black min-w-0 flex-1 outline-none"
+ className="typo-headline-b-14 text-timo-black min-w-0 flex-1 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-timo-blue-500"
/>
</div>
<div className="flex w-full items-center gap-2">
<Checkbox checked={false} onChange={() => {}} disabled />
<input
value={subtaskInput}
onChange={(event) => onSubtaskInputChange(event.target.value)}
placeholder={subtaskPlaceholder}
- className="typo-body-r-12 text-timo-gray-800 min-w-0 flex-1 outline-none"
+ className="typo-body-r-12 text-timo-gray-800 min-w-0 flex-1 focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-timo-blue-500"
/>📝 Committable suggestion
Suggested change
🤖 Prompt for AI AgentsSource: Path instructions |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| </div> | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,89 @@ | ||
| "use client"; | ||
|
|
||
| import { DeleteIcon } from "@repo/timo-design-system/icons"; | ||
| import { CreateButton, TagNameInput } from "@repo/timo-design-system/ui"; | ||
| import { useTranslations } from "next-intl"; | ||
| import { useState } from "react"; | ||
|
|
||
| import { Modal } from "@/components/modal/Modal"; | ||
|
|
||
| const MAX_TAG_NAME_LENGTH = 10; | ||
|
|
||
| export interface CreateTagModalContainerProps { | ||
| isOpen: boolean; | ||
| onClose: () => void; | ||
| onExited: () => void; | ||
| existingLabels: string[]; | ||
| onCreate: (label: string) => void; | ||
| } | ||
|
|
||
| export const CreateTagModalContainer = ({ | ||
| isOpen, | ||
| onClose, | ||
| onExited, | ||
| existingLabels, | ||
| onCreate, | ||
| }: CreateTagModalContainerProps) => { | ||
| const t = useTranslations("Home"); | ||
| const [name, setName] = useState<string>(""); | ||
|
|
||
| const trimmedName = name.trim(); | ||
| const isDuplicate = existingLabels.includes(trimmedName); | ||
| const isValid = | ||
| trimmedName.length > 0 && | ||
| trimmedName.length <= MAX_TAG_NAME_LENGTH && | ||
| !isDuplicate; | ||
|
|
||
| const handleCreate = () => { | ||
| if (!isValid) return; | ||
|
|
||
| onCreate(trimmedName); | ||
| setName(""); | ||
| }; | ||
|
|
||
| return ( | ||
| <Modal | ||
| isOpen={isOpen} | ||
| onClose={onClose} | ||
| onExited={onExited} | ||
| className="w-[490px] items-center gap-3 px-6 py-4" | ||
| > | ||
| <div className="flex w-full items-center justify-between"> | ||
| <p className="typo-body-sb-12 text-timo-blue-300"> | ||
| {t("createTagModal.title")} | ||
| </p> | ||
| <button | ||
| type="button" | ||
| aria-label={t("createModal.close")} | ||
| onClick={onClose} | ||
| className="shrink-0" | ||
| > | ||
| <DeleteIcon /> | ||
| </button> | ||
|
Comment on lines
+55
to
+62
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value 닫기 버튼 aria-label이 태그 모달이 아닌 투두 모달의 키를 참조합니다.
🤖 Prompt for AI Agents |
||
| </div> | ||
|
|
||
| <div className="flex w-full flex-col items-start gap-3"> | ||
| <p className="typo-headline-m-16 text-timo-black w-full"> | ||
| {t("createTagModal.nameLabel")} | ||
| </p> | ||
|
|
||
| <TagNameInput | ||
| value={name} | ||
| onChange={setName} | ||
| maxLength={MAX_TAG_NAME_LENGTH} | ||
| isError={isDuplicate} | ||
| maxLengthHint={t("createTagModal.maxLengthHint")} | ||
| duplicateHint={t("createTagModal.duplicateHint")} | ||
| /> | ||
| </div> | ||
|
|
||
| <div className="flex w-full items-center justify-end"> | ||
| <CreateButton | ||
| label={t("createTagModal.create")} | ||
| disabled={!isValid} | ||
| onClick={handleCreate} | ||
| /> | ||
| </div> | ||
| </Modal> | ||
| ); | ||
| }; | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🗄️ Data Integrity & Integration | 🟡 Minor | ⚡ Quick win
superRefine에서 반복 타입 불일치 시 stale 데이터 검증 누락repeatType이WEEKLY가 아닐 때repeatWeekdays가 비어있는지,MONTHLY가 아닐 때repeatDayOfMonth가 null인지 검증하지 않습니다. 사용자가 WEEKLY → DAILY로 변경하면repeatWeekdays에 이전 선택값이 잔존할 수 있으며, 폼 hook(use-repeat-field.ts)에서 명시적으로 초기화하지 않으면 stale 데이터가 백엔드로 전송됩니다.🛡️ stale 데이터 방지를 위한 superRefine 보강
.superRefine((value, ctx) => { if ( value.repeatType === "WEEKLY" && (!value.repeatWeekdays || value.repeatWeekdays.length === 0) ) { ctx.addIssue({ code: "custom", path: ["repeatWeekdays"], message: "반복할 요일을 선택해주세요.", }); } if (value.repeatType === "MONTHLY" && !value.repeatDayOfMonth) { ctx.addIssue({ code: "custom", path: ["repeatDayOfMonth"], message: "반복할 날짜를 선택해주세요.", }); } + + if (value.repeatType !== "WEEKLY" && value.repeatWeekdays?.length) { + ctx.addIssue({ + code: "custom", + path: ["repeatWeekdays"], + message: "반복 요일은 WEEKLY 타입에서만 설정할 수 있습니다.", + }); + } + + if (value.repeatType !== "MONTHLY" && value.repeatDayOfMonth != null) { + ctx.addIssue({ + code: "custom", + path: ["repeatDayOfMonth"], + message: "반복 날짜는 MONTHLY 타입에서만 설정할 수 있습니다.", + }); + } });📝 Committable suggestion
🤖 Prompt for AI Agents