import React from "react"; import { Modal, Group, Button, Divider, ModalProps, Text, Image, Anchor } from "@mantine/core"; import { toast } from "react-hot-toast"; import { supabase } from "src/lib/api/supabase"; import useModal from "src/store/useModal"; export const CancelPremiumModal: React.FC = ({ opened, onClose }) => { const [cancelling, setCancelling] = React.useState(false); const showFeedback = useModal(state => state.setVisible("review")); const cancelSub = async () => { try { setCancelling(true); const { data: user } = await supabase.auth.getSession(); if (user) { const { error } = await supabase.functions.invoke("lemonsqueezy", { method: "DELETE", body: { jwt: user.session?.access_token, }, }); if (error) { return toast.error( "An error occured while cancelling subscription, please contact: contact@jsoncrack.com" ); } toast.success("Cancelled premium plan!"); showFeedback(true); } else { toast.error("Couldn't fetch user details, please contact: contact@jsoncrack.com"); } toast.success("Cancelled premium plan!"); onClose(); } catch (err) { console.error(err); } finally { setCancelling(false); } }; return ( taken Cancellation will take effect at the end of your current billing period.

You can restart your subscription anytime.
Click here to cancel if you are Patreon member If you have problems with cancelling plan please contact: contact@jsoncrack.com
); };