diff --git a/src/containers/Modals/CancelPremiumModal/index.tsx b/src/containers/Modals/CancelPremiumModal/index.tsx index 6dc682e..61ea099 100644 --- a/src/containers/Modals/CancelPremiumModal/index.tsx +++ b/src/containers/Modals/CancelPremiumModal/index.tsx @@ -1,17 +1,28 @@ 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 { altogic } from "src/api/altogic"; export const CancelPremiumModal: React.FC = ({ opened, onClose }) => { + const [cancelling, setCancelling] = React.useState(false); + const cancelSub = async () => { - altogic.endpoint.delete("/subscription").then(({ data, errors }) => { + try { + setCancelling(true); + const { errors } = await altogic.endpoint.delete("/subscription"); + if (errors?.items.length) { - toast.error("An error occured while cancelling plan!"); - console.log(errors.items); + return toast.error( + "An error occured while cancelling plan! Please contact support@herowand.com" + ); } + toast.success("Cancelled premium plan!"); - }); + } catch (err) { + console.error(err); + } finally { + setCancelling(false); + } }; return ( @@ -22,13 +33,17 @@ export const CancelPremiumModal: React.FC = ({ opened, onClose }) =>

You can restart your subscription anytime. +
+ + Click here to cancel if you are Patreon member + -