From 817d5a27c35a6865ec0cc04c4037e679d8df57b2 Mon Sep 17 00:00:00 2001 From: Victor Santos Date: Mon, 8 Dec 2025 23:02:30 -0300 Subject: [PATCH] refactor(pam): update AwsIamAccountForm to use structured submit data - Changed the onSubmit prop type to accept a structured SubmitData type, enhancing type safety. - Updated the form submission logic to align with the new data structure, ensuring proper handling of form fields. --- .../PamAccountForm/AwsIamAccountForm.tsx | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx index 90e6cfa2e..779c21ba7 100644 --- a/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx +++ b/frontend/src/pages/pam/PamAccountsPage/components/PamAccountForm/AwsIamAccountForm.tsx @@ -30,11 +30,20 @@ import { GenericAccountFields, genericAccountFieldsSchema } from "./GenericAccou const AWS_STS_MIN_SESSION_DURATION = 900; // 15 minutes const AWS_STS_MAX_SESSION_DURATION_ROLE_CHAINING = 3600; // 1 hour +type SubmitData = { + name: string; + description?: string | null; + credentials: { + targetRoleArn: string; + defaultSessionDuration: number; + }; +}; + type Props = { account?: TAwsIamAccount; resourceId?: string; resourceType?: PamResourceType; - onSubmit: (formData: FormData) => Promise; + onSubmit: (formData: SubmitData) => Promise; }; const arnRoleRegex = /^arn:aws:iam::\d{12}:role\/[\w+=,.@/-]+$/; @@ -152,12 +161,13 @@ export const AwsIamAccountForm = ({ account, resourceId, resourceType, onSubmit const durationSeconds = Math.floor(durationMs / 1000); await onSubmit({ - ...formData, + name: formData.name, + description: formData.description, credentials: { - ...formData.credentials, + targetRoleArn: formData.credentials.targetRoleArn, defaultSessionDuration: durationSeconds } - } as any); + }); }; return (