Marketplace updates

This commit is contained in:
Bill 2022-07-27 20:42:32 -04:00
parent 2b9f6b5634
commit 548c6528b4
6 changed files with 32 additions and 27 deletions

View File

@ -0,0 +1,19 @@
import { GetRoomEngine } from '../nitro';
import { ProductTypeEnum } from './ProductTypeEnum';
export const GetImageIconUrlForProduct = (productType: string, productClassId: number, extraData: string = null) =>
{
let imageUrl: string = null;
switch(productType.toLocaleLowerCase())
{
case ProductTypeEnum.FLOOR:
imageUrl = GetRoomEngine().getFurnitureFloorIconUrl(productClassId);
break;
case ProductTypeEnum.WALL:
imageUrl = GetRoomEngine().getFurnitureWallIconUrl(productClassId, extraData);
break;
}
return imageUrl;
}

View File

@ -7,6 +7,7 @@ export * from './CatalogPurchaseState';
export * from './CatalogType'; export * from './CatalogType';
export * from './CatalogUtilities'; export * from './CatalogUtilities';
export * from './FurnitureOffer'; export * from './FurnitureOffer';
export * from './GetImageIconUrlForProduct';
export * from './GiftWrappingConfiguration'; export * from './GiftWrappingConfiguration';
export * from './ICatalogNode'; export * from './ICatalogNode';
export * from './ICatalogOptions'; export * from './ICatalogOptions';

View File

