From f8c5f4f1cca524749437bc08a9c16165d05f8d95 Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Mon, 30 Sep 2024 16:54:33 +0200 Subject: [PATCH 01/10] chore: Add aria-label to buttons for improved accessibility --- components/filters/filter-controls.tsx | 1 + components/providers/add-provider.tsx | 1 + components/providers/forms/AddForm.tsx | 2 ++ components/providers/forms/DeleteForm.tsx | 2 ++ components/providers/forms/EditForm.tsx | 2 ++ components/providers/table/data-table-filter-custom.tsx | 1 + components/ui/custom/CustomButton.tsx | 3 +++ 7 files changed, 12 insertions(+) diff --git a/components/filters/filter-controls.tsx b/components/filters/filter-controls.tsx index 12e2cca17c..5f185a6629 100644 --- a/components/filters/filter-controls.tsx +++ b/components/filters/filter-controls.tsx @@ -57,6 +57,7 @@ export const FilterControls: React.FC = ({ {showClearButton && ( {
( -
+
- + Select All {allFilterKeys.map((value) => ( - - {value} + + {_.capitalize(value)} ))} From fcd1aa5d768f457a57cf938e7a6101ce77d9027d Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Mon, 30 Sep 2024 17:25:08 +0200 Subject: [PATCH 04/10] chore: impot lodash correctly --- components/ui/custom/custom-dropdown-filter.tsx | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/components/ui/custom/custom-dropdown-filter.tsx b/components/ui/custom/custom-dropdown-filter.tsx index 59f211c0e6..1911f3a961 100644 --- a/components/ui/custom/custom-dropdown-filter.tsx +++ b/components/ui/custom/custom-dropdown-filter.tsx @@ -1,5 +1,5 @@ "use client"; -const _ = require("lodash"); + import { Badge, Button, @@ -10,6 +10,7 @@ import { PopoverContent, PopoverTrigger, } from "@nextui-org/react"; +import _ from "lodash"; import { useSearchParams } from "next/navigation"; import React, { useCallback, useEffect, useMemo, useState } from "react"; From 7c2f7d7eeb711446854b31db4a13cce86638abfa Mon Sep 17 00:00:00 2001 From: Pablo Lara Date: Mon, 30 Sep 2024 17:37:09 +0200 Subject: [PATCH 05/10] chore: Fix issue with invalid keys being passed to selectedKeys --- components/filters/custom-select-provider.tsx | 35 +++++++++---------- 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/components/filters/custom-select-provider.tsx b/components/filters/custom-select-provider.tsx index e5b810e1e8..876f42d030 100644 --- a/components/filters/custom-select-provider.tsx +++ b/components/filters/custom-select-provider.tsx @@ -2,7 +2,7 @@ import { Select, SelectItem } from "@nextui-org/react"; import { useRouter, useSearchParams } from "next/navigation"; -import { useCallback, useEffect, useState } from "react"; +import React, { useCallback, useMemo } from "react"; import { CustomProviderInputAWS, @@ -34,10 +34,9 @@ const dataInputsProvider = [ }, ]; -export const CustomSelectProvider = () => { +export const CustomSelectProvider: React.FC = () => { const router = useRouter(); const searchParams = useSearchParams(); - const [selectedProvider, setSelectedProvider] = useState(""); const applyProviderFilter = useCallback( (value: string) => { @@ -52,34 +51,34 @@ export const CustomSelectProvider = () => { [router, searchParams], ); - useEffect(() => { - const providerFromUrl = searchParams.get("filter[provider__in]") || ""; - setSelectedProvider(providerFromUrl); - }, [searchParams]); + const currentProvider = searchParams.get("filter[provider__in]") || ""; + + const selectedKeys = useMemo(() => { + return dataInputsProvider.some( + (provider) => provider.key === currentProvider, + ) + ? [currentProvider] + : []; + }, [currentProvider]); return ( diff --git a/components/filters/filter-controls.tsx b/components/filters/filter-controls.tsx index 13d4962b26..19053cb62b 100644 --- a/components/filters/filter-controls.tsx +++ b/components/filters/filter-controls.tsx @@ -47,7 +47,7 @@ export const FilterControls: React.FC = ({ return (
-
+
{search && } {providers && } {date && } diff --git a/components/findings/FindingsCard.tsx b/components/findings/FindingsCard.tsx index cec81ffb54..b4f9cab7a6 100644 --- a/components/findings/FindingsCard.tsx +++ b/components/findings/FindingsCard.tsx @@ -41,12 +41,12 @@ export const FindingsCard: React.FC = ({ selectedRow }) => { className={clsx( "max-h-[calc(100vh-146px)] overflow-y-auto rounded-md border bg-background transition-all duration-300", { - "w-1/3 translate-x-0 ml-2 p-3 opacity-100": selectedRow, - "translate-x-full w-0 opacity-0": !selectedRow, + "ml-2 w-1/3 translate-x-0 p-3 opacity-100": selectedRow, + "w-0 translate-x-full opacity-0": !selectedRow, }, )} > -

{CheckTitle}

+

{CheckTitle}

= ({ }) => { return ( <> -

{title}

+

{title}

{url ? ( {description} diff --git a/components/findings/FindingsCardDetail.tsx b/components/findings/FindingsCardDetail.tsx index 5b3ffc59bd..957cc6809e 100644 --- a/components/findings/FindingsCardDetail.tsx +++ b/components/findings/FindingsCardDetail.tsx @@ -34,9 +34,9 @@ export const FindingsCardDetail: React.FC = ({ <> {description && (
-

+

{title} {url && (

@@ -180,7 +180,7 @@ const Sidebar = React.forwardRef(
) : ( - item.startContent ?? null + (item.startContent ?? null) ) } > @@ -223,7 +223,7 @@ const Sidebar = React.forwardRef( {...item} key={item.key} endContent={ - isCompact || hideEndContent ? null : item.endContent ?? null + isCompact || hideEndContent ? null : (item.endContent ?? null) } startContent={ isCompact ? null : item.icon ? ( @@ -236,7 +236,7 @@ const Sidebar = React.forwardRef( width={24} /> ) : ( - item.startContent ?? null + (item.startContent ?? null) ) } textValue={item.title} @@ -255,7 +255,7 @@ const Sidebar = React.forwardRef( width={24} /> ) : ( - item.startContent ?? null + (item.startContent ?? null) )}
diff --git a/components/ui/sidebar/SidebarWrap.tsx b/components/ui/sidebar/SidebarWrap.tsx index 6fcf559f93..949cd59da0 100644 --- a/components/ui/sidebar/SidebarWrap.tsx +++ b/components/ui/sidebar/SidebarWrap.tsx @@ -50,7 +50,7 @@ export const SidebarWrap = () => { )} >
@@ -268,9 +268,9 @@ export const SidebarWrap = () => { >
@@ -284,7 +284,7 @@ export const SidebarWrap = () => {