mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-04 19:21:51 +00:00
fix(ui): use shared scan launch action errors (#11664)
This commit is contained in:
@@ -24,6 +24,11 @@ import {
|
||||
} from "@/components/shared/cloud-feature-badge";
|
||||
import { ToastAction, useToast } from "@/components/ui";
|
||||
import { EntityInfo } from "@/components/ui/entities";
|
||||
import {
|
||||
type ActionErrorResult,
|
||||
getActionErrorMessage,
|
||||
hasActionError,
|
||||
} from "@/lib/action-errors";
|
||||
import {
|
||||
getScanScheduleCapability,
|
||||
getScheduleFormDefaults,
|
||||
@@ -129,7 +134,7 @@ export function LaunchStep({
|
||||
}
|
||||
}, [isAdvanced, mode]);
|
||||
|
||||
const launchOnDemandScan = async (): Promise<{ error?: unknown } | null> => {
|
||||
const launchOnDemandScan = async (): Promise<ActionErrorResult | null> => {
|
||||
if (!providerId || isBlocked) return null;
|
||||
const formData = new FormData();
|
||||
formData.set("providerId", providerId);
|
||||
@@ -144,12 +149,12 @@ export function LaunchStep({
|
||||
setIsLaunching(true);
|
||||
const scanResult = await launchOnDemandScan();
|
||||
|
||||
if (scanResult?.error) {
|
||||
if (hasActionError(scanResult)) {
|
||||
setIsLaunching(false);
|
||||
toast({
|
||||
variant: "destructive",
|
||||
title: "Unable to launch scan",
|
||||
description: String(scanResult.error),
|
||||
description: getActionErrorMessage(scanResult),
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user