mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-23 14:40:50 +01:00
Fix catalog offers
This commit is contained in:
parent
06bc3f238e
commit
c7d3022ccb
@ -1,5 +1,6 @@
|
||||
import { IFurnitureData } from '@nitrots/nitro-renderer';
|
||||
import { GetProductOfferComposer, IFurnitureData } from '@nitrots/nitro-renderer';
|
||||
import { GetProductDataForLocalization } from '../../../api';
|
||||
import { SendMessageHook } from '../../../hooks';
|
||||
import { ICatalogPage } from './ICatalogPage';
|
||||
import { IProduct } from './IProduct';
|
||||
import { IPurchasableOffer } from './IPurchasableOffer';
|
||||
@ -18,6 +19,11 @@ export class FurnitureOffer implements IPurchasableOffer
|
||||
this._product = (new Product(this._furniData.type, this._furniData.id, this._furniData.customParams, 1, GetProductDataForLocalization(this._furniData.className), this._furniData) as IProduct);
|
||||
}
|
||||
|
||||
public activate(): void
|
||||
{
|
||||
SendMessageHook(new GetProductOfferComposer((this._furniData.rentOfferId > -1) ? this._furniData.rentOfferId : this._furniData.purchaseOfferId));
|
||||
}
|
||||
|
||||
public get offerId(): number
|
||||
{
|
||||
return (this.isRentOffer) ? this._furniData.rentOfferId : this._furniData.purchaseOfferId;
|
||||
@ -107,4 +113,9 @@ export class FurnitureOffer implements IPurchasableOffer
|
||||
{
|
||||
return this._furniData.description;
|
||||
}
|
||||
|
||||
public get isLazy(): boolean
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ import { IProduct } from './IProduct';
|
||||
|
||||
export interface IPurchasableOffer
|
||||
{
|
||||
activate(): void;
|
||||
clubLevel: number;
|
||||
page: ICatalogPage;
|
||||
offerId: number;
|
||||
@ -19,5 +20,6 @@ export interface IPurchasableOffer
|
||||
badgeCode: string;
|
||||
localizationName: string;
|
||||
localizationDescription: string;
|
||||
isLazy: boolean;
|
||||
products: IProduct[];
|
||||
}
|
||||
|
@ -59,6 +59,11 @@ export class Offer implements IPurchasableOffer
|
||||
}
|
||||
}
|
||||
|
||||
public activate(): void
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public get clubLevel(): number
|
||||
{
|
||||
return this._clubLevel;
|
||||
@ -160,6 +165,11 @@ export class Offer implements IPurchasableOffer
|
||||
return LocalizeText(this._localizationId);
|
||||
}
|
||||
|
||||
public get isLazy(): boolean
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public get products(): IProduct[]
|
||||
{
|
||||
return this._products;
|
||||
|
@ -21,6 +21,10 @@ export const CatalogItemGridWidgetView: FC<CatalogItemGridWidgetViewProps> = pro
|
||||
|
||||
const selectOffer = (offer: IPurchasableOffer) =>
|
||||
{
|
||||
offer.activate();
|
||||
|
||||
if(offer.isLazy) return;
|
||||
|
||||
setCurrentOffer(offer);
|
||||
|
||||
if(offer.product && (offer.product.productType === ProductTypeEnum.WALL))
|
||||
@ -31,10 +35,7 @@ export const CatalogItemGridWidgetView: FC<CatalogItemGridWidgetViewProps> = pro
|
||||
|
||||
return (
|
||||
<AutoGrid columnCount={ columnCount } { ...rest }>
|
||||
{ currentPage.offers && (currentPage.offers.length > 0) && currentPage.offers.map((offer, index) =>
|
||||
{
|
||||
return <CatalogGridOfferView key={ index } itemActive={ (currentOffer && (currentOffer.offerId === offer.offerId)) } offer={ offer } onClick={ event => selectOffer(offer) } />;
|
||||
}) }
|
||||
{ currentPage.offers && (currentPage.offers.length > 0) && currentPage.offers.map((offer, index) => <CatalogGridOfferView key={ index } itemActive={ (currentOffer && (currentOffer.offerId === offer.offerId)) } offer={ offer } onClick={ event => selectOffer(offer) } />) }
|
||||
{ children }
|
||||
</AutoGrid>
|
||||
);
|
||||
|
@ -106,15 +106,15 @@ export const CatalogPurchaseWidgetView: FC<CatalogPurchaseWidgetViewProps> = pro
|
||||
|
||||
let pageId = currentOffer.page.pageId;
|
||||
|
||||
if(pageId === -1)
|
||||
{
|
||||
const nodes = getNodesByOfferId(currentOffer.offerId);
|
||||
// if(pageId === -1)
|
||||
// {
|
||||
// const nodes = getNodesByOfferId(currentOffer.offerId);
|
||||
|
||||
if(nodes) pageId = nodes[0].pageId;
|
||||
}
|
||||
// if(nodes) pageId = nodes[0].pageId;
|
||||
// }
|
||||
|
||||
SendMessageHook(new PurchaseFromCatalogComposer(pageId, currentOffer.offerId, extraData, quantity));
|
||||
}, [ currentOffer, purchaseCallback, extraData, quantity, getNodesByOfferId ]);
|
||||
}, [ currentOffer, purchaseCallback, extraData, quantity ]);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user