From 47703db34809482b22cb6454b1414d256f5284b4 Mon Sep 17 00:00:00 2001 From: Julien Froidefond Date: Wed, 7 Jan 2026 17:32:27 +0100 Subject: [PATCH] refactor: update OKR form and edit page to use new CreateKeyResultInput type for improved type safety and clarity --- src/app/teams/[id]/okrs/[okrId]/edit/page.tsx | 6 ++-- src/components/okrs/OKRForm.tsx | 32 +++++++++---------- src/components/swot/QuadrantHelp.tsx | 2 +- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/teams/[id]/okrs/[okrId]/edit/page.tsx b/src/app/teams/[id]/okrs/[okrId]/edit/page.tsx index 199f516..d525d0e 100644 --- a/src/app/teams/[id]/okrs/[okrId]/edit/page.tsx +++ b/src/app/teams/[id]/okrs/[okrId]/edit/page.tsx @@ -5,7 +5,7 @@ import { useRouter, useParams } from 'next/navigation'; import Link from 'next/link'; import { OKRForm } from '@/components/okrs'; import { Card } from '@/components/ui'; -import type { CreateOKRInput, TeamMember, OKR, KeyResult } from '@/lib/types'; +import type { CreateOKRInput, CreateKeyResultInput, TeamMember, OKR, KeyResult } from '@/lib/types'; type OKRWithTeamMember = OKR & { teamMember: { @@ -66,7 +66,7 @@ export default function EditOKRPage() { startDate: Date | string; endDate: Date | string; keyResultsUpdates?: { - create?: Array<{ title: string; targetValue: number; unit: string; order: number }>; + create?: CreateKeyResultInput[]; update?: KeyResultUpdate[]; delete?: string[] } @@ -87,7 +87,7 @@ export default function EditOKRPage() { startDate: string; endDate: string; keyResultsUpdates?: { - create?: Array<{ title: string; targetValue: number; unit: string; order: number }>; + create?: CreateKeyResultInput[]; update?: KeyResultUpdate[]; delete?: string[]; }; diff --git a/src/components/okrs/OKRForm.tsx b/src/components/okrs/OKRForm.tsx index cf9021f..59c67f8 100644 --- a/src/components/okrs/OKRForm.tsx +++ b/src/components/okrs/OKRForm.tsx @@ -69,21 +69,21 @@ type KeyResultUpdate = { order?: number; }; +type OKRFormSubmitData = + | (CreateOKRInput & { + startDate: Date | string; + endDate: Date | string; + keyResultsUpdates?: { + create?: CreateKeyResultInput[]; + update?: KeyResultUpdate[]; + delete?: string[]; + }; + }) + | CreateOKRInput; + interface OKRFormProps { teamMembers: TeamMember[]; - onSubmit: ( - data: - | (CreateOKRInput & { - startDate: Date | string; - endDate: Date | string; - keyResultsUpdates?: { - create?: CreateKeyResultInput[]; - update?: KeyResultUpdate[]; - delete?: string[]; - }; - }) - | CreateOKRInput - ) => Promise; + onSubmit: (data: OKRFormSubmitData) => Promise; onCancel: () => void; initialData?: Partial & { keyResults?: KeyResult[] }; } @@ -269,8 +269,8 @@ export function OKRForm({ teamMembers, onSubmit, onCancel, initialData }: OKRFor objective, description: description || undefined, period: finalPeriod, - startDate: startDateObj.toISOString(), - endDate: endDateObj.toISOString(), + startDate: startDateObj.toISOString() as Date | string, + endDate: endDateObj.toISOString() as Date | string, keyResults: [], // Not used in edit mode keyResultsUpdates: { create: @@ -285,7 +285,7 @@ export function OKRForm({ teamMembers, onSubmit, onCancel, initialData }: OKRFor update: allUpdates.length > 0 ? allUpdates : undefined, delete: deletedIds.length > 0 ? deletedIds : undefined, }, - }); + } as unknown as OKRFormSubmitData); } else { // In create mode, just send Key Results normally await onSubmit({ diff --git a/src/components/swot/QuadrantHelp.tsx b/src/components/swot/QuadrantHelp.tsx index e6e04a5..c9ef26d 100644 --- a/src/components/swot/QuadrantHelp.tsx +++ b/src/components/swot/QuadrantHelp.tsx @@ -62,8 +62,8 @@ interface QuadrantHelpProps { category: SwotCategory; } +// eslint-disable-next-line @typescript-eslint/no-unused-vars export function QuadrantHelp({ category: _category }: QuadrantHelpProps) { - // eslint-disable-next-line @typescript-eslint/no-unused-vars const [isOpen, setIsOpen] = useState(false); return (