#1407 Checkout Updated Process Cart Entries Number

This commit is contained in:
Nino Righi
2021-02-24 11:46:40 +01:00
parent 26f5a116b6
commit bc64c01d6c
2 changed files with 27 additions and 15 deletions

View File

@@ -34,7 +34,7 @@
class="process-cart-icon"
></lib-icon>
<div [@cartnumber]="cartanimation" class="pt-3 process-cart-number-container">
<span class="process-cart-number" [ngClass]="{ 'number-download': cartBackgroundForDownload }">{{ cartCount }}</span>
<span class="process-cart-number" [ngClass]="{ 'number-download': cartBackgroundForDownload }">{{ cartCount$ | async }}</span>
</div>
</div>
</ng-container>

View File

@@ -35,6 +35,7 @@ import { ModuleSwitcher } from '../../core/models/app-switcher.enum';
import { USER_FORM_STATE_KEY, USER_EXTRAS_FORM_STATE_KEY, USER_ERRORS_FORM_STATE_KEY } from '../../core/utils/app.constants';
import { DeleteFormState } from '../../core/store/actions/forms.actions';
import { ApplicationService } from '@core/application';
import { DomainCheckoutService } from '@domain/checkout';
@Component({
selector: 'app-process-tab',
@@ -70,7 +71,7 @@ export class ProcessTabComponent implements OnInit, OnDestroy, AfterViewInit {
destroy$ = new Subject();
@ViewChild('deleteporcessdialog')
processDeleteDialogComponent: ProcessDeleteDialogComponent;
cartCount = 0;
cartCount$: Observable<number>;
cartanimation = '';
cartBackgroundForDownload = false;
@@ -79,7 +80,8 @@ export class ProcessTabComponent implements OnInit, OnDestroy, AfterViewInit {
private router: Router,
private cdr: ChangeDetectorRef,
private route: ActivatedRoute,
private applicationService: ApplicationService
private applicationService: ApplicationService,
private domainCheckoutService: DomainCheckoutService
) {}
isProcessFinished = this.router.url === '/cart/confirmation';
@@ -134,20 +136,30 @@ export class ProcessTabComponent implements OnInit, OnDestroy, AfterViewInit {
}
ngOnInit() {
this.store
.select(SharedSelectors.getCartTabData)
.pipe(
takeUntil(this.destroy$),
map((filterFn) => filterFn(this.process.id))
)
.subscribe((quantity: number) => {
if (quantity < this.cartCount) {
this.cartanimation = 'delete';
this.cartCount$ = this.domainCheckoutService.getShoppingCart({ processId: this.process.id }).pipe(
map((response) => {
if (response?.items?.length === undefined) {
return 0;
} else {
return response?.items?.length;
}
})
);
this.cartCount = quantity;
this.cdr.detectChanges();
});
// this.store
// .select(SharedSelectors.getCartTabData)
// .pipe(
// takeUntil(this.destroy$),
// map((filterFn) => filterFn(this.process.id))
// )
// .subscribe((quantity: number) => {
// if (quantity < this.cartCount) {
// this.cartanimation = 'delete';
// }
// this.cartCount = quantity;
// this.cdr.detectChanges();
// });
this.store
.select(ProcessSelectors.getCurrentRoute)