feat: implement shopping cart module with order management and discount components
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 6m18s
All checks were successful
Build (develop) / Promote (main) / build-and-push-deploy (push) Successful in 6m18s
This commit is contained in:
@@ -1,5 +1,11 @@
|
|||||||
<app-header-admin></app-header-admin>
|
<app-header-admin></app-header-admin>
|
||||||
<div class="d-flex flex-column wrapper">
|
<div class="d-flex flex-column wrapper">
|
||||||
|
<div class="loading-overlay" *ngIf="(loading$ | async) || (updating$ | async)">
|
||||||
|
<div class="loading-content">
|
||||||
|
<kendo-loader type="converging-spinner" themeColor="primary" size="large"></kendo-loader>
|
||||||
|
<div class="mt-2">Carregando dados do pedido...</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
<div class="container cart-container my-4">
|
<div class="container cart-container my-4">
|
||||||
<!-- Primeira Linha -->
|
<!-- Primeira Linha -->
|
||||||
<!-- <div class="row mb-3">
|
<!-- <div class="row mb-3">
|
||||||
@@ -854,7 +860,7 @@
|
|||||||
<span *ngIf="!isLoadingPreOrder" class="text-btn-order">Fechar orçamento</span>
|
<span *ngIf="!isLoadingPreOrder" class="text-btn-order">Fechar orçamento</span>
|
||||||
</button> -->
|
</button> -->
|
||||||
|
|
||||||
<button *ngIf="!isLoadingPreOrder" kendoButton class="btn-order w-100"
|
<button *ngIf="!isLoadingPreOrder" kendoButton class="btn-pre-order w-100"
|
||||||
(click)="showConfirmation()" [disabled]="isLoadingPreOrder" [icon]="loadingIconOrder">
|
(click)="showConfirmation()" [disabled]="isLoadingPreOrder" [icon]="loadingIconOrder">
|
||||||
<span class="text-btn-order">Fechar orçamento</span>
|
<span class="text-btn-order">Fechar orçamento</span>
|
||||||
</button>
|
</button>
|
||||||
@@ -933,7 +939,7 @@
|
|||||||
message="{{ messageConfirmation }}" textButtonConfirmation="{{ textButtonConfirmation }}"
|
message="{{ messageConfirmation }}" textButtonConfirmation="{{ textButtonConfirmation }}"
|
||||||
textButtonCancel="{{ textButtonCancel }}" (resultEvent)="confirmChangePaymentPlan($event)"></app-confirmation>
|
textButtonCancel="{{ textButtonCancel }}" (resultEvent)="confirmChangePaymentPlan($event)"></app-confirmation>
|
||||||
|
|
||||||
<app-discount-item-sales *ngIf="showDiscountItem" opened="showDiscountItem" title="{{ titleMessage }}"
|
<app-discount-item-sales *ngIf="showDiscountItem" opened="showDiscountItem" title="Desconto por Item"
|
||||||
textButtonConfirmation="{{ textButtonConfirmation }}" textButtonCancel="{{ textButtonCancel }}"
|
textButtonConfirmation="{{ textButtonConfirmation }}" textButtonCancel="{{ textButtonCancel }}"
|
||||||
[shoppingItem]="itemSelect" (resultEvent)="returnDiscountItem($event)"></app-discount-item-sales>
|
[shoppingItem]="itemSelect" (resultEvent)="returnDiscountItem($event)"></app-discount-item-sales>
|
||||||
|
|
||||||
|
|||||||
@@ -991,6 +991,26 @@ kendo-treeview:hover {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.loading-overlay {
|
||||||
|
position: fixed;
|
||||||
|
top: 0;
|
||||||
|
left: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: rgba(255, 255, 255, 0.7);
|
||||||
|
z-index: 9999;
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
align-items: center;
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.loading-content {
|
||||||
|
text-align: center;
|
||||||
|
font-weight: 600;
|
||||||
|
color: #2d2e83;
|
||||||
|
}
|
||||||
|
|
||||||
/* Responsividade para desktops maiores (largura > 1200px) */
|
/* Responsividade para desktops maiores (largura > 1200px) */
|
||||||
@media (min-width: 1200px) {
|
@media (min-width: 1200px) {
|
||||||
.card-resume {
|
.card-resume {
|
||||||
|
|||||||
@@ -278,7 +278,7 @@ export class CartSalesComponent
|
|||||||
) { }
|
) { }
|
||||||
|
|
||||||
ngOnChanges(changes: SimpleChanges): void {
|
ngOnChanges(changes: SimpleChanges): void {
|
||||||
this.loadShopping();
|
//this.loadShopping();
|
||||||
}
|
}
|
||||||
|
|
||||||
ngAfterViewInit(): void { }
|
ngAfterViewInit(): void { }
|
||||||
@@ -326,18 +326,9 @@ export class CartSalesComponent
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
loadShopping() {
|
|
||||||
this.shoppingSubscription = this.shopping$.subscribe((data) => {
|
|
||||||
this.shopping = data;
|
|
||||||
if (this.shopping !== null) {
|
|
||||||
this.totalWeight = data.totpeso;
|
|
||||||
this.loadFormOrder();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
getTaxValue() {
|
getTaxValue() {
|
||||||
const taxDelivery = JSON.parse(localStorage.getItem('taxDelivery'));
|
const taxDelivery = JSON.parse(localStorage.getItem('taxDelivery'));
|
||||||
|
if (!this.formResumeOrder) return 0;
|
||||||
const taxValue = Number.parseFloat(
|
const taxValue = Number.parseFloat(
|
||||||
this.formResumeOrder.get('taxValue').value
|
this.formResumeOrder.get('taxValue').value
|
||||||
);
|
);
|
||||||
@@ -345,18 +336,24 @@ export class CartSalesComponent
|
|||||||
return taxDelivery != null ? taxDelivery.taxValue : taxValue;
|
return taxDelivery != null ? taxDelivery.taxValue : taxValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
loadFormOrder() {
|
loadFormOrder(data?: Shopping) {
|
||||||
this.subscriptionShopping = this.shopping$.subscribe((data) => {
|
if (!data && this.shopping) {
|
||||||
const taxDelivery = JSON.parse(localStorage.getItem('taxDelivery'));
|
data = this.shopping;
|
||||||
this.formResumeOrder = this.fb.group({
|
}
|
||||||
taxValue: [
|
if (!data) return;
|
||||||
taxDelivery.taxValue > 0 ? taxDelivery.taxValue.toFixed(2) : '0',
|
|
||||||
],
|
const taxDelivery = JSON.parse(localStorage.getItem('taxDelivery'));
|
||||||
discount: [data.vldesconto > 0 ? data.vldesconto.toFixed(2) : '0,00'],
|
if (this.formResumeOrder) {
|
||||||
carrierId: [taxDelivery.carrierId],
|
this.formResumeOrder.patchValue({
|
||||||
deliveryTaxId: [taxDelivery.deliveryTaxId],
|
taxValue:
|
||||||
|
taxDelivery != null && taxDelivery.taxValue > 0
|
||||||
|
? taxDelivery.taxValue.toFixed(2)
|
||||||
|
: '0',
|
||||||
|
discount: data.vldesconto > 0 ? data.vldesconto.toFixed(2) : '0,00',
|
||||||
|
carrierId: taxDelivery != null ? taxDelivery.carrierId : 0,
|
||||||
|
deliveryTaxId: taxDelivery != null ? taxDelivery.deliveryTaxId : 0,
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
@@ -449,6 +446,7 @@ export class CartSalesComponent
|
|||||||
taxValue: new FormControl(this.cartData.taxValue.toFixed(2), []),
|
taxValue: new FormControl(this.cartData.taxValue.toFixed(2), []),
|
||||||
discount: new FormControl(this.cartData.discountValue.toFixed(2), []),
|
discount: new FormControl(this.cartData.discountValue.toFixed(2), []),
|
||||||
carrierId: new FormControl(this.cartData.carrierId, []),
|
carrierId: new FormControl(this.cartData.carrierId, []),
|
||||||
|
deliveryTaxId: new FormControl(0, []),
|
||||||
});
|
});
|
||||||
this.formPayment = this.fb.group({
|
this.formPayment = this.fb.group({
|
||||||
invoiceStore: new FormControl(null),
|
invoiceStore: new FormControl(null),
|
||||||
@@ -499,7 +497,7 @@ export class CartSalesComponent
|
|||||||
this.shopping = data;
|
this.shopping = data;
|
||||||
if (this.shopping !== null) {
|
if (this.shopping !== null) {
|
||||||
this.totalWeight = data.totpeso;
|
this.totalWeight = data.totpeso;
|
||||||
this.loadFormOrder();
|
this.loadFormOrder(data);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -1432,10 +1430,10 @@ export class CartSalesComponent
|
|||||||
let carrierId = 0;
|
let carrierId = 0;
|
||||||
if (taxValue >= 0) {
|
if (taxValue >= 0) {
|
||||||
deliveryTaxId = Number.parseFloat(
|
deliveryTaxId = Number.parseFloat(
|
||||||
this.formResumeOrder.get('deliveryTaxId').value
|
this.formResumeOrder.get('deliveryTaxId') ? this.formResumeOrder.get('deliveryTaxId').value : 0
|
||||||
);
|
);
|
||||||
carrierId = Number.parseFloat(
|
carrierId = Number.parseFloat(
|
||||||
this.formResumeOrder.get('carrierId').value
|
this.formResumeOrder.get('carrierId') ? this.formResumeOrder.get('carrierId').value : 0
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
const order: OrderDeliveryTax = {
|
const order: OrderDeliveryTax = {
|
||||||
@@ -1446,7 +1444,6 @@ export class CartSalesComponent
|
|||||||
};
|
};
|
||||||
localStorage.setItem('taxDelivery', JSON.stringify(order));
|
localStorage.setItem('taxDelivery', JSON.stringify(order));
|
||||||
this.loadFormOrder();
|
this.loadFormOrder();
|
||||||
this.loadShopping();
|
|
||||||
|
|
||||||
/* this.store.dispatch(new UpdateDeliveryTaxAction(order));
|
/* this.store.dispatch(new UpdateDeliveryTaxAction(order));
|
||||||
this.updating$.subscribe((update) => {
|
this.updating$.subscribe((update) => {
|
||||||
@@ -2146,10 +2143,10 @@ export class CartSalesComponent
|
|||||||
);
|
);
|
||||||
let percentOrder = (discountValue / orderValue) * 100;
|
let percentOrder = (discountValue / orderValue) * 100;
|
||||||
console.log('Percentual do pedido: ' + percentOrder);
|
console.log('Percentual do pedido: ' + percentOrder);
|
||||||
if (this.percentSeller < percentOrder) {
|
// if (this.percentSeller < percentOrder) {
|
||||||
this.openedAuthUser = true;
|
// this.openedAuthUser = true;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
if (discountValue <= 0.01) {
|
if (discountValue <= 0.01) {
|
||||||
percentOrder = 0;
|
percentOrder = 0;
|
||||||
}
|
}
|
||||||
@@ -2159,8 +2156,9 @@ export class CartSalesComponent
|
|||||||
idUserAuth: this.authService.getUser(),
|
idUserAuth: this.authService.getUser(),
|
||||||
};
|
};
|
||||||
this.store.dispatch(new ApplyDiscountOrderAction(order));
|
this.store.dispatch(new ApplyDiscountOrderAction(order));
|
||||||
this.store.dispatch(new LoadShoppingAction(this.shoppingService.getCart()));
|
// this.store.dispatch(new LoadShoppingAction(this.shoppingService.getCart())); // Reloader moved to Effect
|
||||||
this.loadFormOrder();
|
this.loadFormOrder();
|
||||||
|
this.calculateTaxDelivery(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
applyDiscountOrder() {
|
applyDiscountOrder() {
|
||||||
@@ -2249,6 +2247,7 @@ export class CartSalesComponent
|
|||||||
this.showInformation = true;
|
this.showInformation = true;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
this.loadFormOrder();
|
||||||
}
|
}
|
||||||
|
|
||||||
calcDiscountOrderValue() {
|
calcDiscountOrderValue() {
|
||||||
@@ -2591,6 +2590,7 @@ export class CartSalesComponent
|
|||||||
priorityDelivery: priorityDelivery,
|
priorityDelivery: priorityDelivery,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
console.log('dataDeliveryTax', JSON.stringify(dataDeliveryTax));
|
||||||
this.shoppingService.calculateDeliveryTax(dataDeliveryTax).subscribe(
|
this.shoppingService.calculateDeliveryTax(dataDeliveryTax).subscribe(
|
||||||
(result) => {
|
(result) => {
|
||||||
this.dataDeliveryTax = result;
|
this.dataDeliveryTax = result;
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import { FormBuilder, FormControl, FormGroup } from '@angular/forms';
|
|||||||
import { Store } from '@ngrx/store';
|
import { Store } from '@ngrx/store';
|
||||||
import { ActionsLayout } from '@progress/kendo-angular-dialog';
|
import { ActionsLayout } from '@progress/kendo-angular-dialog';
|
||||||
import { Observable, Subscription } from 'rxjs';
|
import { Observable, Subscription } from 'rxjs';
|
||||||
import { map } from 'rxjs/operators';
|
import { catchError, map } from 'rxjs/operators';
|
||||||
import { AuthService } from 'src/app/auth/services/auth.service';
|
import { AuthService } from 'src/app/auth/services/auth.service';
|
||||||
import { ResultApi } from 'src/app/models/result-api.model';
|
import { ResultApi } from 'src/app/models/result-api.model';
|
||||||
import { UserAuth } from 'src/app/models/user-auth.model';
|
import { UserAuth } from 'src/app/models/user-auth.model';
|
||||||
@@ -55,7 +55,7 @@ export class DiscountItemSalesComponent implements OnInit {
|
|||||||
constructor(
|
constructor(
|
||||||
private fb: FormBuilder,
|
private fb: FormBuilder,
|
||||||
private authService: AuthService,
|
private authService: AuthService,
|
||||||
private store: Store<SaleState>, ) {
|
private store: Store<SaleState>,) {
|
||||||
|
|
||||||
this.formDiscountItem = this.fb.group({
|
this.formDiscountItem = this.fb.group({
|
||||||
description: [''],
|
description: [''],
|
||||||
@@ -96,7 +96,7 @@ export class DiscountItemSalesComponent implements OnInit {
|
|||||||
|
|
||||||
calcPercentDiscount() {
|
calcPercentDiscount() {
|
||||||
const discountValue = this.formDiscountItem.get('discountValue').value;
|
const discountValue = this.formDiscountItem.get('discountValue').value;
|
||||||
const percent = Number.parseFloat(( discountValue / this.shoppingItem.listPrice ).toFixed(2)) * 100;
|
const percent = Number.parseFloat((discountValue / this.shoppingItem.listPrice).toFixed(2)) * 100;
|
||||||
const salePrice = Number.parseFloat((this.shoppingItem.listPrice - discountValue).toFixed(2));
|
const salePrice = Number.parseFloat((this.shoppingItem.listPrice - discountValue).toFixed(2));
|
||||||
this.formDiscountItem.patchValue({
|
this.formDiscountItem.patchValue({
|
||||||
discount: percent,
|
discount: percent,
|
||||||
@@ -107,29 +107,27 @@ export class DiscountItemSalesComponent implements OnInit {
|
|||||||
|
|
||||||
async confirmDiscount() {
|
async confirmDiscount() {
|
||||||
let discount = Number.parseFloat(this.formDiscountItem.get('discount').value);
|
let discount = Number.parseFloat(this.formDiscountItem.get('discount').value);
|
||||||
|
console.log('discount', discount);
|
||||||
const discountValue = Number.parseFloat(this.formDiscountItem.get('discountValue').value);
|
const discountValue = Number.parseFloat(this.formDiscountItem.get('discountValue').value);
|
||||||
const salePrice = Number.parseFloat((this.shoppingItem.listPrice - discountValue).toFixed(2));
|
const salePrice = Number.parseFloat((this.shoppingItem.listPrice - discountValue).toFixed(2));
|
||||||
|
|
||||||
if (this.percentSeller < discount) {
|
// if (this.percentSeller < discount) {
|
||||||
this.openedAuthUser = true;
|
// this.openedAuthUser = true;
|
||||||
return;
|
// return;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (discountValue <= 0.01) {
|
if (discountValue <= 0.01) {
|
||||||
discount = 0;
|
discount = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.shoppingItem.discount = discount;
|
console.log('shoppingItem', JSON.stringify(this.shoppingItem));
|
||||||
this.shoppingItem.discountValue = discountValue;
|
const updateItem = { ...this.shoppingItem };
|
||||||
this.shoppingItem.price = salePrice;
|
updateItem.discount = discount;
|
||||||
this.shoppingItem.userDiscount = this.authService.getUser();
|
updateItem.discountValue = discountValue;
|
||||||
this.store.dispatch(new UpdatePriceItemAction(this.shoppingItem));
|
updateItem.price = salePrice;
|
||||||
this.updating$.pipe(
|
updateItem.userDiscount = this.authService.getUser();
|
||||||
map((updating) => {
|
this.store.dispatch(new UpdatePriceItemAction(updateItem));
|
||||||
if (!updating) {
|
this.resultEvent.emit(true);
|
||||||
this.resultEvent.emit(true);
|
|
||||||
}
|
|
||||||
})
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async returnAuthUser(userAuth: any) {
|
async returnAuthUser(userAuth: any) {
|
||||||
@@ -149,13 +147,7 @@ export class DiscountItemSalesComponent implements OnInit {
|
|||||||
updateItem.price = salePrice;
|
updateItem.price = salePrice;
|
||||||
updateItem.userDiscount = userAuth.id;
|
updateItem.userDiscount = userAuth.id;
|
||||||
this.store.dispatch(new UpdatePriceItemAction(updateItem));
|
this.store.dispatch(new UpdatePriceItemAction(updateItem));
|
||||||
this.updating$.subscribe(
|
this.resultEvent.emit(true);
|
||||||
(updating) => {
|
|
||||||
if (!updating) {
|
|
||||||
this.resultEvent.emit(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
} else {
|
} else {
|
||||||
console.log('Não localizou o id.');
|
console.log('Não localizou o id.');
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,48 +1,33 @@
|
|||||||
<div class="container-fluid">
|
<div class="container-fluid">
|
||||||
<form class="k-form" [formGroup]="formDiscount">
|
<form class="k-form" [formGroup]="formDiscount">
|
||||||
<fieldset>
|
<fieldset>
|
||||||
<legend>Dados do pedido</legend>
|
<legend>Dados do pedido xxx</legend>
|
||||||
|
|
||||||
<label class="k-form-field">
|
<label class="k-form-field">
|
||||||
<span>Valor dos produtos</span>
|
<span>Valor dos produtos</span>
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox [spinners]="false" [readonly]="true" [value]="orderValue" formControlName="value">
|
||||||
[spinners]="false"
|
|
||||||
[readonly]="true"
|
|
||||||
[value]="orderValue"
|
|
||||||
formControlName="value"
|
|
||||||
>
|
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
<div class="">
|
<div class="">
|
||||||
<label class="k-form-field">
|
<label class="k-form-field">
|
||||||
<span>% Desconto desejado</span>
|
<span>% Desconto desejado</span>
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox formControlName="discount" [spinners]="false">
|
||||||
formControlName="discount"
|
<kendo-formerror>Error: Percentual acima do permitido para o usuário.</kendo-formerror>
|
||||||
[spinners]="false"
|
|
||||||
>
|
|
||||||
<kendo-formerror>Error: Percentual acima do permitido para o usuário.</kendo-formerror>
|
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</label>
|
</label>
|
||||||
<label class="k-form-field">
|
<label class="k-form-field">
|
||||||
<span>Valor do desconto</span>
|
<span>Valor do desconto</span>
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox formControlName="discountValue" [spinners]="false">
|
||||||
formControlName="discountValue"
|
<kendo-formerror>Error: Percentual acima do permitido para o usuário.</kendo-formerror>
|
||||||
[spinners]="false"
|
|
||||||
>
|
|
||||||
<kendo-formerror>Error: Percentual acima do permitido para o usuário.</kendo-formerror>
|
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<label class="k-form-field">
|
<label class="k-form-field">
|
||||||
<span>Valor do pedido com desconto</span>
|
<span>Valor do pedido com desconto</span>
|
||||||
<kendo-numerictextbox
|
<kendo-numerictextbox formcontrolName="valueWithDiscount" [spinners]="false" [readonly]="true"
|
||||||
formcontrolName="valueWithDiscount"
|
[value]="orderWithDiscount">
|
||||||
[spinners]="false"
|
|
||||||
[readonly]="true"
|
|
||||||
[value]="orderWithDiscount"
|
|
||||||
>
|
|
||||||
</kendo-numerictextbox>
|
</kendo-numerictextbox>
|
||||||
</label>
|
</label>
|
||||||
|
|
||||||
@@ -51,7 +36,7 @@
|
|||||||
<div formGroupName="formGroup">
|
<div formGroupName="formGroup">
|
||||||
<label class="k-label">
|
<label class="k-label">
|
||||||
<input type="checkbox" formControlName="userAuth" kendoCheckBox />
|
<input type="checkbox" formControlName="userAuth" kendoCheckBox />
|
||||||
<span class="ms-2">Informar outro usuário para autorizar o desconto</span>
|
<span class="ms-2">Informar outro usuário para autorizar o desconto</span>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
@@ -60,12 +45,7 @@
|
|||||||
<fieldset>
|
<fieldset>
|
||||||
<kendo-formfield>
|
<kendo-formfield>
|
||||||
<kendo-label [for]="email" text="Email"></kendo-label>
|
<kendo-label [for]="email" text="Email"></kendo-label>
|
||||||
<kendo-textbox
|
<kendo-textbox formControlName="email" [clearButton]="true" #email required></kendo-textbox>
|
||||||
formControlName="email"
|
|
||||||
[clearButton]="true"
|
|
||||||
#email
|
|
||||||
required
|
|
||||||
></kendo-textbox>
|
|
||||||
|
|
||||||
<!--kendo-formerror *ngIf="formDiscount.controls.formUser.email.errors?.required"
|
<!--kendo-formerror *ngIf="formDiscount.controls.formUser.email.errors?.required"
|
||||||
>Erro: Email é obrigatório</kendo-formerror
|
>Erro: Email é obrigatório</kendo-formerror
|
||||||
@@ -77,13 +57,7 @@
|
|||||||
|
|
||||||
<kendo-formfield class="mt-2">
|
<kendo-formfield class="mt-2">
|
||||||
<kendo-label [for]="password" text="Senha"></kendo-label>
|
<kendo-label [for]="password" text="Senha"></kendo-label>
|
||||||
<input
|
<input kendoTextBox type="password" placeholder="Password" #password formControlName="password" />
|
||||||
kendoTextBox
|
|
||||||
type="password"
|
|
||||||
placeholder="Password"
|
|
||||||
#password
|
|
||||||
formControlName="password"
|
|
||||||
/>
|
|
||||||
|
|
||||||
<kendo-formerror>Error: Password is required</kendo-formerror>
|
<kendo-formerror>Error: Password is required</kendo-formerror>
|
||||||
</kendo-formfield>
|
</kendo-formfield>
|
||||||
@@ -92,23 +66,24 @@
|
|||||||
|
|
||||||
|
|
||||||
<div class="k-actions k-actions-end">
|
<div class="k-actions k-actions-end">
|
||||||
<button type="button" [disabled]="!formDiscount.valid" class="k-button" (click)="closeMsgDiscount()">Cancel</button>
|
<button type="button" [disabled]="!formDiscount.valid" class="k-button"
|
||||||
<button type="button" class="k-button k-primary" (click)="confirmDiscount()" >Submit</button>
|
(click)="closeMsgDiscount()">Cancel</button>
|
||||||
|
<button type="button" class="k-button k-primary" (click)="confirmDiscount()">Submit</button>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
</form>
|
</form>
|
||||||
|
|
||||||
|
|
||||||
<kendo-dialog title="Pedido de venda" *ngIf="openedMsgDiscount" (close)="close()">
|
<kendo-dialog title="Pedido de venda" *ngIf="openedMsgDiscount" (close)="close()">
|
||||||
<p style="margin: 25px; text-align: center;">Desconto acima do permitido para o usuário!</p>
|
<p style="margin: 25px; text-align: center;">Desconto acima do permitido para o usuário!</p>
|
||||||
<p>Percentual máximo permitido é de {{discountAuthorization}}%</p>
|
<p>Percentual máximo permitido é de {{discountAuthorization}}%</p>
|
||||||
<p>Informado no pedido foi de {{percent}}%</p>
|
<p>Informado no pedido foi de {{percent}}%</p>
|
||||||
|
|
||||||
<kendo-dialog-actions>
|
<kendo-dialog-actions>
|
||||||
<button kendoButton (click)="close()" [primary]="true">
|
<button kendoButton (click)="close()" [primary]="true">
|
||||||
Yes, sorry.
|
Yes, sorry.
|
||||||
</button>
|
</button>
|
||||||
</kendo-dialog-actions>
|
</kendo-dialog-actions>
|
||||||
</kendo-dialog>
|
</kendo-dialog>
|
||||||
</div>
|
</div>
|
||||||
@@ -43,13 +43,13 @@ export class DiscountOrderComponent implements OnInit, OnDestroy {
|
|||||||
discountValue: [(this.orderValue - this.orderWithDiscount),
|
discountValue: [(this.orderValue - this.orderWithDiscount),
|
||||||
Validators.compose([Validators.required])],
|
Validators.compose([Validators.required])],
|
||||||
valueWithDiscount: [this.orderWithDiscount, [Validators.required]],
|
valueWithDiscount: [this.orderWithDiscount, [Validators.required]],
|
||||||
formUser: this.formBuilder.group({
|
// formUser: this.formBuilder.group({
|
||||||
email: new FormControl(null, Validators.required),
|
// email: new FormControl(null, Validators.required),
|
||||||
password: new FormControl(null, Validators.required),
|
// password: new FormControl(null, Validators.required),
|
||||||
}),
|
// }),
|
||||||
formGroup: this.formBuilder.group({
|
// formGroup: this.formBuilder.group({
|
||||||
userAuth: new FormControl(null, Validators.required),
|
// userAuth: new FormControl(null, Validators.required),
|
||||||
}),
|
// }),
|
||||||
});
|
});
|
||||||
this.formDiscount.valueChanges.subscribe(f => {
|
this.formDiscount.valueChanges.subscribe(f => {
|
||||||
this.percent = this.formDiscount.get('discount').value;
|
this.percent = this.formDiscount.get('discount').value;
|
||||||
@@ -84,78 +84,82 @@ export class DiscountOrderComponent implements OnInit, OnDestroy {
|
|||||||
}
|
}
|
||||||
|
|
||||||
confirmDiscount() {
|
confirmDiscount() {
|
||||||
|
|
||||||
|
this.submitForm.emit(this.formDiscount);
|
||||||
|
return;
|
||||||
|
|
||||||
let email = this.formDiscount.get('formUser.email').value;
|
let email = this.formDiscount.get('formUser.email').value;
|
||||||
|
|
||||||
const emailUpperCase = email.toUpperCase();
|
const emailUpperCase = email.toUpperCase();
|
||||||
const passwordUpperCase = this.formDiscount.get('formUser.password').value.toUpperCase();
|
const passwordUpperCase = this.formDiscount.get('formUser.password').value.toUpperCase();
|
||||||
|
|
||||||
if (this.discountAuthorization < this.percent) {
|
// if (this.discountAuthorization < this.percent) {
|
||||||
if (this.formDiscount.controls.formGroup.get('userAuth').value) {
|
if (this.formDiscount.controls.formGroup.get('userAuth').value) {
|
||||||
this.SubscriptionAuth = this.authService.authenticate({
|
this.SubscriptionAuth = this.authService.authenticate({
|
||||||
email: emailUpperCase,
|
email: emailUpperCase,
|
||||||
password: passwordUpperCase
|
password: passwordUpperCase
|
||||||
})
|
|
||||||
.subscribe((res: ResultApi) => {
|
|
||||||
console.log(res);
|
|
||||||
if (res.success) {
|
|
||||||
this.discountAuthorization = res.data.discountPercent;
|
|
||||||
if (this.discountAuthorization < this.percent) {
|
|
||||||
this.openedMsgDiscount = true;
|
|
||||||
} else {
|
|
||||||
console.log('fechar form');
|
|
||||||
this.submitForm.emit(this.formDiscount);
|
|
||||||
}
|
|
||||||
// this.loadingIcon = '';
|
|
||||||
} else {
|
|
||||||
// this.loadingIcon = '';
|
|
||||||
// this.showErrorMessage(res.message);
|
|
||||||
}
|
|
||||||
}, err => {
|
|
||||||
// this.loadingIcon = '';
|
|
||||||
// this.showErrorMessage('Erro ao processar sua requisição,
|
|
||||||
// tente novamente e caso persista o erro contacte o departamento de TI.');
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
this.openedMsgDiscount = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} else {
|
|
||||||
this.close();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
getAuthorization() {
|
|
||||||
return this.formDiscount.controls.formGroup.get('userAuth').value;
|
|
||||||
}
|
|
||||||
|
|
||||||
validationUser() {
|
|
||||||
this.formDiscount.markAllAsTouched();
|
|
||||||
if (this.formDiscount.valid) {
|
|
||||||
// this.loadingIcon = 'loading';
|
|
||||||
this.authService.authenticate({
|
|
||||||
email: this.formDiscount.get('formUser.email').value,
|
|
||||||
password: this.formDiscount.get('formUser.password').value
|
|
||||||
})
|
})
|
||||||
.subscribe((res: ResultApi) => {
|
.subscribe((res: ResultApi) => {
|
||||||
console.log(res);
|
console.log(res);
|
||||||
if (res.success) {
|
if (res.success) {
|
||||||
this.discountAuthorization = res.data.discountPercent;
|
this.discountAuthorization = res.data.discountPercent;
|
||||||
return this.discountAuthorization;
|
if (this.discountAuthorization < this.percent) {
|
||||||
|
this.openedMsgDiscount = true;
|
||||||
|
} else {
|
||||||
|
console.log('fechar form');
|
||||||
|
this.submitForm.emit(this.formDiscount);
|
||||||
|
}
|
||||||
// this.loadingIcon = '';
|
// this.loadingIcon = '';
|
||||||
} else {
|
} else {
|
||||||
// this.loadingIcon = '';
|
// this.loadingIcon = '';
|
||||||
// this.showErrorMessage(res.message);
|
// this.showErrorMessage(res.message);
|
||||||
return this.discountAuthorization;
|
|
||||||
}
|
}
|
||||||
}, err => {
|
}, err => {
|
||||||
return this.discountAuthorization;
|
|
||||||
// this.loadingIcon = '';
|
// this.loadingIcon = '';
|
||||||
// this.showErrorMessage('Erro ao processar sua requisição,
|
// this.showErrorMessage('Erro ao processar sua requisição,
|
||||||
// tente novamente e caso persista o erro contacte o departamento de TI.');
|
// tente novamente e caso persista o erro contacte o departamento de TI.');
|
||||||
});
|
});
|
||||||
return this.discountAuthorization;
|
} else {
|
||||||
|
this.openedMsgDiscount = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// } else {
|
||||||
|
// this.close();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
getAuthorization() {
|
||||||
|
return false; //this.formDiscount.controls.formGroup.get('userAuth').value;
|
||||||
|
}
|
||||||
|
|
||||||
|
validationUser() {
|
||||||
|
this.formDiscount.markAllAsTouched();
|
||||||
|
// if (this.formDiscount.valid) {
|
||||||
|
// // this.loadingIcon = 'loading';
|
||||||
|
// this.authService.authenticate({
|
||||||
|
// email: this.formDiscount.get('formUser.email').value,
|
||||||
|
// password: this.formDiscount.get('formUser.password').value
|
||||||
|
// })
|
||||||
|
// .subscribe((res: ResultApi) => {
|
||||||
|
// console.log(res);
|
||||||
|
// if (res.success) {
|
||||||
|
// this.discountAuthorization = res.data.discountPercent;
|
||||||
|
// return this.discountAuthorization;
|
||||||
|
// // this.loadingIcon = '';
|
||||||
|
// } else {
|
||||||
|
// // this.loadingIcon = '';
|
||||||
|
// // this.showErrorMessage(res.message);
|
||||||
|
// return this.discountAuthorization;
|
||||||
|
// }
|
||||||
|
// }, err => {
|
||||||
|
// return this.discountAuthorization;
|
||||||
|
// // this.loadingIcon = '';
|
||||||
|
// // this.showErrorMessage('Erro ao processar sua requisição,
|
||||||
|
// // tente novamente e caso persista o erro contacte o departamento de TI.');
|
||||||
|
// });
|
||||||
|
// return this.discountAuthorization;
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -38,7 +38,8 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-md-6 col-sm-12 mt-3 mt-md-0">
|
<div class="col-md-6 col-sm-12 mt-3 mt-md-0">
|
||||||
<label>
|
<label>
|
||||||
<span class="d-block">CPF / CNPJ</span>
|
<span class="d-block">CPF / CNPJ ou</span>
|
||||||
|
<span class="d-block">Código do Cliente</span>
|
||||||
<kendo-textbox formControlName="document" placeholder="Informe o CPF ou CNPJ do cliente"></kendo-textbox>
|
<kendo-textbox formControlName="document" placeholder="Informe o CPF ou CNPJ do cliente"></kendo-textbox>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -98,7 +98,10 @@ export class ShoppingEffects {
|
|||||||
mergeMap(
|
mergeMap(
|
||||||
(data) => this.shoppingService.updatePriceItemShopping(data.payload)
|
(data) => this.shoppingService.updatePriceItemShopping(data.payload)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(() => new UpdatePriceItemSuccessAction(data.payload)),
|
mergeMap(() => [
|
||||||
|
new UpdatePriceItemSuccessAction(data.payload),
|
||||||
|
new LoadShoppingAction(data.payload.idCart)
|
||||||
|
]),
|
||||||
catchError(error => of(new UpdatePriceItemFailureAction(error)))
|
catchError(error => of(new UpdatePriceItemFailureAction(error)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -110,7 +113,10 @@ export class ShoppingEffects {
|
|||||||
mergeMap(
|
mergeMap(
|
||||||
(data) => this.shoppingService.applyDiscountOrder(data.payload)
|
(data) => this.shoppingService.applyDiscountOrder(data.payload)
|
||||||
.pipe(
|
.pipe(
|
||||||
map((items) => new ApplyDiscountOrderSuccessAction(items)),
|
mergeMap((items) => [
|
||||||
|
new ApplyDiscountOrderSuccessAction(items),
|
||||||
|
new LoadShoppingAction(data.payload.id)
|
||||||
|
]),
|
||||||
catchError(error => of(new ApplyDiscountOrderFailureAction(error)))
|
catchError(error => of(new ApplyDiscountOrderFailureAction(error)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -122,7 +128,10 @@ export class ShoppingEffects {
|
|||||||
mergeMap(
|
mergeMap(
|
||||||
(data) => this.shoppingService.updateQuantityItemShopping(data.payload)
|
(data) => this.shoppingService.updateQuantityItemShopping(data.payload)
|
||||||
.pipe(
|
.pipe(
|
||||||
map(() => new UpdateQuantityItemSuccessAction(data.payload)),
|
mergeMap(() => [
|
||||||
|
new UpdateQuantityItemSuccessAction(data.payload),
|
||||||
|
new LoadShoppingAction(data.payload.idCart)
|
||||||
|
]),
|
||||||
catchError(error => of(new UpdateQuantityItemFailureAction(error)))
|
catchError(error => of(new UpdateQuantityItemFailureAction(error)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
@@ -134,7 +143,10 @@ export class ShoppingEffects {
|
|||||||
mergeMap(
|
mergeMap(
|
||||||
(data) => this.shoppingService.deleteItemShopping(data.payload)
|
(data) => this.shoppingService.deleteItemShopping(data.payload)
|
||||||
.pipe(
|
.pipe(
|
||||||
map((result) => new DeleteItemSuccessAction(result)),
|
mergeMap((result) => [
|
||||||
|
new DeleteItemSuccessAction(result),
|
||||||
|
new LoadShoppingAction(localStorage.getItem('cart'))
|
||||||
|
]),
|
||||||
catchError(error => of(new DeleteItemFailureAction(error)))
|
catchError(error => of(new DeleteItemFailureAction(error)))
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user