Merged in fix/sw-2453-refresh-data-on-tier-match (pull request #1866)

Refresh page if tier match happens on My Pages SAS page

* Refresh page if tier match happens on My Pages SAS page


Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-04-28 07:28:58 +00:00
parent 6cf01e8990
commit 8f67e20300
2 changed files with 13 additions and 1 deletions

View File

@@ -1,16 +1,22 @@
"use client"
import { usePathname, useRouter } from "next/navigation"
import { useEffect, useRef } from "react"
import { useIntl } from "react-intl"
import { TIER_TO_FRIEND_MAP } from "@/constants/membershipLevels"
import { partnerSas } from "@/constants/routes/myPages"
import { trpc } from "@/lib/trpc/client"
import { toast } from "@/components/TempDesignSystem/Toasts"
import useLang from "@/hooks/useLang"
export function SASLevelUpgradeCheck() {
const firedRef = useRef(false)
const intl = useIntl()
const lang = useLang()
const pathname = usePathname()
const router = useRouter()
const { mutate } = trpc.partner.sas.performLevelUpgrade.useMutation({
onSuccess(result) {
@@ -25,6 +31,12 @@ export function SASLevelUpgradeCheck() {
}
)
)
// If we are on the SAS partner page we need to refresh the data to show the new level
const sasPartnerPagePathname = partnerSas[lang]
if (pathname === sasPartnerPagePathname) {
router.refresh()
}
}
},
onError() {

View File

@@ -68,7 +68,7 @@ export const requestOtp = protectedProcedure
if (parseResult.data.status === "SENT") {
setSASOtpCookie(parseResult.data)
} else {
const sasRequestOtpErrorMessage = `[SAS] requestOtp did not return SENT status with body: ${body}`
const sasRequestOtpErrorMessage = `[SAS] requestOtp did not return SENT status with body: ${JSON.stringify(body)}`
console.warn(sasRequestOtpErrorMessage)
Sentry.captureMessage(sasRequestOtpErrorMessage)
}