From 8bbc586a1f3c03b15fc57e785631548547f3c264 Mon Sep 17 00:00:00 2001 From: Shobhan Sundar Goutam Date: Thu, 11 Sep 2025 01:33:56 +0530 Subject: [PATCH 1/3] feat: display created by in Edit Todo modal --- components/create-edit-todo-form.tsx | 14 +++++++++++++- lib/todo-util.ts | 6 ++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/components/create-edit-todo-form.tsx b/components/create-edit-todo-form.tsx index 6d5f65a..ba50a45 100644 --- a/components/create-edit-todo-form.tsx +++ b/components/create-edit-todo-form.tsx @@ -18,7 +18,7 @@ import { cn, isPastDate } from '@/lib/utils' import { SelectLabels } from '@/modules/dashboard/components/select-labels' import { zodResolver } from '@hookform/resolvers/zod' import { useQuery } from '@tanstack/react-query' -import { CalendarIcon, CircleDotIcon, LucideIcon, PlayIcon, TagIcon } from 'lucide-react' +import { CalendarIcon, CircleDotIcon, LucideIcon, PlayIcon, TagIcon, UserIcon } from 'lucide-react' import { useState } from 'react' import { Controller, useForm, UseFormWatch } from 'react-hook-form' import { z } from 'zod' @@ -42,6 +42,10 @@ const todoFormSchema = z.object({ }, { error: 'Assignee is required' }, ), + createdBy: z.object({ + label: z.string(), + value: z.string(), + }), }) export type TTodoFormData = z.infer @@ -136,6 +140,7 @@ export const CreateEditTodoForm = ({ status: initialData?.status || TASK_STATUS_ENUM.TODO, labels: initialData?.labels || [], assignee: initialData?.assignee || undefined, + createdBy: initialData?.assignee || undefined, }, }) @@ -328,6 +333,13 @@ export const CreateEditTodoForm = ({ )} /> + + {/* Created By (only in edit mode) */} + {mode === 'edit' && initialData?.createdBy && ( + +

{initialData.createdBy.label}

+
+ )} diff --git a/lib/todo-util.ts b/lib/todo-util.ts index 6842446..16625a6 100644 --- a/lib/todo-util.ts +++ b/lib/todo-util.ts @@ -62,6 +62,12 @@ export class TodoUtil { type: todo.assignee.user_type, } : undefined, + createdBy: todo.createdBy + ? { + label: todo.createdBy.name, + value: todo.createdBy.id, + } + : undefined, } } } From 6fa66be6d40325e28d0110a2167a5107ae1e75f5 Mon Sep 17 00:00:00 2001 From: Shobhan Sundar Goutam Date: Thu, 11 Sep 2025 02:03:35 +0530 Subject: [PATCH 2/3] refactor: removed unnecessry code --- components/create-edit-todo-form.tsx | 1 - 1 file changed, 1 deletion(-) diff --git a/components/create-edit-todo-form.tsx b/components/create-edit-todo-form.tsx index ba50a45..6c6002f 100644 --- a/components/create-edit-todo-form.tsx +++ b/components/create-edit-todo-form.tsx @@ -140,7 +140,6 @@ export const CreateEditTodoForm = ({ status: initialData?.status || TASK_STATUS_ENUM.TODO, labels: initialData?.labels || [], assignee: initialData?.assignee || undefined, - createdBy: initialData?.assignee || undefined, }, }) From b66b1365334250db2fe76e6aa8eb66df57cd4be2 Mon Sep 17 00:00:00 2001 From: Shobhan Sundar Goutam Date: Thu, 11 Sep 2025 02:16:44 +0530 Subject: [PATCH 3/3] fix: added optional for createdBy to avoid issues in create task --- components/create-edit-todo-form.tsx | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/components/create-edit-todo-form.tsx b/components/create-edit-todo-form.tsx index 6c6002f..c05cf61 100644 --- a/components/create-edit-todo-form.tsx +++ b/components/create-edit-todo-form.tsx @@ -42,10 +42,12 @@ const todoFormSchema = z.object({ }, { error: 'Assignee is required' }, ), - createdBy: z.object({ - label: z.string(), - value: z.string(), - }), + createdBy: z + .object({ + label: z.string(), + value: z.string(), + }) + .optional(), }) export type TTodoFormData = z.infer