Add API calls for profile component
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import { i18nMetaToJSDoc } from '@angular/compiler/src/render3/view/i18n/meta';
|
||||
import { Component, OnInit } from '@angular/core';
|
||||
import { FormControl, PatternValidator, Validators } from '@angular/forms';
|
||||
import { MatDialog } from '@angular/material/dialog';
|
||||
import { BotService } from 'src/app/Services/bot.service';
|
||||
import { DataService } from 'src/app/Services/data.service';
|
||||
import { ProfileService } from 'src/app/Services/profile.service';
|
||||
import { ConfirmationDialogComponent } from './confirmation-dialog/confirmation-dialog.component';
|
||||
|
||||
@Component({
|
||||
@@ -23,24 +25,40 @@ export class ProfileComponent implements OnInit {
|
||||
form: any = {
|
||||
username: null,
|
||||
email: 'example@web.com',
|
||||
password: null,
|
||||
password: 'password',
|
||||
};
|
||||
|
||||
constructor(
|
||||
private botService: BotService,
|
||||
private dataService: DataService,
|
||||
private profileService: ProfileService,
|
||||
public dialog: MatDialog
|
||||
) {}
|
||||
|
||||
ngOnInit(): void {}
|
||||
ngOnInit(): void {
|
||||
this.profileService.getUserData().subscribe((result) => {
|
||||
console.log(result);
|
||||
result = JSON.parse(result);
|
||||
this.form.username = result.data.username;
|
||||
this.form.password = result.data.password;
|
||||
this.userId = result.data.telegram_user_id;
|
||||
});
|
||||
}
|
||||
|
||||
onSubmit() {
|
||||
console.log('NASE1');
|
||||
if (this.userId != '') {
|
||||
console.log(this.userId);
|
||||
this.profileService.addTelegramId(this.userId).subscribe((result) => {
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
updateUser() {
|
||||
const { username, email, password } = this.form;
|
||||
console.log('NASE2');
|
||||
this.profileService
|
||||
.updateProfile(this.form.username, this.form.password)
|
||||
.subscribe((result) => {
|
||||
console.log(result);
|
||||
});
|
||||
}
|
||||
|
||||
openDialog(action: string) {
|
||||
@@ -57,7 +75,6 @@ export class ProfileComponent implements OnInit {
|
||||
this.updateUser();
|
||||
}
|
||||
}
|
||||
console.log(`Dialog result: ${result}`);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user