diff --git a/src/components/catalog/CatalogView.scss b/src/components/catalog/CatalogView.scss index 917d5f9e..e95ec83b 100644 --- a/src/components/catalog/CatalogView.scss +++ b/src/components/catalog/CatalogView.scss @@ -10,6 +10,14 @@ min-width: 30px; width: 30px; } + + .quantity-input { + min-height: 17px; + height: 17px; + width: 20px; + padding: 0 4px; + text-align: right; + } } .catalog-icon-image { diff --git a/src/components/catalog/views/gift/CatalogGiftView.tsx b/src/components/catalog/views/gift/CatalogGiftView.tsx index a0c19623..7bb93e53 100644 --- a/src/components/catalog/views/gift/CatalogGiftView.tsx +++ b/src/components/catalog/views/gift/CatalogGiftView.tsx @@ -3,6 +3,7 @@ import { PurchaseFromCatalogAsGiftComposer } from '@nitrots/nitro-renderer'; import classNames from 'classnames'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { GetSessionDataManager, LocalizeText } from '../../../../api'; +import { Base } from '../../../../common/Base'; import { Button } from '../../../../common/Button'; import { ButtonGroup } from '../../../../common/ButtonGroup'; import { Column } from '../../../../common/Column'; @@ -16,12 +17,14 @@ import { NitroCardContentView, NitroCardHeaderView, NitroCardView, NitroLayoutGi import { CurrencyIcon } from '../../../../views/shared/currency-icon/CurrencyIcon'; import { FurniImageView } from '../../../../views/shared/furni-image/FurniImageView'; import { useCatalogContext } from '../../CatalogContext'; +import { ProductTypeEnum } from '../../common/ProductTypeEnum'; export const CatalogGiftView: FC<{}> = props => { const [ isVisible, setIsVisible ] = useState(false); const [ pageId, setPageId ] = useState(0); const [ offerId, setOfferId ] = useState(0); + const [ extraData, setExtraData ] = useState(''); const [ receiverName, setReceiverName ] = useState(''); const [ showMyFace, setShowMyFace ] = useState(true); const [ message, setMessage ] = useState(''); @@ -42,6 +45,7 @@ export const CatalogGiftView: FC<{}> = props => setIsVisible(false); setPageId(0); setOfferId(0); + setExtraData(''); setReceiverName(''); setShowMyFace(true); setMessage(''); @@ -68,6 +72,7 @@ export const CatalogGiftView: FC<{}> = props => setPageId(castedEvent.pageId); setOfferId(castedEvent.offerId); + setExtraData(castedEvent.extraData); setIsVisible(true); }); return; @@ -86,7 +91,7 @@ export const CatalogGiftView: FC<{}> = props => return giftConfiguration ? (giftConfiguration.defaultStuffTypes.findIndex(s => (s === giftConfiguration.boxTypes[selectedBoxIndex])) > -1) : true; }, [ giftConfiguration, selectedBoxIndex ]); - const extraData = useMemo(() => + const boxExtraData = useMemo(() => { if(!giftConfiguration) return ''; @@ -176,18 +181,19 @@ export const CatalogGiftView: FC<{}> = props => { LocalizeText('catalog.gift_wrapping.receiver') } setReceiverName(e.target.value) } /> - { receiverNotFound &&
{ LocalizeText('catalog.gift_wrapping.receiver_not_found.title') }
} + { receiverNotFound && + { LocalizeText('catalog.gift_wrapping.receiver_not_found.title') } }
setMessage(value) } /> -
+ setShowMyFace(value => !value) } /> -
+ { selectedColorId && -
- -
} + + + } diff --git a/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx b/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx index a3fb78c4..6e7f95b3 100644 --- a/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx +++ b/src/components/catalog/views/page/layout/vip-gifts/CatalogLayoutVipGiftsView.tsx @@ -25,7 +25,6 @@ export const CatalogLayoutVipGiftsView: FC = props => if(subscriptionInfo.isVip) return LocalizeText('catalog.club_gift.not_available'); return LocalizeText('catalog.club_gift.no_club'); - }, [ clubGifts, subscriptionInfo ]); const selectGift = useCallback((localizationId: string) => diff --git a/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx index 7471d563..a9d4280a 100644 --- a/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogPurchaseWidgetView.tsx @@ -3,9 +3,10 @@ import { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { CreateLinkEvent, GetClubMemberLevel, LocalizeText } from '../../../../../api'; import { Button } from '../../../../../common/Button'; import { CatalogEvent, CatalogPurchasedEvent, CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent } from '../../../../../events'; +import { CatalogInitGiftEvent } from '../../../../../events/catalog/CatalogInitGiftEvent'; import { CatalogInitPurchaseEvent } from '../../../../../events/catalog/CatalogInitPurchaseEvent'; import { CatalogWidgetEvent } from '../../../../../events/catalog/CatalogWidgetEvent'; -import { SendMessageHook, useUiEvent } from '../../../../../hooks'; +import { dispatchUiEvent, SendMessageHook, useUiEvent } from '../../../../../hooks'; import { LoadingSpinnerView } from '../../../../../layout'; import { GetCurrencyAmount } from '../../../../../views/purse/common/CurrencyHelper'; import { useCatalogContext } from '../../../CatalogContext'; @@ -87,6 +88,13 @@ export const CatalogPurchaseWidgetView: FC = pro return; } + if(isGift) + { + dispatchUiEvent(new CatalogInitGiftEvent(currentOffer.page.pageId, currentOffer.offerId, extraData)); + + return; + } + setPurchaseState(CatalogPurchaseState.PURCHASE); if(purchaseCallback) @@ -108,8 +116,6 @@ export const CatalogPurchaseWidgetView: FC = pro SendMessageHook(new PurchaseFromCatalogComposer(pageId, currentOffer.offerId, extraData, quantity)); }, [ currentOffer, purchaseCallback, extraData, quantity, getNodesByOfferId ]); - // dispatchUiEvent(new CatalogInitGiftEvent(pageId, offer.offerId, extra)); setup gift - useEffect(() => { if(!currentOffer) return; @@ -171,7 +177,7 @@ export const CatalogPurchaseWidgetView: FC = pro <> { (!noGiftOption && !currentOffer.isRentOffer) && - } diff --git a/src/components/catalog/views/page/widgets/CatalogSpinnerWidgetView.tsx b/src/components/catalog/views/page/widgets/CatalogSpinnerWidgetView.tsx index 8ab9512c..3ba7b7b9 100644 --- a/src/components/catalog/views/page/widgets/CatalogSpinnerWidgetView.tsx +++ b/src/components/catalog/views/page/widgets/CatalogSpinnerWidgetView.tsx @@ -15,6 +15,8 @@ export const CatalogSpinnerWidgetView: FC<{}> = props => const updateQuantity = (value: number) => { + if(isNaN(value)) value = 1; + value = Math.max(value, MIN_VALUE); value = Math.min(value, MAX_VALUE); diff --git a/src/views/shared/furni-image/FurniImageView.tsx b/src/views/shared/furni-image/FurniImageView.tsx index 5acc2017..bcb2172e 100644 --- a/src/views/shared/furni-image/FurniImageView.tsx +++ b/src/views/shared/furni-image/FurniImageView.tsx @@ -1,20 +1,27 @@ import { IGetImageListener, ImageResult, TextureUtils, Vector3d } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useState } from 'react'; import { GetRoomEngine } from '../../../api'; +import { Base } from '../../../common/Base'; import { ProductTypeEnum } from '../../../components/catalog/common/ProductTypeEnum'; -import { FurniImageViewProps } from './FurniImageView.types'; + +interface FurniImageViewProps +{ + productType: string; + productClassId: number; + direction?: number; + extraData?: string; + scale?: number; +} export const FurniImageView: FC = props => { - const { type = 's', spriteId = -1, direction = 0, extras = '', scale = 1 } = props; + const { productType = 's', productClassId = -1, direction = 0, extraData = '', scale = 1 } = props; const [ imageElement, setImageElement ] = useState(null); const buildImage = useCallback(() => { let imageResult: ImageResult = null; - const furniType = type.toLocaleLowerCase(); - const listener: IGetImageListener = { imageReady: (id, texture, image) => { @@ -28,13 +35,13 @@ export const FurniImageView: FC = props => imageFailed: null }; - switch(furniType) + switch(productType.toLocaleLowerCase()) { case ProductTypeEnum.FLOOR: - imageResult = GetRoomEngine().getFurnitureFloorImage(spriteId, new Vector3d(direction), 64, listener, 0, extras); + imageResult = GetRoomEngine().getFurnitureFloorImage(productClassId, new Vector3d(direction), 64, listener, 0, extraData); break; case ProductTypeEnum.WALL: - imageResult = GetRoomEngine().getFurnitureWallImage(spriteId, new Vector3d(direction), 64, listener, 0, extras); + imageResult = GetRoomEngine().getFurnitureWallImage(productClassId, new Vector3d(direction), 64, listener, 0, extraData); break; } @@ -44,7 +51,7 @@ export const FurniImageView: FC = props => image.onload = () => setImageElement(image); } - }, [ type, spriteId, direction, extras ]); + }, [ productType, productClassId, direction, extraData ]); useEffect(() => { @@ -54,6 +61,6 @@ export const FurniImageView: FC = props => if(!imageElement) return null; const imageUrl = `url('${ imageElement.src }')`; - - return
; + + return ; } diff --git a/src/views/shared/furni-image/FurniImageView.types.ts b/src/views/shared/furni-image/FurniImageView.types.ts deleted file mode 100644 index 63f1cb7a..00000000 --- a/src/views/shared/furni-image/FurniImageView.types.ts +++ /dev/null @@ -1,8 +0,0 @@ -export interface FurniImageViewProps -{ - type: string; - spriteId: number; - direction?: number; - extras?: string; - scale?: number; -}