mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-27 08:00:51 +01:00
Catalog add gift configuration
This commit is contained in:
parent
9000756ae5
commit
58d78ebb58
@ -1,4 +1,4 @@
|
||||
import { CatalogApproveNameResultEvent, CatalogClubEvent, CatalogGroupsEvent, CatalogPageEvent, CatalogPagesEvent, CatalogPurchaseEvent, CatalogPurchaseFailedEvent, CatalogPurchaseUnavailableEvent, CatalogSearchEvent, CatalogSoldOutEvent, CatalogUpdatedEvent, SellablePetPalettesEvent, UserSubscriptionEvent } from 'nitro-renderer';
|
||||
import { CatalogApproveNameResultEvent, CatalogClubEvent, CatalogGiftConfigurationEvent, CatalogGroupsEvent, CatalogPageEvent, CatalogPagesEvent, CatalogPurchaseEvent, CatalogPurchaseFailedEvent, CatalogPurchaseUnavailableEvent, CatalogSearchEvent, CatalogSoldOutEvent, CatalogUpdatedEvent, SellablePetPalettesEvent, UserSubscriptionEvent } from 'nitro-renderer';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { CatalogNameResultEvent, CatalogPurchaseFailureEvent } from '../../events';
|
||||
import { CatalogPurchasedEvent } from '../../events/catalog/CatalogPurchasedEvent';
|
||||
@ -145,6 +145,20 @@ export const CatalogMessageHandler: FC<CatalogMessageHandlerProps> = props =>
|
||||
});
|
||||
}, [ dispatchCatalogState ]);
|
||||
|
||||
const onCatalogGiftConfigurationEvent = useCallback((event: CatalogGiftConfigurationEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
console.log(parser);
|
||||
|
||||
dispatchCatalogState({
|
||||
type: CatalogActions.SET_GIFT_CONFIGURATION,
|
||||
payload: {
|
||||
giftConfiguration: parser
|
||||
}
|
||||
});
|
||||
}, [ dispatchCatalogState ]);
|
||||
|
||||
CreateMessageHook(CatalogPagesEvent, onCatalogPagesEvent);
|
||||
CreateMessageHook(CatalogPageEvent, onCatalogPageEvent);
|
||||
CreateMessageHook(CatalogPurchaseEvent, onCatalogPurchaseEvent);
|
||||
@ -158,6 +172,7 @@ export const CatalogMessageHandler: FC<CatalogMessageHandlerProps> = props =>
|
||||
CreateMessageHook(CatalogClubEvent, onCatalogClubEvent);
|
||||
CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent);
|
||||
CreateMessageHook(CatalogUpdatedEvent, onCatalogUpdatedEvent);
|
||||
CreateMessageHook(CatalogGiftConfigurationEvent, onCatalogGiftConfigurationEvent);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CatalogModeComposer, ICatalogPageData, RoomPreviewer } from 'nitro-renderer';
|
||||
import { CatalogModeComposer, CatalogRequestGiftConfigurationComposer, ICatalogPageData, RoomPreviewer } from 'nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useReducer, useState } from 'react';
|
||||
import { GetRoomEngine } from '../../api';
|
||||
import { GetCatalogPageComposer } from '../../api/catalog/GetCatalogPageComposer';
|
||||
@ -49,6 +49,7 @@ export const CatalogView: FC<CatalogViewProps> = props =>
|
||||
if(!catalogState.root)
|
||||
{
|
||||
SendMessageHook(new CatalogModeComposer(CatalogMode.MODE_NORMAL));
|
||||
SendMessageHook(new CatalogRequestGiftConfigurationComposer());
|
||||
}
|
||||
}, [ isVisible, catalogState.root ]);
|
||||
|
||||
|
51
src/views/catalog/common/GiftWrappingConfiguration.ts
Normal file
51
src/views/catalog/common/GiftWrappingConfiguration.ts
Normal file
@ -0,0 +1,51 @@
|
||||
import { CatalogGiftConfigurationParser } from 'nitro-renderer';
|
||||
|
||||
export class GiftWrappingConfiguration
|
||||
{
|
||||
private _isEnabled: boolean = false;
|
||||
private _price: number = null;
|
||||
private _stuffTypes: number[] = null;
|
||||
private _boxTypes: number[] = null;
|
||||
private _ribbonTypes: number[] = null;
|
||||
private _defaultStuffTypes: number[] = null;
|
||||
|
||||
constructor(parser: CatalogGiftConfigurationParser)
|
||||
{
|
||||
this._isEnabled = parser.isEnabled;
|
||||
this._price = parser.price;
|
||||
this._boxTypes = parser.boxTypes;
|
||||
this._ribbonTypes = parser.ribbonTypes;
|
||||
this._stuffTypes = parser.giftWrappers;
|
||||
this._defaultStuffTypes = parser.giftFurnis;
|
||||
}
|
||||
|
||||
public get isEnabled(): boolean
|
||||
{
|
||||
return this._isEnabled;
|
||||
}
|
||||
|
||||
public get price(): number
|
||||
{
|
||||
return this._price;
|
||||
}
|
||||
|
||||
public get stuffTypes(): number[]
|
||||
{
|
||||
return this._stuffTypes;
|
||||
}
|
||||
|
||||
public get boxTypes(): number[]
|
||||
{
|
||||
return this._boxTypes;
|
||||
}
|
||||
|
||||
public get ribbonTypes(): number[]
|
||||
{
|
||||
return this._ribbonTypes;
|
||||
}
|
||||
|
||||
public get defaultStuffTypes(): number[]
|
||||
{
|
||||
return this._defaultStuffTypes;
|
||||
}
|
||||
}
|
@ -1,7 +1,8 @@
|
||||
import { CatalogClubOfferData, CatalogGroupData, CatalogPageOfferData, ICatalogPageData, ICatalogPageParser } from 'nitro-renderer';
|
||||
import { CatalogClubOfferData, CatalogGiftConfigurationParser, CatalogGroupData, CatalogPageOfferData, ICatalogPageData, ICatalogPageParser } from 'nitro-renderer';
|
||||
import { Reducer } from 'react';
|
||||
import { CatalogPetPalette } from '../common/CatalogPetPalette';
|
||||
import { ICatalogOffers, ICatalogSearchResult, SetOffersToNodes } from '../common/CatalogUtilities';
|
||||
import { GiftWrappingConfiguration } from '../common/GiftWrappingConfiguration';
|
||||
import { SubscriptionInfo } from '../common/SubscriptionInfo';
|
||||
|
||||
export interface ICatalogState
|
||||
@ -17,6 +18,7 @@ export interface ICatalogState
|
||||
petPalettes: CatalogPetPalette[];
|
||||
clubOffers: CatalogClubOfferData[];
|
||||
subscriptionInfo: SubscriptionInfo;
|
||||
giftConfiguration: GiftWrappingConfiguration;
|
||||
}
|
||||
|
||||
export interface ICatalogAction
|
||||
@ -34,6 +36,7 @@ export interface ICatalogAction
|
||||
petPalette?: CatalogPetPalette;
|
||||
clubOffers?: CatalogClubOfferData[];
|
||||
subscriptionInfo?: SubscriptionInfo;
|
||||
giftConfiguration?: CatalogGiftConfigurationParser;
|
||||
}
|
||||
}
|
||||
|
||||
@ -50,6 +53,7 @@ export class CatalogActions
|
||||
public static SET_PET_PALETTE: string = 'CA_SET_PET_PALETTE';
|
||||
public static SET_SEARCH_RESULT: string = 'CA_SET_SEARCH_RESULT';
|
||||
public static SET_SUBSCRIPTION_INFO: string = 'CA_SET_SUBSCRIPTION_INFO';
|
||||
public static SET_GIFT_CONFIGURATION: string = 'CA_SET_GIFT_CONFIGURATION';
|
||||
}
|
||||
|
||||
export const initialCatalog: ICatalogState = {
|
||||
@ -63,7 +67,8 @@ export const initialCatalog: ICatalogState = {
|
||||
groups: [],
|
||||
petPalettes: [],
|
||||
clubOffers: null,
|
||||
subscriptionInfo: new SubscriptionInfo()
|
||||
subscriptionInfo: new SubscriptionInfo(),
|
||||
giftConfiguration: null
|
||||
}
|
||||
|
||||
export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, action) =>
|
||||
@ -158,6 +163,11 @@ export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, ac
|
||||
case CatalogActions.RESET_STATE: {
|
||||
return { ...initialCatalog };
|
||||
}
|
||||
case CatalogActions.SET_GIFT_CONFIGURATION: {
|
||||
const giftConfiguration = new GiftWrappingConfiguration((action.payload.giftConfiguration || null));
|
||||
|
||||
return { ...state, giftConfiguration };
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user