@ -1,6 +1,6 @@
import { FC } from 'react'; import { FC } from 'react';
import { LayoutImage, LayoutImageProps } from '.'; import { LayoutImage, LayoutImageProps } from '.';
import { GetRoomEngine, ProductTypeEnum } from '../../api'; import { GetImageIconUrlForProduct } from '../../api';
interface LayoutFurniIconImageViewProps extends LayoutImageProps interface LayoutFurniIconImageViewProps extends LayoutImageProps
{ {
@ -13,22 +13,5 @@ export const LayoutFurniIconImageView: FC<LayoutFurniIconImageViewProps> = props
{ {
const { productType = 's', productClassId = -1, extraData = '', ...rest } = props; const { productType = 's', productClassId = -1, extraData = '', ...rest } = props;
const getImageIconUrl = () => return <LayoutImage imageUrl={ GetImageIconUrlForProduct(productType, productClassId, extraData) } className="furni-image" { ...rest } />;
{
let imageUrl: string = null;
switch(productType.toLocaleLowerCase())
{
case ProductTypeEnum.FLOOR:
imageUrl = GetRoomEngine().getFurnitureFloorIconUrl(productClassId);
break;
case ProductTypeEnum.WALL:
imageUrl = GetRoomEngine().getFurnitureWallIconUrl(productClassId, extraData);
break;
}
return imageUrl;
}
return <LayoutImage imageUrl={ getImageIconUrl() } className="furni-image" { ...rest } />;
} }

View File

@ -49,14 +49,14 @@ export const LayoutGridItem: FC<LayoutGridItemProps> = props =>
{ {
let newStyle = { ...style }; let newStyle = { ...style };
if(itemImage) newStyle.backgroundImage = `url(${ itemImage })`; if(itemImage && !(itemUniqueSoldout || (itemUniqueNumber > 0))) newStyle.backgroundImage = `url(${ itemImage })`;
if(itemColor) newStyle.backgroundColor = itemColor; if(itemColor) newStyle.backgroundColor = itemColor;
if(Object.keys(style).length) newStyle = { ...newStyle, ...style }; if(Object.keys(style).length) newStyle = { ...newStyle, ...style };
return newStyle; return newStyle;
}, [ style, itemImage, itemColor ]); }, [ style, itemImage, itemColor, itemUniqueSoldout, itemUniqueNumber ]);
return ( return (
<Column center={ center } pointer position={ position } overflow={ overflow } column={ column } classNames={ getClassNames } style={ getStyle } { ...rest }> <Column center={ center } pointer position={ position } overflow={ overflow } column={ column } classNames={ getClassNames } style={ getStyle } { ...rest }>

View File

@ -1,6 +1,6 @@
import { FC, useCallback, useMemo } from 'react'; import { FC, useCallback, useMemo } from 'react';
import { LocalizeText, ProductTypeEnum } from '../../../../../../api'; import { GetImageIconUrlForProduct, LocalizeText, ProductTypeEnum } from '../../../../../../api';
import { Button, Column, LayoutFurniIconImageView, LayoutGridItem, Text } from '../../../../../../common'; import { Button, Column, LayoutGridItem, Text } from '../../../../../../common';
import { MarketplaceOfferData } from './common/MarketplaceOfferData'; import { MarketplaceOfferData } from './common/MarketplaceOfferData';
import { MarketPlaceOfferState } from './common/MarketplaceOfferState'; import { MarketPlaceOfferState } from './common/MarketplaceOfferState';
@ -49,7 +49,9 @@ export const CatalogLayoutMarketplaceItemView: FC<MarketplaceItemViewProps> = pr
return ( return (
<LayoutGridItem shrink center={ false } column={ false } alignItems="center" className="p-1"> <LayoutGridItem shrink center={ false } column={ false } alignItems="center" className="p-1">
<LayoutFurniIconImageView productType={ offerData.furniType === MarketplaceOfferData.TYPE_FLOOR ? ProductTypeEnum.FLOOR : ProductTypeEnum.WALL } productClassId={ offerData.furniId } extraData={ offerData.extraData } style={ { width: 50, height: 50 } } /> <Column style={ { width: 40, height: 40 } }>
<LayoutGridItem column={ false } itemImage={ GetImageIconUrlForProduct(((offerData.furniType === MarketplaceOfferData.TYPE_FLOOR) ? ProductTypeEnum.FLOOR : ProductTypeEnum.WALL), offerData.furniId, offerData.extraData) } itemUniqueNumber={ offerData.stuffData.uniqueNumber } />
</Column>
<Column grow gap={ 0 }> <Column grow gap={ 0 }>
<Text fontWeight="bold">{ getMarketplaceOfferTitle }</Text> <Text fontWeight="bold">{ getMarketplaceOfferTitle }</Text>
{ (type === OWN_OFFER) && { (type === OWN_OFFER) &&
@ -59,7 +61,7 @@ export const CatalogLayoutMarketplaceItemView: FC<MarketplaceItemViewProps> = pr
</> } </> }
{ (type === PUBLIC_OFFER) && { (type === PUBLIC_OFFER) &&
<> <>
<Text>{ LocalizeText('catalog.marketplace.offer.price_public_item', [ 'price', 'average' ], [ offerData.price.toString(), offerData.averagePrice.toString() ]) }</Text> <Text>{ LocalizeText('catalog.marketplace.offer.price_public_item', [ 'price', 'average' ], [ offerData.price.toString(), ((offerData.averagePrice > 0) ? offerData.averagePrice.toString() : '-') ]) }</Text>
<Text>{ LocalizeText('catalog.marketplace.offer_count', [ 'count' ], [ offerData.offerCount.toString() ]) }</Text> <Text>{ LocalizeText('catalog.marketplace.offer_count', [ 'count' ], [ offerData.offerCount.toString() ]) }</Text>
</> } </> }
</Column> </Column>

View File

@ -1,5 +1,5 @@
import { FC } from 'react'; import { FC } from 'react';
import { LocalizeText } from '../../../api'; import { GetConfiguration, LocalizeText } from '../../../api';
import { Column, Flex, LayoutRoomThumbnailView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common'; import { Column, Flex, LayoutRoomThumbnailView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../common';
import { useNavigatorContext } from '../NavigatorContext'; import { useNavigatorContext } from '../NavigatorContext';
@ -24,7 +24,7 @@ export const NavigatorRoomLinkView: FC<NavigatorRoomLinkViewProps> = props =>
<Column> <Column>
<Text bold fontSize={ 5 }>{ LocalizeText('navigator.embed.headline') }</Text> <Text bold fontSize={ 5 }>{ LocalizeText('navigator.embed.headline') }</Text>
<Text>{ LocalizeText('navigator.embed.info') }</Text> <Text>{ LocalizeText('navigator.embed.info') }</Text>
<input type="text" readOnly className="form-control form-control-sm" value={ LocalizeText('navigator.embed.src', [ 'roomId' ], [ navigatorData.enteredGuestRoom.roomId.toString() ]) } /> <input type="text" readOnly className="form-control form-control-sm" value={ LocalizeText('navigator.embed.src', [ 'roomId' ], [ navigatorData.enteredGuestRoom.roomId.toString() ]).replace('${url.prefix}', GetConfiguration<string>('url.prefix', '')) } />
</Column> </Column>
</Flex> </Flex>
</NitroCardContentView> </NitroCardContentView>