Skip to content

Commit 505f8a6

Browse files
authored
Merge pull request #524 from ever-co/develop
New features: - Track merchants (warehouses) on the map (with filtering) - Payment Gateways config on the Merchant Wizard Note: DB structure changes, you may need to regenerate DB or migrate your schema/data manually
2 parents 5e62fd9 + 737930f commit 505f8a6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1786
-29
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import { Injectable } from '@angular/core';
2+
import { Apollo } from 'apollo-angular';
3+
import { Observable } from 'rxjs';
4+
import Currency from '@modules/server.common/entities/Currency';
5+
import gql from 'graphql-tag';
6+
import { map, share } from 'rxjs/operators';
7+
8+
export interface CurrencyMutationRespone {
9+
success: boolean;
10+
message?: string;
11+
data?: Currency;
12+
}
13+
14+
@Injectable()
15+
export class CurrenciesService {
16+
constructor(private readonly apollo: Apollo) {}
17+
18+
private currencies$: Observable<Currency[]> = this.apollo
19+
.watchQuery<{ currencies: Currency[] }>({
20+
query: gql`
21+
query allCurrencies {
22+
currencies {
23+
currencyCode
24+
}
25+
}
26+
`,
27+
pollInterval: 2000
28+
})
29+
.valueChanges.pipe(
30+
map((result) => result.data.currencies),
31+
share()
32+
);
33+
34+
getCurrencies(): Observable<Currency[]> {
35+
return this.currencies$;
36+
}
37+
38+
create(createInput: {
39+
currencyCode: string;
40+
}): Observable<CurrencyMutationRespone> {
41+
return this.apollo
42+
.mutate<{ createCurrency: CurrencyMutationRespone }>({
43+
mutation: gql`
44+
mutation CreateCurrency(
45+
$createInput: CurrencyCreateInput!
46+
) {
47+
createCurrency(createInput: $createInput) {
48+
success
49+
message
50+
data {
51+
currencyCode
52+
}
53+
}
54+
}
55+
`,
56+
variables: {
57+
createInput
58+
}
59+
})
60+
.pipe(
61+
map((result) => result.data.createCurrency),
62+
share()
63+
);
64+
}
65+
}

admin/website-angular/src/app/@core/data/warehouses.service.ts

