diff --git a/actions/update-card/index.ts b/actions/update-card/index.ts index 2c9d393..4559a07 100644 --- a/actions/update-card/index.ts +++ b/actions/update-card/index.ts @@ -16,7 +16,7 @@ const handler = async (data: InputType): Promise => { if (!userId || !orgId) return { error: 'Unauthorized' }; - const { id, boardId, ...values } = data; + const { id, boardId, startedAt, dueDate, ...values } = data; let card; try { @@ -31,6 +31,7 @@ const handler = async (data: InputType): Promise => { }, data: { ...values, + dueDate: dueDate, }, }); diff --git a/actions/update-card/schema.ts b/actions/update-card/schema.ts index b17aa92..bc90a1f 100644 --- a/actions/update-card/schema.ts +++ b/actions/update-card/schema.ts @@ -22,5 +22,15 @@ export const UpdateCard = z.object({ message: 'Title must be at least 3 characters', }) ), + dueDate: z.optional( + z.date({ + invalid_type_error: 'Due date must be a date', + }) + ), + startedAt: z.optional( + z.date({ + invalid_type_error: 'Due date must be a date', + }) + ), id: z.string(), }); diff --git a/app/(platform)/(dashboard)/board/[boardId]/_components/card-item.tsx b/app/(platform)/(dashboard)/board/[boardId]/_components/card-item.tsx index c059add..516e3ff 100644 --- a/app/(platform)/(dashboard)/board/[boardId]/_components/card-item.tsx +++ b/app/(platform)/(dashboard)/board/[boardId]/_components/card-item.tsx @@ -2,8 +2,10 @@ import { Draggable } from '@hello-pangea/dnd'; import { Card } from '@prisma/client'; +import { format } from 'date-fns'; import { useCardModal } from '@/hooks/use-card-modal'; +import { Calendar } from 'lucide-react'; interface CardItemProps { index: number; @@ -25,6 +27,10 @@ export const CardItem = ({ index, data }: CardItemProps) => { className='truncate rounded-md border-2 border-transparent bg-white px-3 py-2 text-sm shadow-sm hover:border-black' > {data.title} +
+ + {data?.dueDate ? 'Due: ' + format(data.dueDate, 'PP') : 'No Due Date'} +
)} diff --git a/components/modals/card-modal/actions.tsx b/components/modals/card-modal/actions.tsx index 4c293b8..c6306b9 100644 --- a/components/modals/card-modal/actions.tsx +++ b/components/modals/card-modal/actions.tsx @@ -12,6 +12,7 @@ import { copyCard } from '@/actions/copy-card'; import { CardWithList } from '@/types'; import { useCardModal } from '@/hooks/use-card-modal'; +import { DatePicker } from '@/components/ui/date-picker'; interface ActionsProps { data: CardWithList; @@ -78,6 +79,15 @@ export const Actions = ({ data }: ActionsProps) => { Copy + + + + + + + ); +} diff --git a/prisma/schema.prisma b/prisma/schema.prisma index cae208f..fd44433 100644 --- a/prisma/schema.prisma +++ b/prisma/schema.prisma @@ -42,10 +42,12 @@ model List { } model Card { - id String @id @default(uuid()) + id String @id @default(uuid()) title String order Int - description String? @db.Text + description String? @db.Text + dueDate DateTime? + startedAt DateTime? listId String list List @relation(fields: [listId], references: [id], onDelete: Cascade)