diff --git a/src/components/BacklogView.tsx b/src/components/BacklogView.tsx index 64975ca..9178f6c 100644 --- a/src/components/BacklogView.tsx +++ b/src/components/BacklogView.tsx @@ -22,7 +22,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card" import { Badge } from "@/components/ui/badge" import { Button } from "@/components/ui/button" import { Plus, GripVertical, ChevronDown, ChevronRight, Calendar } from "lucide-react" -import { format } from "date-fns" +import { format, isValid, parseISO } from "date-fns" const priorityColors: Record = { low: "bg-slate-600", @@ -294,10 +294,12 @@ export function BacklogView() { currentSprint ? { name: currentSprint.name, - date: `${format(new Date(currentSprint.startDate), "MMM d")} - ${format( - new Date(currentSprint.endDate), - "MMM d" - )}`, + date: `${(() => { + const start = parseISO(currentSprint.startDate) + const end = parseISO(currentSprint.endDate) + if (!isValid(start) || !isValid(end)) return "Invalid dates" + return `${format(start, "MMM d")} - ${format(end, "MMM d")}` + })()}`, status: currentSprint.status, } : undefined @@ -320,10 +322,12 @@ export function BacklogView() { onTaskClick={(task) => selectTask(task.id)} sprintInfo={{ name: sprint.name, - date: `${format(new Date(sprint.startDate), "MMM d")} - ${format( - new Date(sprint.endDate), - "MMM d" - )}`, + date: (() => { + const start = parseISO(sprint.startDate) + const end = parseISO(sprint.endDate) + if (!isValid(start) || !isValid(end)) return "Invalid dates" + return `${format(start, "MMM d")} - ${format(end, "MMM d")}` + })(), status: sprint.status, }} />