From fde233dac429957b5db44caa3610161261a0e4e0 Mon Sep 17 00:00:00 2001 From: Christian Andolf Date: Thu, 17 Oct 2024 14:02:14 +0200 Subject: [PATCH] fix(SW-556): don't show toast if we're already at benefits page --- .../Rewards/Surprises/index.tsx | 29 +++++++++++-------- 1 file changed, 17 insertions(+), 12 deletions(-) diff --git a/components/Blocks/DynamicContent/Rewards/Surprises/index.tsx b/components/Blocks/DynamicContent/Rewards/Surprises/index.tsx index d0317236a..86d1ab2c5 100644 --- a/components/Blocks/DynamicContent/Rewards/Surprises/index.tsx +++ b/components/Blocks/DynamicContent/Rewards/Surprises/index.tsx @@ -1,5 +1,6 @@ "use client" +import { usePathname } from "next/navigation" import React, { useState } from "react" import { Dialog, Modal, ModalOverlay } from "react-aria-components" import { useIntl } from "react-intl" @@ -27,6 +28,7 @@ export default function Surprises({ membershipNumber, }: SurprisesProps) { const lang = useLang() + const pathname = usePathname() const [open, setOpen] = useState(true) const [selectedSurprise, setSelectedSurprise] = useState(0) const [showSurprises, setShowSurprises] = useState(false) @@ -49,19 +51,22 @@ export default function Surprises({ function closeModal(close: VoidFunction) { viewRewards() - toast.success( - <> - {intl.formatMessage( - { id: "Gift(s) added to your benefits" }, - { amount: surprises.length } - )} -
- - {intl.formatMessage({ id: "Go to My Benefits" })} - - - ) close() + + if (pathname.indexOf(benefits[lang]) !== 0) { + toast.success( + <> + {intl.formatMessage( + { id: "Gift(s) added to your benefits" }, + { amount: surprises.length } + )} +
+ + {intl.formatMessage({ id: "Go to My Benefits" })} + + + ) + } } const surprise = surprises[selectedSurprise]