+30
Original file line numberDiff line numberDiff line change
@@ -77,13 +77,43 @@ export class WarehousesService {
7777
getAllStores {
7878
id
7979
_createdAt
80+
geoLocation {
81+
loc {
82+
coordinates
83+
}
84+
}
8085
}
8186
}
8287
`
8388
})
8489
.pipe(map((res) => res.data.getAllStores));
8590
}
8691

92+
getStoreLivePosition() {
93+
return this._apollo
94+
.watchQuery<{ getAllStores: Warehouse[] }>({
95+
query: gql`
96+
query GetAllStores {
97+
getAllStores {
98+
id
99+
_createdAt
100+
name
101+
logo
102+
geoLocation {
103+
loc {
104+
coordinates
105+
}
106+
city
107+
countryId
108+
}
109+
}
110+
}
111+
`,
112+
pollInterval: 5000
113+
})
114+
.valueChanges.pipe(map((res) => res.data.getAllStores));
115+
}
116+
87117
getStores(pagingOptions?: IPagingOptions): Observable<Warehouse[]> {
88118
return this._apollo
89119
.watchQuery<{ warehouses: IWarehouse[] }>({

admin/website-angular/src/app/@shared/file-uploader/file-uploader.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,14 @@
1010
/>
1111

1212
<input
13+
#shownInput="ngModel"
1314
type="text"
1415
class="form-control col-10"
1516
[ngClass]="customClass"
1617
placeholder="{{ placeholder }}"
1718
(change)="imageUrlChanged()"
1819
[(ngModel)]="fileUrl"
1920
/>
20-
2121
<button
2222
(click)="fileInput.click()"
2323
class="btn btn-primary btn-rectangle col-2"

admin/website-angular/src/app/@shared/file-uploader/file-uploader.component.ts

+11-1
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,25 @@
1-
import { Component, Input, Output, EventEmitter } from '@angular/core';
1+
import {
2+
Component,
3+
Input,
4+
Output,
5+
EventEmitter,
6+
ViewChild
7+
} from '@angular/core';
28
import { FileUploader, FileUploaderOptions } from 'ng2-file-upload';
39
import { environment } from 'environment';
410
import { ProductLocalesService } from '@modules/client.common.angular2/locale/product-locales.service';
511
import { IProductImage } from '@modules/server.common/interfaces/IProduct';
12+
import { NgModel } from '@angular/forms';
613

714
@Component({
815
selector: 'e-cu-file-uploader',
916
templateUrl: './file-uploader.component.html',
1017
styleUrls: ['./file-uploader.component.scss']
1118
})
1219
export class FileUploaderComponent {
20+
@ViewChild('shownInput')
21+
shownInput: NgModel;
22+
1323
@Input()
1424
placeholder: string;
1525
@Input()

admin/website-angular/src/app/@shared/warehouse/forms/contact-info/contact-info-form.component.html

+10-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,12 @@
6868
<nb-checkbox
6969
[value]="forwardingEmail"
7070
(change)="forwardingEmailChange()"
71-
>Order Forwarding Email</nb-checkbox
7271
>
72+
{{
73+
'WAREHOUSE_VIEW.MUTATION.CONTACT_INFO_TAB.ORDER_FORWARDING_EMAIL'
74+
| translate
75+
}}
76+
</nb-checkbox>
7377
<input
7478
*ngIf="forwardingEmail"
7579
type="email"
@@ -106,8 +110,12 @@
106110
<nb-checkbox
107111
[value]="forwardingPhone"
108112
(change)="forwardingPhoneChange()"
109-
>Order Forwarding Phone</nb-checkbox
110113
>
114+
{{
115+
'WAREHOUSE_VIEW.MUTATION.CONTACT_INFO_TAB.ORDER_FORWARDING_PHONE'
116+
| translate
117+
}}
118+
</nb-checkbox>
111119
<input
112120
*ngIf="forwardingPhone"
113121
type="text"

admin/website-angular/src/app/@theme/styles/styles.scss

+21
Original file line numberDiff line numberDiff line change
@@ -206,3 +206,24 @@ nb-card.no-box-shadow {
206206
box-shadow: none;
207207
margin-bottom: 0;
208208
}
209+
210+
.preview-img-container {
211+
.preview-img {
212+
padding-right: 16px;
213+
}
214+
215+
.img-rounded {
216+
margin-top: 3px;
217+
max-height: 70px !important;
218+
}
219+
220+
.remove-icon {
221+
cursor: pointer;
222+
223+
span {
224+
padding-right: 7px;
225+
position: absolute;
226+
font-size: 1.1em;
227+
}
228+
}
229+
}

admin/website-angular/src/app/pages/+carriers/track/carrier-tracking/carrier-tracking.component.html

+24-6
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,24 @@ <h5>
112112
</h5>
113113
<ul>
114114
<li>
115-
Phone:
115+
{{
116+
'CARRIERS_VIEW.TRACK_PAGE.PHONE'
117+
| translate
118+
}}:
116119
{{ selectedStore.contactPhone }}
117120
</li>
118121
<li>
119-
Email:
122+
{{
123+
'CARRIERS_VIEW.TRACK_PAGE.EMAIL'
124+
| translate
125+
}}:
120126
{{ selectedStore.contactEmail }}
121127
</li>
122128
<li>
123-
Address:
129+
{{
130+
'CARRIERS_VIEW.TRACK_PAGE.ADDRESS'
131+
| translate
132+
}}:
124133
{{
125134
selectedStore.geoLocation
126135
.streetAddress
@@ -134,16 +143,25 @@ <h5>
134143
</h5>
135144
<ul>
136145
<li>
137-
Delivery Count:
146+
{{
147+
'CARRIERS_VIEW.TRACK_PAGE.DELIVERY_COUNT'
148+
| translate
149+
}}:
138150
{{
139151
selectedCarrier.numberOfDeliveries
140152
}}
141153
</li>
142154
<li>
143-
Phone: {{ selectedCarrier.phone }}
155+
{{
156+
'CARRIERS_VIEW.TRACK_PAGE.PHONE'
157+
| translate
158+
}}: {{ selectedCarrier.phone }}
144159
</li>
145160
<li>
146-
Address:
161+
{{
162+
'CARRIERS_VIEW.TRACK_PAGE.ADDRESS'
163+
| translate
164+
}}:
147165
{{
148166
selectedCarrier.geoLocation
149167
.streetAddress

admin/website-angular/src/app/pages/+fakeData/fakeData.component.ts

+25-1
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ import { InvitesRequestsService } from 'app/@core/data/invites-requests.service'
4343
import { UsersService } from 'app/@core/data/users.service';
4444
import { environment } from 'environments/environment';
4545
import * as _ from 'lodash';
46+
import { CurrenciesService } from 'app/@core/data/currencies.service';
4647

4748
const NEED_DEFAULT_SETTINGS_MESSAGE =
4849
"Can't generate fake data without DEFAULT_LONGITUDE and DEFAULT_LATITUDE";
@@ -102,7 +103,8 @@ export class FakeDataComponent implements OnInit, OnDestroy {
102103
private readonly _invitesService: InvitesService,
103104
private readonly _inviteRequestsService: InvitesRequestsService,
104105
private readonly _notifyService: NotifyService,
105-
private readonly _usersService: UsersService
106+
private readonly _usersService: UsersService,
107+
private readonly _currenciesService: CurrenciesService
106108
) {
107109
this._setupButtonStatuses();
108110
this._setupButtonLoading();
@@ -162,6 +164,10 @@ export class FakeDataComponent implements OnInit, OnDestroy {
162164
this.isBtnDisabled.all = true;
163165
this.loading.all = true;
164166

167+
if (!this.includeHardcodedData) {
168+
await this._generateCurrencies();
169+
}
170+
165171
await this.createInvite1();
166172
await this.createInvite2();
167173
await this.createInvite3();
@@ -212,6 +218,8 @@ export class FakeDataComponent implements OnInit, OnDestroy {
212218
this.loading.hardcoded = true;
213219
this.isBtnDisabled.hardcoded = true;
214220

221+
await this._generateCurrencies();
222+
215223
await this._createHardcodedInvites();
216224
await this._createHardcodedWarehouses();
217225
await this._generateProducts();
@@ -1145,6 +1153,22 @@ export class FakeDataComponent implements OnInit, OnDestroy {
11451153
return warehouseProductCreateObjects;
11461154
}
11471155

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+
11481172
ngOnDestroy() {
11491173
this._ngDestroy$.next();
11501174
this._ngDestroy$.complete();

admin/website-angular/src/app/pages/+fakeData/fakeData.module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import { NotifyService } from 'app/@core/services/notify/notify.service';
2020
import { InvitesService } from 'app/@core/data/invites.service';
2121
import { InvitesRequestsService } from 'app/@core/data/invites-requests.service';
2222
import { UsersService } from 'app/@core/data/users.service';
23+
import { CurrenciesService } from 'app/@core/data/currencies.service';
2324

2425
export function HttpLoaderFactory(http: HttpClient) {
2526
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
@@ -52,7 +53,8 @@ export function HttpLoaderFactory(http: HttpClient) {
5253
InvitesService,
5354
InvitesRequestsService,
5455
UsersService,
55-
NotifyService
56+
NotifyService,
57+
CurrenciesService
5658
]
5759
})
5860
export class FakeDataModule {

admin/website-angular/src/app/pages/+setup/+merchants/components/basic-info/basic-info.component.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ export class SetupMerchantBasicInfoComponent implements OnInit, OnDestroy {
3636
uploaderPlaceholder: string = 'Photo (optional)';
3737
barcodetDataUrl: string;
3838
invalidUrl: boolean;
39-
private basicInfoModel = {
39+
basicInfoModel = {
4040
name: '',
4141
logo: '',
4242
barcodeData: ''

admin/website-angular/src/app/pages/+setup/+merchants/components/components.module.ts

-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import { MerchantsSetupInstructionsComponent } from './instructions/instructions
88
import { SetupMerchantAccountComponent } from './account/account.component';
99
import { SetupMerchantBasicInfoComponent } from './basic-info/basic-info.component';
1010
import { SetupMerchantContactInfoComponent } from './contact-info/contact-info.component';
11-
import { SetupMerchantPaymentsComponent } from './payments/payments.component';
1211
import { SetupMerchantManufacturingComponent } from './manufacturing/manufacturing.component';
1312
import { SetupMerchantOrdersSettingsComponent } from './settings/orders/orders.component';
1413
import { NbRadioModule } from '@nebular/theme';
@@ -22,7 +21,6 @@ const COMPONENTS = [
2221
SetupMerchantBasicInfoComponent,
2322
SetupMerchantContactInfoComponent,
2423
MerchantsSetupInstructionsComponent,
25-
SetupMerchantPaymentsComponent,
2624
SetupMerchantManufacturingComponent,
2725
SetupMerchantOrdersSettingsComponent,
2826
SetupMerchantProductCategoriesComponent

0 commit comments

Comments
 (0)