-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Sayuck <[email protected]> Co-authored-by: EduardoPicolo <[email protected]>
- Loading branch information
1 parent
aa8521b
commit 5fcdf7e
Showing
7 changed files
with
123 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
import '@testing-library/jest-dom/extend-expect'; | ||
import '@testing-library/jest-dom'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
import { Url } from 'url'; | ||
|
||
import React, { ReactElement, useMemo } from 'react'; | ||
import Link from 'next/link'; | ||
import { useRouter } from 'next/router'; | ||
import { Flex } from '@chakra-ui/react'; | ||
import { IRoute } from 'routes'; | ||
|
||
export interface SideBarItemAttributes extends IRoute { | ||
query?: { [key: string]: string }; | ||
as?: string; | ||
isActive?: boolean; | ||
} | ||
|
||
export interface SideBarItemProps extends Partial<SideBarItemAttributes> { | ||
children?: ReactElement<{ isActive: boolean }>; | ||
} | ||
|
||
export const SideBarItem = ({ | ||
pathname, | ||
query, | ||
as, | ||
label, | ||
icon, | ||
}: SideBarItemProps) => { | ||
const router = useRouter(); | ||
|
||
const href: Partial<Url> = useMemo( | ||
() => ({ | ||
pathname, | ||
query, | ||
}), | ||
[pathname, query] | ||
); | ||
|
||
// replace the pathname slug '/path/[slug]' with the actual slug | ||
const path = query | ||
? pathname?.replace(`[${Object.keys(query)[0]}]`, Object.values(query)[0]) | ||
: pathname; | ||
const isActive = router?.asPath === path; | ||
|
||
return ( | ||
<Link href={href} as={as} shallow={!pathname}> | ||
<Flex | ||
alignItems={'center'} | ||
gap={2} | ||
fontSize={18} | ||
fontWeight={'medium'} | ||
cursor='pointer' | ||
px={2} | ||
py={2.5} | ||
borderRadius={'base'} | ||
bg={isActive ? 'primary' : 'inherit'} | ||
color={isActive ? 'white' : 'inherit'} | ||
boxShadow={isActive ? 'soft' : 'none'} | ||
// eslint-disable-next-line react-perf/jsx-no-new-object-as-prop -- não irei implementar uma classe que aplica hover | ||
_hover={{ | ||
bg: 'primary', | ||
color: 'white', | ||
boxShadow: 'soft', | ||
}} | ||
> | ||
{icon} {label} | ||
</Flex> | ||
</Link> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { FiLayout } from 'react-icons/fi'; | ||
import { | ||
MdOutlineCallToAction, | ||
MdOutlineDashboard, | ||
MdOutlineLocationCity, | ||
MdOutlineViewAgenda, | ||
} from 'react-icons/md'; | ||
import { TbTestPipe } from 'react-icons/tb'; | ||
|
||
export interface IRoute { | ||
label: string; | ||
pathname: string; | ||
icon?: JSX.Element; | ||
} | ||
|
||
export const routes: IRoute[] = [ | ||
{ | ||
label: 'Dashboard', | ||
pathname: '/dashboard', | ||
icon: <MdOutlineDashboard size={28} />, | ||
}, | ||
{ | ||
label: 'Chamados', | ||
pathname: '/chamados', | ||
icon: <MdOutlineViewAgenda size={28} />, | ||
}, | ||
{ | ||
label: 'Registrar Chamado', | ||
pathname: '/registrachamado', | ||
icon: <MdOutlineCallToAction size={28} />, | ||
}, | ||
{ | ||
label: 'Tipos De Problemas', | ||
pathname: '/listaCategoria', | ||
icon: <FiLayout size={28} />, | ||
}, | ||
{ | ||
label: 'Cidades [admin]', | ||
pathname: '/listaCidades', | ||
icon: <MdOutlineLocationCity size={28} />, | ||
}, | ||
{ | ||
label: 'Teste', | ||
pathname: '/teste', | ||
icon: <TbTestPipe size={28} />, | ||
}, | ||
]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters