Merged in feat/sw-1732-trigger-tier-match (pull request #1408)

SW-1732 Trigger SAS tier match

* Add endpoint for SAS tier match

* Add comment about future fix

* Move tier match to background request on my-pages/*

* Log result from tier match

* Clean up name etc

* Fix tier matched toast

Approved-by: Joakim Jäderberg
This commit is contained in:
Anton Gunnarsson
2025-03-13 14:12:31 +00:00
parent 4df5e52a92
commit 29f0eb4f21
13 changed files with 170 additions and 86 deletions

View File

@@ -1,50 +0,0 @@
"use client"
import { useIntl } from "react-intl"
import { trpc } from "@/lib/trpc/client"
import Refresh from "@/components/Icons/Refresh"
import { Loading } from "@/components/Loading"
import Button from "@/components/TempDesignSystem/Button"
import { toast } from "@/components/TempDesignSystem/Toasts"
import styles from "./levelupgradebutton.module.css"
export function LevelUpgradeButton() {
const intl = useIntl()
const { mutate, isPending } =
trpc.partner.sas.performLevelUpgrade.useMutation({
onSuccess() {
toast.success(intl.formatMessage({ id: "Level upgraded" }))
},
onError() {
toast.error(intl.formatMessage({ id: "Failed to upgrade level" }))
},
})
const handleClick = () => {
mutate()
}
return (
<>
<Button
intent="primary"
theme="primaryLight"
onClick={handleClick}
className={styles.button}
>
<div
className={styles.textContainer}
style={{ visibility: isPending ? "hidden" : "visible" }}
>
<Refresh color="currentColor" />
{intl.formatMessage({ id: "Check for level upgrade" })}
</div>
{isPending && <Loading color="white" className={styles.loading} />}
</Button>
</>
)
}

View File

@@ -1,25 +0,0 @@
.button {
position: relative;
display: flex;
justify-content: center;
align-items: center;
width: 100%;
& .textContainer {
display: flex;
justify-content: center;
align-items: center;
gap: var(--Spacing-x1);
}
@media screen and (min-width: 768px) {
width: fit-content;
}
}
.loading {
position: absolute;
&.hidden {
opacity: 0;
}
}