mirror of
https://github.com/prowler-cloud/prowler.git
synced 2026-11-02 01:15:31 +00:00
* feat(compliance): Add in initial shell for Compliance page * feat(compliance): Mock data in the same way as Services and Providers, create files for rest of page and card structure * feat(compliance): Add in more data to json, continue building Compliance Card * feat(compliance): Add in icons for Compliance types, update Compliance skeleton * feat(compliance): Compliance card/page - add in colors for progress bar, styling * feat(compliance): Add image definitions to fix CI * feat(compliance): Add in aws.svg instead of .png * Fix file suffix * feat(compliance) remove duplicate spacer
40 lines
1.1 KiB
TypeScript
40 lines
1.1 KiB
TypeScript
"use server";
|
|
|
|
import { revalidatePath } from "next/cache";
|
|
import { redirect } from "next/navigation";
|
|
|
|
import { parseStringify } from "@/lib";
|
|
|
|
export const getCompliance = async ({ page = 1 }) => {
|
|
if (isNaN(Number(page)) || page < 1) redirect("/compliance");
|
|
const keyServer = process.env.LOCAL_SITE_URL;
|
|
|
|
try {
|
|
const compliance = await fetch(
|
|
`${keyServer}/api/compliance?page%5Bnumber%5D=${page}`,
|
|
);
|
|
const data = await compliance.json();
|
|
const parsedData = parseStringify(data);
|
|
revalidatePath("/compliance");
|
|
return parsedData;
|
|
} catch (error) {
|
|
console.error("Error fetching Compliance:", error);
|
|
return undefined;
|
|
}
|
|
};
|
|
|
|
export const getErrorMessage = (error: unknown): string => {
|
|
let message: string;
|
|
|
|
if (error instanceof Error) {
|
|
message = error.message;
|
|
} else if (error && typeof error === "object" && "message" in error) {
|
|
message = String(error.message);
|
|
} else if (typeof error === "string") {
|
|
message = error;
|
|
} else {
|
|
message = "Wops! Something when wrong.";
|
|
}
|
|
return message;
|
|
};
|