/* This is the pricing component. You can switch between flat payment or subscription by setting the flat variable. ---------- Dont forget to create your customer portal on Stripe https://dashboard.stripe.com/test/settings/billing/portal */ import { getSub, supabase } from 'utils/supabaseClient'; import { useEffect, useState } from 'react'; import axios from 'axios'; import router from 'next/router'; import { useAuth } from 'utils/AuthContext'; const Pricing = (): JSX.Element => { const { user, session } = useAuth(); const [customerId, setCustomerId] = useState(null); const [sub, setSub] = useState(false); useEffect(() => { if (user) { getSub().then((result) => setSub(result)); supabase .from('subscriptions') .select(`customer_id`) .eq('id', user.id) .single() .then((result) => { setCustomerId(result.data?.customer_id); }); } }, [user]); const handleSubmit = async (e: React.SyntheticEvent, priceId: string) => { e.preventDefault(); // Create a Checkout Session. This will redirect the user to the Stripe website for the payment. if (sub) { axios .post('/api/stripe/customer-portal', { customerId, }) .then((result) => { router.push(result.data.url); }); } else axios .post('/api/stripe/create-checkout-session', { priceId, email: user.email, customerId, userId: user.id, tokenId: session.access_token, pay_mode: 'subscription', }) .then((result) => router.push(result.data.url)); }; return (

Pricing

Casual

FREE
  • Up to 10 projects
  • Up to 20 collaborators
  • 10Gb of storage

Professional

$4.90 /month
  • Up to 30 projects
  • Up to 25 collaborators
  • 100Gb of storage
  • Real-time collaborations
{user ? ( ) : ( )}

Business

$24.90 /month
  • Up to 60 projects
  • Up to 200 collaborators
  • 1Tb of storage
  • Real-time collaborations
{user ? ( ) : ( )}
); }; export default Pricing;