mirror of
https://github.com/valitydev/koffing.git
synced 2024-11-06 09:15:20 +00:00
FE-702: fix doubled get shop request (#227)
This commit is contained in:
parent
c81a8da611
commit
05bf992d59
@ -5,8 +5,6 @@ import { Invoice } from 'koffing/backend/model/invoice';
|
||||
import { InvoiceService } from 'koffing/backend/invoice.service';
|
||||
import { CreateInvoiceService } from './create-invoice.service';
|
||||
import { InvoiceFormService } from 'koffing/invoices/invoice-form/invoice-form.service';
|
||||
import { ActivatedRoute } from '@angular/router';
|
||||
import { ShopService } from 'koffing/backend/shop.service';
|
||||
|
||||
@Component({
|
||||
selector: 'kof-create-invoice',
|
||||
@ -18,6 +16,9 @@ export class CreateInvoiceComponent implements OnInit {
|
||||
@Input()
|
||||
public shopID: string;
|
||||
|
||||
@Input()
|
||||
public shopCurrency: string;
|
||||
|
||||
@Output()
|
||||
public onCreate: EventEmitter<Invoice> = new EventEmitter();
|
||||
|
||||
@ -25,10 +26,8 @@ export class CreateInvoiceComponent implements OnInit {
|
||||
|
||||
constructor(
|
||||
private invoiceService: InvoiceService,
|
||||
private invoiceFormService: InvoiceFormService,
|
||||
private route: ActivatedRoute,
|
||||
private shopService: ShopService
|
||||
) { }
|
||||
private invoiceFormService: InvoiceFormService
|
||||
) {}
|
||||
|
||||
public ngOnInit() {
|
||||
this.invoiceForm = this.invoiceFormService.form;
|
||||
@ -44,10 +43,6 @@ export class CreateInvoiceComponent implements OnInit {
|
||||
}
|
||||
|
||||
public setDefaultFormValues() {
|
||||
this.route.parent.params.switchMap((params) =>
|
||||
this.shopService.getShopByID(params.shopID)).subscribe((shop) => {
|
||||
this.invoiceFormService.setDefaultValues({currency: shop.account.currency});
|
||||
});
|
||||
|
||||
this.invoiceFormService.setDefaultValues({currency: this.shopCurrency});
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,5 @@
|
||||
import { Component, OnInit, ElementRef, ViewChild, Input } from '@angular/core';
|
||||
import { FormGroup } from '@angular/forms';
|
||||
import { ActivatedRoute, Params } from '@angular/router';
|
||||
|
||||
import { PaymentMethod, InvoiceTemplateAndToken } from 'koffing/backend';
|
||||
import { InvoiceTemplateService } from 'koffing/backend/invoice-template.service';
|
||||
@ -9,7 +8,6 @@ import { CheckoutConfigFormService } from 'koffing/checkout/checkout-config-form
|
||||
import { InvoiceTemplateFormService } from '../invoice-template-form/invoice-template-form.service';
|
||||
import { InvoiceTemplatePaymentLinkService } from './invoice-template-payment-link.service';
|
||||
import { PAYMENT_LINK_CREATION_STEP } from './invoice-template-payment-link-step';
|
||||
import { ShopService } from 'koffing/backend/shop.service';
|
||||
import { AccountsService } from 'koffing/backend/accounts.service';
|
||||
|
||||
@Component({
|
||||
@ -22,6 +20,9 @@ export class InvoiceTemplatePaymentLinkComponent implements OnInit {
|
||||
@Input()
|
||||
public shopID: string;
|
||||
|
||||
@Input()
|
||||
public settlementID: number;
|
||||
|
||||
@ViewChild('paymentLinkInput')
|
||||
public paymentLinkInput: ElementRef;
|
||||
|
||||
@ -36,9 +37,7 @@ export class InvoiceTemplatePaymentLinkComponent implements OnInit {
|
||||
|
||||
private invoiceTemplateAndToken: InvoiceTemplateAndToken;
|
||||
|
||||
constructor(private route: ActivatedRoute,
|
||||
private shopService: ShopService,
|
||||
private accountsService: AccountsService,
|
||||
constructor(private accountsService: AccountsService,
|
||||
private invoiceTemplateService: InvoiceTemplateService,
|
||||
private invoiceTemplateFormService: InvoiceTemplateFormService,
|
||||
private checkoutConfigFormService: CheckoutConfigFormService,
|
||||
@ -46,14 +45,9 @@ export class InvoiceTemplatePaymentLinkComponent implements OnInit {
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.route.parent.params.subscribe((params: Params) => {
|
||||
const shopID = params['shopID'];
|
||||
this.shopService.getShopByID(shopID).subscribe((shop) => {
|
||||
this.accountsService.getAccountByID(shop.account.settlementID).subscribe((account) => {
|
||||
this.accountsService.getAccountByID(this.settlementID).subscribe((account) => {
|
||||
this.currency = account.currency;
|
||||
});
|
||||
});
|
||||
});
|
||||
this.invoiceTemplateForm = this.invoiceTemplateFormService.form;
|
||||
this.checkoutConfigForm = this.checkoutConfigFormService.form;
|
||||
this.checkoutConfigForm.valueChanges.subscribe(() => {
|
||||
|
@ -4,11 +4,13 @@
|
||||
.x_title
|
||||
h5 Действия
|
||||
.x_content
|
||||
.row
|
||||
.row(*ngIf="shop")
|
||||
.col-xs-12.col-sm-6.col-md-3
|
||||
kof-create-invoice([shopID]="shopID", (onCreate)="onCreate($event)")
|
||||
kof-create-invoice([shopID]="shop.id", [shopCurrency]="shop.account.currency", (onCreate)="onCreate($event)")
|
||||
.col-xs-12.col-sm-6.col-md-3
|
||||
kof-invoice-template-payment-link([shopID]="shopID")
|
||||
kof-invoice-template-payment-link([shopID]="shop.id", [settlementID]="shop.account.settlementID")
|
||||
.row(*ngIf="!shop")
|
||||
.col-xs-12 Загрузка...
|
||||
.x_panel
|
||||
.x_title
|
||||
h5 Поиск инвойсов
|
||||
|
@ -9,6 +9,8 @@ import { InvoiceFormService } from 'koffing/invoices/invoice-form/invoice-form.s
|
||||
import { InvoiceTemplateFormService } from 'koffing/invoices/invoice-template-form/invoice-template-form.service';
|
||||
import { InvoicesService } from 'koffing/invoices/invoices.service';
|
||||
import { SearchFormService } from 'koffing/invoices/search-form/search-form.service';
|
||||
import { Shop } from 'koffing/backend';
|
||||
import { ShopService } from 'koffing/backend/shop.service';
|
||||
|
||||
@Component({
|
||||
templateUrl: 'invoices.component.pug',
|
||||
@ -24,7 +26,7 @@ import { SearchFormService } from 'koffing/invoices/search-form/search-form.serv
|
||||
export class InvoicesComponent implements OnInit {
|
||||
|
||||
public invoices: Subject<Invoice[]> = new Subject();
|
||||
public shopID: string;
|
||||
public shop: Shop;
|
||||
public page: number = 0;
|
||||
public limit: number = 20;
|
||||
private continuationTokens: string[] = [];
|
||||
@ -34,13 +36,16 @@ export class InvoicesComponent implements OnInit {
|
||||
private router: Router,
|
||||
private searchService: SearchService,
|
||||
private invoicesService: InvoicesService,
|
||||
private searchFormService: SearchFormService) {
|
||||
private searchFormService: SearchFormService,
|
||||
private shopService: ShopService) {
|
||||
}
|
||||
|
||||
public ngOnInit() {
|
||||
this.searchForm = this.searchFormService.searchForm;
|
||||
this.route.parent.params.subscribe((params) => {
|
||||
this.shopID = params['shopID'];
|
||||
this.route.parent.params
|
||||
.switchMap((params) => this.shopService.getShopByID(params['shopID']))
|
||||
.subscribe((shop) => {
|
||||
this.shop = shop;
|
||||
this.search();
|
||||
});
|
||||
}
|
||||
@ -64,14 +69,14 @@ export class InvoicesComponent implements OnInit {
|
||||
}
|
||||
|
||||
public onCreate(invoice: Invoice) {
|
||||
this.router.navigate(['shop', this.shopID, 'invoice', invoice.id]);
|
||||
this.router.navigate(['shop', this.shop.id, 'invoice', invoice.id]);
|
||||
}
|
||||
|
||||
private search(num: number = 0) {
|
||||
this.page += num;
|
||||
const continuationToken = this.continuationTokens[this.page];
|
||||
const request = this.invoicesService.toSearchParams(this.limit, continuationToken, this.searchForm.value);
|
||||
this.searchService.searchInvoices(this.shopID, request).subscribe((response) => {
|
||||
this.searchService.searchInvoices(this.shop.id, request).subscribe((response) => {
|
||||
this.continuationTokens[this.page + 1] = response.continuationToken;
|
||||
this.invoices.next(response.result);
|
||||
});
|
||||
|
@ -26,7 +26,7 @@ export class ContractBindingDetailsComponent implements OnChanges {
|
||||
private payoutToolService: PayoutToolService,
|
||||
private shopService: ShopService,
|
||||
private claimDetailsService: ClaimDetailsService
|
||||
) { }
|
||||
) {}
|
||||
|
||||
public ngOnChanges() {
|
||||
const bindings = this.claimDetailsService.toContractBinding(this.partyModifications);
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Component, Input, OnChanges } from '@angular/core';
|
||||
import { last } from 'lodash';
|
||||
|
||||
import { Contractor, PartyModification, PayoutTool, Shop} from 'koffing/backend';
|
||||
import { Contractor, PartyModification, PayoutTool, Shop } from 'koffing/backend';
|
||||
import { ShopService } from 'koffing/backend/shop.service';
|
||||
import { ClaimDetailsService } from '../claim-details.service';
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user