Add search by phone number functionality.

This commit is contained in:
Spencer Ofwiti 2021-04-24 22:21:15 +03:00
parent 36cbe3c7a9
commit affffa8ffe
5 changed files with 157 additions and 20623 deletions

20744
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -30,8 +30,8 @@
"block-syncer": "^0.2.4", "block-syncer": "^0.2.4",
"bootstrap": "^4.5.3", "bootstrap": "^4.5.3",
"chart.js": "^2.9.4", "chart.js": "^2.9.4",
"cic-client": "^0.1.1", "cic-client": "0.1.4",
"cic-client-meta": "0.0.7-alpha.3", "cic-client-meta": "0.0.7-alpha.6",
"datatables.net": "^1.10.22", "datatables.net": "^1.10.22",
"datatables.net-dt": "^1.10.22", "datatables.net-dt": "^1.10.22",
"ethers": "^5.0.31", "ethers": "^5.0.31",

View File

@ -13,11 +13,11 @@ export class HttpConfigInterceptor implements HttpInterceptor {
constructor() {} constructor() {}
intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> { intercept(request: HttpRequest<unknown>, next: HttpHandler): Observable<HttpEvent<unknown>> {
const token = sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN')); // const token = sessionStorage.getItem(btoa('CICADA_SESSION_TOKEN'));
if (token) { // if (token) {
request = request.clone({headers: request.headers.set('Authorization', 'Bearer ' + token)}); // request = request.clone({headers: request.headers.set('Authorization', 'Bearer ' + token)});
} // }
return next.handle(request); return next.handle(request);
} }

View File

@ -180,15 +180,21 @@ export class UserService {
} }
this.accountsList.next(this.accounts); this.accountsList.next(this.accounts);
accountSubject.next(accountInfo); accountSubject.next(accountInfo);
console.log(accountInfo);
}); });
return accountSubject.asObservable(); return accountSubject.asObservable();
} }
async getAccountByPhone(phoneNumber: string): Promise<any> { async getAccountByPhone(phoneNumber: string, limit: number = 100): Promise<any> {
this.getAccountDetailsFromMeta(await Phone.toKey(Number(phoneNumber))).pipe(first()).subscribe(res => { let accountSubject = new Subject<any>();
console.log(res); this.getAccountDetailsFromMeta(await Phone.toKey(phoneNumber)).pipe(first()).subscribe(async res => {
const response = Envelope.fromJSON(JSON.stringify(res)).unwrap();
const address = '0x' + response.m.data;
const account = await this.getAccountByAddress(address, limit);
account.subscribe(result => {
accountSubject.next(result);
});
}); });
return accountSubject.asObservable();
} }
resetAccountsList(): void { resetAccountsList(): void {
@ -197,6 +203,4 @@ export class UserService {
} }
searchAccountByName(name: string): any { return; } searchAccountByName(name: string): any { return; }
searchAccountByPhone(phoneNumber: string): any { return; }
} }

View File

@ -56,7 +56,13 @@ export class AccountSearchComponent implements OnInit {
this.phoneSearchSubmitted = true; this.phoneSearchSubmitted = true;
if (this.phoneSearchForm.invalid) { return; } if (this.phoneSearchForm.invalid) { return; }
this.phoneSearchLoading = true; this.phoneSearchLoading = true;
await this.userService.getAccountByPhone(this.phoneSearchFormStub.phoneNumber.value); (await this.userService.getAccountByPhone(this.phoneSearchFormStub.phoneNumber.value, 100)).subscribe(async res => {
if (res !== undefined) {
await this.router.navigateByUrl(`/accounts/${res.identities.evm['bloxberg:8996']}`);
} else {
alert('Account not found!');
}
});
this.phoneSearchLoading = false; this.phoneSearchLoading = false;
} }