Add API calls for profile component
This commit is contained in:
@@ -53,14 +53,12 @@ export class DashboardComponent implements OnInit {
|
||||
for (let i = 0; i < data.data.length; i++) {
|
||||
STOCK_DATA.push({
|
||||
count: data.data[i].count,
|
||||
// price: data.data[i].price,
|
||||
symbol: data.data[i].symbol,
|
||||
time: data.data[i].last_transaction,
|
||||
});
|
||||
}
|
||||
console.log(STOCK_DATA);
|
||||
this.dataSourceStocks = STOCK_DATA;
|
||||
//TODO map data on array for display
|
||||
//TODO move to helper service
|
||||
});
|
||||
this.dataService.getTransactionData().subscribe((response: any) => {
|
||||
@@ -76,7 +74,6 @@ export class DashboardComponent implements OnInit {
|
||||
}
|
||||
console.log(TRANSACTION_DATA);
|
||||
this.dataSourceTransactions = TRANSACTION_DATA;
|
||||
//TODO map data on array for display
|
||||
//TODO move to helper service
|
||||
});
|
||||
}
|
||||
|
||||
@@ -114,7 +114,7 @@
|
||||
[formControl]="telegramIdFormControl"
|
||||
[(ngModel)]="userId"
|
||||
required
|
||||
placeholder="Ex. 123456789"
|
||||
#telegramId
|
||||
/>
|
||||
<mat-error *ngIf="telegramIdFormControl.hasError('required')">
|
||||
Id is <strong>required</strong>
|
||||
|
||||
@@ -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