mirror of
https://dev.azure.com/hugendubel/ISA/_git/ISA-Frontend
synced 2025-12-28 22:42:11 +01:00
Merged PR 197: #537 - Meldetext von Downloads und NonBooks richtig anzeigen
#537 - Meldetext von Downloads und NonBooks richtig anzeigen
This commit is contained in:
@@ -68,8 +68,28 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
_halfStars = 0;
|
||||
_emptyStars = 0;
|
||||
loadBranchesInfoComponent = false;
|
||||
availabilityStatus: string;
|
||||
availabilityStatusText: string;
|
||||
|
||||
ssc: {
|
||||
store: { status?: string; text?: string };
|
||||
shipping: { status?: string; text?: string };
|
||||
download: { status?: string; text?: string };
|
||||
} = {
|
||||
download: {},
|
||||
shipping: {},
|
||||
store: {},
|
||||
};
|
||||
|
||||
// availabilityStatus: string;
|
||||
// availabilityStatusText: string;
|
||||
|
||||
get availabilityStatus() {
|
||||
return this.ssc.download.status || this.ssc.store.status || this.ssc.shipping.status;
|
||||
}
|
||||
|
||||
get availabilityStatusText() {
|
||||
return this.ssc.download.text || this.ssc.store.text || this.ssc.shipping.text;
|
||||
}
|
||||
|
||||
currentPickUpDate = '';
|
||||
currentDeliveryDate = '';
|
||||
storeError: string;
|
||||
@@ -267,7 +287,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
private cdrf: ChangeDetectorRef,
|
||||
private printer: PrinterService,
|
||||
private datePipe: DatePipe
|
||||
) { }
|
||||
) {}
|
||||
|
||||
ngOnInit() {
|
||||
this.loadCartState();
|
||||
@@ -314,6 +334,11 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
if (item) {
|
||||
this.availability = [];
|
||||
this.ssc = {
|
||||
download: {},
|
||||
shipping: {},
|
||||
store: {},
|
||||
};
|
||||
this.addSelectedItemToProcessIfMissingOrChanged(item);
|
||||
this.addItemIfDoesNotExistToProductState(item);
|
||||
this.item = item;
|
||||
@@ -350,7 +375,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
|
||||
private loadTempData() {
|
||||
combineLatest(this.store.select(SharedSelectors.getProcessSelectedItem), this.route.params, this.route.queryParams)
|
||||
combineLatest([this.store.select(SharedSelectors.getProcessSelectedItem), this.route.params, this.route.queryParams])
|
||||
.pipe(takeUntil(this.destroy$), this.filterTempData)
|
||||
.subscribe((item) => {
|
||||
if (this.productDetailContainer) {
|
||||
@@ -426,10 +451,10 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
review.length === 0
|
||||
? 0
|
||||
: review
|
||||
.map((t) => t.rating)
|
||||
.reduce((total, num) => {
|
||||
return total + num;
|
||||
}) / review.length,
|
||||
.map((t) => t.rating)
|
||||
.reduce((total, num) => {
|
||||
return total + num;
|
||||
}) / review.length,
|
||||
employeeReviews: review.length,
|
||||
reviews: review.map((t) => {
|
||||
return <Review>{
|
||||
@@ -633,7 +658,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
.getShippingAvailabilityWithCheck(item, ean, branch.id)
|
||||
.pipe(takeUntil(this.destroy$))
|
||||
.subscribe((response) => {
|
||||
if ((response as { error: boolean; message: string; type: CheckoutType; }).error) {
|
||||
if ((response as { error: boolean; message: string; type: CheckoutType }).error) {
|
||||
this.downloadError = true;
|
||||
this.downloadLoaded = true;
|
||||
if (this.addToCartBtn) {
|
||||
@@ -648,8 +673,10 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (successfulResponse) {
|
||||
const preferredAvailability = successfulResponse.av.find((t) => t.preferred === 1 && t.supplier === 'DIG');
|
||||
if (preferredAvailability) {
|
||||
this.availabilityStatus = preferredAvailability.ssc;
|
||||
this.availabilityStatusText = preferredAvailability.sscText;
|
||||
this.ssc.download = {
|
||||
status: preferredAvailability.ssc,
|
||||
text: preferredAvailability.sscText,
|
||||
};
|
||||
if (preferredAvailability.price && preferredAvailability.price.value && preferredAvailability.price.value.value) {
|
||||
this.downloadPrice = preferredAvailability.price.value.value;
|
||||
}
|
||||
@@ -686,7 +713,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
|
||||
async loadAvailability(it: ItemDTO, ean: string): Promise<boolean> {
|
||||
const availabilityObservables: Observable<
|
||||
{ branchId: number; type: CheckoutType; av: AvailabilityDTO[]; } | { error: boolean; message: string; type: CheckoutType; }
|
||||
{ branchId: number; type: CheckoutType; av: AvailabilityDTO[] } | { error: boolean; message: string; type: CheckoutType }
|
||||
>[] = [];
|
||||
const userBranchNumber = this.store.selectSnapshot(BranchSelectors.getUserBranch);
|
||||
const branch = this.store.selectSnapshot(BranchSelectors.getBranchesIterable).find((t) => t.branchNumber === userBranchNumber);
|
||||
@@ -711,11 +738,11 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
(
|
||||
response:
|
||||
| {
|
||||
branchId: number;
|
||||
type: CheckoutType;
|
||||
av: AvailabilityDTO[];
|
||||
}
|
||||
| { error: boolean; message: string; type: CheckoutType; }
|
||||
branchId: number;
|
||||
type: CheckoutType;
|
||||
av: AvailabilityDTO[];
|
||||
}
|
||||
| { error: boolean; message: string; type: CheckoutType }
|
||||
) => {
|
||||
if (
|
||||
(response as {
|
||||
@@ -753,8 +780,10 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
return;
|
||||
}
|
||||
if (item.type === CheckoutType.store) {
|
||||
this.availabilityStatus = preferredAvailability.ssc;
|
||||
this.availabilityStatusText = preferredAvailability.sscText;
|
||||
this.ssc.store = {
|
||||
status: preferredAvailability.ssc,
|
||||
text: preferredAvailability.sscText,
|
||||
};
|
||||
this.currentPickUpDate = preferredAvailability.at
|
||||
? this.datePipe.transform(new Date(preferredAvailability.at), 'dd.MM.yy')
|
||||
: null;
|
||||
@@ -771,6 +800,10 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
if (preferredAvailability.price && preferredAvailability.price.value && preferredAvailability.price.value.value) {
|
||||
this.deliveryPrice = preferredAvailability.price.value.value;
|
||||
}
|
||||
this.ssc.shipping = {
|
||||
status: preferredAvailability.ssc,
|
||||
text: preferredAvailability.sscText,
|
||||
};
|
||||
}
|
||||
|
||||
item.av.forEach((av) => {
|
||||
@@ -851,7 +884,7 @@ export class ProductDetailsComponent implements OnInit, OnDestroy {
|
||||
}
|
||||
}
|
||||
|
||||
cartActionCompleted(open: boolean) { }
|
||||
cartActionCompleted(open: boolean) {}
|
||||
|
||||
formatDate(date: Date | string): string {
|
||||
if (!!date) {
|
||||
|
||||
Reference in New Issue
Block a user