From 840fd893a60432e8950e7804f31613830faf8f94 Mon Sep 17 00:00:00 2001 From: Hadi <104451011+khanhadi@users.noreply.github.com> Date: Sat, 7 Sep 2024 15:38:59 +0300 Subject: [PATCH 1/2] feat: add icons search to create module popover [WIP] --- .../app/_components/create-module-popover.tsx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/app/(dashboard)/app/_components/create-module-popover.tsx b/src/app/(dashboard)/app/_components/create-module-popover.tsx index e6d70245..52ea95ae 100644 --- a/src/app/(dashboard)/app/_components/create-module-popover.tsx +++ b/src/app/(dashboard)/app/_components/create-module-popover.tsx @@ -58,6 +58,7 @@ const formSchema = z.object({ export function CreateModulePopover() { const [popoverOpen, setPopoverOpen] = useState(false); const [step, setStep] = useState<1 | 2 | 3>(1); + const [iconSearchTerm, setIconSearchTerm] = useState(''); const router = useRouter(); @@ -95,6 +96,12 @@ export function CreateModulePopover() { }); } + const filteredIcons = iconSearchTerm + ? iconNames.filter((icon) => + icon.toLowerCase().includes(iconSearchTerm.toLowerCase()), + ) + : iconNames; + return ( - + { + setIconSearchTerm(e.target.value); + }} + > +
- {iconNames.map((icon) => ( + {filteredIcons.map((icon) => ( + ))} +
+
+ + ); +} + const formSchema = z.object({ name: z.string().min(2), description: z.string().optional(), @@ -58,7 +100,6 @@ const formSchema = z.object({ export function CreateModulePopover() { const [popoverOpen, setPopoverOpen] = useState(false); const [step, setStep] = useState<1 | 2 | 3>(1); - const [iconSearchTerm, setIconSearchTerm] = useState(''); const router = useRouter(); @@ -96,12 +137,6 @@ export function CreateModulePopover() { }); } - const filteredIcons = iconSearchTerm - ? iconNames.filter((icon) => - icon.toLowerCase().includes(iconSearchTerm.toLowerCase()), - ) - : iconNames; - return ( - { - setIconSearchTerm(e.target.value); + { + form.setValue('icon', icon); + setStep(1); }} - > - -
- {filteredIcons.map((icon) => ( - - ))} -
-
+ /> )}