mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
#1796 Abholung + Rücklage kann nicht in WK gelegt werden
This commit is contained in:
@@ -119,7 +119,6 @@ export class PurchasingOptionsModalComponent {
|
||||
this.purchasingOptionsModalStore.setAvailableOptions(this.modalRef.data.availableOptions);
|
||||
this.purchasingOptionsModalStore.setItem(this.modalRef.data.item);
|
||||
this.purchasingOptionsModalStore.setProcessId(this.modalRef.data.processId || this.application.activatedProcessId);
|
||||
this.purchasingOptionsModalStore.setBranchNo(this.modalRef.data.branchNo);
|
||||
this.purchasingOptionsModalStore.setAvailabilities(this.modalRef.data.availabilities || {});
|
||||
this.purchasingOptionsModalStore.setQuantity(this.modalRef?.data?.shoppingCartItem?.quantity || 1);
|
||||
|
||||
|
||||
@@ -4,7 +4,6 @@ import { PurchasingOptions } from './purchasing-options-modal.store';
|
||||
|
||||
export interface PurchasingOptionsModalData {
|
||||
item: ItemDTO;
|
||||
branchNo: string;
|
||||
availableOptions: PurchasingOptions[];
|
||||
processId?: number;
|
||||
option?: PurchasingOptions;
|
||||
|
||||
@@ -17,7 +17,7 @@ interface PurchasingOptionsModalState {
|
||||
item?: ItemDTO;
|
||||
shoppingCartItem?: ShoppingCartItemDTO;
|
||||
option?: PurchasingOptions;
|
||||
branchNo?: string;
|
||||
defaultBranch?: BranchDTO;
|
||||
branch?: BranchDTO;
|
||||
processId?: number;
|
||||
fetchingAvailability: boolean;
|
||||
@@ -63,9 +63,9 @@ export class PurchasingOptionsModalStore extends ComponentStore<PurchasingOption
|
||||
|
||||
readonly selectBranch = this.select((s) => {
|
||||
if (s.option === 'take-away') {
|
||||
return s.availableBranches.find((branch) => branch.branchNumber === s.branchNo);
|
||||
return s.defaultBranch;
|
||||
}
|
||||
return s.branch;
|
||||
return s.branch || s.defaultBranch;
|
||||
});
|
||||
|
||||
readonly selectQuantity = this.select((s) => s.quantity);
|
||||
@@ -179,6 +179,8 @@ export class PurchasingOptionsModalStore extends ComponentStore<PurchasingOption
|
||||
fetchingAvailability: false,
|
||||
maxQuantityError: false,
|
||||
});
|
||||
|
||||
this.loadDefaultBranch();
|
||||
}
|
||||
|
||||
readonly setItem = this.updater((state, item: ItemDTO) => {
|
||||
@@ -281,7 +283,7 @@ export class PurchasingOptionsModalStore extends ComponentStore<PurchasingOption
|
||||
});
|
||||
|
||||
readonly setAvailableBranches = this.updater((state, availableBranches: BranchDTO[]) => {
|
||||
const branch = state.branch || availableBranches.find((b) => b.branchNumber === state.branchNo);
|
||||
const branch = state.branch || state.defaultBranch;
|
||||
const filterResult = availableBranches;
|
||||
filterResult.sort((a: BranchDTO, b: BranchDTO) => this.branchSorterFn(a, b, branch));
|
||||
return {
|
||||
@@ -316,7 +318,7 @@ export class PurchasingOptionsModalStore extends ComponentStore<PurchasingOption
|
||||
});
|
||||
|
||||
readonly setFilteredBranches = this.updater((state, filterValue?: string) => {
|
||||
const branch = state.branch || state.availableBranches.find((b) => b.branchNumber === state.branchNo);
|
||||
const branch = state.branch || state.defaultBranch;
|
||||
if (!!filterValue) {
|
||||
const filterResult = state.availableBranches.filter((b) => {
|
||||
const name = b.name.toLowerCase();
|
||||
@@ -479,4 +481,17 @@ export class PurchasingOptionsModalStore extends ComponentStore<PurchasingOption
|
||||
geoDistance(userBranch?.address?.geoLocation, b?.address?.geoLocation)
|
||||
);
|
||||
}
|
||||
|
||||
readonly loadDefaultBranch = this.effect(($) =>
|
||||
$.pipe(
|
||||
switchMap((_) =>
|
||||
this.availabilityService.getCurrentBranch().pipe(
|
||||
tapResponse(
|
||||
(defaultBranch) => this.patchState({ defaultBranch }),
|
||||
(err) => {}
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user