web: allow requesting refunds from settings

This commit is contained in:
Abdullah Atta
2023-05-01 12:55:33 +05:00
committed by Abdullah Atta
parent a0229729b7
commit 7f873f240e
2 changed files with 44 additions and 0 deletions

View File

@@ -1357,6 +1357,40 @@ function AccountStatus(props) {
tip="Update the payment method you used to purchase this subscription."
/>
</Button>
<Button
variant="list"
onClick={async () => {
const refundSubscription = await confirm({
title: "Request refund?",
message:
"You will only be issued a refund if you are eligible as per our refund policy. Your account will be immediately downgraded to Basic and your funds will be transferred to your account within 24 hours.",
negativeButtonText: "No",
positiveButtonText: "Yes"
});
if (refundSubscription) {
const error = await TaskManager.startTask({
id: "refund-subscription",
type: "modal",
title: "Requesting refund for your subscription",
subtitle: "Please wait...",
action: () => db.subscriptions.refund()
});
if (error instanceof Error) {
showToast("error", error.message);
} else {
showToast(
"success",
"Your refund has been issued. Please wait 24 hours before reaching out to us in case you do not receive your funds."
);
}
}
}}
>
<Tip
text="Request refund"
tip="If you are eligible for a refund, your account will be immediately downgraded to Basic and your funds will be transferred to your account within 24 hours."
/>
</Button>
<Button
variant="list"
sx={{ ":hover": { borderColor: "error" } }}

View File

@@ -34,6 +34,16 @@ export default class Subscriptions {
await http.delete(`${hosts.SUBSCRIPTIONS_HOST}/subscriptions`, token);
}
async refund() {
const token = await this._tokenManager.getAccessToken();
if (!token) return;
await http.post(
`${hosts.SUBSCRIPTIONS_HOST}/subscriptions/refund`,
null,
token
);
}
async updateUrl() {
const token = await this._tokenManager.getAccessToken();
if (!token) return;