2021-05-10 20:56:20 +02:00
|
|
|
<!doctype html>
|
|
|
|
<html class="no-js" lang="">
|
|
|
|
<head>
|
|
|
|
<meta charset="utf-8">
|
|
|
|
<meta http-equiv="x-ua-compatible" content="ie=edge">
|
|
|
|
<title>CICADA</title>
|
|
|
|
<meta name="description" content="">
|
|
|
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
|
|
|
|
|
|
<link rel="icon" type="image/x-icon" href="../images/favicon.ico">
|
|
|
|
<link rel="stylesheet" href="../styles/style.css">
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
|
|
|
|
<div class="navbar navbar-default navbar-fixed-top visible-xs">
|
|
|
|
<a href="../" class="navbar-brand">CICADA</a>
|
|
|
|
<button type="button" class="btn btn-default btn-menu ion-ios-menu" id="btn-menu"></button>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="xs-menu menu" id="mobile-menu">
|
|
|
|
<div id="book-search-input" role="search"><input type="text" placeholder="Type to search"></div> <compodoc-menu></compodoc-menu>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<div class="container-fluid main">
|
|
|
|
<div class="row main">
|
|
|
|
<div class="hidden-xs menu">
|
|
|
|
<compodoc-menu mode="normal"></compodoc-menu>
|
|
|
|
</div>
|
|
|
|
<!-- START CONTENT -->
|
|
|
|
<div class="content interceptor">
|
|
|
|
<div class="content-data">
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
<ol class="breadcrumb">
|
|
|
|
<li>Interceptors</li>
|
|
|
|
<li>MockBackendInterceptor</li>
|
|
|
|
</ol>
|
|
|
|
|
|
|
|
<ul class="nav nav-tabs" role="tablist">
|
|
|
|
<li class="active">
|
|
|
|
<a href="#info" role="tab" id="info-tab" data-toggle="tab" data-link="info">Info</a>
|
|
|
|
</li>
|
|
|
|
<li >
|
|
|
|
<a href="#source" role="tab" id="source-tab" data-toggle="tab" data-link="source">Source</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
<div class="tab-content">
|
|
|
|
<div class="tab-pane fade active in" id="c-info">
|
|
|
|
<p class="comment">
|
|
|
|
<h3>File</h3>
|
|
|
|
</p>
|
|
|
|
<p class="comment">
|
|
|
|
<code>src/app/_helpers/mock-backend.ts</code>
|
|
|
|
</p>
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
<p class="comment">
|
|
|
|
<h3>Description</h3>
|
|
|
|
</p>
|
|
|
|
<p class="comment">
|
|
|
|
<p>Intercepts HTTP requests and handles some specified requests internally.
|
|
|
|
Provides a backend that can handle requests for certain data items.</p>
|
2021-05-10 20:56:20 +02:00
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
</p>
|
|
|
|
|
2021-05-10 20:56:20 +02:00
|
|
|
|
|
|
|
<section>
|
|
|
|
<h3 id="index">Index</h3>
|
|
|
|
<table class="table table-sm table-bordered index-table">
|
|
|
|
<tbody>
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="col-md-4">
|
|
|
|
<h6><b>Methods</b></h6>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="col-md-4">
|
|
|
|
<ul class="index-list">
|
|
|
|
<li>
|
|
|
|
<a href="#intercept">intercept</a>
|
|
|
|
</li>
|
|
|
|
</ul>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
|
|
|
|
<section>
|
|
|
|
|
|
|
|
<h3 id="methods">
|
|
|
|
Methods
|
|
|
|
</h3>
|
|
|
|
<table class="table table-sm table-bordered">
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td class="col-md-4">
|
|
|
|
<a name="intercept"></a>
|
|
|
|
<span class="name">
|
|
|
|
<b>
|
|
|
|
intercept
|
|
|
|
</b>
|
|
|
|
<a href="#intercept"><span class="icon ion-ios-link"></span></a>
|
|
|
|
</span>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td class="col-md-4">
|
|
|
|
<code>intercept(request: HttpRequest<any>, next: <a href="https://angular.io/api/common/http/HttpHandler" target="_blank">HttpHandler</a>)</code>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="col-md-4">
|
2021-05-11 19:51:48 +02:00
|
|
|
<div class="io-line">Defined in <a href="" data-line="1097"
|
|
|
|
class="link-to-prism">src/app/_helpers/mock-backend.ts:1097</a></div>
|
2021-05-10 20:56:20 +02:00
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
|
|
|
|
|
|
|
|
<tr>
|
|
|
|
<td class="col-md-4">
|
2021-05-11 13:34:23 +02:00
|
|
|
<div class="io-description"><p>Intercepts HTTP requests.</p>
|
|
|
|
</div>
|
2021-05-10 20:56:20 +02:00
|
|
|
|
|
|
|
<div class="io-description">
|
|
|
|
<b>Parameters :</b>
|
|
|
|
<table class="params">
|
|
|
|
<thead>
|
|
|
|
<tr>
|
|
|
|
<td>Name</td>
|
|
|
|
<td>Type</td>
|
|
|
|
<td>Optional</td>
|
2021-05-11 13:34:23 +02:00
|
|
|
<td>Description</td>
|
2021-05-10 20:56:20 +02:00
|
|
|
</tr>
|
|
|
|
</thead>
|
|
|
|
<tbody>
|
|
|
|
<tr>
|
|
|
|
<td>request</td>
|
|
|
|
<td>
|
|
|
|
<code>HttpRequest<any></code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
No
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
<td>
|
|
|
|
<ul>
|
|
|
|
<li>An outgoing HTTP request with an optional typed body.</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</td>
|
2021-05-10 20:56:20 +02:00
|
|
|
</tr>
|
|
|
|
<tr>
|
|
|
|
<td>next</td>
|
|
|
|
<td>
|
|
|
|
<code><a href="https://angular.io/api/common/http/HttpHandler" target="_blank" >HttpHandler</a></code>
|
|
|
|
</td>
|
|
|
|
|
|
|
|
<td>
|
|
|
|
No
|
|
|
|
</td>
|
|
|
|
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
<td>
|
|
|
|
<ul>
|
|
|
|
<li>The next HTTP handler or the outgoing request dispatcher.</li>
|
|
|
|
</ul>
|
|
|
|
|
|
|
|
</td>
|
2021-05-10 20:56:20 +02:00
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</div>
|
|
|
|
<div>
|
|
|
|
</div>
|
|
|
|
<div class="io-description">
|
|
|
|
<b>Returns : </b> <code>Observable<HttpEvent<any>></code>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<div class="io-description">
|
2021-05-11 13:34:23 +02:00
|
|
|
<p>The response from the resolved request.</p>
|
|
|
|
|
2021-05-10 20:56:20 +02:00
|
|
|
</div>
|
|
|
|
</td>
|
|
|
|
</tr>
|
|
|
|
</tbody>
|
|
|
|
</table>
|
|
|
|
</section>
|
|
|
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
<div class="tab-pane fade tab-source-code" id="c-source">
|
2021-05-11 19:51:48 +02:00
|
|
|
<pre class="line-numbers compodoc-sourcecode"><code class="language-typescript">import {
|
|
|
|
HTTP_INTERCEPTORS,
|
|
|
|
HttpEvent,
|
|
|
|
HttpHandler,
|
|
|
|
HttpInterceptor,
|
|
|
|
HttpRequest,
|
|
|
|
HttpResponse,
|
|
|
|
} from '@angular/common/http';
|
|
|
|
import { Injectable } from '@angular/core';
|
2021-05-11 13:34:23 +02:00
|
|
|
|
|
|
|
// Third party imports
|
2021-05-11 19:51:48 +02:00
|
|
|
import { Observable, of, throwError } from 'rxjs';
|
|
|
|
import { delay, dematerialize, materialize, mergeMap } from 'rxjs/operators';
|
2021-05-11 13:34:23 +02:00
|
|
|
|
|
|
|
// Application imports
|
2021-05-11 19:51:48 +02:00
|
|
|
import { Action, AreaName, AreaType, Category, Token } from '@app/_models';
|
2021-05-10 20:56:20 +02:00
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** A mock of the curated account types. */
|
|
|
|
const accountTypes: Array<string> = ['user', 'cashier', 'vendor', 'tokenagent', 'group'];
|
|
|
|
|
|
|
|
/** A mock of actions made by the admin staff. */
|
2021-05-10 20:56:20 +02:00
|
|
|
const actions: Array<Action> = [
|
|
|
|
{ id: 1, user: 'Tom', role: 'enroller', action: 'Disburse RSV 100', approval: false },
|
|
|
|
{ id: 2, user: 'Christine', role: 'admin', action: 'Change user phone number', approval: true },
|
|
|
|
{ id: 3, user: 'Will', role: 'superadmin', action: 'Reclaim RSV 1000', approval: true },
|
|
|
|
{ id: 4, user: 'Vivian', role: 'enroller', action: 'Complete user profile', approval: true },
|
|
|
|
{ id: 5, user: 'Jack', role: 'enroller', action: 'Reclaim RSV 200', approval: false },
|
2021-05-11 19:51:48 +02:00
|
|
|
{ id: 6, user: 'Patience', role: 'enroller', action: 'Change user information', approval: false },
|
2021-05-10 20:56:20 +02:00
|
|
|
];
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** A mock of curated area names. */
|
|
|
|
const areaNames: Array<AreaName> = [
|
2021-05-10 20:56:20 +02:00
|
|
|
{
|
2021-05-11 13:34:23 +02:00
|
|
|
name: 'Mukuru Nairobi',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'kayaba',
|
|
|
|
'kayba',
|
|
|
|
'kambi',
|
|
|
|
'mukuru',
|
|
|
|
'masai',
|
|
|
|
'hazina',
|
|
|
|
'south',
|
|
|
|
'tetra',
|
|
|
|
'tetrapak',
|
|
|
|
'ruben',
|
|
|
|
'rueben',
|
|
|
|
'kingston',
|
|
|
|
'korokocho',
|
|
|
|
'kingstone',
|
|
|
|
'kamongo',
|
|
|
|
'lungalunga',
|
|
|
|
'sinai',
|
|
|
|
'sigei',
|
|
|
|
'lungu',
|
|
|
|
'lunga lunga',
|
|
|
|
'owino road',
|
|
|
|
'seigei',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 13:34:23 +02:00
|
|
|
name: 'Kinango Kwale',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'amani',
|
|
|
|
'bofu',
|
|
|
|
'chibuga',
|
|
|
|
'chikomani',
|
|
|
|
'chilongoni',
|
|
|
|
'chigojoni',
|
|
|
|
'chinguluni',
|
|
|
|
'chigato',
|
|
|
|
'chigale',
|
|
|
|
'chikole',
|
|
|
|
'chilongoni',
|
|
|
|
'chilumani',
|
|
|
|
'chigojoni',
|
|
|
|
'chikomani',
|
|
|
|
'chizini',
|
|
|
|
'chikomeni',
|
|
|
|
'chidzuvini',
|
|
|
|
'chidzivuni',
|
|
|
|
'chikuyu',
|
|
|
|
'chizingo',
|
|
|
|
'doti',
|
|
|
|
'dzugwe',
|
|
|
|
'dzivani',
|
|
|
|
'dzovuni',
|
|
|
|
'hanje',
|
|
|
|
'kasemeni',
|
|
|
|
'katundani',
|
|
|
|
'kibandaogo',
|
|
|
|
'kibandaongo',
|
|
|
|
'kwale',
|
|
|
|
'kinango',
|
|
|
|
'kidzuvini',
|
|
|
|
'kalalani',
|
|
|
|
'kafuduni',
|
|
|
|
'kaloleni',
|
|
|
|
'kilibole',
|
|
|
|
'lutsangani',
|
|
|
|
'peku',
|
|
|
|
'gona',
|
|
|
|
'guro',
|
|
|
|
'gandini',
|
|
|
|
'mkanyeni',
|
|
|
|
'myenzeni',
|
|
|
|
'miyenzeni',
|
|
|
|
'miatsiani',
|
|
|
|
'mienzeni',
|
|
|
|
'mnyenzeni',
|
|
|
|
'minyenzeni',
|
|
|
|
'miyani',
|
|
|
|
'mioleni',
|
|
|
|
'makuluni',
|
|
|
|
'mariakani',
|
|
|
|
'makobeni',
|
|
|
|
'madewani',
|
|
|
|
'mwangaraba',
|
|
|
|
'mwashanga',
|
|
|
|
'miloeni',
|
|
|
|
'mabesheni',
|
|
|
|
'mazeras',
|
|
|
|
'mazera',
|
|
|
|
'mlola',
|
|
|
|
'muugano',
|
|
|
|
'mulunguni',
|
|
|
|
'mabesheni',
|
|
|
|
'miatsani',
|
|
|
|
'miatsiani',
|
|
|
|
'mwache',
|
|
|
|
'mwangani',
|
|
|
|
'mwehavikonje',
|
|
|
|
'miguneni',
|
|
|
|
'nzora',
|
|
|
|
'nzovuni',
|
|
|
|
'vikinduni',
|
|
|
|
'vikolani',
|
|
|
|
'vitangani',
|
|
|
|
'viogato',
|
|
|
|
'vyogato',
|
|
|
|
'vistangani',
|
|
|
|
'yapha',
|
|
|
|
'yava',
|
|
|
|
'yowani',
|
|
|
|
'ziwani',
|
|
|
|
'majengo',
|
|
|
|
'matuga',
|
|
|
|
'vigungani',
|
|
|
|
'vidziweni',
|
|
|
|
'vinyunduni',
|
|
|
|
'ukunda',
|
|
|
|
'kokotoni',
|
|
|
|
'mikindani',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 13:34:23 +02:00
|
|
|
name: 'Misc Nairobi',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'nairobi',
|
|
|
|
'west',
|
|
|
|
'lindi',
|
|
|
|
'kibera',
|
|
|
|
'kibira',
|
|
|
|
'kibra',
|
|
|
|
'makina',
|
|
|
|
'soweto',
|
|
|
|
'olympic',
|
|
|
|
'kangemi',
|
|
|
|
'ruiru',
|
|
|
|
'congo',
|
|
|
|
'kawangware',
|
|
|
|
'kwangware',
|
|
|
|
'donholm',
|
|
|
|
'dagoreti',
|
|
|
|
'dandora',
|
|
|
|
'kabete',
|
|
|
|
'sinai',
|
|
|
|
'donhom',
|
|
|
|
'donholm',
|
|
|
|
'huruma',
|
|
|
|
'kitengela',
|
|
|
|
'makadara',
|
|
|
|
',mlolongo',
|
|
|
|
'kenyatta',
|
|
|
|
'mlolongo',
|
|
|
|
'tassia',
|
|
|
|
'tasia',
|
|
|
|
'gatina',
|
|
|
|
'56',
|
|
|
|
'industrial',
|
|
|
|
'kariobangi',
|
|
|
|
'kasarani',
|
|
|
|
'kayole',
|
|
|
|
'mathare',
|
|
|
|
'pipe',
|
|
|
|
'juja',
|
|
|
|
'uchumi',
|
|
|
|
'jogoo',
|
|
|
|
'umoja',
|
|
|
|
'thika',
|
|
|
|
'kikuyu',
|
|
|
|
'stadium',
|
|
|
|
'buru buru',
|
|
|
|
'ngong',
|
|
|
|
'starehe',
|
|
|
|
'mwiki',
|
|
|
|
'fuata',
|
|
|
|
'kware',
|
|
|
|
'kabiro',
|
|
|
|
'embakassi',
|
|
|
|
'embakasi',
|
|
|
|
'kmoja',
|
|
|
|
'east',
|
|
|
|
'githurai',
|
|
|
|
'landi',
|
|
|
|
'langata',
|
|
|
|
'limuru',
|
|
|
|
'mathere',
|
|
|
|
'dagoretti',
|
|
|
|
'kirembe',
|
|
|
|
'muugano',
|
|
|
|
'mwiki',
|
|
|
|
'toi market',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 13:34:23 +02:00
|
|
|
name: 'Misc Mombasa',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'mombasa',
|
|
|
|
'likoni',
|
|
|
|
'bangla',
|
|
|
|
'bangladesh',
|
|
|
|
'kizingo',
|
|
|
|
'old town',
|
|
|
|
'makupa',
|
|
|
|
'mvita',
|
|
|
|
'ngombeni',
|
|
|
|
'ngómbeni',
|
|
|
|
'ombeni',
|
|
|
|
'magongo',
|
|
|
|
'miritini',
|
|
|
|
'changamwe',
|
|
|
|
'jomvu',
|
|
|
|
'ohuru',
|
|
|
|
'tudor',
|
|
|
|
'diani',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 13:34:23 +02:00
|
|
|
name: 'Kisauni',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'bamburi',
|
|
|
|
'kisauni',
|
|
|
|
'mworoni',
|
|
|
|
'nyali',
|
|
|
|
'shanzu',
|
|
|
|
'bombolulu',
|
|
|
|
'mtopanga',
|
|
|
|
'mjambere',
|
|
|
|
'majaoni',
|
|
|
|
'manyani',
|
|
|
|
'magogoni',
|
|
|
|
'junda',
|
|
|
|
'mwakirunge',
|
|
|
|
'mshomoroni',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 13:34:23 +02:00
|
|
|
name: 'Kilifi',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'kilfi',
|
|
|
|
'kilifi',
|
|
|
|
'mtwapa',
|
|
|
|
'takaungu',
|
|
|
|
'makongeni',
|
|
|
|
'mnarani',
|
|
|
|
'mnarani',
|
|
|
|
'office',
|
|
|
|
'g.e',
|
|
|
|
'ge',
|
|
|
|
'raibai',
|
|
|
|
'ribe',
|
|
|
|
],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Kakuma',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: ['kakuma'],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Kitui',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: ['kitui', 'mwingi'],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Nyanza',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'busia',
|
|
|
|
'nyalgunga',
|
|
|
|
'mbita',
|
|
|
|
'siaya',
|
|
|
|
'kisumu',
|
|
|
|
'nyalenda',
|
|
|
|
'hawinga',
|
|
|
|
'rangala',
|
|
|
|
'uyoma',
|
|
|
|
'mumias',
|
|
|
|
'homabay',
|
|
|
|
'homaboy',
|
|
|
|
'migori',
|
|
|
|
'kusumu',
|
|
|
|
],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'Misc Rural Counties',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: [
|
|
|
|
'makueni',
|
|
|
|
'meru',
|
|
|
|
'kisii',
|
|
|
|
'bomet',
|
|
|
|
'machakos',
|
|
|
|
'bungoma',
|
|
|
|
'eldoret',
|
|
|
|
'kakamega',
|
|
|
|
'kericho',
|
|
|
|
'kajiado',
|
|
|
|
'nandi',
|
|
|
|
'nyeri',
|
|
|
|
'wote',
|
|
|
|
'kiambu',
|
|
|
|
'mwea',
|
|
|
|
'nakuru',
|
|
|
|
'narok',
|
|
|
|
],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'other',
|
2021-05-11 19:51:48 +02:00
|
|
|
locations: ['other', 'none', 'unknown'],
|
|
|
|
},
|
2021-05-10 20:56:20 +02:00
|
|
|
];
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** A mock of curated area types. */
|
|
|
|
const areaTypes: Array<AreaType> = [
|
|
|
|
{
|
|
|
|
name: 'urban',
|
2021-05-11 19:51:48 +02:00
|
|
|
area: ['urban', 'nairobi', 'mombasa'],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'rural',
|
2021-05-11 19:51:48 +02:00
|
|
|
area: ['rural', 'kakuma', 'kwale', 'kinango', 'kitui', 'nyanza'],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'periurban',
|
2021-05-11 19:51:48 +02:00
|
|
|
area: ['kilifi', 'periurban'],
|
2021-05-11 13:34:23 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'other',
|
2021-05-11 19:51:48 +02:00
|
|
|
area: ['other'],
|
|
|
|
},
|
2021-05-11 13:34:23 +02:00
|
|
|
];
|
|
|
|
|
|
|
|
/** A mock of the user's business categories */
|
2021-05-10 20:56:20 +02:00
|
|
|
const categories: Array<Category> = [
|
|
|
|
{
|
|
|
|
name: 'system',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: ['system', 'office main', 'office main phone'],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'education',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'book',
|
|
|
|
'coach',
|
|
|
|
'teacher',
|
|
|
|
'sch',
|
|
|
|
'school',
|
|
|
|
'pry',
|
|
|
|
'education',
|
|
|
|
'student',
|
|
|
|
'mwalimu',
|
|
|
|
'maalim',
|
|
|
|
'consultant',
|
|
|
|
'consult',
|
|
|
|
'college',
|
|
|
|
'university',
|
|
|
|
'lecturer',
|
|
|
|
'primary',
|
|
|
|
'secondary',
|
|
|
|
'daycare',
|
|
|
|
'babycare',
|
|
|
|
'baby care',
|
|
|
|
'elim',
|
|
|
|
'eimu',
|
|
|
|
'nursery',
|
|
|
|
'red cross',
|
|
|
|
'volunteer',
|
|
|
|
'instructor',
|
|
|
|
'journalist',
|
|
|
|
'lesson',
|
|
|
|
'academy',
|
|
|
|
'headmistress',
|
|
|
|
'headteacher',
|
|
|
|
'cyber',
|
|
|
|
'researcher',
|
|
|
|
'professor',
|
|
|
|
'demo',
|
|
|
|
'expert',
|
|
|
|
'tution',
|
|
|
|
'tuition',
|
|
|
|
'children',
|
|
|
|
'headmaster',
|
|
|
|
'educator',
|
|
|
|
'Marital counsellor',
|
|
|
|
'counsellor',
|
|
|
|
'trainer',
|
|
|
|
'vijana',
|
|
|
|
'youth',
|
|
|
|
'intern',
|
|
|
|
'redcross',
|
|
|
|
'KRCS',
|
|
|
|
'danish',
|
|
|
|
'science',
|
|
|
|
'data',
|
|
|
|
'facilitator',
|
|
|
|
'vitabu',
|
|
|
|
'kitabu',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'faith',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'pastor',
|
|
|
|
'imam',
|
|
|
|
'madrasa',
|
|
|
|
'religous',
|
|
|
|
'religious',
|
|
|
|
'ustadh',
|
|
|
|
'ustadhi',
|
|
|
|
'Marital counsellor',
|
|
|
|
'counsellor',
|
|
|
|
'church',
|
|
|
|
'kanisa',
|
|
|
|
'mksiti',
|
|
|
|
'donor',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'government',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'elder',
|
|
|
|
'chief',
|
|
|
|
'police',
|
|
|
|
'government',
|
|
|
|
'country',
|
|
|
|
'county',
|
|
|
|
'soldier',
|
|
|
|
'village admin',
|
|
|
|
'ward',
|
|
|
|
'leader',
|
|
|
|
'kra',
|
|
|
|
'mailman',
|
|
|
|
'immagration',
|
|
|
|
'immigration',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'environment',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'conservation',
|
|
|
|
'toilet',
|
|
|
|
'choo',
|
|
|
|
'garbage',
|
|
|
|
'fagio',
|
|
|
|
'waste',
|
|
|
|
'tree',
|
|
|
|
'taka',
|
|
|
|
'scrap',
|
|
|
|
'cleaning',
|
|
|
|
'gardener',
|
|
|
|
'rubbish',
|
|
|
|
'usafi',
|
|
|
|
'mazingira',
|
|
|
|
'miti',
|
|
|
|
'trash',
|
|
|
|
'cleaner',
|
|
|
|
'plastic',
|
|
|
|
'collection',
|
|
|
|
'seedling',
|
|
|
|
'seedlings',
|
|
|
|
'recycling',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'farming',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'farm',
|
|
|
|
'farmer',
|
|
|
|
'farming',
|
|
|
|
'mkulima',
|
|
|
|
'kulima',
|
|
|
|
'ukulima',
|
|
|
|
'wakulima',
|
|
|
|
'jembe',
|
|
|
|
'shamba',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'labour',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'artist',
|
|
|
|
'agent',
|
|
|
|
'guard',
|
|
|
|
'askari',
|
|
|
|
'accountant',
|
|
|
|
'baker',
|
|
|
|
'beadwork',
|
|
|
|
'beauty',
|
|
|
|
'business',
|
|
|
|
'barber',
|
|
|
|
'casual',
|
|
|
|
'electrian',
|
|
|
|
'caretaker',
|
|
|
|
'car wash',
|
|
|
|
'capenter',
|
|
|
|
'construction',
|
|
|
|
'chef',
|
|
|
|
'catering',
|
|
|
|
'cobler',
|
|
|
|
'cobbler',
|
|
|
|
'carwash',
|
|
|
|
'dhobi',
|
|
|
|
'landlord',
|
|
|
|
'design',
|
|
|
|
'carpenter',
|
|
|
|
'fundi',
|
|
|
|
'hawking',
|
|
|
|
'hawker',
|
|
|
|
'househelp',
|
|
|
|
'hsehelp',
|
|
|
|
'house help',
|
|
|
|
'help',
|
|
|
|
'housegirl',
|
|
|
|
'kushona',
|
|
|
|
'juakali',
|
|
|
|
'jualikali',
|
|
|
|
'juacali',
|
|
|
|
'jua kali',
|
|
|
|
'shepherd',
|
|
|
|
'makuti',
|
|
|
|
'kujenga',
|
|
|
|
'kinyozi',
|
|
|
|
'kazi',
|
|
|
|
'knitting',
|
|
|
|
'kufua',
|
|
|
|
'fua',
|
|
|
|
'hustler',
|
|
|
|
'biashara',
|
|
|
|
'labour',
|
|
|
|
'labor',
|
|
|
|
'laundry',
|
|
|
|
'repair',
|
|
|
|
'hair',
|
|
|
|
'posho',
|
|
|
|
'mill',
|
|
|
|
'mtambo',
|
|
|
|
'uvuvi',
|
|
|
|
'engineer',
|
|
|
|
'manager',
|
|
|
|
'tailor',
|
|
|
|
'nguo',
|
|
|
|
'mason',
|
|
|
|
'mtumba',
|
|
|
|
'garage',
|
|
|
|
'mechanic',
|
|
|
|
'mjenzi',
|
|
|
|
'mfugaji',
|
|
|
|
'painter',
|
|
|
|
'receptionist',
|
|
|
|
'printing',
|
|
|
|
'programming',
|
|
|
|
'plumb',
|
|
|
|
'charging',
|
|
|
|
'salon',
|
|
|
|
'mpishi',
|
|
|
|
'msusi',
|
|
|
|
'mgema',
|
|
|
|
'footballer',
|
|
|
|
'photocopy',
|
|
|
|
'peddler',
|
|
|
|
'staff',
|
|
|
|
'sales',
|
|
|
|
'service',
|
|
|
|
'saloon',
|
|
|
|
'seremala',
|
|
|
|
'security',
|
|
|
|
'insurance',
|
|
|
|
'secretary',
|
|
|
|
'shoe',
|
|
|
|
'shepard',
|
|
|
|
'shephard',
|
|
|
|
'tout',
|
|
|
|
'tv',
|
|
|
|
'mvuvi',
|
|
|
|
'mawe',
|
|
|
|
'majani',
|
|
|
|
'maembe',
|
|
|
|
'freelance',
|
|
|
|
'mjengo',
|
|
|
|
'electronics',
|
|
|
|
'photographer',
|
|
|
|
'programmer',
|
|
|
|
'electrician',
|
|
|
|
'washing',
|
|
|
|
'bricks',
|
|
|
|
'welder',
|
|
|
|
'welding',
|
|
|
|
'working',
|
|
|
|
'worker',
|
|
|
|
'watchman',
|
|
|
|
'waiter',
|
|
|
|
'waitress',
|
|
|
|
'viatu',
|
|
|
|
'yoga',
|
|
|
|
'guitarist',
|
|
|
|
'house',
|
|
|
|
'artisan',
|
|
|
|
'musician',
|
|
|
|
'trade',
|
|
|
|
'makonge',
|
|
|
|
'ujenzi',
|
|
|
|
'vendor',
|
|
|
|
'watchlady',
|
|
|
|
'marketing',
|
|
|
|
'beautician',
|
|
|
|
'photo',
|
|
|
|
'metal work',
|
|
|
|
'supplier',
|
|
|
|
'law firm',
|
|
|
|
'brewer',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'food',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'avocado',
|
|
|
|
'bhajia',
|
|
|
|
'bajia',
|
|
|
|
'mbonga',
|
|
|
|
'bofu',
|
|
|
|
'beans',
|
|
|
|
'biscuits',
|
|
|
|
'biringanya',
|
|
|
|
'banana',
|
|
|
|
'bananas',
|
|
|
|
'crisps',
|
|
|
|
'chakula',
|
|
|
|
'coconut',
|
|
|
|
'chapati',
|
|
|
|
'cereal',
|
|
|
|
'chipo',
|
|
|
|
'chapo',
|
|
|
|
'chai',
|
|
|
|
'chips',
|
|
|
|
'cassava',
|
|
|
|
'cake',
|
|
|
|
'cereals',
|
|
|
|
'cook',
|
|
|
|
'corn',
|
|
|
|
'coffee',
|
|
|
|
'chicken',
|
|
|
|
'dagaa',
|
|
|
|
'donut',
|
|
|
|
'dough',
|
|
|
|
'groundnuts',
|
|
|
|
'hotel',
|
|
|
|
'holel',
|
|
|
|
'hoteli',
|
|
|
|
'butcher',
|
|
|
|
'butchery',
|
|
|
|
'fruit',
|
|
|
|
'food',
|
|
|
|
'fruits',
|
|
|
|
'fish',
|
|
|
|
'githeri',
|
|
|
|
'grocery',
|
|
|
|
'grocer',
|
|
|
|
'pojo',
|
|
|
|
'papa',
|
|
|
|
'goats',
|
|
|
|
'mabenda',
|
|
|
|
'mbenda',
|
|
|
|
'poultry',
|
|
|
|
'soda',
|
|
|
|
'peanuts',
|
|
|
|
'potatoes',
|
|
|
|
'samosa',
|
|
|
|
'soko',
|
|
|
|
'samaki',
|
|
|
|
'tomato',
|
|
|
|
'tomatoes',
|
|
|
|
'mchele',
|
|
|
|
'matunda',
|
|
|
|
'mango',
|
|
|
|
'melon',
|
|
|
|
'mellon',
|
|
|
|
'nyanya',
|
|
|
|
'nyama',
|
|
|
|
'omena',
|
|
|
|
'umena',
|
|
|
|
'ndizi',
|
|
|
|
'njugu',
|
|
|
|
'kamba kamba',
|
|
|
|
'khaimati',
|
|
|
|
'kaimati',
|
|
|
|
'kunde',
|
|
|
|
'kuku',
|
|
|
|
'kahawa',
|
|
|
|
'keki',
|
|
|
|
'muguka',
|
|
|
|
'miraa',
|
|
|
|
'milk',
|
|
|
|
'choma',
|
|
|
|
'maziwa',
|
|
|
|
'mboga',
|
|
|
|
'mbog',
|
|
|
|
'busaa',
|
|
|
|
'chumvi',
|
|
|
|
'cabbages',
|
|
|
|
'mabuyu',
|
|
|
|
'machungwa',
|
|
|
|
'mbuzi',
|
|
|
|
'mnazi',
|
|
|
|
'mchicha',
|
|
|
|
'ngombe',
|
|
|
|
'ngano',
|
|
|
|
'nazi',
|
|
|
|
'oranges',
|
|
|
|
'peanuts',
|
|
|
|
'mkate',
|
|
|
|
'bread',
|
|
|
|
'mikate',
|
|
|
|
'vitungu',
|
|
|
|
'sausages',
|
|
|
|
'maize',
|
|
|
|
'mbata',
|
|
|
|
'mchuzi',
|
|
|
|
'mchuuzi',
|
|
|
|
'mandazi',
|
|
|
|
'mbaazi',
|
|
|
|
'mahindi',
|
|
|
|
'maandazi',
|
|
|
|
'mogoka',
|
|
|
|
'meat',
|
|
|
|
'mhogo',
|
|
|
|
'mihogo',
|
|
|
|
'muhogo',
|
|
|
|
'maharagwe',
|
|
|
|
'miwa',
|
|
|
|
'mahamri',
|
|
|
|
'mitumba',
|
|
|
|
'simsim',
|
|
|
|
'porridge',
|
|
|
|
'pilau',
|
|
|
|
'vegetable',
|
|
|
|
'egg',
|
|
|
|
'mayai',
|
|
|
|
'mifugo',
|
|
|
|
'unga',
|
|
|
|
'good',
|
|
|
|
'sima',
|
|
|
|
'sweet',
|
|
|
|
'sweats',
|
|
|
|
'sambusa',
|
|
|
|
'snacks',
|
|
|
|
'sugar',
|
|
|
|
'suger',
|
|
|
|
'ugoro',
|
|
|
|
'sukari',
|
|
|
|
'soup',
|
|
|
|
'spinach',
|
|
|
|
'smokie',
|
|
|
|
'smokies',
|
|
|
|
'sukuma',
|
|
|
|
'tea',
|
|
|
|
'uji',
|
|
|
|
'ugali',
|
|
|
|
'uchuzi',
|
|
|
|
'uchuuzi',
|
|
|
|
'viazi',
|
|
|
|
'yoghurt',
|
|
|
|
'yogurt',
|
|
|
|
'wine',
|
|
|
|
'marondo',
|
|
|
|
'maandzi',
|
|
|
|
'matoke',
|
|
|
|
'omeno',
|
|
|
|
'onions',
|
|
|
|
'nzugu',
|
|
|
|
'korosho',
|
|
|
|
'barafu',
|
|
|
|
'juice',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'water',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: ['maji', 'water'],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'health',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'agrovet',
|
|
|
|
'dispensary',
|
|
|
|
'barakoa',
|
|
|
|
'chemist',
|
|
|
|
'Chemicals',
|
|
|
|
'chv',
|
|
|
|
'doctor',
|
|
|
|
'daktari',
|
|
|
|
'dawa',
|
|
|
|
'hospital',
|
|
|
|
'herbalist',
|
|
|
|
'mganga',
|
|
|
|
'sabuni',
|
|
|
|
'soap',
|
|
|
|
'nurse',
|
|
|
|
'heath',
|
|
|
|
'community health worker',
|
|
|
|
'clinic',
|
|
|
|
'clinical',
|
|
|
|
'mask',
|
|
|
|
'medicine',
|
|
|
|
'lab technician',
|
|
|
|
'pharmacy',
|
|
|
|
'cosmetics',
|
|
|
|
'veterinary',
|
|
|
|
'vet',
|
|
|
|
'sickly',
|
|
|
|
'emergency response',
|
|
|
|
'emergency',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'savings',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: ['chama', 'group', 'savings', 'loan', 'silc', 'vsla', 'credit', 'finance'],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'shop',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'bag',
|
|
|
|
'bead',
|
|
|
|
'belt',
|
|
|
|
'bedding',
|
|
|
|
'jik',
|
|
|
|
'bed',
|
|
|
|
'cement',
|
|
|
|
'botique',
|
|
|
|
'boutique',
|
|
|
|
'lines',
|
|
|
|
'kibanda',
|
|
|
|
'kiosk',
|
|
|
|
'spareparts',
|
|
|
|
'candy',
|
|
|
|
'cloth',
|
|
|
|
'electricals',
|
|
|
|
'mutumba',
|
|
|
|
'cafe',
|
|
|
|
'leso',
|
|
|
|
'lesso',
|
|
|
|
'duka',
|
|
|
|
'spare parts',
|
|
|
|
'socks',
|
|
|
|
'malimali',
|
|
|
|
'mitungi',
|
|
|
|
'mali mali',
|
|
|
|
'hardware',
|
|
|
|
'detergent',
|
|
|
|
'detergents',
|
|
|
|
'dera',
|
|
|
|
'retail',
|
|
|
|
'kamba',
|
|
|
|
'pombe',
|
|
|
|
'pampers',
|
|
|
|
'pool',
|
|
|
|
'phone',
|
|
|
|
'simu',
|
|
|
|
'mangwe',
|
|
|
|
'mikeka',
|
|
|
|
'movie',
|
|
|
|
'shop',
|
|
|
|
'acces',
|
|
|
|
'mchanga',
|
|
|
|
'uto',
|
|
|
|
'airtime',
|
|
|
|
'matress',
|
|
|
|
'mattress',
|
|
|
|
'mattresses',
|
|
|
|
'mpsea',
|
|
|
|
'mpesa',
|
|
|
|
'shirt',
|
|
|
|
'wholesaler',
|
|
|
|
'perfume',
|
|
|
|
'playstation',
|
|
|
|
'tissue',
|
|
|
|
'vikapu',
|
|
|
|
'uniform',
|
|
|
|
'flowers',
|
|
|
|
'vitenge',
|
|
|
|
'utencils',
|
|
|
|
'utensils',
|
|
|
|
'station',
|
|
|
|
'jewel',
|
|
|
|
'pool table',
|
|
|
|
'club',
|
|
|
|
'pub',
|
|
|
|
'bar',
|
|
|
|
'furniture',
|
|
|
|
'm-pesa',
|
|
|
|
'vyombo',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'transport',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'kebeba',
|
|
|
|
'beba',
|
|
|
|
'bebabeba',
|
|
|
|
'bike',
|
|
|
|
'bicycle',
|
|
|
|
'matatu',
|
|
|
|
'boda',
|
|
|
|
'bodaboda',
|
|
|
|
'cart',
|
|
|
|
'carrier',
|
|
|
|
'tour',
|
|
|
|
'travel',
|
|
|
|
'driver',
|
|
|
|
'dereva',
|
|
|
|
'tout',
|
|
|
|
'conductor',
|
|
|
|
'kubeba',
|
|
|
|
'tuktuk',
|
|
|
|
'taxi',
|
|
|
|
'piki',
|
|
|
|
'pikipiki',
|
|
|
|
'manamba',
|
|
|
|
'trasportion',
|
|
|
|
'mkokoteni',
|
|
|
|
'mover',
|
|
|
|
'motorist',
|
|
|
|
'motorbike',
|
|
|
|
'transport',
|
|
|
|
'transpoter',
|
|
|
|
'gari',
|
|
|
|
'magari',
|
|
|
|
'makanga',
|
|
|
|
'car',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'fuel/energy',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: [
|
|
|
|
'timber',
|
|
|
|
'timberyard',
|
|
|
|
'biogas',
|
|
|
|
'charcol',
|
|
|
|
'charcoal',
|
|
|
|
'kuni',
|
|
|
|
'mbao',
|
|
|
|
'fuel',
|
|
|
|
'makaa',
|
|
|
|
'mafuta',
|
|
|
|
'moto',
|
|
|
|
'solar',
|
|
|
|
'stima',
|
|
|
|
'fire',
|
|
|
|
'firewood',
|
|
|
|
'wood',
|
|
|
|
'oil',
|
|
|
|
'taa',
|
|
|
|
'gas',
|
|
|
|
'paraffin',
|
|
|
|
'parrafin',
|
|
|
|
'parafin',
|
|
|
|
'petrol',
|
|
|
|
'petro',
|
|
|
|
'kerosine',
|
|
|
|
'kerosene',
|
|
|
|
'diesel',
|
|
|
|
],
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
|
|
|
name: 'other',
|
2021-05-11 19:51:48 +02:00
|
|
|
products: ['other', 'none', 'unknown', 'none'],
|
|
|
|
},
|
2021-05-10 20:56:20 +02:00
|
|
|
];
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** A mock of curated genders */
|
|
|
|
const genders: Array<string> = ['male', 'female', 'other'];
|
|
|
|
|
|
|
|
/** A mock of the tokens in the system. */
|
|
|
|
const tokens: Array<Token> = [
|
2021-05-10 20:56:20 +02:00
|
|
|
{
|
2021-05-11 19:51:48 +02:00
|
|
|
name: 'Giftable Reserve',
|
|
|
|
symbol: 'GRZ',
|
|
|
|
address: '0xa686005CE37Dce7738436256982C3903f2E4ea8E',
|
|
|
|
supply: '1000000001000000000000000000',
|
|
|
|
decimals: '18',
|
|
|
|
reserves: {},
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 19:51:48 +02:00
|
|
|
name: 'Demo Token',
|
|
|
|
symbol: 'DEMO',
|
|
|
|
address: '0xc80D6aFF8194114c52AEcD84c9f15fd5c8abb187',
|
|
|
|
supply: '99999999999999998976',
|
|
|
|
decimals: '18',
|
|
|
|
reserves: {
|
|
|
|
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {
|
|
|
|
weight: '1000000',
|
|
|
|
balance: '99999999999999998976',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
reserveRatio: '1000000',
|
|
|
|
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 19:51:48 +02:00
|
|
|
name: 'Foo Token',
|
|
|
|
symbol: 'FOO',
|
|
|
|
address: '0x9ceD86089f7aBB5A97B40eb0E7521e7aa308d354',
|
|
|
|
supply: '1000000000000000001014',
|
|
|
|
decimals: '18',
|
|
|
|
reserves: {
|
|
|
|
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': {
|
|
|
|
weight: '1000000',
|
|
|
|
balance: '1000000000000000001014',
|
|
|
|
},
|
|
|
|
},
|
|
|
|
reserveRatio: '1000000',
|
|
|
|
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 19:51:48 +02:00
|
|
|
name: 'testb',
|
|
|
|
symbol: 'tstb',
|
|
|
|
address: '0xC63cFA91A3BFf41cE31Ff436f67D3ACBC977DB95',
|
|
|
|
supply: '99000',
|
|
|
|
decimals: '18',
|
|
|
|
reserves: {
|
|
|
|
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': { weight: '1000000', balance: '99000' },
|
|
|
|
},
|
|
|
|
reserveRatio: '1000000',
|
|
|
|
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 19:51:48 +02:00
|
|
|
name: 'testa',
|
|
|
|
symbol: 'tsta',
|
|
|
|
address: '0x8fA4101ef19D0a078239d035659e92b278bD083C',
|
|
|
|
supply: '9981',
|
|
|
|
decimals: '18',
|
|
|
|
reserves: {
|
|
|
|
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': { weight: '1000000', balance: '9981' },
|
|
|
|
},
|
|
|
|
reserveRatio: '1000000',
|
|
|
|
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
2021-05-10 20:56:20 +02:00
|
|
|
},
|
|
|
|
{
|
2021-05-11 19:51:48 +02:00
|
|
|
name: 'testc',
|
|
|
|
symbol: 'tstc',
|
|
|
|
address: '0x4A6fA6bc3BfE4C9661bC692D9798425350C9e3D4',
|
|
|
|
supply: '100990',
|
|
|
|
decimals: '18',
|
|
|
|
reserves: {
|
|
|
|
'0xa686005CE37Dce7738436256982C3903f2E4ea8E': { weight: '1000000', balance: '100990' },
|
|
|
|
},
|
|
|
|
reserveRatio: '1000000',
|
|
|
|
owner: '0x3Da99AAD2D9CA01D131eFc3B17444b832B31Ff4a',
|
|
|
|
},
|
2021-05-10 20:56:20 +02:00
|
|
|
];
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** A mock of curated transaction types. */
|
2021-05-11 19:51:48 +02:00
|
|
|
const transactionTypes: Array<string> = [
|
|
|
|
'transactions',
|
|
|
|
'conversions',
|
|
|
|
'disbursements',
|
|
|
|
'rewards',
|
|
|
|
'reclamation',
|
|
|
|
];
|
2021-05-10 20:56:20 +02:00
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/**
|
|
|
|
* Intercepts HTTP requests and handles some specified requests internally.
|
|
|
|
* Provides a backend that can handle requests for certain data items.
|
|
|
|
*/
|
2021-05-10 20:56:20 +02:00
|
|
|
@Injectable()
|
|
|
|
export class MockBackendInterceptor implements HttpInterceptor {
|
2021-05-11 13:34:23 +02:00
|
|
|
/**
|
|
|
|
* Intercepts HTTP requests.
|
|
|
|
*
|
|
|
|
* @param request - An outgoing HTTP request with an optional typed body.
|
|
|
|
* @param next - The next HTTP handler or the outgoing request dispatcher.
|
|
|
|
* @returns The response from the resolved request.
|
|
|
|
*/
|
2021-05-10 20:56:20 +02:00
|
|
|
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
|
|
|
|
const { url, method, headers, body } = request;
|
|
|
|
|
|
|
|
// wrap in delayed observable to simulate server api call\
|
|
|
|
// call materialize and dematerialize to ensure delay even is thrown
|
|
|
|
return of(null)
|
|
|
|
.pipe(mergeMap(handleRoute))
|
|
|
|
.pipe(materialize())
|
|
|
|
.pipe(delay(500))
|
|
|
|
.pipe(dematerialize());
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
/** Forward requests from select routes to their internal handlers. */
|
2021-05-10 20:56:20 +02:00
|
|
|
function handleRoute(): Observable<any> {
|
|
|
|
switch (true) {
|
2021-05-11 13:34:23 +02:00
|
|
|
case url.endsWith('/accounttypes') && method === 'GET':
|
|
|
|
return getAccountTypes();
|
2021-05-10 20:56:20 +02:00
|
|
|
case url.endsWith('/actions') && method === 'GET':
|
|
|
|
return getActions();
|
|
|
|
case url.match(/\/actions\/\d+$/) && method === 'GET':
|
|
|
|
return getActionById();
|
|
|
|
case url.match(/\/actions\/\d+$/) && method === 'POST':
|
|
|
|
return approveAction();
|
|
|
|
case url.endsWith('/areanames') && method === 'GET':
|
|
|
|
return getAreaNames();
|
|
|
|
case url.match(/\/areanames\/\w+$/) && method === 'GET':
|
|
|
|
return getAreaNameByLocation();
|
|
|
|
case url.endsWith('/areatypes') && method === 'GET':
|
|
|
|
return getAreaTypes();
|
|
|
|
case url.match(/\/areatypes\/\w+$/) && method === 'GET':
|
|
|
|
return getAreaTypeByArea();
|
2021-05-11 13:34:23 +02:00
|
|
|
case url.endsWith('/categories') && method === 'GET':
|
|
|
|
return getCategories();
|
|
|
|
case url.match(/\/categories\/\w+$/) && method === 'GET':
|
|
|
|
return getCategoryByProduct();
|
2021-05-10 20:56:20 +02:00
|
|
|
case url.endsWith('/genders') && method === 'GET':
|
|
|
|
return getGenders();
|
2021-05-11 13:34:23 +02:00
|
|
|
case url.endsWith('/tokens') && method === 'GET':
|
|
|
|
return getTokens();
|
|
|
|
case url.match(/\/tokens\/\w+$/) && method === 'GET':
|
|
|
|
return getTokenBySymbol();
|
|
|
|
case url.endsWith('/transactiontypes') && method === 'GET':
|
|
|
|
return getTransactionTypes();
|
2021-05-10 20:56:20 +02:00
|
|
|
default:
|
|
|
|
// pass through any requests not handled above
|
|
|
|
return next.handle(request);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// route functions
|
|
|
|
|
|
|
|
function approveAction(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const queriedAction: Action = actions.find((action) => action.id === idFromUrl());
|
2021-05-10 20:56:20 +02:00
|
|
|
queriedAction.approval = body.approval;
|
|
|
|
const message: string = `Action approval status set to ${body.approval} successfully!`;
|
|
|
|
return ok(message);
|
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getAccountTypes(): Observable<HttpResponse<any>> {
|
|
|
|
return ok(accountTypes);
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getActions(): Observable<HttpResponse<any>> {
|
|
|
|
return ok(actions);
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getActionById(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const queriedAction: Action = actions.find((action) => action.id === idFromUrl());
|
2021-05-11 13:34:23 +02:00
|
|
|
return ok(queriedAction);
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getAreaNames(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const areaNameList: Array<string> = areaNames.map((areaName) => areaName.name);
|
2021-05-10 20:56:20 +02:00
|
|
|
return ok(areaNameList);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAreaNameByLocation(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const queriedAreaName: AreaName = areaNames.find((areaName) =>
|
|
|
|
areaName.locations.includes(stringFromUrl())
|
|
|
|
);
|
2021-06-14 13:28:53 +02:00
|
|
|
return ok(queriedAreaName.name || 'other');
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getAreaTypes(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const areaTypeList: Array<string> = areaTypes.map((areaType) => areaType.name);
|
2021-05-10 20:56:20 +02:00
|
|
|
return ok(areaTypeList);
|
|
|
|
}
|
|
|
|
|
|
|
|
function getAreaTypeByArea(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const queriedAreaType: AreaType = areaTypes.find((areaType) =>
|
|
|
|
areaType.area.includes(stringFromUrl())
|
|
|
|
);
|
2021-06-14 13:28:53 +02:00
|
|
|
return ok(queriedAreaType.name || 'other');
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getCategories(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const categoryList: Array<string> = categories.map((category) => category.name);
|
2021-05-11 13:34:23 +02:00
|
|
|
return ok(categoryList);
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getCategoryByProduct(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const queriedCategory: Category = categories.find((category) =>
|
|
|
|
category.products.includes(stringFromUrl())
|
|
|
|
);
|
2021-06-14 13:28:53 +02:00
|
|
|
return ok(queriedCategory.name || 'other');
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
function getGenders(): Observable<HttpResponse<any>> {
|
|
|
|
return ok(genders);
|
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getTokens(): Observable<HttpResponse<any>> {
|
|
|
|
return ok(tokens);
|
|
|
|
}
|
2021-05-10 20:56:20 +02:00
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getTokenBySymbol(): Observable<HttpResponse<any>> {
|
2021-05-11 19:51:48 +02:00
|
|
|
const queriedToken: Token = tokens.find((token) => token.symbol === stringFromUrl());
|
2021-05-11 13:34:23 +02:00
|
|
|
return ok(queriedToken);
|
2021-05-10 20:56:20 +02:00
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function getTransactionTypes(): Observable<HttpResponse<any>> {
|
|
|
|
return ok(transactionTypes);
|
|
|
|
}
|
|
|
|
|
|
|
|
// helper functions
|
|
|
|
|
2021-05-10 20:56:20 +02:00
|
|
|
function error(message): Observable<any> {
|
|
|
|
return throwError({ status: 400, error: { message } });
|
|
|
|
}
|
|
|
|
|
|
|
|
function idFromUrl(): number {
|
|
|
|
const urlParts: Array<string> = url.split('/');
|
|
|
|
return parseInt(urlParts[urlParts.length - 1], 10);
|
|
|
|
}
|
|
|
|
|
2021-05-11 13:34:23 +02:00
|
|
|
function ok(responseBody: any): Observable<HttpResponse<any>> {
|
|
|
|
return of(new HttpResponse({ status: 200, body: responseBody }));
|
|
|
|
}
|
|
|
|
|
2021-05-10 20:56:20 +02:00
|
|
|
function stringFromUrl(): string {
|
|
|
|
const urlParts: Array<string> = url.split('/');
|
|
|
|
return urlParts[urlParts.length - 1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-05-11 19:51:48 +02:00
|
|
|
/** Exports the MockBackendInterceptor as an Angular provider. */
|
2021-05-10 20:56:20 +02:00
|
|
|
export const MockBackendProvider = {
|
|
|
|
provide: HTTP_INTERCEPTORS,
|
|
|
|
useClass: MockBackendInterceptor,
|
2021-05-11 19:51:48 +02:00
|
|
|
multi: true,
|
2021-05-10 20:56:20 +02:00
|
|
|
};
|
|
|
|
</code></pre>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
</div><div class="search-results">
|
|
|
|
<div class="has-results">
|
|
|
|
<h1 class="search-results-title"><span class='search-results-count'></span> result-matching "<span class='search-query'></span>"</h1>
|
|
|
|
<ul class="search-results-list"></ul>
|
|
|
|
</div>
|
|
|
|
<div class="no-results">
|
|
|
|
<h1 class="search-results-title">No results matching "<span class='search-query'></span>"</h1>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<!-- END CONTENT -->
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
|
|
var COMPODOC_CURRENT_PAGE_DEPTH = 1;
|
|
|
|
var COMPODOC_CURRENT_PAGE_CONTEXT = 'interceptor';
|
|
|
|
var COMPODOC_CURRENT_PAGE_URL = 'MockBackendInterceptor.html';
|
|
|
|
var MAX_SEARCH_RESULTS = 15;
|
|
|
|
</script>
|
|
|
|
|
|
|
|
<script src="../js/libs/custom-elements.min.js"></script>
|
|
|
|
<script src="../js/libs/lit-html.js"></script>
|
|
|
|
<!-- Required to polyfill modern browsers as code is ES5 for IE... -->
|
|
|
|
<script src="../js/libs/custom-elements-es5-adapter.js" charset="utf-8" defer></script>
|
|
|
|
<script src="../js/menu-wc.js" defer></script>
|
|
|
|
|
|
|
|
<script src="../js/libs/bootstrap-native.js"></script>
|
|
|
|
|
|
|
|
<script src="../js/libs/es6-shim.min.js"></script>
|
|
|
|
<script src="../js/libs/EventDispatcher.js"></script>
|
|
|
|
<script src="../js/libs/promise.min.js"></script>
|
|
|
|
<script src="../js/libs/zepto.min.js"></script>
|
|
|
|
|
|
|
|
<script src="../js/compodoc.js"></script>
|
|
|
|
|
|
|
|
<script src="../js/tabs.js"></script>
|
|
|
|
<script src="../js/menu.js"></script>
|
|
|
|
<script src="../js/libs/clipboard.min.js"></script>
|
|
|
|
<script src="../js/libs/prism.js"></script>
|
|
|
|
<script src="../js/sourceCode.js"></script>
|
|
|
|
<script src="../js/search/search.js"></script>
|
|
|
|
<script src="../js/search/lunr.min.js"></script>
|
|
|
|
<script src="../js/search/search-lunr.js"></script>
|
|
|
|
<script src="../js/search/search_index.js"></script>
|
|
|
|
<script src="../js/lazy-load-graphs.js"></script>
|
|
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
</html>
|