diff --git a/app/clouds/page.tsx b/app/clouds/page.tsx
index 61212ab268..d7f378b8a1 100644
--- a/app/clouds/page.tsx
+++ b/app/clouds/page.tsx
@@ -89,21 +89,58 @@ const users = [
];
export default function CloudsPage() {
- const { data, error, isLoading } = useSWR(
+ const getAccounts = useSWR(
`http://localhost:8080/api/v1/providers/aws/accounts`,
fetcher,
);
- console.log("### data", data);
+ const getAudits = useSWR(
+ `http://localhost:8080/api/v1/providers/aws/audits`,
+ fetcher,
+ );
// TODO FIX TYPE CHECKING
- // const rowItems = data?.map((row: any) => (
- //
- // {row.account_id}
- // {row.alias}
- // {row.connected ? "True" : "False"}
- //
- // ));
+ const getScanDetails = (account_id: Number, detail: String) => {
+ const scan =
+ getAudits.data &&
+ getAudits.data.find((audit: any) => audit.account_id === account_id);
+
+ console.log("### scan", scan);
+ console.log("### new date", new Date("2024-06-25T09:05:49.405000Z"));
+
+ if (detail === "status") {
+ return scan?.audit_complete && "Completed";
+ }
+
+ if (detail === "duration") {
+ return scan?.audit_duration;
+ }
+
+ if (detail === "added") {
+ return new Date(scan?.inserted_at).toString();
+ }
+
+ return;
+ };
+
+ console.log("### getAccounts data", getAccounts.data);
+ console.log("### getAudits data", getAudits.data);
+
+ // TODO FIX TYPE CHECKING
+ const rowItems = getAccounts.data?.map((row: any) => (
+
+ {row.account_id}
+ {row.provider_id}
+ TBD
+ TBD
+ {row.groups.map(String).join(", ")}
+ {getScanDetails(row.account_id, "status")}
+ {getScanDetails(row.account_id, "duration")}
+ TBD
+ {row.resources}
+ {getScanDetails(row.account_id, "added")}
+
+ ));
// console.log("### rows", rows);
@@ -230,44 +267,55 @@ export default function CloudsPage() {
Cloud Accounts
- {error && Failed to load}
- {isLoading && Loading}
+ {getAccounts.error && (
+ Failed to load
+ )}
+ {getAccounts.isLoading && (
+ Loading
+ )}
- {data && (
- //
- //
- // ACCOUNT ID
- // ALIAS
- // CONNECTED
- //
- // {rowItems}
- //
-
-
-
- {(column) => (
-
- {column.name}
-
- )}
+ {getAccounts.data && (
+
+
+ ACCOUNT ID
+ PROVIDER ID
+ ALIAS
+ CONNECTED
+ GROUP(S)
+ SCAN STATUS
+ LAST SCAN
+ NEXT SCAN
+ RESOURCES
+ ADDED
-
- {(item) => (
-
- {(columnKey) => (
- {renderCell(item, columnKey)}
- )}
-
- )}
-
+ {rowItems}
+
+ //
+ //
+ // {(column) => (
+ //
+ // {column.name}
+ //
+ // )}
+ //
+ //
+ // {(item) => (
+ //
+ // {(columnKey) => (
+ // {renderCell(item, columnKey)}
+ // )}
+ //
+ // )}
+ //
+ //
)}
This is a page with "use client", useSWR