mirror of
https://github.com/billsonnn/nitro-react.git
synced 2025-02-18 18:02:36 +01:00
Update catalog
This commit is contained in:
parent
ed2cc49253
commit
f55664c157
@ -1,4 +1,4 @@
|
||||
import { GetCatalogIndexComposer, GetCatalogPageComposer, GetGiftWrappingConfigurationComposer, ICatalogPageData, ILinkEventTracker, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { GetCatalogIndexComposer, GetCatalogPageComposer, GetGiftWrappingConfigurationComposer, ILinkEventTracker, INodeData, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useReducer, useState } from 'react';
|
||||
import { AddEventLinkTracker, GetRoomEngine, LocalizeText, RemoveLinkEventTracker } from '../../api';
|
||||
import { CatalogEvent } from '../../events';
|
||||
@ -18,10 +18,10 @@ export const CatalogView: FC<CatalogViewProps> = props =>
|
||||
const [ isVisible, setIsVisible ] = useState(false);
|
||||
const [ roomPreviewer, setRoomPreviewer ] = useState<RoomPreviewer>(null);
|
||||
const [ pendingPageLookup, setPendingPageLookup ] = useState<{ value: string, isOffer: boolean }>(null);
|
||||
const [ pendingTree, setPendingTree ] = useState<ICatalogPageData[]>(null);
|
||||
const [ pendingOpenTree, setPendingOpenTree ] = useState<ICatalogPageData[]>(null);
|
||||
const [ pendingTree, setPendingTree ] = useState<INodeData[]>(null);
|
||||
const [ pendingOpenTree, setPendingOpenTree ] = useState<INodeData[]>(null);
|
||||
const [ catalogState, dispatchCatalogState ] = useReducer(CatalogReducer, initialCatalog);
|
||||
const [ currentTab, setCurrentTab ] = useState<ICatalogPageData>(null);
|
||||
const [ currentTab, setCurrentTab ] = useState<INodeData>(null);
|
||||
const { root = null, pageParser = null, activeOffer = null, searchResult = null } = catalogState;
|
||||
|
||||
const saveActivePages = useCallback(() =>
|
||||
@ -124,7 +124,7 @@ export const CatalogView: FC<CatalogViewProps> = props =>
|
||||
|
||||
if(pendingPageLookup !== null || pendingOpenTree)
|
||||
{
|
||||
let tree: ICatalogPageData[] = [];
|
||||
let tree: INodeData[] = [];
|
||||
|
||||
if(pendingPageLookup !== null)
|
||||
{
|
||||
|
@ -1,14 +1,14 @@
|
||||
import { CatalogPageMessageOfferData, ICatalogPageData, ICatalogPageParser, IFurnitureData, SellablePetPaletteData } from '@nitrots/nitro-renderer';
|
||||
import { CatalogPageMessageOfferData, CatalogPageMessageParser, IFurnitureData, INodeData, SellablePetPaletteData } from '@nitrots/nitro-renderer';
|
||||
import { GetConfiguration, GetProductDataForLocalization, GetRoomEngine } from '../../../api';
|
||||
|
||||
export interface ICatalogOffers
|
||||
{
|
||||
[key: string]: ICatalogPageData[];
|
||||
[key: string]: INodeData[];
|
||||
}
|
||||
|
||||
export interface ICatalogSearchResult
|
||||
{
|
||||
page: ICatalogPageData;
|
||||
page: INodeData;
|
||||
furniture: IFurnitureData[];
|
||||
}
|
||||
|
||||
@ -21,10 +21,10 @@ export function GetOfferName(offer: CatalogPageMessageOfferData): string
|
||||
return offer.localizationId;
|
||||
}
|
||||
|
||||
export function GetOfferNodes(offers: ICatalogOffers, offerId: number): ICatalogPageData[]
|
||||
export function GetOfferNodes(offers: ICatalogOffers, offerId: number): INodeData[]
|
||||
{
|
||||
const pages = offers[offerId.toString()];
|
||||
const allowedPages: ICatalogPageData[] = [];
|
||||
const allowedPages: INodeData[] = [];
|
||||
|
||||
if(pages && pages.length)
|
||||
{
|
||||
@ -39,7 +39,7 @@ export function GetOfferNodes(offers: ICatalogOffers, offerId: number): ICatalog
|
||||
return allowedPages;
|
||||
}
|
||||
|
||||
export function SetOffersToNodes(offers: ICatalogOffers, pageData: ICatalogPageData): void
|
||||
export function SetOffersToNodes(offers: ICatalogOffers, pageData: INodeData): void
|
||||
{
|
||||
if(pageData.offerIds && pageData.offerIds.length)
|
||||
{
|
||||
@ -66,7 +66,7 @@ export function SetOffersToNodes(offers: ICatalogOffers, pageData: ICatalogPageD
|
||||
}
|
||||
}
|
||||
|
||||
export function GetCatalogPageImage(page: ICatalogPageParser, index: number = 0): string
|
||||
export function GetCatalogPageImage(page: CatalogPageMessageParser, index: number = 0): string
|
||||
{
|
||||
const imageName = page.localization.images && page.localization.images[index];
|
||||
|
||||
@ -79,7 +79,7 @@ export function GetCatalogPageImage(page: ICatalogPageParser, index: number = 0)
|
||||
return assetUrl;
|
||||
}
|
||||
|
||||
export function GetCatalogPageText(page: ICatalogPageParser, index: number = 0): string
|
||||
export function GetCatalogPageText(page: CatalogPageMessageParser, index: number = 0): string
|
||||
{
|
||||
let message = (page.localization.texts[index] || '');
|
||||
|
||||
@ -150,7 +150,7 @@ export function GetPetAvailableColors(petIndex: number, palettes: SellablePetPal
|
||||
}
|
||||
}
|
||||
|
||||
export function GetCatalogPageTreeByName(page: ICatalogPageData, lookup: string, tree: ICatalogPageData[])
|
||||
export function GetCatalogPageTreeByName(page: INodeData, lookup: string, tree: INodeData[])
|
||||
{
|
||||
if(page.pageName === lookup) return page;
|
||||
|
||||
@ -167,7 +167,7 @@ export function GetCatalogPageTreeByName(page: ICatalogPageData, lookup: string,
|
||||
}
|
||||
}
|
||||
|
||||
export function GetCatalogPageTreeById(page: ICatalogPageData, lookup: number, tree: ICatalogPageData[])
|
||||
export function GetCatalogPageTreeById(page: INodeData, lookup: number, tree: INodeData[])
|
||||
{
|
||||
if(page.pageId === lookup) return page;
|
||||
|
||||
@ -184,7 +184,7 @@ export function GetCatalogPageTreeById(page: ICatalogPageData, lookup: number, t
|
||||
}
|
||||
}
|
||||
|
||||
export function GetCatalogPageTreeByOfferId(page: ICatalogPageData, lookup: number, tree: ICatalogPageData[])
|
||||
export function GetCatalogPageTreeByOfferId(page: INodeData, lookup: number, tree: INodeData[])
|
||||
{
|
||||
if(page.offerIds.indexOf(lookup) >= 0) return page;
|
||||
|
||||
@ -201,9 +201,9 @@ export function GetCatalogPageTreeByOfferId(page: ICatalogPageData, lookup: numb
|
||||
}
|
||||
}
|
||||
|
||||
export function BuildCatalogPageTree(page: ICatalogPageData, lookup: string, isOffer: boolean = false)
|
||||
export function BuildCatalogPageTree(page: INodeData, lookup: string, isOffer: boolean = false)
|
||||
{
|
||||
const pageTree: ICatalogPageData[] = [];
|
||||
const pageTree: INodeData[] = [];
|
||||
|
||||
if(isOffer)
|
||||
{
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { CatalogGroupData, CatalogPageMessageOfferData, ClubOfferData, GiftWrappingConfigurationParser, ICatalogPageData, ICatalogPageParser } from '@nitrots/nitro-renderer';
|
||||
import { CatalogPageMessageOfferData, CatalogPageMessageParser, ClubOfferData, GiftWrappingConfigurationParser, INodeData } from '@nitrots/nitro-renderer';
|
||||
import { HabboGroupEntryData } from '@nitrots/nitro-renderer/src/nitro/communication/messages/parser/user/HabboGroupEntryData';
|
||||
import { Reducer } from 'react';
|
||||
import { CatalogPetPalette } from '../common/CatalogPetPalette';
|
||||
import { ICatalogOffers, ICatalogSearchResult, SetOffersToNodes } from '../common/CatalogUtilities';
|
||||
@ -7,13 +8,13 @@ import { SubscriptionInfo } from '../common/SubscriptionInfo';
|
||||
|
||||
export interface ICatalogState
|
||||
{
|
||||
root: ICatalogPageData;
|
||||
root: INodeData;
|
||||
offerRoot: ICatalogOffers;
|
||||
currentTab: ICatalogPageData;
|
||||
pageParser: ICatalogPageParser;
|
||||
currentTab: INodeData;
|
||||
pageParser: CatalogPageMessageParser;
|
||||
activeOffer: CatalogPageMessageOfferData;
|
||||
searchResult: ICatalogSearchResult;
|
||||
groups: CatalogGroupData[];
|
||||
groups: HabboGroupEntryData[];
|
||||
petPalettes: CatalogPetPalette[];
|
||||
clubOffers: ClubOfferData[];
|
||||
subscriptionInfo: SubscriptionInfo;
|
||||
@ -24,13 +25,13 @@ export interface ICatalogAction
|
||||
{
|
||||
type: string;
|
||||
payload: {
|
||||
root?: ICatalogPageData;
|
||||
root?: INodeData;
|
||||
offerRoot?: ICatalogOffers;
|
||||
currentTab?: ICatalogPageData;
|
||||
pageParser?: ICatalogPageParser;
|
||||
currentTab?: INodeData;
|
||||
pageParser?: CatalogPageMessageParser;
|
||||
activeOffer?: CatalogPageMessageOfferData;
|
||||
searchResult?: ICatalogSearchResult;
|
||||
groups?: CatalogGroupData[];
|
||||
groups?: HabboGroupEntryData[];
|
||||
petPalette?: CatalogPetPalette;
|
||||
clubOffers?: ClubOfferData[];
|
||||
subscriptionInfo?: SubscriptionInfo;
|
||||
@ -88,7 +89,7 @@ export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, ac
|
||||
return { ...state, currentTab, searchResult };
|
||||
}
|
||||
case CatalogActions.SET_CATALOG_PAGE_PARSER: {
|
||||
let pageParser = (Object.create(action.payload.pageParser) as ICatalogPageParser);
|
||||
let pageParser = (Object.create(action.payload.pageParser) as CatalogPageMessageParser);
|
||||
let activeOffer = null;
|
||||
|
||||
if(pageParser.layoutCode === 'single_bundle')
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { ICatalogPageData } from '@nitrots/nitro-renderer';
|
||||
import { INodeData } from '@nitrots/nitro-renderer';
|
||||
import { FC, useEffect } from 'react';
|
||||
import { CatalogSearchView } from '../search/CatalogSearchView';
|
||||
import { CatalogNavigationViewProps } from './CatalogNavigationView.types';
|
||||
import { CatalogNavigationSetView } from './set/CatalogNavigationSetView';
|
||||
|
||||
export let ACTIVE_PAGES: ICatalogPageData[] = [];
|
||||
export let ACTIVE_PAGES: INodeData[] = [];
|
||||
|
||||
export const CatalogNavigationView: FC<CatalogNavigationViewProps> = props =>
|
||||
{
|
||||
|
@ -1,9 +1,9 @@
|
||||
import { ICatalogPageData } from '@nitrots/nitro-renderer';
|
||||
import { INodeData } from '@nitrots/nitro-renderer';
|
||||
import { Dispatch, SetStateAction } from 'react';
|
||||
|
||||
export interface CatalogNavigationViewProps
|
||||
{
|
||||
page: ICatalogPageData;
|
||||
pendingTree: ICatalogPageData[];
|
||||
setPendingTree: Dispatch<SetStateAction<ICatalogPageData[]>>;
|
||||
page: INodeData;
|
||||
pendingTree: INodeData[];
|
||||
setPendingTree: Dispatch<SetStateAction<INodeData[]>>;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { GetCatalogPageComposer, ICatalogPageData } from '@nitrots/nitro-renderer';
|
||||
import { GetCatalogPageComposer, INodeData } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { SendMessageHook } from '../../../../../hooks/messages/message-event';
|
||||
import { CatalogMode } from '../../../CatalogView.types';
|
||||
@ -12,7 +12,7 @@ export const CatalogNavigationItemView: FC<CatalogNavigationItemViewProps> = pro
|
||||
const { page = null, isActive = false, pendingTree = null, setPendingTree = null, setActiveChild = null } = props;
|
||||
const [ isExpanded, setIsExpanded ] = useState(false);
|
||||
|
||||
const select = useCallback((selectPage: ICatalogPageData, expand: boolean = false) =>
|
||||
const select = useCallback((selectPage: INodeData, expand: boolean = false) =>
|
||||
{
|
||||
if(!selectPage) return;
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
import { ICatalogPageData } from '@nitrots/nitro-renderer';
|
||||
import { INodeData } from '@nitrots/nitro-renderer';
|
||||
import { Dispatch, SetStateAction } from 'react';
|
||||
|
||||
export interface CatalogNavigationItemViewProps
|
||||
{
|
||||
page: ICatalogPageData;
|
||||
page: INodeData;
|
||||
isActive: boolean;
|
||||
pendingTree: ICatalogPageData[];
|
||||
setPendingTree: Dispatch<SetStateAction<ICatalogPageData[]>>;
|
||||
setActiveChild: Dispatch<SetStateAction<ICatalogPageData>>;
|
||||
pendingTree: INodeData[];
|
||||
setPendingTree: Dispatch<SetStateAction<INodeData[]>>;
|
||||
setActiveChild: Dispatch<SetStateAction<INodeData>>;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ICatalogPageData } from '@nitrots/nitro-renderer';
|
||||
import { INodeData } from '@nitrots/nitro-renderer';
|
||||
import { FC, useEffect, useState } from 'react';
|
||||
import { CatalogNavigationItemView } from '../item/CatalogNavigationItemView';
|
||||
import { CatalogNavigationSetViewProps } from './CatalogNavigationSetView.types';
|
||||
@ -6,7 +6,7 @@ import { CatalogNavigationSetViewProps } from './CatalogNavigationSetView.types'
|
||||
export const CatalogNavigationSetView: FC<CatalogNavigationSetViewProps> = props =>
|
||||
{
|
||||
const { page = null, isFirstSet = false, pendingTree = null, setPendingTree = null } = props;
|
||||
const [ activeChild, setActiveChild ] = useState<ICatalogPageData>(null);
|
||||
const [ activeChild, setActiveChild ] = useState<INodeData>(null);
|
||||
|
||||
useEffect(() =>
|
||||
{
|
||||
|
@ -1,10 +1,10 @@
|
||||
import { ICatalogPageData } from '@nitrots/nitro-renderer';
|
||||
import { INodeData } from '@nitrots/nitro-renderer';
|
||||
import { Dispatch, SetStateAction } from 'react';
|
||||
|
||||
export interface CatalogNavigationSetViewProps
|
||||
{
|
||||
page: ICatalogPageData;
|
||||
page: INodeData;
|
||||
isFirstSet?: boolean;
|
||||
pendingTree: ICatalogPageData[];
|
||||
setPendingTree: Dispatch<SetStateAction<ICatalogPageData[]>>;
|
||||
pendingTree: INodeData[];
|
||||
setPendingTree: Dispatch<SetStateAction<INodeData[]>>;
|
||||
}
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { ICatalogPageParser, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { CatalogPageMessageParser, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
|
||||
export interface CatalogLayoutProps
|
||||
{
|
||||
roomPreviewer: RoomPreviewer;
|
||||
pageParser?: ICatalogPageParser;
|
||||
pageParser?: CatalogPageMessageParser;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ICatalogPageParser, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { CatalogPageMessageParser, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { CatalogLayoutBadgeDisplayView } from './badge-display/CatalogLayoutBadgeDisplayView';
|
||||
import { CatalogLayoutDefaultView } from './default/CatalogLayoutDefaultView';
|
||||
import { CatalogLayoutFrontpage4View } from './frontpage4/CatalogLayoutFrontpage4View';
|
||||
@ -13,7 +13,7 @@ import { CatalogLayoutSpacesView } from './spaces-new/CatalogLayoutSpacesView';
|
||||
import { CatalogLayoutTrophiesView } from './trophies/CatalogLayoutTrophiesView';
|
||||
import { CatalogLayoutVipBuyView } from './vip-buy/CatalogLayoutVipBuyView';
|
||||
|
||||
export const GetCatalogLayout = (pageParser: ICatalogPageParser, roomPreviewer: RoomPreviewer) =>
|
||||
export const GetCatalogLayout = (pageParser: CatalogPageMessageParser, roomPreviewer: RoomPreviewer) =>
|
||||
{
|
||||
switch(pageParser.layoutCode)
|
||||
{
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { ICatalogPageData, IFurnitureData } from '@nitrots/nitro-renderer';
|
||||
import { IFurnitureData, INodeData } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useState } from 'react';
|
||||
import { GetSessionDataManager, LocalizeText } from '../../../../api';
|
||||
import { GetOfferNodes } from '../../common/CatalogUtilities';
|
||||
@ -44,7 +44,7 @@ export const CatalogSearchView: FC<CatalogSearchViewProps> = props =>
|
||||
|
||||
if(!furnitureData) return;
|
||||
|
||||
const foundPages: ICatalogPageData[] = [];
|
||||
const foundPages: INodeData[] = [];
|
||||
const foundFurniture: IFurnitureData[] = [];
|
||||
|
||||
for(const furniture of furnitureData)
|
||||
@ -71,7 +71,7 @@ export const CatalogSearchView: FC<CatalogSearchViewProps> = props =>
|
||||
return (self.indexOf(value) === index);
|
||||
});
|
||||
|
||||
const catalogPage: ICatalogPageData = {
|
||||
const catalogPage: INodeData = {
|
||||
visible: true,
|
||||
icon: 0,
|
||||
pageId: -1,
|
||||
|
@ -18,7 +18,6 @@ export const InventoryBadgeView: FC<InventoryBadgeViewProps> = props =>
|
||||
{
|
||||
if(needsBadgeUpdate)
|
||||
{
|
||||
console.log('yee')
|
||||
dispatchBadgeState({
|
||||
type: InventoryBadgeActions.SET_NEEDS_UPDATE,
|
||||
payload: {
|
||||
|
Loading…
x
Reference in New Issue
Block a user