Skip to content

Commit

Permalink
Merge pull request #524 from ever-co/develop
Browse files Browse the repository at this point in the history
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
  • Loading branch information
evereq authored May 28, 2019
2 parents 5e62fd9 + 737930f commit 505f8a6
Show file tree
Hide file tree
Showing 48 changed files with 1,786 additions and 29 deletions.
65 changes: 65 additions & 0 deletions admin/website-angular/src/app/@core/data/currencies.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { Injectable } from '@angular/core';
import { Apollo } from 'apollo-angular';
import { Observable } from 'rxjs';
import Currency from '@modules/server.common/entities/Currency';
import gql from 'graphql-tag';
import { map, share } from 'rxjs/operators';

export interface CurrencyMutationRespone {
success: boolean;
message?: string;
data?: Currency;
}

@Injectable()
export class CurrenciesService {
constructor(private readonly apollo: Apollo) {}

private currencies$: Observable<Currency[]> = this.apollo
.watchQuery<{ currencies: Currency[] }>({
query: gql`
query allCurrencies {
currencies {
currencyCode
}
}
`,
pollInterval: 2000
})
.valueChanges.pipe(
map((result) => result.data.currencies),
share()
);

getCurrencies(): Observable<Currency[]> {
return this.currencies$;
}

create(createInput: {
currencyCode: string;
}): Observable<CurrencyMutationRespone> {
return this.apollo
.mutate<{ createCurrency: CurrencyMutationRespone }>({
mutation: gql`
mutation CreateCurrency(
$createInput: CurrencyCreateInput!
) {
createCurrency(createInput: $createInput) {
success
message
data {
currencyCode
}
}
}
`,
variables: {
createInput
}
})
.pipe(
map((result) => result.data.createCurrency),
share()
);
}
}
30 changes: 30 additions & 0 deletions admin/website-angular/src/app/@core/data/warehouses.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,13 +77,43 @@ export class WarehousesService {
getAllStores {
id
_createdAt
geoLocation {
loc {
coordinates
}
}
}
}
`
})
.pipe(map((res) => res.data.getAllStores));
}

getStoreLivePosition() {
return this._apollo
.watchQuery<{ getAllStores: Warehouse[] }>({
query: gql`
query GetAllStores {
getAllStores {
id
_createdAt
name
logo
geoLocation {
loc {
coordinates
}
city
countryId
}
}
}
`,
pollInterval: 5000
})
.valueChanges.pipe(map((res) => res.data.getAllStores));
}

getStores(pagingOptions?: IPagingOptions): Observable<Warehouse[]> {
return this._apollo
.watchQuery<{ warehouses: IWarehouse[] }>({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@
/>

<input
#shownInput="ngModel"
type="text"
class="form-control col-10"
[ngClass]="customClass"
placeholder="{{ placeholder }}"
(change)="imageUrlChanged()"
[(ngModel)]="fileUrl"
/>

<button
(click)="fileInput.click()"
class="btn btn-primary btn-rectangle col-2"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,25 @@
import { Component, Input, Output, EventEmitter } from '@angular/core';
import {
Component,
Input,
Output,
EventEmitter,
ViewChild
} from '@angular/core';
import { FileUploader, FileUploaderOptions } from 'ng2-file-upload';
import { environment } from 'environment';
import { ProductLocalesService } from '@modules/client.common.angular2/locale/product-locales.service';
import { IProductImage } from '@modules/server.common/interfaces/IProduct';
import { NgModel } from '@angular/forms';

@Component({
selector: 'e-cu-file-uploader',
templateUrl: './file-uploader.component.html',
styleUrls: ['./file-uploader.component.scss']
})
export class FileUploaderComponent {
@ViewChild('shownInput')
shownInput: NgModel;

@Input()
placeholder: string;
@Input()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,12 @@
<nb-checkbox
[value]="forwardingEmail"
(change)="forwardingEmailChange()"
>Order Forwarding Email</nb-checkbox
>
{{
'WAREHOUSE_VIEW.MUTATION.CONTACT_INFO_TAB.ORDER_FORWARDING_EMAIL'
| translate
}}
</nb-checkbox>
<input
*ngIf="forwardingEmail"
type="email"
Expand Down Expand Up @@ -106,8 +110,12 @@
<nb-checkbox
[value]="forwardingPhone"
(change)="forwardingPhoneChange()"
>Order Forwarding Phone</nb-checkbox
>
{{
'WAREHOUSE_VIEW.MUTATION.CONTACT_INFO_TAB.ORDER_FORWARDING_PHONE'
| translate
}}
</nb-checkbox>
<input
*ngIf="forwardingPhone"
type="text"
Expand Down
21 changes: 21 additions & 0 deletions admin/website-angular/src/app/@theme/styles/styles.scss
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,24 @@ nb-card.no-box-shadow {
box-shadow: none;
margin-bottom: 0;
}

.preview-img-container {
.preview-img {
padding-right: 16px;
}

.img-rounded {
margin-top: 3px;
max-height: 70px !important;
}

.remove-icon {
cursor: pointer;

span {
padding-right: 7px;
position: absolute;
font-size: 1.1em;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -112,15 +112,24 @@ <h5>
</h5>
<ul>
<li>
Phone:
{{
'CARRIERS_VIEW.TRACK_PAGE.PHONE'
| translate
}}:
{{ selectedStore.contactPhone }}
</li>
<li>
Email:
{{
'CARRIERS_VIEW.TRACK_PAGE.EMAIL'
| translate
}}:
{{ selectedStore.contactEmail }}
</li>
<li>
Address:
{{
'CARRIERS_VIEW.TRACK_PAGE.ADDRESS'
| translate
}}:
{{
selectedStore.geoLocation
.streetAddress
Expand All @@ -134,16 +143,25 @@ <h5>
</h5>
<ul>
<li>
Delivery Count:
{{
'CARRIERS_VIEW.TRACK_PAGE.DELIVERY_COUNT'
| translate
}}:
{{
selectedCarrier.numberOfDeliveries
}}
</li>
<li>
Phone: {{ selectedCarrier.phone }}
{{
'CARRIERS_VIEW.TRACK_PAGE.PHONE'
| translate
}}: {{ selectedCarrier.phone }}
</li>
<li>
Address:
{{
'CARRIERS_VIEW.TRACK_PAGE.ADDRESS'
| translate
}}:
{{
selectedCarrier.geoLocation
.streetAddress
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import { InvitesRequestsService } from 'app/@core/data/invites-requests.service'
import { UsersService } from 'app/@core/data/users.service';
import { environment } from 'environments/environment';
import * as _ from 'lodash';
import { CurrenciesService } from 'app/@core/data/currencies.service';

const NEED_DEFAULT_SETTINGS_MESSAGE =
"Can't generate fake data without DEFAULT_LONGITUDE and DEFAULT_LATITUDE";
Expand Down Expand Up @@ -102,7 +103,8 @@ export class FakeDataComponent implements OnInit, OnDestroy {
private readonly _invitesService: InvitesService,
private readonly _inviteRequestsService: InvitesRequestsService,
private readonly _notifyService: NotifyService,
private readonly _usersService: UsersService
private readonly _usersService: UsersService,
private readonly _currenciesService: CurrenciesService
) {
this._setupButtonStatuses();
this._setupButtonLoading();
Expand Down Expand Up @@ -162,6 +164,10 @@ export class FakeDataComponent implements OnInit, OnDestroy {
this.isBtnDisabled.all = true;
this.loading.all = true;

if (!this.includeHardcodedData) {
await this._generateCurrencies();
}

await this.createInvite1();
await this.createInvite2();
await this.createInvite3();
Expand Down Expand Up @@ -212,6 +218,8 @@ export class FakeDataComponent implements OnInit, OnDestroy {
this.loading.hardcoded = true;
this.isBtnDisabled.hardcoded = true;

await this._generateCurrencies();

await this._createHardcodedInvites();
await this._createHardcodedWarehouses();
await this._generateProducts();
Expand Down Expand Up @@ -1145,6 +1153,22 @@ export class FakeDataComponent implements OnInit, OnDestroy {
return warehouseProductCreateObjects;
}

private async _generateCurrencies() {
const currenciesCodes = ['USD', 'ILS', 'EUR', 'BGN', 'RUB'];

for (const currencyCode of currenciesCodes) {
const res = await this._currenciesService
.create({ currencyCode })
.pipe(first())
.toPromise();

this.toasterService.pop(
res.success ? 'success' : 'warning',
res.message
);
}
}

ngOnDestroy() {
this._ngDestroy$.next();
this._ngDestroy$.complete();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import { NotifyService } from 'app/@core/services/notify/notify.service';
import { InvitesService } from 'app/@core/data/invites.service';
import { InvitesRequestsService } from 'app/@core/data/invites-requests.service';
import { UsersService } from 'app/@core/data/users.service';
import { CurrenciesService } from 'app/@core/data/currencies.service';

export function HttpLoaderFactory(http: HttpClient) {
return new TranslateHttpLoader(http, './assets/i18n/', '.json');
Expand Down Expand Up @@ -52,7 +53,8 @@ export function HttpLoaderFactory(http: HttpClient) {
InvitesService,
InvitesRequestsService,
UsersService,
NotifyService
NotifyService,
CurrenciesService
]
})
export class FakeDataModule {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export class SetupMerchantBasicInfoComponent implements OnInit, OnDestroy {
uploaderPlaceholder: string = 'Photo (optional)';
barcodetDataUrl: string;
invalidUrl: boolean;
private basicInfoModel = {
basicInfoModel = {
name: '',
logo: '',
barcodeData: ''
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { MerchantsSetupInstructionsComponent } from './instructions/instructions
import { SetupMerchantAccountComponent } from './account/account.component';
import { SetupMerchantBasicInfoComponent } from './basic-info/basic-info.component';
import { SetupMerchantContactInfoComponent } from './contact-info/contact-info.component';
import { SetupMerchantPaymentsComponent } from './payments/payments.component';
import { SetupMerchantManufacturingComponent } from './manufacturing/manufacturing.component';
import { SetupMerchantOrdersSettingsComponent } from './settings/orders/orders.component';
import { NbRadioModule } from '@nebular/theme';
Expand All @@ -22,7 +21,6 @@ const COMPONENTS = [
SetupMerchantBasicInfoComponent,
SetupMerchantContactInfoComponent,
MerchantsSetupInstructionsComponent,
SetupMerchantPaymentsComponent,
SetupMerchantManufacturingComponent,
SetupMerchantOrdersSettingsComponent,
SetupMerchantProductCategoriesComponent
Expand Down
Loading

0 comments on commit 505f8a6

Please sign in to comment.