-
Notifications
You must be signed in to change notification settings - Fork 0
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: Joaovitor045 <joaovitoralvestf@gmail.com> Co-Authored-By: gsVieiraaa <Gabriel.vieira.santos.110@gmail.com>
- Loading branch information
1 parent
5978267
commit 5202fbe
Showing
19 changed files
with
585 additions
and
48 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,17 @@ | ||
import { useNavigate } from "react-router"; | ||
import { useAuth } from "./hooks/useAuth" | ||
import { useEffect } from "react"; | ||
|
||
const PrivateRoute = ({ children }: { children: any }) => { | ||
const navigate = useNavigate(); | ||
const { token } = useAuth(); | ||
|
||
useEffect(() => { | ||
if (token) return; | ||
navigate('/cadastro'); | ||
}) | ||
|
||
return children; | ||
} | ||
|
||
export default PrivateRoute |
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,39 @@ | ||
import { Box, Center, Flex, Stack, Text } from "@chakra-ui/react" | ||
import { Button } from "../ui/button" | ||
import { BsHouse, BsBell, BsBook, BsPerson } from 'react-icons/bs'; | ||
import { useLocation, useNavigate } from "react-router"; | ||
|
||
export const NavBar = () => { | ||
const navigate = useNavigate() | ||
const location = useLocation() | ||
|
||
const selectedTab = location.pathname.replace('/', ''); | ||
const tabs = [ | ||
{ label: 'Início', value: 'inicio', icon: <BsHouse /> }, | ||
{ label: 'Empréstimos', value: 'emprestimos', icon: <BsBook /> }, | ||
{ label: 'Avisos', value: 'avisos', icon: <BsBell /> }, | ||
{ label: 'Perfil', value: 'perfil', icon: <BsPerson /> }, | ||
] | ||
|
||
return ( | ||
<Box position='fixed' width='100%' bottom='0' boxShadow='2xl'> | ||
<Center> | ||
<Flex width={'100%'} justifyContent={'space-between'} padding={'20px'}> | ||
{tabs.map(tab => ( | ||
<Button | ||
key={tab.value} | ||
variant='plain' | ||
onClick={() => navigate('/' + tab.value)} | ||
color={selectedTab === tab.value ? 'blue.100' : ''} | ||
> | ||
<Stack align='center'> | ||
{tab.icon} | ||
<Text textAlign='center'>{tab.label}</Text> | ||
</Stack> | ||
</Button> | ||
))} | ||
</Flex> | ||
</Center> | ||
</Box> | ||
); | ||
} |
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,43 @@ | ||
"use client" | ||
|
||
import { | ||
Toaster as ChakraToaster, | ||
Portal, | ||
Spinner, | ||
Stack, | ||
Toast, | ||
createToaster, | ||
} from "@chakra-ui/react" | ||
|
||
export const toaster = createToaster({ | ||
placement: "bottom-end", | ||
pauseOnPageIdle: true, | ||
}) | ||
|
||
export const Toaster = () => { | ||
return ( | ||
<Portal> | ||
<ChakraToaster toaster={toaster} insetInline={{ mdDown: "4" }}> | ||
{(toast) => ( | ||
<Toast.Root width={{ md: "sm" }}> | ||
{toast.type === "loading" ? ( | ||
<Spinner size="sm" color="blue.solid" /> | ||
) : ( | ||
<Toast.Indicator /> | ||
)} | ||
<Stack gap="1" flex="1" maxWidth="100%"> | ||
{toast.title && <Toast.Title>{toast.title}</Toast.Title>} | ||
{toast.description && ( | ||
<Toast.Description>{toast.description}</Toast.Description> | ||
)} | ||
</Stack> | ||
{toast.action && ( | ||
<Toast.ActionTrigger>{toast.action.label}</Toast.ActionTrigger> | ||
)} | ||
{toast.meta?.closable && <Toast.CloseTrigger />} | ||
</Toast.Root> | ||
)} | ||
</ChakraToaster> | ||
</Portal> | ||
) | ||
} |
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
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 was deleted.
Oops, something went wrong.
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,12 @@ | ||
import { Box } from '@chakra-ui/react'; | ||
import { NavBar } from '../../components/NavBar'; | ||
|
||
function Loans() { | ||
return ( | ||
<Box> | ||
<NavBar /> | ||
</Box> | ||
); | ||
} | ||
|
||
export default Loans |
Oops, something went wrong.