mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-10-04 02:04:06 +00:00
Co-authored-by: alejandrobailo <alejandrobailo94@gmail.com>
43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
"use client";
|
|
|
|
import { revalidateIntegrationConnectionPages } from "@/actions/integrations";
|
|
import { toast } from "@/components/shadcn/toast";
|
|
import { evaluateIntegrationConnectionTask } from "@/lib/integrations/test-connection-result";
|
|
import type { TaskKindHandler } from "@/store/task-watcher/store";
|
|
import type { IntegrationConnectionTaskResult } from "@/types/integrations";
|
|
|
|
const refreshIntegrationPages = (): void => {
|
|
void revalidateIntegrationConnectionPages().catch(() => undefined);
|
|
};
|
|
|
|
export const integrationConnectionTaskHandler: TaskKindHandler = {
|
|
onReady: (task) => {
|
|
refreshIntegrationPages();
|
|
const result = evaluateIntegrationConnectionTask(
|
|
task.result as IntegrationConnectionTaskResult | undefined,
|
|
);
|
|
|
|
if (result.success) {
|
|
toast({
|
|
title: "Connection test successful!",
|
|
description: result.message,
|
|
});
|
|
return;
|
|
}
|
|
|
|
toast({
|
|
variant: "destructive",
|
|
title: "Connection test failed",
|
|
description: result.error,
|
|
});
|
|
},
|
|
onError: (task) => {
|
|
refreshIntegrationPages();
|
|
toast({
|
|
variant: "destructive",
|
|
title: "Connection test failed",
|
|
description: task.error || "The connection test failed unexpectedly.",
|
|
});
|
|
},
|
|
};
|