Catalog add gift configuration

This commit is contained in:
Bill 2021-07-17 13:11:47 -04:00
parent 9000756ae5
commit 58d78ebb58
4 changed files with 81 additions and 4 deletions

View File

@ -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 { FC, useCallback } from 'react';
import { CatalogNameResultEvent, CatalogPurchaseFailureEvent } from '../../events'; import { CatalogNameResultEvent, CatalogPurchaseFailureEvent } from '../../events';
import { CatalogPurchasedEvent } from '../../events/catalog/CatalogPurchasedEvent'; import { CatalogPurchasedEvent } from '../../events/catalog/CatalogPurchasedEvent';
@ -145,6 +145,20 @@ export const CatalogMessageHandler: FC<CatalogMessageHandlerProps> = props =>
}); });
}, [ dispatchCatalogState ]); }, [ 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(CatalogPagesEvent, onCatalogPagesEvent);
CreateMessageHook(CatalogPageEvent, onCatalogPageEvent); CreateMessageHook(CatalogPageEvent, onCatalogPageEvent);
CreateMessageHook(CatalogPurchaseEvent, onCatalogPurchaseEvent); CreateMessageHook(CatalogPurchaseEvent, onCatalogPurchaseEvent);
@ -158,6 +172,7 @@ export const CatalogMessageHandler: FC<CatalogMessageHandlerProps> = props =>
CreateMessageHook(CatalogClubEvent, onCatalogClubEvent); CreateMessageHook(CatalogClubEvent, onCatalogClubEvent);
CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent); CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent);
CreateMessageHook(CatalogUpdatedEvent, onCatalogUpdatedEvent); CreateMessageHook(CatalogUpdatedEvent, onCatalogUpdatedEvent);
CreateMessageHook(CatalogGiftConfigurationEvent, onCatalogGiftConfigurationEvent);
return null; return null;
} }

View File

@ -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 { FC, useCallback, useEffect, useReducer, useState } from 'react';
import { GetRoomEngine } from '../../api'; import { GetRoomEngine } from '../../api';
import { GetCatalogPageComposer } from '../../api/catalog/GetCatalogPageComposer'; import { GetCatalogPageComposer } from '../../api/catalog/GetCatalogPageComposer';
@ -49,6 +49,7 @@ export const CatalogView: FC<CatalogViewProps> = props =>
if(!catalogState.root) if(!catalogState.root)
{ {
SendMessageHook(new CatalogModeComposer(CatalogMode.MODE_NORMAL)); SendMessageHook(new CatalogModeComposer(CatalogMode.MODE_NORMAL));
SendMessageHook(new CatalogRequestGiftConfigurationComposer());
} }
}, [ isVisible, catalogState.root ]); }, [ isVisible, catalogState.root ]);

View 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;
}
}

View File

@ -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 { Reducer } from 'react';
import { CatalogPetPalette } from '../common/CatalogPetPalette'; import { CatalogPetPalette } from '../common/CatalogPetPalette';
import { ICatalogOffers, ICatalogSearchResult, SetOffersToNodes } from '../common/CatalogUtilities'; import { ICatalogOffers, ICatalogSearchResult, SetOffersToNodes } from '../common/CatalogUtilities';
import { GiftWrappingConfiguration } from '../common/GiftWrappingConfiguration';
import { SubscriptionInfo } from '../common/SubscriptionInfo'; import { SubscriptionInfo } from '../common/SubscriptionInfo';
export interface ICatalogState export interface ICatalogState
@ -17,6 +18,7 @@ export interface ICatalogState
petPalettes: CatalogPetPalette[]; petPalettes: CatalogPetPalette[];
clubOffers: CatalogClubOfferData[]; clubOffers: CatalogClubOfferData[];
subscriptionInfo: SubscriptionInfo; subscriptionInfo: SubscriptionInfo;
giftConfiguration: GiftWrappingConfiguration;
} }
export interface ICatalogAction export interface ICatalogAction
@ -34,6 +36,7 @@ export interface ICatalogAction
petPalette?: CatalogPetPalette; petPalette?: CatalogPetPalette;
clubOffers?: CatalogClubOfferData[]; clubOffers?: CatalogClubOfferData[];
subscriptionInfo?: SubscriptionInfo; subscriptionInfo?: SubscriptionInfo;
giftConfiguration?: CatalogGiftConfigurationParser;
} }
} }
@ -50,6 +53,7 @@ export class CatalogActions
public static SET_PET_PALETTE: string = 'CA_SET_PET_PALETTE'; public static SET_PET_PALETTE: string = 'CA_SET_PET_PALETTE';
public static SET_SEARCH_RESULT: string = 'CA_SET_SEARCH_RESULT'; public static SET_SEARCH_RESULT: string = 'CA_SET_SEARCH_RESULT';
public static SET_SUBSCRIPTION_INFO: string = 'CA_SET_SUBSCRIPTION_INFO'; public static SET_SUBSCRIPTION_INFO: string = 'CA_SET_SUBSCRIPTION_INFO';
public static SET_GIFT_CONFIGURATION: string = 'CA_SET_GIFT_CONFIGURATION';
} }
export const initialCatalog: ICatalogState = { export const initialCatalog: ICatalogState = {
@ -63,7 +67,8 @@ export const initialCatalog: ICatalogState = {
groups: [], groups: [],
petPalettes: [], petPalettes: [],
clubOffers: null, clubOffers: null,
subscriptionInfo: new SubscriptionInfo() subscriptionInfo: new SubscriptionInfo(),
giftConfiguration: null
} }
export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, action) => export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, action) =>
@ -158,6 +163,11 @@ export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, ac
case CatalogActions.RESET_STATE: { case CatalogActions.RESET_STATE: {
return { ...initialCatalog }; return { ...initialCatalog };
} }
case CatalogActions.SET_GIFT_CONFIGURATION: {
const giftConfiguration = new GiftWrappingConfiguration((action.payload.giftConfiguration || null));
return { ...state, giftConfiguration };
}
default: default:
return state; return state;
} }