@@ -43,6 +43,7 @@ import { InvitesRequestsService } from 'app/@core/data/invites-requests.service'
43
43
import { UsersService } from 'app/@core/data/users.service' ;
44
44
import { environment } from 'environments/environment' ;
45
45
import * as _ from 'lodash' ;
46
+ import { CurrenciesService } from 'app/@core/data/currencies.service' ;
46
47
47
48
const NEED_DEFAULT_SETTINGS_MESSAGE =
48
49
"Can't generate fake data without DEFAULT_LONGITUDE and DEFAULT_LATITUDE" ;
@@ -102,7 +103,8 @@ export class FakeDataComponent implements OnInit, OnDestroy {
102
103
private readonly _invitesService : InvitesService ,
103
104
private readonly _inviteRequestsService : InvitesRequestsService ,
104
105
private readonly _notifyService : NotifyService ,
105
- private readonly _usersService : UsersService
106
+ private readonly _usersService : UsersService ,
107
+ private readonly _currenciesService : CurrenciesService
106
108
) {
107
109
this . _setupButtonStatuses ( ) ;
108
110
this . _setupButtonLoading ( ) ;
@@ -162,6 +164,10 @@ export class FakeDataComponent implements OnInit, OnDestroy {
162
164
this . isBtnDisabled . all = true ;
163
165
this . loading . all = true ;
164
166
167
+ if ( ! this . includeHardcodedData ) {
168
+ await this . _generateCurrencies ( ) ;
169
+ }
170
+
165
171
await this . createInvite1 ( ) ;
166
172
await this . createInvite2 ( ) ;
167
173
await this . createInvite3 ( ) ;
@@ -212,6 +218,8 @@ export class FakeDataComponent implements OnInit, OnDestroy {
212
218
this . loading . hardcoded = true ;
213
219
this . isBtnDisabled . hardcoded = true ;
214
220
221
+ await this . _generateCurrencies ( ) ;
222
+
215
223
await this . _createHardcodedInvites ( ) ;
216
224
await this . _createHardcodedWarehouses ( ) ;
217
225
await this . _generateProducts ( ) ;
@@ -1145,6 +1153,22 @@ export class FakeDataComponent implements OnInit, OnDestroy {
1145
1153
return warehouseProductCreateObjects ;
1146
1154
}
1147
1155
1156
+ private async _generateCurrencies ( ) {
1157
+ const currenciesCodes = [ 'USD' , 'ILS' , 'EUR' , 'BGN' , 'RUB' ] ;
1158
+
1159
+ for ( const currencyCode of currenciesCodes ) {
1160
+ const res = await this . _currenciesService
1161
+ . create ( { currencyCode } )
1162
+ . pipe ( first ( ) )
1163
+ . toPromise ( ) ;
1164
+
1165
+ this . toasterService . pop (
1166
+ res . success ? 'success' : 'warning' ,
1167
+ res . message
1168
+ ) ;
1169
+ }
1170
+ }
1171
+
1148
1172
ngOnDestroy ( ) {
1149
1173
this . _ngDestroy$ . next ( ) ;
1150
1174
this . _ngDestroy$ . complete ( ) ;
0 commit comments