diff --git a/src/components/catalog/views/gift/CatalogGiftView.tsx b/src/components/catalog/views/gift/CatalogGiftView.tsx index 64e1dd1..2bb2827 100644 --- a/src/components/catalog/views/gift/CatalogGiftView.tsx +++ b/src/components/catalog/views/gift/CatalogGiftView.tsx @@ -2,7 +2,7 @@ import { GiftReceiverNotFoundEvent, PurchaseFromCatalogAsGiftComposer } from '@n import { ChangeEvent, FC, useCallback, useEffect, useMemo, useState } from 'react'; import { FaChevronLeft, FaChevronRight } from 'react-icons/fa'; import { ColorUtils, GetSessionDataManager, LocalizeText, MessengerFriend, ProductTypeEnum, SendMessageComposer } from '../../../../api'; -import { Base, Button, ButtonGroup, classNames, Column, Flex, FormGroup, LayoutCurrencyIcon, LayoutFurniImageView, LayoutGiftTagView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text } from '../../../../common'; +import { Base, Button, ButtonGroup, Column, Flex, FormGroup, LayoutCurrencyIcon, LayoutFurniImageView, LayoutGiftTagView, NitroCardContentView, NitroCardHeaderView, NitroCardView, Text, classNames } from '../../../../common'; import { CatalogEvent, CatalogInitGiftEvent, CatalogPurchasedEvent } from '../../../../events'; import { useCatalog, useFriends, useMessageEvent, useUiEvent } from '../../../../hooks'; @@ -22,7 +22,7 @@ export const CatalogGiftView: FC<{}> = props => const [ maxBoxIndex, setMaxBoxIndex ] = useState(0); const [ maxRibbonIndex, setMaxRibbonIndex ] = useState(0); const [ receiverNotFound, setReceiverNotFound ] = useState(false); - const { catalogOptions = null } = useCatalog(); + const { catalogOptions = null, getNodesByOfferId = null } = useCatalog(); const { friends } = useFriends(); const { giftConfiguration = null } = catalogOptions; const [ boxTypes, setBoxTypes ] = useState([]); @@ -121,10 +121,19 @@ export const CatalogGiftView: FC<{}> = props => return; } - SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(pageId, offerId, extraData, receiverName, message, colourId , selectedBoxIndex, selectedRibbonIndex, showMyFace)); + let buyPageId = pageId + + if(buyPageId === -1) + { + const nodes = getNodesByOfferId(offerId); + + if(nodes) buyPageId = nodes[0].pageId; + } + + SendMessageComposer(new PurchaseFromCatalogAsGiftComposer(buyPageId, offerId, extraData, receiverName, message, colourId, selectedBoxIndex, selectedRibbonIndex, showMyFace)); return; } - }, [ colourId, extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedRibbonIndex, showMyFace ]); + }, [ colourId, extraData, maxBoxIndex, maxRibbonIndex, message, offerId, pageId, receiverName, selectedBoxIndex, selectedRibbonIndex, showMyFace, getNodesByOfferId ]); useMessageEvent(GiftReceiverNotFoundEvent, event => setReceiverNotFound(true)); @@ -184,7 +193,8 @@ export const CatalogGiftView: FC<{}> = props => if(!giftData) continue; - if(giftData.colors && giftData.colors.length > 0) newColors.push({ id: colorId, color: ColorUtils.makeColorNumberHex(giftData.colors[0]) }); + if (giftData.colors && giftData.colors.length > 0) newColors.push({ id: colorId, color: ColorUtils.makeColorNumberHex(giftData.colors[0]) }); + else newColors.push({ id: colorId, color: '#000000' }); } createBoxTypes(); diff --git a/src/components/inventory/views/furniture/InventoryFurnitureSearchView.tsx b/src/components/inventory/views/furniture/InventoryFurnitureSearchView.tsx index c677e3a..12a459f 100644 --- a/src/components/inventory/views/furniture/InventoryFurnitureSearchView.tsx +++ b/src/components/inventory/views/furniture/InventoryFurnitureSearchView.tsx @@ -1,8 +1,7 @@ -import { Dispatch, FC, SetStateAction, useEffect } from 'react'; +import { Dispatch, FC, SetStateAction, useEffect, useState } from 'react'; import { FaSearch } from 'react-icons/fa'; import { GroupItem, LocalizeText } from '../../../../api'; import { Button, Flex } from '../../../../common'; -import { useLocalStorage } from '../../../../hooks'; export interface InventoryFurnitureSearchViewProps { @@ -13,7 +12,7 @@ export interface InventoryFurnitureSearchViewProps export const InventoryFurnitureSearchView: FC = props => { const { groupItems = [], setGroupItems = null } = props; - const [ searchValue, setSearchValue ] = useLocalStorage('inventoryFurnitureSearchValue', ''); + const [ searchValue, setSearchValue ] = useState(''); useEffect(() => { @@ -27,8 +26,7 @@ export const InventoryFurnitureSearchView: FC { if(comparison && comparison.length) { - if(comparison === 'rare' && item.isSellable) return item; - if(comparison !== 'rare' && item.name.toLocaleLowerCase().includes(comparison)) return item; + if(item.name.toLocaleLowerCase().includes(comparison)) return item; } return null; diff --git a/src/hooks/catalog/useCatalog.ts b/src/hooks/catalog/useCatalog.ts index 6572baa..6a8b266 100644 --- a/src/hooks/catalog/useCatalog.ts +++ b/src/hooks/catalog/useCatalog.ts @@ -2,7 +2,7 @@ import { BuildersClubFurniCountMessageEvent, BuildersClubPlaceRoomItemMessageCom import { useCallback, useEffect, useRef, useState } from 'react'; import { useBetween } from 'use-between'; import { BuilderFurniPlaceableStatus, CatalogNode, CatalogPage, CatalogPetPalette, CatalogType, CreateLinkEvent, DispatchUiEvent, FurniCategory, GetFurnitureData, GetProductDataForLocalization, GetRoomEngine, GetRoomSession, GiftWrappingConfiguration, ICatalogNode, ICatalogOptions, ICatalogPage, IPageLocalization, IProduct, IPurchasableOffer, IPurchaseOptions, LocalizeText, NotificationAlertType, Offer, PageLocalization, PlacedObjectPurchaseData, PlaySound, Product, ProductTypeEnum, RequestedPage, SearchResult, SendMessageComposer, SoundNames } from '../../api'; -import { CatalogPurchasedEvent, CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent, InventoryFurniAddedEvent } from '../../events'; +import { CatalogPurchaseFailureEvent, CatalogPurchaseNotAllowedEvent, CatalogPurchaseSoldOutEvent, CatalogPurchasedEvent, InventoryFurniAddedEvent } from '../../events'; import { useMessageEvent, useRoomEngineEvent, useUiEvent } from '../events'; import { useNotification } from '../notification'; import { useCatalogPlaceMultipleItems } from './useCatalogPlaceMultipleItems';