From 1c4e8b3f3ddc6f846959a4cde78870c85cee0fea Mon Sep 17 00:00:00 2001 From: Albert Folch Date: Tue, 14 May 2024 18:03:11 +0200 Subject: [PATCH] fix: when you click on phygitals in templates page, it should redirect you to create a product with phygital selected --- .../product/utils/useInitialValues.ts | 15 ++++++++ src/lib/routing/parameters.ts | 3 +- src/pages/sell/landing/SellerLandingPage.tsx | 34 ++++++++++++++++--- 3 files changed, 46 insertions(+), 6 deletions(-) diff --git a/src/components/product/utils/useInitialValues.ts b/src/components/product/utils/useInitialValues.ts index 4c2df6ccd..66b70f42b 100644 --- a/src/components/product/utils/useInitialValues.ts +++ b/src/components/product/utils/useInitialValues.ts @@ -58,6 +58,7 @@ import { OPTIONS_UNIT, OPTIONS_WEIGHT, ProductMetadataAttributeKeys, + ProductTypeTypeValues, ProductTypeVariantsValues, SUPPORTED_FILE_FORMATS, TOKEN_CRITERIA, @@ -80,6 +81,12 @@ export function useInitialValues() { const isTokenGated = searchParams.get( SellerLandingPageParameters.sltokenGated ); + const productTypeQueryParam = searchParams.get( + SellerLandingPageParameters.slproductType + ); + const productType = Object.values(ProductTypeTypeValues).find( + (validProductType) => validProductType === productTypeQueryParam + ); const fromProductUuid = searchParams.get( SellerHubQueryParameters.fromProductUuid ); @@ -208,6 +215,14 @@ export function useInitialValues() { cloneInitialValues.productType.tokenGatedOffer = "true"; } } + if (productType) { + if (cloneBaseValues.productType) { + cloneBaseValues.productType.productType = productType; + } + if (cloneInitialValues?.productType) { + cloneInitialValues.productType.productType = productType; + } + } return { shouldDisplayModal: diff --git a/src/lib/routing/parameters.ts b/src/lib/routing/parameters.ts index 044246531..dd22b1543 100644 --- a/src/lib/routing/parameters.ts +++ b/src/lib/routing/parameters.ts @@ -35,7 +35,8 @@ export const UrlParameters = { export const SellerLandingPageParameters = { slsteps: "slsteps", // slsteps = seller landing steps sltitle: "sltitle", - sltokenGated: "sltokenGated" + sltokenGated: "sltokenGated", + slproductType: "slproductType" }; export const configQueryParameters = { diff --git a/src/pages/sell/landing/SellerLandingPage.tsx b/src/pages/sell/landing/SellerLandingPage.tsx index 5df5b7dc4..6fd603271 100644 --- a/src/pages/sell/landing/SellerLandingPage.tsx +++ b/src/pages/sell/landing/SellerLandingPage.tsx @@ -1,3 +1,4 @@ +import { ProductTypeTypeValues } from "components/product/utils"; import React from "react"; import styled from "styled-components"; @@ -197,7 +198,13 @@ export const SellerLandingPage: React.FC = () => { VariableStep.AddSalesChannels ], to: { - pathname: SellerCenterRoutes.CreateProduct + pathname: SellerCenterRoutes.CreateProduct, + search: [ + [ + SellerLandingPageParameters.slproductType, + ProductTypeTypeValues.physical + ] + ] }, firstActiveStep: hasSeller ? 1 : 0, doSetQueryParams: true @@ -208,10 +215,27 @@ export const SellerLandingPage: React.FC = () => { image={} title="Create Phygitals" subtitle="Bundle physical products with a digital twin all in one offer" - as="a" - href="https://form.typeform.com/to/NaiNUsqn" - target="_blank" - rel="noopener noreferrer" + onClick={() => { + showModal("VARIABLE_STEPS_EXPLAINER", { + title: "Create Phygitals", + order: [ + VariableStep.CreateYourProfile, + VariableStep.CreateYourProducts, + VariableStep.AddSalesChannels + ], + to: { + pathname: SellerCenterRoutes.CreateProduct, + search: [ + [ + SellerLandingPageParameters.slproductType, + ProductTypeTypeValues.phygital + ] + ] + }, + firstActiveStep: hasSeller ? 1 : 0, + doSetQueryParams: true + }); + }} />