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:
@@ -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() {
|
||||
|
||||
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user