From ab51207548af314788be745ba6b96c1fd42b1099 Mon Sep 17 00:00:00 2001 From: Belen Curcio Date: Mon, 19 Oct 2020 12:02:17 -0300 Subject: [PATCH] Active Product Page back to working again --- .../product/ProductView/ProductView.tsx | 25 +++++++------------ components/product/Swatch/Swatch.tsx | 3 ++- lib/logger.ts | 15 ++++++++++- package.json | 2 ++ yarn.lock | 12 +++++++++ 5 files changed, 39 insertions(+), 18 deletions(-) diff --git a/components/product/ProductView/ProductView.tsx b/components/product/ProductView/ProductView.tsx index e8f91c99b..71d874a25 100644 --- a/components/product/ProductView/ProductView.tsx +++ b/components/product/ProductView/ProductView.tsx @@ -15,19 +15,12 @@ interface Props { product: Product } -interface Choices { - size?: string | null - color?: string | null -} - const ProductView: FC = ({ product, className }) => { - const options = getProductOptions(product) - // console.log(options) - const addItem = useAddItem() const { openSidebar } = useUI() + const options = getProductOptions(product) - const [choices, setChoices] = useState({ + const [choices, setChoices] = useState>({ size: null, color: null, }) @@ -48,9 +41,6 @@ const ProductView: FC = ({ product, className }) => { } } - const activeSize = choices.size - const activeColor = choices.color - return ( = ({ product, className }) => { {/** TODO: Change with Image Component */} {product.images.edges?.map((image, i) => ( = ({ product, className }) => {
{options?.map((opt: any) => ( -
+

{opt.displayName}

{opt.values.map((v: any) => { + const active = choices[opt.displayName] + return ( + onClick={() => { setChoices((choices) => { return { ...choices, [opt.displayName]: v.label, } }) - } + }} /> ) })} diff --git a/components/product/Swatch/Swatch.tsx b/components/product/Swatch/Swatch.tsx index 3085e6e0a..6d8a7dfb2 100644 --- a/components/product/Swatch/Swatch.tsx +++ b/components/product/Swatch/Swatch.tsx @@ -24,7 +24,7 @@ const Swatch: FC = ({ }) => { variant = variant?.toLowerCase() label = label?.toLowerCase() - // console.log(variant) + const rootClassName = cn( s.root, { @@ -38,6 +38,7 @@ const Swatch: FC = ({