diff --git a/apps/console/src/components/organizations/InviteUserDialog.tsx b/apps/console/src/components/organizations/InviteUserDialog.tsx index f29f65229..300b97b11 100644 --- a/apps/console/src/components/organizations/InviteUserDialog.tsx +++ b/apps/console/src/components/organizations/InviteUserDialog.tsx @@ -34,7 +34,10 @@ export function InviteUserDialog({ children }: PropsWithChildren) { successMessage: __("User invited successfully"), errorMessage: __("Failed to invite user"), }); - const { register, handleSubmit, formState } = useFormWithSchema(schema, {}); + const { register, handleSubmit, formState, reset } = useFormWithSchema( + schema, + {}, + ); const dialogRef = useDialogRef(); @@ -48,6 +51,7 @@ export function InviteUserDialog({ children }: PropsWithChildren) { }, }, onSuccess: () => { + reset(); dialogRef.current?.close(); }, }); diff --git a/apps/console/src/components/tasks/TaskFormDialog.tsx b/apps/console/src/components/tasks/TaskFormDialog.tsx index dfb3bb6ce..4d6d13c8e 100644 --- a/apps/console/src/components/tasks/TaskFormDialog.tsx +++ b/apps/console/src/components/tasks/TaskFormDialog.tsx @@ -103,9 +103,8 @@ export default function TaskFormDialog(props: Props) { errorMessage: __("Failed to create task. Please try again."), }); - const { control, handleSubmit, register, formState } = useFormWithSchema( - schema, - { + const { control, handleSubmit, register, formState, reset } = + useFormWithSchema(schema, { defaultValues: { name: task?.name ?? "", description: task?.description ?? "", @@ -114,8 +113,7 @@ export default function TaskFormDialog(props: Props) { measureId: task?.measure?.id ?? props.measureId ?? "", deadline: task?.deadline?.split("T")[0] ?? null, }, - } - ); + }); const onSubmit = handleSubmit(async (data) => { if (task) { @@ -145,6 +143,7 @@ export default function TaskFormDialog(props: Props) { connections: [props.connection!], }, }); + reset(); } dialogRef.current?.close(); }); diff --git a/apps/console/src/pages/auth/RegisterPage.tsx b/apps/console/src/pages/auth/RegisterPage.tsx index c377f7a57..091e252ef 100644 --- a/apps/console/src/pages/auth/RegisterPage.tsx +++ b/apps/console/src/pages/auth/RegisterPage.tsx @@ -34,7 +34,7 @@ export default function RegisterPage() { }, credentials: "include", body: JSON.stringify(data), - } + }, ); // Registration failed diff --git a/apps/console/src/pages/organizations/assets/dialogs/CreateAssetDialog.tsx b/apps/console/src/pages/organizations/assets/dialogs/CreateAssetDialog.tsx index 95545ad12..16ab03d84 100644 --- a/apps/console/src/pages/organizations/assets/dialogs/CreateAssetDialog.tsx +++ b/apps/console/src/pages/organizations/assets/dialogs/CreateAssetDialog.tsx @@ -32,18 +32,23 @@ type Props = { organizationId: string; }; -export function CreateAssetDialog({ children, connection, organizationId }: Props) { +export function CreateAssetDialog({ + children, + connection, + organizationId, +}: Props) { const { __ } = useTranslate(); - const { control, handleSubmit, register, formState } = useFormWithSchema(schema, { - defaultValues: { - name: "", - amount: 0, - criticity: "LOW", - assetType: "VIRTUAL", - ownerId: "", - vendorIds: [], - }, - }); + const { control, handleSubmit, register, formState, reset } = + useFormWithSchema(schema, { + defaultValues: { + name: "", + amount: 0, + criticity: "LOW", + assetType: "VIRTUAL", + ownerId: "", + vendorIds: [], + }, + }); const ref = useDialogRef(); const createAsset = useCreateAsset(connection); @@ -54,6 +59,7 @@ export function CreateAssetDialog({ children, connection, organizationId }: Prop organizationId, }); ref.current?.close(); + reset(); } catch (error) { console.error("Failed to create asset:", error); } @@ -67,11 +73,7 @@ export function CreateAssetDialog({ children, connection, organizationId }: Prop >