feat(ux): implement sprint 11 user experience module
This commit is contained in:
@@ -5,11 +5,12 @@ import { Product } from '../../../../core/products/models/product-domain.model';
|
||||
import { EngagementListResult, Question, RatingSummary, Review, SubmitQuestionInput, SubmitReviewInput } from '../../../../core/products/models/product-engagement.model';
|
||||
import { ConfigService } from '../../../../core/config/config.service';
|
||||
import { ProductFacade } from '../../../../facades/platform/product.facade';
|
||||
import { UserExperienceFacade } from '../../../../facades/platform/user-experience.facade';
|
||||
import { TranslatePipe } from '../../../../i18n/translate.pipe';
|
||||
import { LangRoutePipe } from '../../../../pipes/lang-route.pipe';
|
||||
import { CartService } from '../../../../services';
|
||||
import { LanguageService } from '../../../../services/language.service';
|
||||
import { DEFAULT_PRODUCT_PAGE_CONFIG, ProductPageConfig } from '../../../../shared/models/config';
|
||||
import { DEFAULT_PRODUCT_PAGE_CONFIG, DEFAULT_USER_EXPERIENCE_CONFIG, ProductPageConfig } from '../../../../shared/models/config';
|
||||
import { getStockStatus, getTranslatedField } from '../../../../utils/item.utils';
|
||||
import { ProductDeliveryInformationComponent } from '../components/delivery-information/delivery-information.component';
|
||||
import { ProductGalleryComponent } from '../components/product-gallery/product-gallery.component';
|
||||
@@ -52,10 +53,12 @@ export class ProductDetailsContainerComponent {
|
||||
private readonly destroyRef = inject(DestroyRef);
|
||||
private readonly configService = inject(ConfigService);
|
||||
private readonly productFacade = inject(ProductFacade);
|
||||
private readonly uxFacade = inject(UserExperienceFacade);
|
||||
private readonly cartService = inject(CartService);
|
||||
private readonly languageService = inject(LanguageService);
|
||||
|
||||
readonly productPageConfigState = signal<Required<ProductPageConfig>>(this.resolveProductPageConfig());
|
||||
readonly userExperienceConfig = signal(this.resolveUserExperienceConfig());
|
||||
|
||||
readonly product = signal<Product | null>(null);
|
||||
readonly relatedProducts = signal<Product[]>([]);
|
||||
@@ -178,6 +181,9 @@ export class ProductDetailsContainerComponent {
|
||||
}
|
||||
|
||||
this.product.set(product);
|
||||
if (this.userExperienceConfig().recentlyViewed.enabled) {
|
||||
this.uxFacade.trackRecentlyViewed(product, this.userExperienceConfig().recentlyViewed.maxItems);
|
||||
}
|
||||
this.initVariantSelection(product);
|
||||
this.loadRelatedProducts(product);
|
||||
this.loadEngagement(product.itemID);
|
||||
@@ -461,4 +467,20 @@ export class ProductDetailsContainerComponent {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private resolveUserExperienceConfig() {
|
||||
const raw = (this.configService.getBootstrapSnapshot() as any)?.userExperience ?? {};
|
||||
|
||||
return {
|
||||
...DEFAULT_USER_EXPERIENCE_CONFIG,
|
||||
...raw,
|
||||
recentlyViewed: {
|
||||
...DEFAULT_USER_EXPERIENCE_CONFIG.recentlyViewed,
|
||||
...(raw.recentlyViewed ?? {}),
|
||||
maxItems: Number.isFinite(raw.recentlyViewed?.maxItems)
|
||||
? Math.max(1, Number(raw.recentlyViewed.maxItems))
|
||||
: DEFAULT_USER_EXPERIENCE_CONFIG.recentlyViewed.maxItems
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user