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
All checks were successful
Deploy with Docker Compose / deploy (push) Successful in 6m54s
This commit is contained in:
@@ -5,7 +5,7 @@ import { useRouter, useParams } from 'next/navigation';
|
|||||||
import Link from 'next/link';
|
import Link from 'next/link';
|
||||||
import { OKRForm } from '@/components/okrs';
|
import { OKRForm } from '@/components/okrs';
|
||||||
import { Card } from '@/components/ui';
|
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 & {
|
type OKRWithTeamMember = OKR & {
|
||||||
teamMember: {
|
teamMember: {
|
||||||
@@ -66,7 +66,7 @@ export default function EditOKRPage() {
|
|||||||
startDate: Date | string;
|
startDate: Date | string;
|
||||||
endDate: Date | string;
|
endDate: Date | string;
|
||||||
keyResultsUpdates?: {
|
keyResultsUpdates?: {
|
||||||
create?: Array<{ title: string; targetValue: number; unit: string; order: number }>;
|
create?: CreateKeyResultInput[];
|
||||||
update?: KeyResultUpdate[];
|
update?: KeyResultUpdate[];
|
||||||
delete?: string[]
|
delete?: string[]
|
||||||
}
|
}
|
||||||
@@ -87,7 +87,7 @@ export default function EditOKRPage() {
|
|||||||
startDate: string;
|
startDate: string;
|
||||||
endDate: string;
|
endDate: string;
|
||||||
keyResultsUpdates?: {
|
keyResultsUpdates?: {
|
||||||
create?: Array<{ title: string; targetValue: number; unit: string; order: number }>;
|
create?: CreateKeyResultInput[];
|
||||||
update?: KeyResultUpdate[];
|
update?: KeyResultUpdate[];
|
||||||
delete?: string[];
|
delete?: string[];
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -69,21 +69,21 @@ type KeyResultUpdate = {
|
|||||||
order?: number;
|
order?: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type OKRFormSubmitData =
|
||||||
|
| (CreateOKRInput & {
|
||||||
|
startDate: Date | string;
|
||||||
|
endDate: Date | string;
|
||||||
|
keyResultsUpdates?: {
|
||||||
|
create?: CreateKeyResultInput[];
|
||||||
|
update?: KeyResultUpdate[];
|
||||||
|
delete?: string[];
|
||||||
|
};
|
||||||
|
})
|
||||||
|
| CreateOKRInput;
|
||||||
|
|
||||||
interface OKRFormProps {
|
interface OKRFormProps {
|
||||||
teamMembers: TeamMember[];
|
teamMembers: TeamMember[];
|
||||||
onSubmit: (
|
onSubmit: (data: OKRFormSubmitData) => Promise<void>;
|
||||||
data:
|
|
||||||
| (CreateOKRInput & {
|
|
||||||
startDate: Date | string;
|
|
||||||
endDate: Date | string;
|
|
||||||
keyResultsUpdates?: {
|
|
||||||
create?: CreateKeyResultInput[];
|
|
||||||
update?: KeyResultUpdate[];
|
|
||||||
delete?: string[];
|
|
||||||
};
|
|
||||||
})
|
|
||||||
| CreateOKRInput
|
|
||||||
) => Promise<void>;
|
|
||||||
onCancel: () => void;
|
onCancel: () => void;
|
||||||
initialData?: Partial<CreateOKRInput> & { keyResults?: KeyResult[] };
|
initialData?: Partial<CreateOKRInput> & { keyResults?: KeyResult[] };
|
||||||
}
|
}
|
||||||
@@ -269,8 +269,8 @@ export function OKRForm({ teamMembers, onSubmit, onCancel, initialData }: OKRFor
|
|||||||
objective,
|
objective,
|
||||||
description: description || undefined,
|
description: description || undefined,
|
||||||
period: finalPeriod,
|
period: finalPeriod,
|
||||||
startDate: startDateObj.toISOString(),
|
startDate: startDateObj.toISOString() as Date | string,
|
||||||
endDate: endDateObj.toISOString(),
|
endDate: endDateObj.toISOString() as Date | string,
|
||||||
keyResults: [], // Not used in edit mode
|
keyResults: [], // Not used in edit mode
|
||||||
keyResultsUpdates: {
|
keyResultsUpdates: {
|
||||||
create:
|
create:
|
||||||
@@ -285,7 +285,7 @@ export function OKRForm({ teamMembers, onSubmit, onCancel, initialData }: OKRFor
|
|||||||
update: allUpdates.length > 0 ? allUpdates : undefined,
|
update: allUpdates.length > 0 ? allUpdates : undefined,
|
||||||
delete: deletedIds.length > 0 ? deletedIds : undefined,
|
delete: deletedIds.length > 0 ? deletedIds : undefined,
|
||||||
},
|
},
|
||||||
});
|
} as unknown as OKRFormSubmitData);
|
||||||
} else {
|
} else {
|
||||||
// In create mode, just send Key Results normally
|
// In create mode, just send Key Results normally
|
||||||
await onSubmit({
|
await onSubmit({
|
||||||
|
|||||||
@@ -62,8 +62,8 @@ interface QuadrantHelpProps {
|
|||||||
category: SwotCategory;
|
category: SwotCategory;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
||||||
export function QuadrantHelp({ category: _category }: QuadrantHelpProps) {
|
export function QuadrantHelp({ category: _category }: QuadrantHelpProps) {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
||||||
const [isOpen, setIsOpen] = useState(false);
|
const [isOpen, setIsOpen] = useState(false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user