mirror of
https://github.com/AykutSarac/jsoncrack.com.git
synced 2025-01-27 15:22:56 +08:00
fix cancel premium btn
This commit is contained in:
parent
9a8d5f334d
commit
5964b257c3
@ -1,17 +1,28 @@
|
|||||||
import React from "react";
|
import React from "react";
|
||||||
import { Modal, Group, Button, Divider, ModalProps, Text, Image } from "@mantine/core";
|
import { Modal, Group, Button, Divider, ModalProps, Text, Image, Anchor } from "@mantine/core";
|
||||||
import { toast } from "react-hot-toast";
|
import { toast } from "react-hot-toast";
|
||||||
import { altogic } from "src/api/altogic";
|
import { altogic } from "src/api/altogic";
|
||||||
|
|
||||||
export const CancelPremiumModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
export const CancelPremiumModal: React.FC<ModalProps> = ({ opened, onClose }) => {
|
||||||
|
const [cancelling, setCancelling] = React.useState(false);
|
||||||
|
|
||||||
const cancelSub = async () => {
|
const cancelSub = async () => {
|
||||||
altogic.endpoint.delete("/subscription").then(({ data, errors }) => {
|
try {
|
||||||
|
setCancelling(true);
|
||||||
|
const { errors } = await altogic.endpoint.delete("/subscription");
|
||||||
|
|
||||||
if (errors?.items.length) {
|
if (errors?.items.length) {
|
||||||
toast.error("An error occured while cancelling plan!");
|
return toast.error(
|
||||||
console.log(errors.items);
|
"An error occured while cancelling plan! Please contact support@herowand.com"
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
toast.success("Cancelled premium plan!");
|
toast.success("Cancelled premium plan!");
|
||||||
});
|
} catch (err) {
|
||||||
|
console.error(err);
|
||||||
|
} finally {
|
||||||
|
setCancelling(false);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@ -22,13 +33,17 @@ export const CancelPremiumModal: React.FC<ModalProps> = ({ opened, onClose }) =>
|
|||||||
<br />
|
<br />
|
||||||
<br />
|
<br />
|
||||||
You can restart your subscription anytime.
|
You can restart your subscription anytime.
|
||||||
|
<br />
|
||||||
|
<Anchor target="_blank" href="https://patreon.com/herowand">
|
||||||
|
Click here to cancel if you are Patreon member
|
||||||
|
</Anchor>
|
||||||
</Text>
|
</Text>
|
||||||
<Divider py="xs" />
|
<Divider py="xs" />
|
||||||
<Group position="right">
|
<Group position="right">
|
||||||
<Button color="dark" variant="subtle" onClick={onClose}>
|
<Button color="dark" variant="subtle" onClick={onClose}>
|
||||||
Cancel
|
Cancel
|
||||||
</Button>
|
</Button>
|
||||||
<Button onClick={cancelSub} color="red">
|
<Button onClick={cancelSub} loading={cancelling} color="red">
|
||||||
QUIT SUBSCRIPTION
|
QUIT SUBSCRIPTION
|
||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user