/* 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 { definitions } from 'types/database/index'; import router from 'next/router'; import { useAuth } from 'utils/AuthContext'; const Pricing = (): JSX.Element => { const { user, session } = useAuth(); const [customerId, setCustomerId] = useState(); const [sub, setSub] = useState(); useEffect(() => { if (user) { const subFunction = async (): Promise => { const sub = await getSub(); if (sub) { setSub(sub); } const subSupa = await supabase .from('subscriptions') .select(`customer_id`) .eq('id', user.id) .single(); setCustomerId(subSupa.data?.customer_id); }; void subFunction(); } }, [user]); interface Test { url: string; } const handleSubmit = async ( event: React.SyntheticEvent, priceId: string ): Promise => { event.preventDefault(); // Create a Checkout Session. This will redirect the user to the Stripe website for the payment. if (user && session) { if (sub) { const stripeInfo = await axios.post( '/api/stripe/customerPortal', { customerId, } ); void router.push(stripeInfo.data.url); } else { const stripeInfo = await axios.post('/api/stripe/checkout', { priceId, email: user.email, customerId, userId: user.id, tokenId: session.access_token, pay_mode: 'subscription', }); void router.push(stripeInfo.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;