diff --git a/components/providers/workflow/forms/connect-account-form.tsx b/components/providers/workflow/forms/connect-account-form.tsx index 9a0825ef66..54acff1491 100644 --- a/components/providers/workflow/forms/connect-account-form.tsx +++ b/components/providers/workflow/forms/connect-account-form.tsx @@ -60,7 +60,9 @@ export const ConnectAccountForm = () => { if (data?.errors && data.errors.length > 0) { data.errors.forEach((error: ApiError) => { const errorMessage = error.detail; - switch (error.source.pointer) { + const pointer = error.source?.pointer; + + switch (pointer) { case "/data/attributes/provider": form.setError("providerType", { type: "server", diff --git a/components/providers/workflow/forms/launch-scan-form.tsx b/components/providers/workflow/forms/launch-scan-form.tsx index 86325d437b..2532fd2e90 100644 --- a/components/providers/workflow/forms/launch-scan-form.tsx +++ b/components/providers/workflow/forms/launch-scan-form.tsx @@ -7,7 +7,7 @@ import { useForm } from "react-hook-form"; import { z } from "zod"; import { scanOnDemand } from "@/actions/scans/scans"; -import { RocketIcon, ScheduleIcon } from "@/components/icons"; +import { AddIcon } from "@/components/icons"; import { CustomButton } from "@/components/ui/custom"; import { Form } from "@/components/ui/form"; import { ProviderProps } from "@/types"; // Asegúrate de importar la interfaz correcta @@ -51,7 +51,7 @@ export const LaunchScanForm = ({ }, }); - const isLoading = form.formState.isSubmitting; + // const isLoading = form.formState.isSubmitting; const onSubmitClient = async (values: FormValues) => { const formData = new FormData(); @@ -94,10 +94,11 @@ export const LaunchScanForm = ({ >
- Launch scan + Scan started
- Launch the scan now or schedule it for a later date and time. + The scan has just started. From now on, a new scan will be launched + every 24 hours, starting from this moment.
@@ -116,7 +117,7 @@ export const LaunchScanForm = ({ -
+ {/*
{isLoading ? <>Loading : Start now} +
*/} +
+ } + > + Go to Scans +
diff --git a/components/providers/workflow/forms/test-connection-form.tsx b/components/providers/workflow/forms/test-connection-form.tsx index 6d7ca16dbe..6431c1a814 100644 --- a/components/providers/workflow/forms/test-connection-form.tsx +++ b/components/providers/workflow/forms/test-connection-form.tsx @@ -12,6 +12,7 @@ import { checkConnectionProvider, deleteCredentials, } from "@/actions/providers"; +import { scanOnDemand } from "@/actions/scans"; import { getTask } from "@/actions/task/tasks"; import { CheckIcon, SaveIcon } from "@/components/icons"; import { useToast } from "@/components/ui"; @@ -115,9 +116,26 @@ export const TestConnectionForm = ({ }); if (connected) { - router.push( - `/providers/launch-scan?type=${providerType}&id=${providerId}`, - ); + try { + const data = await scanOnDemand(formData); + + if (data.error) { + setApiErrorMessage(data.error); + form.setError("providerId", { + type: "server", + message: data.error, + }); + } else { + router.push( + `/providers/launch-scan?type=${providerType}&id=${providerId}`, + ); + } + } catch (error) { + form.setError("providerId", { + type: "server", + message: "An unexpected error occurred. Please try again.", + }); + } } else { setConnectionStatus({ connected: false, diff --git a/components/scans/table/scans/column-get-scans.tsx b/components/scans/table/scans/column-get-scans.tsx index 0d8bfb4360..ed235d2965 100644 --- a/components/scans/table/scans/column-get-scans.tsx +++ b/components/scans/table/scans/column-get-scans.tsx @@ -127,9 +127,11 @@ export const ColumnGetScans: ColumnDef[] = [ const { attributes: { name }, } = getScanData(row); - if (name.length === 0) { + + if (!name || name.length === 0) { return -; } + return {name}; }, },