Skip to content

Commit

Permalink
Correção do bug01, onde ocorria erro ao realizar alteração de vínculo.
Browse files Browse the repository at this point in the history
  • Loading branch information
vicamatos committed Jan 25, 2025
1 parent ac9982b commit 23799a2
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/app/pages/edit-user/edit-user.component.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
height: '2.25rem',
textAlign: 'justify',
alignItems: 'center',
display: 'flex'}" [options]="vinculo" optionLabel="name" formControlName="connection" [showClear]="true" placeholder="Vinculo"></p-dropdown>
display: 'flex'}" [options]="vinculo" optionLabel="name" optionValue="name" [(ngModel)]="selectedConnection" [showClear]="true" [placeholder]="selectedConnection ? selectedConnection : 'Vinculo'" (onChange)="onDropdownChange($event)"></p-dropdown>
</div>
<button class="w-24 h-8 bg-blue-brand rounded-lg justify-center my-8 text-white" type="submit">Editar</button>
</form>
Expand Down
10 changes: 8 additions & 2 deletions src/app/pages/edit-user/edit-user.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export class EditUserComponent implements OnInit {
userId: any;
userData: any;
vinculo: any = {};
selectedConnection = '';

constructor(
private router: Router,
Expand Down Expand Up @@ -52,6 +53,7 @@ export class EditUserComponent implements OnInit {
}

initializeForm() {
this.selectedConnection = this.userData.connection;
this.userForm = this.fb.group({
name: [this.userData ? this.userData.name : '', [Validators.required]],
email: [
Expand Down Expand Up @@ -84,15 +86,19 @@ export class EditUserComponent implements OnInit {
});
}

onDropdownChange(event: any) {
this.selectedConnection = event.value;
}

updateUser() {
if (this.userForm?.valid) {
const data = {
...this.userForm.value,
connection: this.userForm.value.connection.name,
connection: this.selectedConnection,
};

this.userService.updateUser(this.userId, data).subscribe({
next: (data) => {
console.log(data);
this.alertService.showMessage(
'success',
'Sucesso',
Expand Down

0 comments on commit 23799a2

Please sign in to comment.