From 5a5eb25549f90b30f3b63452f817a08d0f466896 Mon Sep 17 00:00:00 2001 From: Austin Parker Date: Wed, 13 Mar 2024 08:01:36 -0400 Subject: [PATCH] Reset quantity in frontend when product changes (#1447) * reset quantity when product ID changes * update changelog --------- Co-authored-by: Juliano Costa --- CHANGELOG.md | 2 ++ src/frontend/pages/product/[productId]/index.tsx | 6 +++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 03d82cc02c..f66a41042a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ the release. ## Unreleased +* [frontend] reset quantity when new product selected + ([#1447](https://github.com/open-telemetry/opentelemetry-demo/pull/1447)) * [featureflag] deprecate in favor of flagd ([#1338](https://github.com/open-telemetry/opentelemetry-demo/pull/1388)) * [checkoutservice] add producer interceptor for tracing diff --git a/src/frontend/pages/product/[productId]/index.tsx b/src/frontend/pages/product/[productId]/index.tsx index 02a9cfaca3..c0a4dbd086 100644 --- a/src/frontend/pages/product/[productId]/index.tsx +++ b/src/frontend/pages/product/[productId]/index.tsx @@ -4,7 +4,7 @@ import { NextPage } from 'next'; import Image from 'next/image'; import { useRouter } from 'next/router'; -import { useCallback, useState } from 'react'; +import { useCallback, useState, useEffect } from 'react'; import { useQuery } from '@tanstack/react-query'; import Ad from '../../../components/Ad'; import Footer from '../../../components/Footer'; @@ -32,6 +32,10 @@ const ProductDetail: NextPage = () => { const { selectedCurrency } = useCurrency(); const productId = query.productId as string; + useEffect(() => { + setQuantity(1); + }, [productId]); + const { data: { name,