From f07e7335c436a8dcd63c21bd156f01a763111e72 Mon Sep 17 00:00:00 2001 From: nicollassilva Date: Tue, 25 Feb 2025 14:46:39 -0300 Subject: [PATCH] Adding 'trophies' catalog layout --- .../components/catalog/CatalogPageView.tsx | 4 +- .../layout/CatalogTrophiesLayoutView.tsx | 61 +++++++++++++++++++ .../components/catalog/layout/index.ts | 1 + 3 files changed, 65 insertions(+), 1 deletion(-) create mode 100644 packages/nitro-react/themes/default/components/catalog/layout/CatalogTrophiesLayoutView.tsx diff --git a/packages/nitro-react/themes/default/components/catalog/CatalogPageView.tsx b/packages/nitro-react/themes/default/components/catalog/CatalogPageView.tsx index 9b46d38..27b32cd 100644 --- a/packages/nitro-react/themes/default/components/catalog/CatalogPageView.tsx +++ b/packages/nitro-react/themes/default/components/catalog/CatalogPageView.tsx @@ -1,5 +1,5 @@ import { FC } from 'react'; -import { CatalogDefaultLayoutView, CatalogLayoutProps } from './layout'; +import { CatalogDefaultLayoutView, CatalogLayoutProps, CatalogTrophiesLayoutView } from './layout'; export const CatalogPageView: FC = props => { @@ -9,6 +9,8 @@ export const CatalogPageView: FC = props => switch(page.layoutCode) { + case 'trophies': + return ; case 'bots': case 'default_3x3': default: diff --git a/packages/nitro-react/themes/default/components/catalog/layout/CatalogTrophiesLayoutView.tsx b/packages/nitro-react/themes/default/components/catalog/layout/CatalogTrophiesLayoutView.tsx new file mode 100644 index 0000000..510dfbd --- /dev/null +++ b/packages/nitro-react/themes/default/components/catalog/layout/CatalogTrophiesLayoutView.tsx @@ -0,0 +1,61 @@ +import { useOfferLocalization } from '#base/hooks/index.ts'; +import { useCatalogStore } from '#base/stores/useCatalogStore.ts'; +import { FC, useEffect, useState } from 'react'; +import { useShallow } from 'zustand/shallow'; +import { CatalogPageImageView, CatalogPageTextView } from '../common'; +import { CatalogOfferGridWidgetView, CatalogPriceDisplayWidget, CatalogPurchaseWidgetView, CatalogViewOfferWidgetView } from '../widgets'; +import { CatalogLayoutProps } from './CatalogLayoutProps'; + +export const CatalogTrophiesLayoutView: FC = props => +{ + const { page = null, roomPreviewer = null, currentOffer = null } = props; + const [ trophyText, setTrophyText ] = useState(''); + + const offerLocalization = useOfferLocalization(currentOffer); + + const [ + updateCurrentOfferOptions + ] = useCatalogStore( + useShallow(state => [ + state.updateCurrentOfferOptions + ])); + + useEffect(() => { + if(!currentOffer) return; + + updateCurrentOfferOptions({ + extraData: (trophyText || '') + }); + }, [currentOffer, trophyText, updateCurrentOfferOptions]); + + return ( +
+
+ +