Skip to content

Commit

Permalink
Refactor fetching and updating user data
Browse files Browse the repository at this point in the history
  • Loading branch information
yoelmarain committed Sep 27, 2024
1 parent 5115278 commit 8bce5fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 2 deletions.
2 changes: 1 addition & 1 deletion FrontAdmin/src/API/Login.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const FetchLogin = async (password: string, account: string) => {
Cookies.set('refresh_token', data.refresh);
Cookies.set('access_expiration', data.access_expiration);
Cookies.set('refresh_expiration', data.refresh_expiration);

Cookies.set('full_name', data.user.full_name);

return data;
} else {
Expand Down
3 changes: 2 additions & 1 deletion FrontAdmin/src/Context.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,8 @@ const AuthProvider = ({ children }: { children: ReactNode }) => {
'access_expiration',
'refresh_expiration',
'username',
'dni'
'dni',
'full_name',
];

cookiesToRemove.forEach(cookie => {
Expand Down
6 changes: 6 additions & 0 deletions FrontAdmin/src/components/Header/HeaderContent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,17 @@ import {
Button,
IconButton,
Box,
Text,
} from '@chakra-ui/react';
import imgLogo from '../icons/Logos TUP_Mesa de trabajo 1.png';
import logoUser from '../icons/logo-user.png';
import { FiMenu } from 'react-icons/fi';
import { useAuth } from '../../Context';
import Cookies from 'js-cookie';

export function HeaderContent({ onOpen }: { onOpen: any }) {
const { onLogout } = useAuth();
const user = Cookies.get('full_name');
return (
<Flex
borderBottom="1px"
Expand Down Expand Up @@ -44,6 +47,8 @@ export function HeaderContent({ onOpen }: { onOpen: any }) {
display={{ base: 'flex', md: 'none' }}
color="white"
/>
<Flex direction={"row"} alignItems={"center"} gap={5}>
<Text fontFamily={"serif"} >{user}</Text>
<MenuButton as={Button} borderRadius="50%" w="50px" h="50px" p="0px">
<Image src={logoUser} w="100%"></Image>
</MenuButton>
Expand All @@ -53,6 +58,7 @@ export function HeaderContent({ onOpen }: { onOpen: any }) {
</MenuItem>
<MenuItem onClick={() => onLogout()}>Cerrar sesión</MenuItem>
</MenuList>
</Flex>
</Menu>
</Flex>
);
Expand Down

0 comments on commit 8bce5fa

Please sign in to comment.