diff --git a/app/(prowler)/scans/page.tsx b/app/(prowler)/scans/page.tsx
index d696bdc9a0..c93ea87ad8 100644
--- a/app/(prowler)/scans/page.tsx
+++ b/app/(prowler)/scans/page.tsx
@@ -3,15 +3,10 @@ import { Suspense } from "react";
import { getProviders } from "@/actions/providers";
import { getScans } from "@/actions/scans";
-import {
- FilterControls,
- filterProviders,
- filterScans,
-} from "@/components/filters";
+import { FilterControls, filterScans } from "@/components/filters";
import { SkeletonTableScans } from "@/components/scans/table";
import { ColumnProviderScans } from "@/components/scans/table/provider-scans";
import { ColumnGetScans } from "@/components/scans/table/scans";
-import { ColumnGetScansSchedule } from "@/components/scans/table/schedule-scans";
import { Header } from "@/components/ui";
import { DataTable } from "@/components/ui/table";
import { SearchParamsProps } from "@/types";
@@ -32,75 +27,26 @@ export default async function Scans({
-
- }>
-
-
-
-
- }>
-
-
-
}>
+
+ }>
+
+
+
>
);
}
const SSRDataTableProviders = async () => {
- // const page = parseInt(searchParams.page?.toString() || "1", 10);
- // const sort = searchParams.sort?.toString();
-
- // Extract all filter parameters
- // const filters = Object.fromEntries(
- // Object.entries(searchParams).filter(([key]) => key.startsWith("filter[")),
- // );
-
- // Extract query from filters
- // const query = (filters["filter[search]"] as string) || "";
-
- const providersData = await getProviders({ page: 1 });
-
+ const filters = { "filter[connected]": "true" };
+ const providersData = await getProviders({ page: 1, filters });
return (
-
- );
-};
-
-const SSRDataTableScansSchedule = async ({
- searchParams,
-}: {
- searchParams: SearchParamsProps;
-}) => {
- const page = parseInt(searchParams.page?.toString() || "1", 10);
- const sort = searchParams.sort?.toString();
-
- // Extract all filter parameters
- const filters = Object.fromEntries(
- Object.entries(searchParams).filter(([key]) => key.startsWith("filter[")),
- );
-
- // Extract query from filters
- const query = (filters["filter[search]"] as string) || "";
-
- const scansData = await getScans({ query, page, sort, filters });
-
- return (
-
+
);
};
diff --git a/components/auth/oss/auth-form.tsx b/components/auth/oss/auth-form.tsx
index e8c997f6a9..2afe281f2a 100644
--- a/components/auth/oss/auth-form.tsx
+++ b/components/auth/oss/auth-form.tsx
@@ -4,8 +4,6 @@ import { zodResolver } from "@hookform/resolvers/zod";
import { Icon } from "@iconify/react";
import { Button, Checkbox, Divider, Link } from "@nextui-org/react";
import { useRouter } from "next/navigation";
-import { useEffect, useState } from "react";
-import { useFormState } from "react-dom";
import { useForm } from "react-hook-form";
import { z } from "zod";
@@ -40,35 +38,43 @@ export const AuthForm = ({ type }: { type: string }) => {
},
});
- const [state, dispatch] = useFormState(authenticate, undefined);
- const [isLoading, setIsLoading] = useState(false);
+ const isLoading = form.formState.isSubmitting;
const { toast } = useToast();
- useEffect(() => {
- if (state?.message === "Success") {
- router.push("/");
- }
- }, [state]);
-
const onSubmit = async (data: z.infer) => {
if (type === "sign-in") {
- setIsLoading(true);
- dispatch({
+ const result = await authenticate(null, {
email: data.email.toLowerCase(),
password: data.password,
});
- setIsLoading(false);
+
+ if (result?.message === "Success") {
+ router.push("/");
+ } else if (result?.errors && "credentials" in result.errors) {
+ form.setError("email", {
+ type: "server",
+ message: result.errors.credentials ?? "Incorrect email or password",
+ });
+ } else {
+ toast({
+ variant: "destructive",
+ title: "Oops! Something went wrong",
+ description: "An unexpected error occurred. Please try again.",
+ });
+ }
}
+
if (type === "sign-up") {
- setIsLoading(true);
const newUser = await createNewUser(data);
- setIsLoading(false);
if (!newUser.errors) {
+ toast({
+ title: "Success!",
+ description: "The user was registered successfully.",
+ });
+ form.reset();
router.push("/sign-in");
- }
-
- if (newUser?.errors && newUser.errors.length > 0) {
+ } else {
newUser.errors.forEach((error: ApiError) => {
const errorMessage = error.detail;
switch (error.source.pointer) {
@@ -98,18 +104,6 @@ export const AuthForm = ({ type }: { type: string }) => {
});
}
});
- } else {
- toast({
- title: "Success!",
- description: "The user was registered successfully.",
- });
- form.reset({
- name: "",
- company: "",
- email: "",
- password: "",
- termsAndConditions: false,
- });
}
}
};
@@ -222,7 +216,7 @@ export const AuthForm = ({ type }: { type: string }) => {
>
)}
- {state?.message === "Credentials error" && (
+ {form.formState.errors?.email && (
No user found
diff --git a/components/scans/table/schedule-scans/column-get-scans-schedule.tsx b/components/scans/table/schedule-scans/column-get-scans-schedule.tsx
deleted file mode 100644
index 69bb478ecc..0000000000
--- a/components/scans/table/schedule-scans/column-get-scans-schedule.tsx
+++ /dev/null
@@ -1,83 +0,0 @@
-"use client";
-
-import { ColumnDef } from "@tanstack/react-table";
-
-import { PlusIcon } from "@/components/icons";
-import { DateWithTime, EntityInfoShort } from "@/components/ui/entities";
-import { TriggerSheet } from "@/components/ui/sheet";
-import { DataTableColumnHeader, StatusBadge } from "@/components/ui/table";
-import { ScanProps } from "@/types";
-
-import { DataTableRowActions } from "../scans/data-table-row-actions";
-import { DataTableRowDetails } from ".";
-
-const getScanData = (row: { original: ScanProps }) => {
- return row.original;
-};
-
-export const ColumnGetScansSchedule: ColumnDef
[] = [
- {
- accessorKey: "name",
- header: ({ column }) => (
-
- ),
- cell: ({ row }) => {
- const {
- attributes: { name },
- } = getScanData(row);
- return ;
- },
- },
-
- {
- accessorKey: "status",
- header: ({ column }) => (
-
- ),
- cell: ({ row }) => {
- const {
- attributes: { state },
- } = getScanData(row);
- return ;
- },
- },
- {
- accessorKey: "scheduled_at",
- header: ({ column }) => (
-
- ),
- cell: ({ row }) => {
- const {
- attributes: { scheduled_at },
- } = getScanData(row);
- return ;
- },
- },
-
- {
- id: "moreInfo",
- header: "Details",
- cell: ({ row }) => {
- return (
- }
- title="Scan Details"
- description="View the scan details"
- >
-
-
- );
- },
- },
-
- {
- id: "actions",
- cell: ({ row }) => {
- return ;
- },
- },
-];
diff --git a/components/scans/table/schedule-scans/data-table-row-details.tsx b/components/scans/table/schedule-scans/data-table-row-details.tsx
deleted file mode 100644
index 997fa0e5d9..0000000000
--- a/components/scans/table/schedule-scans/data-table-row-details.tsx
+++ /dev/null
@@ -1,37 +0,0 @@
-"use client";
-
-import { useEffect, useState } from "react";
-
-import { getScan } from "@/actions/scans";
-import { ScanDetail, SkeletonTableScans } from "@/components/scans/table";
-import { ScanProps } from "@/types";
-
-export const DataTableRowDetails = ({ entityId }: { entityId: string }) => {
- const [scanDetails, setScanDetails] = useState(null);
- const [isLoading, setIsLoading] = useState(true);
-
- useEffect(() => {
- const fetchScanDetails = async () => {
- try {
- const result = await getScan(entityId);
- setScanDetails(result?.data);
- } catch (error) {
- console.error("Error fetching scan details:", error);
- } finally {
- setIsLoading(false);
- }
- };
-
- fetchScanDetails();
- }, [entityId]);
-
- if (isLoading) {
- return ;
- }
-
- if (!scanDetails) {
- return No scan details available
;
- }
-
- return ;
-};
diff --git a/components/scans/table/schedule-scans/index.ts b/components/scans/table/schedule-scans/index.ts
deleted file mode 100644
index e93f00f4c5..0000000000
--- a/components/scans/table/schedule-scans/index.ts
+++ /dev/null
@@ -1,2 +0,0 @@
-export * from "./column-get-scans-schedule";
-export * from "./data-table-row-details";