refactor: update OKR form and edit page to use new CreateKeyResultInput type for improved type safety and clarity
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m54s

This commit is contained in:
Julien Froidefond
2026-01-07 17:32:27 +01:00
parent 86c26b5af8
commit 47703db348
3 changed files with 20 additions and 20 deletions

View File

@@ -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<void>;
onSubmit: (data: OKRFormSubmitData) => Promise<void>;
onCancel: () => void;
initialData?: Partial<CreateOKRInput> & { 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({