Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 30 additions & 1 deletion src/components/todos/create-edit-todo-form.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,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'
Expand All @@ -40,6 +40,12 @@ const todoFormSchema = z.object({
},
{ error: 'Assignee is required' },
),
createdBy: z
.object({
label: z.string(),
value: z.string(),
})
.optional(),
Comment on lines +43 to +48

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • we have added createdBy in the zod schema, but we're not passing it in the default value object in useForm. Can you please pass it there, similar to the assignee?

})

export type TTodoFormData = z.infer<typeof todoFormSchema>
Expand Down Expand Up @@ -134,6 +140,7 @@ export const CreateEditTodoForm = ({
status: initialData?.status || TASK_STATUS_ENUM.TODO,
labels: initialData?.labels || [],
assignee: initialData?.assignee || undefined,
createdBy: initialData?.createdBy || undefined,
},
})

Expand Down Expand Up @@ -326,6 +333,28 @@ export const CreateEditTodoForm = ({
</FormInput>
)}
/>

{mode === 'edit' && (
<Controller
control={control}
name="createdBy"
render={({ field }) => (
<FormInput
label="Created By"
htmlFor="createdBy"
icon={UserIcon}
errorMessage={errors.createdBy?.message}
>
<Input
{...field}
value={field.value?.label ?? '--'}
readOnly
className="cursor-default border-0 text-gray-700 shadow-none focus:ring-0 focus:outline-none focus-visible:ring-0"
/>
</FormInput>
)}
/>
)}
</div>
</div>

Expand Down
3 changes: 0 additions & 3 deletions src/components/todos/todo-list-table.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ export const TodoListTableHeader = ({
<TableHead className="text-black">Label</TableHead>
<TableHead className="text-black">Priority</TableHead>
<TableHead className="text-black">Assignee</TableHead>
<TableHead className="text-black">Created By</TableHead>
<TableHead className="text-black">Due Date</TableHead>
{showDeferredColumn && <TableHead className="text-black">Deferred Until</TableHead>}
{showActions && <TableHead className="text-black">Actions</TableHead>}
Expand Down Expand Up @@ -75,8 +74,6 @@ const TodoListTableRow = ({

<TableCell className="whitespace-nowrap">{todo.assignee?.assignee_name ?? '--'}</TableCell>

<TableCell className="whitespace-nowrap">{todo.createdBy?.name ?? '--'}</TableCell>

<TableCell className="whitespace-nowrap">
{todo.dueAt ? new DateUtil(todo.dueAt).format(DateFormats.D_MMM_YYYY) : '--'}
</TableCell>
Expand Down
6 changes: 6 additions & 0 deletions src/lib/todo-util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
2 changes: 0 additions & 2 deletions src/modules/teams/team-tasks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ const TodoListTableRow = ({ todo, team }: TodoListTableRowProps) => {

<TableCell className="whitespace-nowrap">{todo.assignee?.assignee_name ?? '--'}</TableCell>

<TableCell className="whitespace-nowrap">{todo.createdBy?.name ?? '--'}</TableCell>

<TableCell className="whitespace-nowrap">
{todo.dueAt ? new DateUtil(todo.dueAt).format(DateFormats.D_MMM_YYYY) : '--'}
</TableCell>
Expand Down