mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-07-23 20:42:02 +00:00
fix: avoid app crashed when there is no data to render
This commit is contained in:
@@ -31,6 +31,9 @@ async function SSRTestConnection({
|
||||
formData.append("id", searchParams.id);
|
||||
|
||||
const providerData = await getProvider(formData);
|
||||
if (providerData.errors) {
|
||||
redirect("/providers/connect-account");
|
||||
}
|
||||
|
||||
return (
|
||||
<TestConnectionForm
|
||||
|
||||
+12
-9
@@ -3,17 +3,20 @@ import { MetaDataProps } from "@/types";
|
||||
export const wait = (ms: number) =>
|
||||
new Promise((resolve) => setTimeout(resolve, ms));
|
||||
// Helper function to create dictionaries by type
|
||||
export const createDict = (
|
||||
type: string,
|
||||
data: any,
|
||||
includedField: string = "included",
|
||||
) =>
|
||||
Object.fromEntries(
|
||||
data[includedField]
|
||||
.filter((item: { type: string }) => item.type === type)
|
||||
.map((item: { id: string }) => [item.id, item]),
|
||||
export function createDict(type: string, data: any) {
|
||||
const includedField = data?.included?.filter(
|
||||
(item: { type: string }) => item.type === type,
|
||||
);
|
||||
|
||||
if (!includedField || includedField.length === 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
return Object.fromEntries(
|
||||
includedField.map((item: { id: string }) => [item.id, item]),
|
||||
);
|
||||
}
|
||||
|
||||
export const parseStringify = (value: any) => JSON.parse(JSON.stringify(value));
|
||||
|
||||
export const convertFileToUrl = (file: File) => URL.createObjectURL(file);
|
||||
|
||||
Reference in New Issue
Block a user