From 6b8c039df733dba72fc368503f7b4b6937e76585 Mon Sep 17 00:00:00 2001 From: laynester Date: Tue, 13 Dec 2022 04:58:59 -0500 Subject: [PATCH] fix purchasing & the colours --- .../catalog/views/gift/CatalogGiftView.tsx | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/components/catalog/views/gift/CatalogGiftView.tsx b/src/components/catalog/views/gift/CatalogGiftView.tsx index fd9bdb7a..74003a60 100644 --- a/src/components/catalog/views/gift/CatalogGiftView.tsx +++ b/src/components/catalog/views/gift/CatalogGiftView.tsx @@ -1,7 +1,7 @@ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; import { GiftReceiverNotFoundEvent, PurchaseFromCatalogAsGiftComposer } from '@nitrots/nitro-renderer'; import { FC, useCallback, useEffect, useMemo, useState } from 'react'; -import { GetSessionDataManager, LocalizeText, ProductTypeEnum, SendMessageComposer } from '../../../../api'; +import { ColorUtils, GetSessionDataManager, LocalizeText, ProductTypeEnum, SendMessageComposer } from '../../../../api'; import { Base, Button, ButtonGroup, classNames, Column, Flex, FormGroup, LayoutCurrencyIcon, LayoutFurniImageView, LayoutGiftTagView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; import { CatalogEvent, CatalogInitGiftEvent, CatalogPurchasedEvent } from '../../../../events'; import { useCatalog, useMessageEvent, useUiEvent } from '../../../../hooks'; @@ -62,6 +62,11 @@ export const CatalogGiftView: FC<{}> = props => return (boxType === 8 || (boxType >= 3 && boxType <= 6)) ? false : true; }, [ giftConfiguration, selectedBoxIndex, isBoxDefault ]); + + const colourId = useMemo(() => + { + return isBoxDefault ? giftConfiguration.boxTypes[selectedBoxIndex] : selectedColorId; + },[ isBoxDefault, giftConfiguration, selectedBoxIndex,selectedColorId ]) const handleAction = useCallback((action: string) => @@ -87,10 +92,10 @@ export const CatalogGiftView: FC<{}> = props => return; } - SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, selectedColorId, selectedBoxIndex, selectedRibbonIndex, showMyFace)); + SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, colourId , selectedBoxIndex, selectedRibbonIndex, showMyFace)); return; } - }, [ extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedColorId, selectedRibbonIndex, showMyFace ]); + }, [ colourId, extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedRibbonIndex, showMyFace ]); useMessageEvent(GiftReceiverNotFoundEvent, event => setReceiverNotFound(true)); @@ -133,7 +138,7 @@ export const CatalogGiftView: FC<{}> = props => if(!giftData) continue; - if(giftData.colors && giftData.colors.length > 0) newColors.push({ id: colorId, color: `#${ giftData.colors[0].toString(16) }` }); + if(giftData.colors && giftData.colors.length > 0) newColors.push({ id: colorId, color: ColorUtils.makeColorNumberHex(giftData.colors[0]) }); } giftConfiguration.boxTypes.push(giftConfiguration.defaultStuffTypes[Math.floor((Math.random() * giftConfiguration.defaultStuffTypes.length) - 1)]); @@ -152,7 +157,7 @@ export const CatalogGiftView: FC<{}> = props => const boxName = 'catalog.gift_wrapping_new.box.' + (isBoxDefault ? 'default' : giftConfiguration.boxTypes[selectedBoxIndex]); const ribbonName = `catalog.gift_wrapping_new.ribbon.${ selectedRibbonIndex }`; - const priceText = 'catalog.gift_wrapping_new.' + (isBoxDefault ? 'freeprice' : 'price'); + const priceText = 'catalog.gift_wrapping_new.' + (isBoxDefault ? 'freeprice' : 'price');; return ( @@ -172,7 +177,7 @@ export const CatalogGiftView: FC<{}> = props => { selectedColorId && - + }