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"
|
"use client"
|
||||||
|
|
||||||
|
import { usePathname, useRouter } from "next/navigation"
|
||||||
import { useEffect, useRef } from "react"
|
import { useEffect, useRef } from "react"
|
||||||
import { useIntl } from "react-intl"
|
import { useIntl } from "react-intl"
|
||||||
|
|
||||||
import { TIER_TO_FRIEND_MAP } from "@/constants/membershipLevels"
|
import { TIER_TO_FRIEND_MAP } from "@/constants/membershipLevels"
|
||||||
|
import { partnerSas } from "@/constants/routes/myPages"
|
||||||
import { trpc } from "@/lib/trpc/client"
|
import { trpc } from "@/lib/trpc/client"
|
||||||
|
|
||||||
import { toast } from "@/components/TempDesignSystem/Toasts"
|
import { toast } from "@/components/TempDesignSystem/Toasts"
|
||||||
|
import useLang from "@/hooks/useLang"
|
||||||
|
|
||||||
export function SASLevelUpgradeCheck() {
|
export function SASLevelUpgradeCheck() {
|
||||||
const firedRef = useRef(false)
|
const firedRef = useRef(false)
|
||||||
const intl = useIntl()
|
const intl = useIntl()
|
||||||
|
const lang = useLang()
|
||||||
|
const pathname = usePathname()
|
||||||
|
const router = useRouter()
|
||||||
|
|
||||||
const { mutate } = trpc.partner.sas.performLevelUpgrade.useMutation({
|
const { mutate } = trpc.partner.sas.performLevelUpgrade.useMutation({
|
||||||
onSuccess(result) {
|
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() {
|
onError() {
|
||||||
|
|||||||
@@ -68,7 +68,7 @@ export const requestOtp = protectedProcedure
|
|||||||
if (parseResult.data.status === "SENT") {
|
if (parseResult.data.status === "SENT") {
|
||||||
setSASOtpCookie(parseResult.data)
|
setSASOtpCookie(parseResult.data)
|
||||||
} else {
|
} 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)
|
console.warn(sasRequestOtpErrorMessage)
|
||||||
Sentry.captureMessage(sasRequestOtpErrorMessage)
|
Sentry.captureMessage(sasRequestOtpErrorMessage)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user