From 1e79555f35e723e242c584bf49989c2879f418f1 Mon Sep 17 00:00:00 2001 From: Mornieur Date: Sun, 3 Sep 2023 14:59:11 -0300 Subject: [PATCH] perf: add filter components --- src/components/ViewComponent/index.tsx | 31 +++++++++++++++----------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/src/components/ViewComponent/index.tsx b/src/components/ViewComponent/index.tsx index c6ebfec..f8f3b27 100644 --- a/src/components/ViewComponent/index.tsx +++ b/src/components/ViewComponent/index.tsx @@ -1,6 +1,7 @@ import * as S from './styles'; import { FC, useState } from 'react'; import { motion, Variants } from 'framer-motion'; +import { orderByValues, useVideoStore } from '@/store'; interface ViewComponentProps { orderList?: string; @@ -19,10 +20,10 @@ const itemVariants: Variants = { export const ViewComponent: FC = ({ orderList = 'Ordenar por', - dropDownText = 'Data de Publicação', itemText = 'Item', }) => { const [isOpen, setIsOpen] = useState(false); + const { category, handleStoreValues, orderBy } = useVideoStore(); const menuItems = [ 'Agencias', 'Chatbot', @@ -31,8 +32,6 @@ export const ViewComponent: FC = ({ 'Mídia Paga', ]; - const [activeButton, setActiveButton] = useState(null); - return ( = ({ { - setActiveButton(activeButton === item ? null : item); + handleStoreValues('category', item === category ? null : item); }} > {item} @@ -68,9 +67,11 @@ export const ViewComponent: FC = ({ > setIsOpen(!isOpen)} + onClick={() => { + setIsOpen(!isOpen); + }} > - {dropDownText} + {orderBy} = ({ pointerEvents: isOpen ? 'auto' : 'none', zIndex: isOpen ? '999' : 'none', position: 'absolute', - maxWidth: '300px', + maxWidth: '200px', width: '100%', }} > - {itemText} - {itemText} - {itemText} - {itemText} - {itemText} + {orderByValues.map((value, index) => ( + handleStoreValues('orderBy', value)} + key={index} + variants={itemVariants} + > + {value} + + ))}