fix: improve error handling in API routes and update date handling for OKR and Key Result submissions
Some checks failed
Deploy with Docker Compose / deploy (push) Failing after 3m38s

This commit is contained in:
Julien Froidefond
2026-01-07 17:22:33 +01:00
parent 97045342b7
commit 86c26b5af8
10 changed files with 170 additions and 70 deletions

View File

@@ -54,7 +54,23 @@ export default function EditOKRPage() {
});
}, [okrId, teamId]);
const handleSubmit = async (data: CreateOKRInput & { keyResultsUpdates?: { create?: any[]; update?: any[]; delete?: string[] } }) => {
type KeyResultUpdate = {
id: string;
title?: string;
targetValue?: number;
unit?: string;
order?: number;
};
const handleSubmit = async (data: CreateOKRInput & {
startDate: Date | string;
endDate: Date | string;
keyResultsUpdates?: {
create?: Array<{ title: string; targetValue: number; unit: string; order: number }>;
update?: KeyResultUpdate[];
delete?: string[]
}
}) => {
// Convert to UpdateOKRInput format
const updateData = {
objective: data.objective,
@@ -64,7 +80,18 @@ export default function EditOKRPage() {
endDate: typeof data.endDate === 'string' ? new Date(data.endDate) : data.endDate,
};
const payload: any = {
const payload: {
objective: string;
description?: string;
period: string;
startDate: string;
endDate: string;
keyResultsUpdates?: {
create?: Array<{ title: string; targetValue: number; unit: string; order: number }>;
update?: KeyResultUpdate[];
delete?: string[];
};
} = {
...updateData,
startDate: updateData.startDate.toISOString(),
endDate: updateData.endDate.toISOString(),
@@ -83,7 +110,7 @@ export default function EditOKRPage() {
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Erreur lors de la mise à jour de l\'OKR');
throw new Error(error.error || 'Erreur lors de la mise à jour de l&apos;OKR');
}
router.push(`/teams/${teamId}/okrs/${okrId}`);
@@ -121,12 +148,12 @@ export default function EditOKRPage() {
<main className="mx-auto max-w-4xl px-4 py-8">
<div className="mb-6">
<Link href={`/teams/${teamId}/okrs/${okrId}`} className="text-muted hover:text-foreground">
Retour à l'OKR
Retour à l&apos;OKR
</Link>
</div>
<Card className="p-6">
<h1 className="text-2xl font-bold text-foreground mb-6">Modifier l'OKR</h1>
<h1 className="text-2xl font-bold text-foreground mb-6">Modifier l&apos;OKR</h1>
<OKRForm
teamMembers={teamMembers}
onSubmit={handleSubmit}

View File

@@ -148,7 +148,7 @@ export default function OKRDetailPage() {
<main className="mx-auto max-w-4xl px-4 py-8">
<div className="mb-6">
<Link href={`/teams/${teamId}`} className="text-muted hover:text-foreground">
Retour à lquipe
Retour à l&apos;équipe
</Link>
</div>

View File

@@ -45,7 +45,7 @@ export default function NewOKRPage() {
if (!response.ok) {
const error = await response.json();
throw new Error(error.error || 'Erreur lors de la création de l\'OKR');
throw new Error(error.error || 'Erreur lors de la création de l&apos;OKR');
}
router.push(`/teams/${teamId}`);
@@ -64,7 +64,7 @@ export default function NewOKRPage() {
<main className="mx-auto max-w-4xl px-4 py-8">
<div className="mb-6">
<Link href={`/teams/${teamId}`} className="text-muted hover:text-foreground">
Retour à l'équipe
Retour à l&apos;équipe
</Link>
</div>