mirror of
https://github.com/billsonnn/nitro-react.git
synced 2024-11-26 23:50:52 +01:00
Merge branch 'feature/marketplace' into more-layout-changes
This commit is contained in:
commit
9a2a9df3b1
@ -1,12 +1,15 @@
|
||||
import { ApproveNameMessageEvent, CatalogPageMessageEvent, CatalogPagesListEvent, CatalogPublishedMessageEvent, GiftReceiverNotFoundEvent, GiftWrappingConfigurationEvent, HabboClubOffersMessageEvent, LimitedEditionSoldOutEvent, ProductOfferEvent, PurchaseErrorMessageEvent, PurchaseNotAllowedMessageEvent, PurchaseOKMessageEvent, SellablePetPalettesMessageEvent, UserSubscriptionEvent } from '@nitrots/nitro-renderer';
|
||||
import { ApproveNameMessageEvent, CatalogPageMessageEvent, CatalogPagesListEvent, CatalogPublishedMessageEvent, GiftReceiverNotFoundEvent, GiftWrappingConfigurationEvent, HabboClubOffersMessageEvent, LimitedEditionSoldOutEvent, MarketplaceConfigurationEvent, MarketplaceMakeOfferResult, ProductOfferEvent, PurchaseErrorMessageEvent, PurchaseNotAllowedMessageEvent, PurchaseOKMessageEvent, SellablePetPalettesMessageEvent, UserSubscriptionEvent } from '@nitrots/nitro-renderer';
|
||||
import { GuildMembershipsMessageEvent } from '@nitrots/nitro-renderer/src/nitro/communication/messages/incoming/user/GuildMembershipsMessageEvent';
|
||||
import { FC, useCallback } from 'react';
|
||||
import { LocalizeText } from '../../api';
|
||||
import { CatalogNameResultEvent, CatalogPurchaseFailureEvent } from '../../events';
|
||||
import { CatalogGiftReceiverNotFoundEvent } from '../../events/catalog/CatalogGiftReceiverNotFoundEvent';
|
||||
import { CatalogPurchasedEvent } from '../../events/catalog/CatalogPurchasedEvent';
|
||||
import { CatalogPurchaseSoldOutEvent } from '../../events/catalog/CatalogPurchaseSoldOutEvent';
|
||||
import { dispatchUiEvent } from '../../hooks/events/ui/ui-event';
|
||||
import { CreateMessageHook } from '../../hooks/messages/message-event';
|
||||
import { NotificationAlertType } from '../../views/notification-center/common/NotificationAlertType';
|
||||
import { NotificationUtilities } from '../../views/notification-center/common/NotificationUtilities';
|
||||
import { CatalogPetPalette } from './common/CatalogPetPalette';
|
||||
import { SubscriptionInfo } from './common/SubscriptionInfo';
|
||||
import { useCatalogContext } from './context/CatalogContext';
|
||||
@ -163,6 +166,43 @@ export const CatalogMessageHandler: FC<{}> = props =>
|
||||
});
|
||||
}, [ dispatchCatalogState ]);
|
||||
|
||||
const onMarketplaceMakeOfferResult = useCallback((event: MarketplaceMakeOfferResult) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
let title = '';
|
||||
if(parser.result === 1)
|
||||
{
|
||||
title = LocalizeText('inventory.marketplace.result.title.success');
|
||||
}
|
||||
else
|
||||
{
|
||||
title = LocalizeText('inventory.marketplace.result.title.failure');
|
||||
}
|
||||
|
||||
const message = LocalizeText(`inventory.marketplace.result.${parser.result}`);
|
||||
|
||||
NotificationUtilities.simpleAlert(message, NotificationAlertType.DEFAULT, null, null, title);
|
||||
}, []);
|
||||
|
||||
const onMarketplaceConfigurationEvent = useCallback((event: MarketplaceConfigurationEvent) =>
|
||||
{
|
||||
const parser = event.getParser();
|
||||
|
||||
if(!parser) return;
|
||||
|
||||
console.log(parser);
|
||||
|
||||
dispatchCatalogState({
|
||||
type: CatalogActions.SET_MARKETPLACE_CONFIGURATION,
|
||||
payload: {
|
||||
marketplaceConfiguration: parser
|
||||
}
|
||||
});
|
||||
}, [dispatchCatalogState]);
|
||||
|
||||
CreateMessageHook(CatalogPagesListEvent, onCatalogPagesListEvent);
|
||||
CreateMessageHook(CatalogPageMessageEvent, onCatalogPageMessageEvent);
|
||||
CreateMessageHook(PurchaseOKMessageEvent, onPurchaseOKMessageEvent);
|
||||
@ -178,6 +218,8 @@ export const CatalogMessageHandler: FC<{}> = props =>
|
||||
CreateMessageHook(UserSubscriptionEvent, onUserSubscriptionEvent);
|
||||
CreateMessageHook(CatalogPublishedMessageEvent, onCatalogPublishedMessageEvent);
|
||||
CreateMessageHook(GiftWrappingConfigurationEvent, onGiftWrappingConfigurationEvent);
|
||||
CreateMessageHook(MarketplaceMakeOfferResult, onMarketplaceMakeOfferResult);
|
||||
CreateMessageHook(MarketplaceConfigurationEvent, onMarketplaceConfigurationEvent);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
@ -1,10 +1,11 @@
|
||||
import { GetCatalogIndexComposer, GetCatalogPageComposer, GetGiftWrappingConfigurationComposer, ILinkEventTracker, INodeData, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { GetCatalogIndexComposer, GetCatalogPageComposer, GetGiftWrappingConfigurationComposer, GetMarketplaceConfigurationMessageComposer, ILinkEventTracker, INodeData, RoomPreviewer } from '@nitrots/nitro-renderer';
|
||||
import { FC, useCallback, useEffect, useReducer, useState } from 'react';
|
||||
import { AddEventLinkTracker, GetRoomEngine, LocalizeText, RemoveLinkEventTracker } from '../../api';
|
||||
import { CREDITS, PlaySound } from '../../api/utils/PlaySound';
|
||||
import { Column } from '../../common/Column';
|
||||
import { Grid } from '../../common/Grid';
|
||||
import { CatalogEvent } from '../../events';
|
||||
import { UseMountEffect } from '../../hooks';
|
||||
import { useUiEvent } from '../../hooks/events/ui/ui-event';
|
||||
import { SendMessageHook } from '../../hooks/messages/message-event';
|
||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardTabsItemView, NitroCardTabsView, NitroCardView } from '../../layout';
|
||||
@ -117,7 +118,6 @@ export const CatalogView: FC<{}> = props =>
|
||||
if(loadCatalog)
|
||||
{
|
||||
SendMessageHook(new GetCatalogIndexComposer(CatalogMode.MODE_NORMAL));
|
||||
SendMessageHook(new GetGiftWrappingConfigurationComposer());
|
||||
|
||||
return;
|
||||
}
|
||||
@ -191,6 +191,12 @@ export const CatalogView: FC<{}> = props =>
|
||||
}
|
||||
}, []);
|
||||
|
||||
UseMountEffect(() =>
|
||||
{
|
||||
SendMessageHook(new GetMarketplaceConfigurationMessageComposer());
|
||||
SendMessageHook(new GetGiftWrappingConfigurationComposer());
|
||||
});
|
||||
|
||||
const currentNavigationPage = ((searchResult && searchResult.page) || currentTab);
|
||||
const navigationHidden = !!(pageParser && pageParser.frontPageItems.length);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
import { CatalogPageMessageOfferData, CatalogPageMessageParser, ClubOfferData, GiftWrappingConfigurationParser, INodeData } from '@nitrots/nitro-renderer';
|
||||
import { CatalogPageMessageOfferData, CatalogPageMessageParser, ClubOfferData, GiftWrappingConfigurationParser, INodeData, MarketplaceConfigurationMessageParser } 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';
|
||||
@ -19,6 +19,7 @@ export interface ICatalogState
|
||||
clubOffers: ClubOfferData[];
|
||||
subscriptionInfo: SubscriptionInfo;
|
||||
giftConfiguration: GiftWrappingConfiguration;
|
||||
marketplaceConfiguration: MarketplaceConfigurationMessageParser;
|
||||
}
|
||||
|
||||
export interface ICatalogAction
|
||||
@ -36,6 +37,7 @@ export interface ICatalogAction
|
||||
clubOffers?: ClubOfferData[];
|
||||
subscriptionInfo?: SubscriptionInfo;
|
||||
giftConfiguration?: GiftWrappingConfigurationParser;
|
||||
marketplaceConfiguration?: MarketplaceConfigurationMessageParser;
|
||||
}
|
||||
}
|
||||
|
||||
@ -52,6 +54,7 @@ export class CatalogActions
|
||||
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';
|
||||
public static SET_MARKETPLACE_CONFIGURATION: string = 'CA_SET_MARKETPLACE_CONFIGURATION';
|
||||
}
|
||||
|
||||
export const initialCatalog: ICatalogState = {
|
||||
@ -65,7 +68,8 @@ export const initialCatalog: ICatalogState = {
|
||||
petPalettes: [],
|
||||
clubOffers: null,
|
||||
subscriptionInfo: new SubscriptionInfo(),
|
||||
giftConfiguration: null
|
||||
giftConfiguration: null,
|
||||
marketplaceConfiguration: null
|
||||
}
|
||||
|
||||
export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, action) =>
|
||||
@ -160,6 +164,11 @@ export const CatalogReducer: Reducer<ICatalogState, ICatalogAction> = (state, ac
|
||||
|
||||
return { ...state, giftConfiguration };
|
||||
}
|
||||
case CatalogActions.SET_MARKETPLACE_CONFIGURATION: {
|
||||
let marketplaceConfiguration = (action.payload.marketplaceConfiguration || state.marketplaceConfiguration || null);
|
||||
|
||||
return { ...state, marketplaceConfiguration }
|
||||
}
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
|
@ -6,11 +6,13 @@ import { SendMessageHook, useUiEvent } from '../../../../../../../hooks';
|
||||
import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutFlex } from '../../../../../../../layout';
|
||||
import { NotificationUtilities } from '../../../../../../../views/notification-center/common/NotificationUtilities';
|
||||
import { FurnitureItem } from '../../../../../../inventory/common/FurnitureItem';
|
||||
import { useCatalogContext } from '../../../../../context/CatalogContext';
|
||||
|
||||
export const MarketplacePostOfferView : FC<{}> = props =>
|
||||
{
|
||||
const [ item, setItem ] = useState<FurnitureItem>(null);
|
||||
const [ askingPrice, setAskingPrice ] = useState(0);
|
||||
const { catalogState = null, dispatchCatalogState = null } = useCatalogContext();
|
||||
|
||||
const close = useCallback(() =>
|
||||
{
|
||||
@ -91,17 +93,21 @@ export const MarketplacePostOfferView : FC<{}> = props =>
|
||||
</div>
|
||||
</NitroLayoutFlex>
|
||||
<div className='mx-2 fst-italic text-break mb-3'>
|
||||
{ LocalizeText('inventory.marketplace.make_offer.expiration_info') }
|
||||
{ LocalizeText('inventory.marketplace.make_offer.expiration_info', ['time'], [catalogState.marketplaceConfiguration.offerTime.toString()]) }
|
||||
</div>
|
||||
<div className="d-flex flex-row text-black mb-3">
|
||||
<div className="mr-2 align-self-center fw-bold" style={ { whiteSpace: 'nowrap' } }>{ LocalizeText('inventory.marketplace.make_offer.price_request') }</div>
|
||||
<input className="form-control form-control-sm" type="number" min={0} value={ askingPrice } onChange={ event => setAskingPrice(event.target.valueAsNumber) } />
|
||||
</div>
|
||||
<div className="alert alert-light" role="alert">
|
||||
{ askingPrice <= 0 || isNaN(askingPrice) ? LocalizeText('inventory.marketplace.make_offer.min_price', ['minprice'], ['1']) : LocalizeText('inventory.marketplace.make_offer.final_price', ['commission', 'finalprice'], ['1', (askingPrice + 1).toString()])}
|
||||
{ (askingPrice < catalogState.marketplaceConfiguration.minimumPrice || isNaN(askingPrice)) && LocalizeText('inventory.marketplace.make_offer.min_price', ['minprice'], [catalogState.marketplaceConfiguration.minimumPrice.toString()]) }
|
||||
{ askingPrice > catalogState.marketplaceConfiguration.maximumPrice && !isNaN(askingPrice) &&
|
||||
LocalizeText('inventory.marketplace.make_offer.max_price', ['maxprice'], [catalogState.marketplaceConfiguration.maximumPrice.toString()])
|
||||
}
|
||||
{ !(askingPrice < catalogState.marketplaceConfiguration.minimumPrice || askingPrice > catalogState.marketplaceConfiguration.maximumPrice || isNaN(askingPrice)) && LocalizeText('inventory.marketplace.make_offer.final_price', ['commission', 'finalprice'], [catalogState.marketplaceConfiguration.commission.toString(), (askingPrice + catalogState.marketplaceConfiguration.commission).toString()])}
|
||||
</div>
|
||||
<div className="btn-group btn-group-sm mt-3" role="group">
|
||||
<button className='btn btn-primary' disabled={askingPrice <= 0 || isNaN(askingPrice)} onClick={ postItem }>
|
||||
<button className='btn btn-primary' disabled={askingPrice < catalogState.marketplaceConfiguration.minimumPrice || askingPrice > catalogState.marketplaceConfiguration.maximumPrice || isNaN(askingPrice)} onClick={ postItem }>
|
||||
{ LocalizeText('inventory.marketplace.make_offer.post') }
|
||||
</button>
|
||||
</div>
|
||||
|
Loading…
Reference in New Issue
Block a user