diff --git a/src/api/nitro/CreateLinkEvent.ts b/src/api/nitro/CreateLinkEvent.ts index e9ff2859..2acfa86a 100644 --- a/src/api/nitro/CreateLinkEvent.ts +++ b/src/api/nitro/CreateLinkEvent.ts @@ -2,5 +2,7 @@ import { GetNitroInstance } from './GetNitroInstance'; export function CreateLinkEvent(link: string): void { + link = (link.startsWith('event:') ? link.substring(6) : link); + GetNitroInstance().createLinkEvent(link); } diff --git a/src/components/catalog/CatalogMessageHandler.tsx b/src/components/catalog/CatalogMessageHandler.tsx index 87efa40b..eda934d6 100644 --- a/src/components/catalog/CatalogMessageHandler.tsx +++ b/src/components/catalog/CatalogMessageHandler.tsx @@ -27,7 +27,7 @@ import { CatalogActions } from './reducers/CatalogReducer'; export const CatalogMessageHandler: FC<{}> = props => { - const { setIsBusy, pageId, currentType, setRootNode, setCurrentOffers, currentPage, setCurrentOffer, setPurchasableOffer, setFrontPageItems, resetState, showCatalogPage, catalogState, dispatchCatalogState } = useCatalogContext(); + const { setIsBusy, pageId, currentType, setRootNode, setOffersToNodes, currentPage, setCurrentOffer, setPurchasableOffer, setFrontPageItems, resetState, showCatalogPage, catalogState, dispatchCatalogState } = useCatalogContext(); const onCatalogPagesListEvent = useCallback((event: CatalogPagesListEvent) => { @@ -54,9 +54,9 @@ export const CatalogMessageHandler: FC<{}> = props => BatchUpdates(() => { setRootNode(getCatalogNode(parser.root, 0, null)); - setCurrentOffers(offers); + setOffersToNodes(offers); }); - }, [ setRootNode, setCurrentOffers ]); + }, [ setRootNode, setOffersToNodes ]); const onCatalogPageMessageEvent = useCallback((event: CatalogPageMessageEvent) => { @@ -273,8 +273,6 @@ export const CatalogMessageHandler: FC<{}> = props => const parser = event.getParser(); if(!parser) return; - - console.log(parser); dispatchCatalogState({ type: CatalogActions.SET_MARKETPLACE_CONFIGURATION, diff --git a/src/components/catalog/CatalogView.tsx b/src/components/catalog/CatalogView.tsx index 7bae11e1..0b203ce9 100644 --- a/src/components/catalog/CatalogView.tsx +++ b/src/components/catalog/CatalogView.tsx @@ -42,7 +42,6 @@ export const CatalogView: FC<{}> = props => const [ currentPage, setCurrentPage ] = useState(null); const [ currentOffer, setCurrentOffer ] = useState(null); const [ purchasableOffer, setPurchasableOffer ] = useState(null); - const [ currentTab, setCurrentTab ] = useState(null); const [ activeNodes, setActiveNodes ] = useState([]); const [ searchResult, setSearchResult ] = useState(null); const [ frontPageItems, setFrontPageItems ] = useState([]); @@ -60,7 +59,6 @@ export const CatalogView: FC<{}> = props => setCurrentPage(null); setCurrentOffer(null); setPurchasableOffer(null); - setCurrentTab(null); setActiveNodes([]); setSearchResult(null); setFrontPageItems([]); @@ -68,6 +66,20 @@ export const CatalogView: FC<{}> = props => }); }, []); + const getFirstNodeByName = useCallback((name: string, node: ICatalogNode) => + { + if((node.pageName === name) && (node !== rootNode)) return node; + + for(const child of node.children) + { + const found = (getFirstNodeByName(name, child) as ICatalogNode); + + if(found) return found; + } + + return null; + }, [ rootNode ]); + const getNodesByOfferId = useCallback((offerId: number, flag: boolean = false) => { if(!offersToNodes || !offersToNodes.size) return null; @@ -194,6 +206,27 @@ export const CatalogView: FC<{}> = props => if(targetNode.pageId > -1) loadCatalogPage(targetNode.pageId, offerId); }, [ setActiveNodes, loadCatalogPage ]); + const openPageByName = useCallback((name: string) => + { + BatchUpdates(() => + { + setSearchResult(null); + + if(!isVisible) + { + REQUESTED_PAGE.requestByName = name; + + setIsVisible(true); + } + else + { + const node = getFirstNodeByName(name, rootNode); + + if(node) activateNode(node); + } + }); + }, [ isVisible, rootNode, getFirstNodeByName, activateNode ]); + const openPageByOfferId = useCallback((offerId: number) => { BatchUpdates(() => @@ -258,6 +291,12 @@ export const CatalogView: FC<{}> = props => return; } } + else + { + openPageByName(parts[2]); + + return; + } } else { @@ -266,7 +305,7 @@ export const CatalogView: FC<{}> = props => return; } - }, [ openPageByOfferId ]); + }, [ openPageByOfferId, openPageByName ]); useEffect(() => { @@ -335,10 +374,11 @@ export const CatalogView: FC<{}> = props => REQUESTED_PAGE.resetRequest(); return; case RequestedPage.REQUEST_TYPE_NAME: + openPageByName(REQUESTED_PAGE.requestByName); REQUESTED_PAGE.resetRequest(); return; } - }, [ isVisible, rootNode, activeNodes, activateNode, openPageByOfferId ]); + }, [ isVisible, rootNode, activeNodes, activateNode, openPageByOfferId, openPageByName ]); useEffect(() => { @@ -348,7 +388,7 @@ export const CatalogView: FC<{}> = props => }, [ currentPage ]); return ( - + { isVisible && diff --git a/src/components/catalog/context/CatalogContext.tsx b/src/components/catalog/context/CatalogContext.tsx index 6d1c300d..14be5819 100644 --- a/src/components/catalog/context/CatalogContext.tsx +++ b/src/components/catalog/context/CatalogContext.tsx @@ -17,8 +17,8 @@ export interface ICatalogContext setCurrentType: Dispatch>; rootNode: ICatalogNode; setRootNode: Dispatch>; - currentOffers: Map; - setCurrentOffers: Dispatch>>; + offersToNodes: Map; + setOffersToNodes: Dispatch>>; currentPage: ICatalogPage; setCurrentPage: Dispatch>; currentOffer: IPurchasableOffer; @@ -50,8 +50,8 @@ const CatalogContext = createContext({ setCurrentType: null, rootNode: null, setRootNode: null, - currentOffers: null, - setCurrentOffers: null, + offersToNodes: null, + setOffersToNodes: null, currentPage: null, setCurrentPage: null, currentOffer: null, diff --git a/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx b/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx index b5caf217..6d2318d4 100644 --- a/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx +++ b/src/components/catalog/views/catalog-room-previewer/CatalogRoomPreviewerView.tsx @@ -2,6 +2,7 @@ import { NitroToolbarAnimateIconEvent, TextureUtils, ToolbarIconEnum } from '@ni import { FC, useCallback, useRef, useState } from 'react'; import { GetRoomEngine } from '../../../../api'; import { CatalogEvent, CatalogSelectProductEvent } from '../../../../events'; +import { CatalogWidgetEvent } from '../../../../events/catalog/CatalogWidgetEvent'; import { useUiEvent } from '../../../../hooks'; import { RoomPreviewerView } from '../../../../views/shared/room-previewer/RoomPreviewerView'; import { RoomPreviewerViewProps } from '../../../../views/shared/room-previewer/RoomPreviewerView.types'; @@ -18,7 +19,7 @@ export const CatalogRoomPreviewerView: FC = props => setOffer(event.offer); }, []); - useUiEvent(CatalogSelectProductEvent.SELECT_PRODUCT, onCatalogSelectProductEvent) + useUiEvent(CatalogWidgetEvent.SELECT_PRODUCT, onCatalogSelectProductEvent) const animatePurchase = useCallback(() => { diff --git a/src/components/catalog/views/page/layout/CatalogLayout.scss b/src/components/catalog/views/page/layout/CatalogLayout.scss index bc476e25..77724f9f 100644 --- a/src/components/catalog/views/page/layout/CatalogLayout.scss +++ b/src/components/catalog/views/page/layout/CatalogLayout.scss @@ -48,3 +48,10 @@ width: $marketplace-post-offer-width; height: $marketplace-post-offer-height; } + +.nitro-catalog-layout-bundle-grid { + + .layout-grid-item { + background-color: transparent; + } +} diff --git a/src/components/catalog/views/search/CatalogSearchView.tsx b/src/components/catalog/views/search/CatalogSearchView.tsx index 22e8a8c8..c1a5eb7f 100644 --- a/src/components/catalog/views/search/CatalogSearchView.tsx +++ b/src/components/catalog/views/search/CatalogSearchView.tsx @@ -19,7 +19,7 @@ import { useCatalogContext } from '../../context/CatalogContext'; export const CatalogSearchView: FC<{}> = props => { const [ searchValue, setSearchValue ] = useState(''); - const { currentType = null, rootNode = null, setActiveNodes = null, currentOffers = null, searchResult = null, setSearchResult = null, setCurrentPage = null } = useCatalogContext(); + const { currentType = null, rootNode = null, setActiveNodes = null, offersToNodes = null, searchResult = null, setSearchResult = null, setCurrentPage = null } = useCatalogContext(); const processSearch = useCallback((search: string) => { @@ -54,8 +54,8 @@ export const CatalogSearchView: FC<{}> = props => else { const foundNodes = [ - ...GetOfferNodes(currentOffers, furniture.purchaseOfferId), - ...GetOfferNodes(currentOffers, furniture.rentOfferId) + ...GetOfferNodes(offersToNodes, furniture.purchaseOfferId), + ...GetOfferNodes(offersToNodes, furniture.rentOfferId) ]; if(foundNodes.length) @@ -81,7 +81,7 @@ export const CatalogSearchView: FC<{}> = props => setSearchResult(new SearchResult(search, offers, nodes.filter(node => (node.isVisible)))); setActiveNodes(prevValue => prevValue.slice(0, 1)); }); - }, [ currentOffers, currentType, rootNode, setCurrentPage, setSearchResult, setActiveNodes ]); + }, [ offersToNodes, currentType, rootNode, setCurrentPage, setSearchResult, setActiveNodes ]); useEffect(() => { diff --git a/src/views/notification-center/common/NotificationUtilities.ts b/src/views/notification-center/common/NotificationUtilities.ts index b41220fb..86c73b5e 100644 --- a/src/views/notification-center/common/NotificationUtilities.ts +++ b/src/views/notification-center/common/NotificationUtilities.ts @@ -182,7 +182,7 @@ export class NotificationUtilities } else { - CreateLinkEvent(url.substring(6)); + CreateLinkEvent(url); } }