Skip to content

Commit

Permalink
Reset quantity in frontend when product changes (open-telemetry#1447)
Browse files Browse the repository at this point in the history
* reset quantity when product ID changes

* update changelog

---------

Co-authored-by: Juliano Costa <[email protected]>
  • Loading branch information
austinlparker and julianocosta89 authored Mar 13, 2024
1 parent 87e051d commit 5a5eb25
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion src/frontend/pages/product/[productId]/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -32,6 +32,10 @@ const ProductDetail: NextPage = () => {
const { selectedCurrency } = useCurrency();
const productId = query.productId as string;

useEffect(() => {
setQuantity(1);
}, [productId]);

const {
data: {
name,
Expand Down

0 comments on commit 5a5eb25

Please sign in to comment.