Skip to content

Commit

Permalink
Merge pull request #51 from fga-eps-mds/127-visualizar-perfil-usuario
Browse files Browse the repository at this point in the history
127 visualizar perfil usuario
  • Loading branch information
JPedroCh authored Jun 21, 2023
2 parents 3581cc8 + 2a92d9b commit b375d57
Show file tree
Hide file tree
Showing 10 changed files with 513 additions and 470 deletions.
273 changes: 0 additions & 273 deletions src/components/form-fields/equipment/edit-equipment-form.tsx

This file was deleted.

24 changes: 17 additions & 7 deletions src/components/side-bar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,28 @@ export const SideBar = memo(() => {
</Text>
))}
<Box position="absolute" bottom="20px" fontSize="4xs">
{user?.role === 'administrador' ? (
<Text
key={optionUser.name}
fontSize="4xs"
fontWeight="bold"
marginTop="10"
_hover={{ cursor: 'pointer', color: 'orange.500' }}
onClick={() => navigate(optionUser.link)}
>
{optionUser.name}
</Text>
) : (
''
)}
<Text
key={optionUser.name}
fontSize="4xs"
fontWeight="bold"
marginTop="10"
marginTop="2"
_hover={{ cursor: 'pointer', color: 'orange.500' }}
onClick={() => navigate(optionUser.link)}
onClick={() => navigate('/view-profile')}
>
{optionUser.name}
</Text>
<Text fontWeight="bold" marginTop="2">
Admin
{user?.name}
</Text>
<Button
onClick={signOut}
Expand Down
18 changes: 18 additions & 0 deletions src/config/routes/Routes.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ import { OrderServiceTable } from '@/pages/order-service/OrderServiceControl';
import { RequireAuth } from './require-auth';
import { UserRegister } from '@/pages/user-register/UserRegister';
import { PasswordRecover } from '@/pages/password-recover/PasswordRecover';
import { ChangePassword } from '@/pages/change-password';
import { ViewProfile } from '@/pages/view-profile/ViewProfileControl';

export function Router() {
return (
Expand Down Expand Up @@ -64,6 +66,22 @@ export function Router() {
<UserRegister />
</RequireAuth>} />

<Route
path="/change-password"
element={
<RequireAuth>
<ChangePassword />
</RequireAuth>
}
/>
<Route
path="/view-profile"
element={
<RequireAuth>
<ViewProfile />
</RequireAuth>
}
/>
<Route path="*" element={<p>404</p>} />
</Routes>
);
Expand Down
9 changes: 6 additions & 3 deletions src/contexts/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,13 @@ export function AuthProvider({ children }: AuthProviderProps) {
const signIn = useCallback(
async ({ username, password }: SignInCredentials) => {
try {
const response = await api.post('user/login', {
const response = await api.post<AuthResponse>(`/user/login`, {
username,
password,
});

const { email, expireIn, job, name, role, token } = response.data;
const { email, expireIn, job, name, role, token, cpf, id } =
response.data;

localStorage.setItem('@alectrion:token', token);
localStorage.setItem(
Expand All @@ -56,10 +57,12 @@ export function AuthProvider({ children }: AuthProviderProps) {
token,
job,
role,
cpf,
id,
})
);

setUser({ email, expireIn, job, name, role, token });
setUser({ email, expireIn, job, name, role, token, cpf, id });

api.defaults.headers.common.Authorization = `Bearer ${token}`;

Expand Down
Loading

0 comments on commit b375d57

Please sign in to comment.