chore: tsx tweaks

This commit is contained in:
Pablo Lara
2024-10-08 12:05:29 +02:00
parent 3d533b56ef
commit b3c2f3a3fc
6 changed files with 115 additions and 38 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import { Spacer } from "@nextui-org/react";
import { Suspense } from "react";
import { getProviders } from "@/actions/providers";
import { FilterControls, filtersProviders } from "@/components/filters";
import { FilterControls, filterProviders } from "@/components/filters";
import { AddProvider } from "@/components/providers";
import {
ColumnsProvider,
@@ -24,7 +24,7 @@ export default async function Providers({
<Header title="Providers" icon="fluent:cloud-sync-24-regular" />
<Spacer y={4} />
<FilterControls search providers customFilters={filtersProviders} />
<FilterControls search providers customFilters={filterProviders} />
<Spacer y={4} />
<AddProvider />
+61
View File
@@ -0,0 +1,61 @@
import { Spacer } from "@nextui-org/react";
import { Suspense } from "react";
// import { getProviders } from "@/actions/providers";
import { FilterControls, filterScans } from "@/components/filters";
import {
// ColumnsProvider,
// DataTableProvider,
SkeletonTableProvider,
} from "@/components/providers/table";
import { Header } from "@/components/ui";
import { SearchParamsProps } from "@/types";
export default async function Scan({
searchParams,
}: {
searchParams: SearchParamsProps;
}) {
const searchParamsKey = JSON.stringify(searchParams || {});
return (
<>
<Header title="Scanners" icon="lucide:scan-search" />
<Spacer y={4} />
<FilterControls search date providers customFilters={filterScans} />
<Spacer y={4} />
<Suspense key={searchParamsKey} fallback={<SkeletonTableProvider />}>
{/* <SSRDataTable searchParams={searchParams} /> */}
</Suspense>
</>
);
}
// const SSRDataTable = 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 providersData = await getProviders({ query, page, sort, filters });
// return (
// <DataTableProvider
// columns={ColumnsProvider}
// data={providersData?.data || []}
// metadata={providersData?.meta}
// />
// );
// };
+10 -1
View File
@@ -1,4 +1,13 @@
export const filtersProviders = [
export const filterProviders = [
{
key: "connected",
labelCheckboxGroup: "Connection",
values: ["false", "true"],
},
// Add more filter categories as needed
];
export const filterScans = [
{
key: "connected",
labelCheckboxGroup: "Connection",
+1 -1
View File
@@ -4,7 +4,7 @@ import { IconSvgProps } from "../../../types/index";
export const ProwlerExtended: React.FC<IconSvgProps> = ({
size,
width = 164,
width = 216,
height,
...props
}) => {
+2 -19
View File
@@ -120,8 +120,8 @@ export const sectionItems: SidebarItem[] = [
title: "Scan",
items: [
{
key: "scanners",
href: "#",
key: "scan",
href: "/scan",
icon: "lucide:scan-search",
title: "Scanners",
},
@@ -130,23 +130,6 @@ export const sectionItems: SidebarItem[] = [
href: "/findings",
title: "Findings",
icon: "ph:list-checks-duotone",
items: [
{
key: "shareholders",
href: "#",
title: "Shareholders",
},
{
key: "note_holders",
href: "#",
title: "Note Holders",
},
{
key: "transactions_log",
href: "#",
title: "Transactions Log",
},
],
},
],
},
+39 -15
View File
@@ -10,6 +10,7 @@ import React, { Suspense, useCallback } from "react";
import { useMediaQuery } from "usehooks-ts";
import { logOut } from "@/actions/auth";
import { AddIcon } from "@/components/icons";
import { useUIStore } from "@/store";
import {
@@ -17,6 +18,7 @@ import {
ProwlerShort,
} from "../../icons/prowler/ProwlerIcons";
import { ThemeSwitch } from "../../ThemeSwitch";
import { CustomButton } from "../custom";
import Sidebar from "./sidebar";
import { sectionItemsWithTeams } from "./sidebar-items";
import { UserAvatar } from "./user-avatar";
@@ -50,9 +52,12 @@ export const SidebarWrap = () => {
)}
>
<div
className={clsx("flex items-center justify-center gap-3 px-3", {
"gap-0": isCompact,
})}
className={clsx(
"flex w-full flex-col items-center justify-center gap-y-4 px-3",
{
"gap-0": isCompact,
},
)}
>
<div
className={clsx({
@@ -64,24 +69,43 @@ export const SidebarWrap = () => {
<div
className={clsx({
hidden: isCompact,
"!mt-0": !isCompact,
})}
>
<ProwlerExtended />
</div>
<Link href={"/profile"}>
<Suspense fallback={<p>Loading...</p>}>
<UserAvatar
userName={session?.user.name ?? "Guest"}
position={session?.user.companyName ?? "Company Name"}
isCompact={isCompact}
/>
</Suspense>
</Link>
<div
className={clsx({
hidden: isCompact,
"w-full": !isCompact,
})}
>
<Link href={"/scan"}>
<CustomButton
className="w-full"
ariaLabel="Launch Scan"
variant="solid"
color="action"
size="md"
endContent={<AddIcon size={20} />}
>
Launch Scan
</CustomButton>
</Link>
</div>
</div>
<Spacer y={8} />
<Link href={"/profile"}>
<Suspense fallback={<p>Loading...</p>}>
<UserAvatar
userName={session?.user.name ?? "Guest"}
position={session?.user.companyName ?? "Company Name"}
isCompact={isCompact}
/>
</Suspense>
</Link>
<ScrollShadow hideScrollBar className="-mr-6 h-full max-h-full py-6 pr-6">
<ScrollShadow hideScrollBar className="-mr-6 h-full max-h-full py-4 pr-6">
<Sidebar
defaultSelectedKey="overview"
isCompact={isCompact}