Add connection to cic-meta.
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import {BehaviorSubject, Observable} from 'rxjs';
|
||||
import {HttpClient, HttpParams} from '@angular/common/http';
|
||||
import {BehaviorSubject, Observable, of} from 'rxjs';
|
||||
import {HttpClient, HttpHeaders, HttpParams} from '@angular/common/http';
|
||||
import {environment} from '../../environments/environment';
|
||||
import {first, map} from 'rxjs/operators';
|
||||
import {} from '../../assets/js/cic-meta/sync';
|
||||
import { Envelope, Syncable } from '../../assets/js/cic-meta/sync.js';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
@@ -48,10 +48,37 @@ export class UserService {
|
||||
);
|
||||
}
|
||||
|
||||
changeAccountInfo(status: string, name: string, phoneNumber: string, type: string, token: string, failedPinAttempts: string, bio: string,
|
||||
gender: string, businessCategory: string, userLocation: string, location: string, referrer: string): Observable<any> {
|
||||
console.log(status);
|
||||
return ;
|
||||
changeAccountInfo(address: string, status: string, name: string, phoneNumber: string, type: string, token: string,
|
||||
failedPinAttempts: string, bio: string, gender: string, businessCategory: string, userLocation: string,
|
||||
location: string, referrer: string): Observable<any> {
|
||||
const accountDetails = {
|
||||
status,
|
||||
name,
|
||||
phoneNumber,
|
||||
type,
|
||||
token,
|
||||
failedPinAttempts,
|
||||
bio,
|
||||
gender,
|
||||
businessCategory,
|
||||
userLocation,
|
||||
location,
|
||||
referrer
|
||||
};
|
||||
const addressStub = address.slice(2);
|
||||
const headers = new HttpHeaders().append('x-cic-automerge', 'client');
|
||||
this.http.get(`${environment.cicMetaUrl}/${addressStub}`, { headers }).pipe(first()).subscribe(res => {
|
||||
console.log(res);
|
||||
const response = Envelope.fromJSON(res);
|
||||
response.unwrap();
|
||||
console.log(response);
|
||||
}, error => {
|
||||
console.error('There is an error!', error);
|
||||
});
|
||||
this.http.put(`${environment.cicMetaUrl}/${addressStub}`, { data: accountDetails }, { headers }).pipe(first()).subscribe(res => {
|
||||
console.log(res);
|
||||
});
|
||||
return of(addressStub);
|
||||
}
|
||||
|
||||
getAccounts(): void {
|
||||
@@ -109,8 +136,4 @@ export class UserService {
|
||||
return response;
|
||||
}));
|
||||
}
|
||||
|
||||
changeUserCredentials(): void {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import {Component, OnInit, ViewChild} from '@angular/core';
|
||||
import {MatTableDataSource} from '@angular/material/table';
|
||||
import {Transaction, User} from '../../../_models';
|
||||
import {SelectionModel} from '@angular/cdk/collections';
|
||||
import {MatPaginator} from '@angular/material/paginator';
|
||||
import {MatSort} from '@angular/material/sort';
|
||||
@@ -158,9 +157,9 @@ export class AccountDetailsComponent implements OnInit {
|
||||
|
||||
saveInfo(): void {
|
||||
this.submitted = true;
|
||||
console.log(this.accountInfoFormStub.userLocation.value);
|
||||
if (this.accountInfoForm.invalid) { return; }
|
||||
this.userService.changeAccountInfo(
|
||||
this.account.address,
|
||||
this.accountInfoFormStub.status.value,
|
||||
this.accountInfoFormStub.name.value,
|
||||
this.accountInfoFormStub.phoneNumber.value,
|
||||
|
||||
Reference in New Issue
Block a user