mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-24 13:01:56 +00:00
fix(ui): redirection after deleting providers group and improve erro… (#8389)
Co-authored-by: Pablo Lara <larabjj@gmail.com>
This commit is contained in:
@@ -81,6 +81,7 @@ All notable changes to the **Prowler UI** are documented in this file.
|
||||
|
||||
- Error message when launching a scan if user has no permissions [(#8280)](https://github.com/prowler-cloud/prowler/pull/8280)
|
||||
- Include compliance in the download button tooltip [(#8307)](https://github.com/prowler-cloud/prowler/pull/8307)
|
||||
- Redirection and error handling issues after deleting a provider groups [(#8389)](https://github.com/prowler-cloud/prowler/pull/8389)
|
||||
|
||||
---
|
||||
|
||||
|
||||
@@ -201,7 +201,9 @@ export const deleteProviderGroup = async (formData: FormData) => {
|
||||
const providerGroupId = formData.get("id");
|
||||
|
||||
if (!providerGroupId) {
|
||||
return { error: "Provider Group ID is required" };
|
||||
return {
|
||||
errors: [{ detail: "Provider Group ID is required." }],
|
||||
};
|
||||
}
|
||||
|
||||
const url = new URL(`${apiBaseUrl}/provider-groups/${providerGroupId}`);
|
||||
@@ -233,6 +235,7 @@ export const deleteProviderGroup = async (formData: FormData) => {
|
||||
} catch (error) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error("Error deleting provider group:", error);
|
||||
return { error: getErrorMessage(error) };
|
||||
const message = await getErrorMessage(error);
|
||||
return { errors: [{ detail: message }] };
|
||||
}
|
||||
};
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import { zodResolver } from "@hookform/resolvers/zod";
|
||||
import { useRouter } from "next/navigation";
|
||||
import React, { Dispatch, SetStateAction } from "react";
|
||||
import { useForm } from "react-hook-form";
|
||||
import * as z from "zod";
|
||||
@@ -26,6 +27,7 @@ export const DeleteGroupForm = ({
|
||||
resolver: zodResolver(formSchema),
|
||||
});
|
||||
const { toast } = useToast();
|
||||
const router = useRouter();
|
||||
const isLoading = form.formState.isSubmitting;
|
||||
|
||||
async function onSubmitClient(formData: FormData) {
|
||||
@@ -46,6 +48,7 @@ export const DeleteGroupForm = ({
|
||||
title: "Success!",
|
||||
description: "The provider group was removed successfully.",
|
||||
});
|
||||
router.push("/manage-groups");
|
||||
}
|
||||
setIsOpen(false); // Close the modal on success
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user