Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Perfil #27

Merged
merged 11 commits into from
Dec 1, 2023
1 change: 1 addition & 0 deletions src/app/pages/profile/profile.component.css
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

67 changes: 33 additions & 34 deletions src/app/pages/profile/profile.component.html
Original file line number Diff line number Diff line change
@@ -1,44 +1,43 @@
<div class="flex justify-center items-center flex-col">
<div class="text-center">
<div class="w-full h-full flex justify-center items-center flex-col gap-11">
<div
class="max-w-[280px] max-h-[170px] grid grid-cols-1 align-middle p-4 m-0 gap-4 rounded-xl border border-gray-300 divide-y font-custom break-words text-center"
*ngIf="user"
>
<div class="text-center font-bold text-sm text-blue-brand">Perfil</div>

<div
class="mb-4 flex flex-col justify-start items-center bg-zinc-300 p-4 rounded-xl shadow-md"
*ngIf="user"
class="flex flex-col justify-center items-center gap-2 pt-3 text-[12px] text-[#3c3c3b]"
>
<div class="flex flex-row">
<div class="font-bold">Nome:&nbsp;</div>
<span class="w-full font-bold">
{{ user.name }}
</div>
<div class="flex flex-row">
<div class="font-bold">Vínculo:&nbsp;</div>
{{ user.connection }}
</div>
<div class="flex flex-row">
<div class="font-bold">Email:&nbsp;</div>
</span>
<span class="w-full font-normal">
{{ user.email }}
</div>
</span>
</div>
<button id="editUser"
class="p-2 bg-blue-brand rounded-lg justify-center my-8 text-white md:h-10 md:w-32"
(click)="navigatorEdit()"
>
Editar perfil
</button>
</div>
<div class="flex items-center justify-center">
<button id="deleteUser"
class="p-2 bg-blue-brand rounded-lg justify-center my-8 text-white md:h-10 md:w-32"
(click)="deleteUser()"

<div
class="w-full h-8 flex justify-center items-center font-normal text-[12px] text-[#3c3c3b]"
>
Deletar usuário
</button>
{{ connection }}
</div>
</div>
<div class="flex items-center justify-center">
<button
id="logout"
class="p-2 bg-blue-brand rounded-lg justify-center my-8 text-white md:h-10 md:w-16"
(click)="logoutUser()"
>
Sair

<button
id="editUser"
class="w-full h-[30px] max-w-[103px] bg-blue-brand rounded-lg text-white"
(click)="navigatorEdit()"
>
Editar
</button>

<div class="flex flex-initial flex-col gap-4 text-[11px] text-blue-brand">
<button id="deleteUser" class="rounded-lg" (click)="deleteUser()">
Deseja excluir o perfil?
</button>

<button id="changePassword">Alterar senha</button>

<button id="logout" (click)="logoutUser()">Sair</button>
</div>
</div>
17 changes: 10 additions & 7 deletions src/app/pages/profile/profile.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import { HttpErrorResponse } from '@angular/common/http';

type ErrorResponseType = HttpErrorResponse;


@Component({
selector: 'app-profile',
templateUrl: './profile.component.html',
Expand All @@ -19,6 +18,7 @@ type ErrorResponseType = HttpErrorResponse;
export class ProfileComponent {
user: any;
userId: any;
connection: string = '';

constructor(
private router: Router,
Expand All @@ -27,7 +27,7 @@ export class ProfileComponent {
private alertService: AlertService,
private confirmationService: ConfirmationService,
private authService: AuthService
) { }
) {}

ngOnInit(): void {
this.setUserIdFromToken(localStorage.getItem('token') as string);
Expand All @@ -43,6 +43,7 @@ export class ProfileComponent {
this.userService.getUser(this.userId).subscribe({
next: (data) => {
this.user = data;
this.connection = this.formatingConnection(this.user.connection);
},
error: (error: ErrorResponseType) => {
console.log(error);
Expand All @@ -60,8 +61,7 @@ export class ProfileComponent {
accept: () => {
this.authService.logout();
},
reject: () => {
},
reject: () => {},
});
}

Expand All @@ -87,13 +87,16 @@ export class ProfileComponent {
},
});
},
reject: () => {
},
reject: () => {},
});

}

navigatorEdit(): void {
this.router.navigate([`/editUser/${this.user.id}`]);
}

formatingConnection(value: string): string {
let str = value.toLowerCase();
return str.charAt(0).toUpperCase() + str.slice(1);
}
}
Loading