web: simplify subscription cancellation

This commit is contained in:
Abdullah Atta
2023-03-20 12:18:04 +05:00
committed by Abdullah Atta
parent be957d058f
commit fb54125ee6

View File

@@ -1288,40 +1288,49 @@ function AccountStatus(props) {
</>
) : isPro ? (
<>
<Button
variant="list"
onClick={async () => {
if (!user.subscription.updateURL)
return showToast(
"error",
"Failed to update. Please reach out to us at support@streetwriters.co so we can help you resolve the issue."
);
window.open(user.subscription.updateURL, "_blank");
}}
>
<Tip
text="Update payment method"
tip="Update the payment method you used to purchase this subscription."
/>
</Button>
<Button
variant="list"
sx={{ ":hover": { borderColor: "error" } }}
onClick={async () => {
if (!user.subscription.cancelURL)
return showToast(
"error",
"Failed to cancel subscription. Please reach out to us at support@streetwriters.co so we can help you resolve the issue."
);
window.open(user.subscription.cancelURL, "_blank");
}}
>
<Tip
color="error"
text="Cancel subscription"
tip="You will be downgraded to the Basic plan at the end of your billing period."
/>
</Button>
{provider === "Web" ? (
<>
<Button
variant="list"
onClick={async () => {
try {
window.open(await db.subscriptions.updateUrl(), "_blank");
} catch (e) {
showToast("error", e.message);
}
}}
>
<Tip
text="Update payment method"
tip="Update the payment method you used to purchase this subscription."
/>
</Button>
<Button
variant="list"
sx={{ ":hover": { borderColor: "error" } }}
onClick={async () => {
try {
await db.subscriptions.cancel();
showToast(
"success",
"Your subscription has been cancelled."
);
setTimeout(() => {
window.location.reload();
}, 5000);
} catch (e) {
showToast("error", e.message);
}
}}
>
<Tip
color="error"
text="Cancel subscription"
tip="You will be downgraded to the Basic plan at the end of your billing period."
/>
</Button>
</>
) : null}
<Text
variant="subBody"
mt={1}