'use client'; // @ts-nocheck import { FooterWebsite } from '../footer/FooterWebsite'; import Card from '@/components/card/Card'; import Faq from '@/components/landing/faq'; import InnerContent from '@/components/layout/innerContent'; import NavbarFixed from '@/components/navbar/NavbarFixed'; import { Database } from '@/types_db'; import { getStripe } from '@/utils/stripe/client'; import { Badge, Button, Flex, Icon, Link, SimpleGrid, Text, useColorModeValue } from '@chakra-ui/react'; import { User } from '@supabase/supabase-js'; import { usePathname, useRouter } from 'next/navigation'; import React, { useState } from 'react'; import { FaCcVisa, FaCcMastercard, FaCcPaypal, FaCcAmex, FaCcApplePay } from 'react-icons/fa'; import { MdChevronRight, MdCheckCircle, MdAttachMoney, MdLock, MdOutlineDoDisturbOn } from 'react-icons/md'; import { checkoutWithStripe } from '@/utils/stripe/server'; import { getErrorRedirect } from '@/utils/helpers'; type Subscription = Database['public']['Tables']['subscriptions']['Row']; type Product = Database['public']['Tables']['products']['Row']; type Price = Database['public']['Tables']['prices']['Row']; interface ProductWithPrices extends Product { prices: Price[]; } interface PriceWithProduct extends Price { products: Product | null; } interface SubscriptionWithProduct extends Subscription { prices: PriceWithProduct | null; } interface Props { user: User | null | undefined; products: ProductWithPrices[]; subscription: SubscriptionWithProduct | null; } export default function Pricing({ user, products, subscription }: Props) { const router = useRouter(); const currentPath = usePathname(); const [priceIdLoading, setPriceIdLoading] = useState(); const handleCheckout = async (price: Price) => { setPriceIdLoading(price.id); if (!user) { setPriceIdLoading(undefined); return router.push('/signin/signup'); } const { errorRedirect, sessionId } = await checkoutWithStripe( price, currentPath ); if (errorRedirect) { setPriceIdLoading(undefined); return router.push(errorRedirect); } if (!sessionId) { setPriceIdLoading(undefined); return router.push( getErrorRedirect( currentPath, 'An unknown error occurred.', 'Please try again later or contact a system administrator.' ) ); } const stripe = await getStripe(); stripe?.redirectToCheckout({ sessionId }); setPriceIdLoading(undefined); }; const [version, setVersion] = useState('monthly'); const textColor = useColorModeValue('#120F43', 'white'); const brandColor = useColorModeValue('brand.500', 'white'); const brandColorPrice = useColorModeValue('brand.500', 'white'); const card = useColorModeValue('#fff', 'rgba(255, 255, 255, 0.05)'); return ( {/* Title */} PRICING PLANS Create outstanding Essays for less than a Netflix subscription per month Demo Plan Free Standard Essays Up to 4 Essay types Up to 300 words per Essay Essay Tones (Academic, etc.) Academic Citation formats (APA, etc) Academic Levels (Master, etc.) Premium features Priority Support {products.map((product) => { const price = product?.prices?.find( (price) => price.id === 'price_1P3gGXGx8VbJPRgzdEZODy8K' ); if (product.id === 'prod_PtTCPDFZbburMa') { if (!price) return null; return ( {/* @ts-ignore-nextline */} {product.name?.toString()} $ {price.unit_amount !== null ? price.unit_amount / 100 : price.unit_amount} {version !== 'yearly' ? '/month' : '/month'} {/* {version !== 'yearly' ? 'reg. $24' : 'reg. $24'} */} {/* Features */} Unlimited Premium Essays / month Access to 12+ Essay types Up to 1500 words per Essay Academic Citation formats (APA, etc) Essay Tones (Academic, etc.) Academic Levels (Master, etc.) Exceptional Essays in seconds Easy-to-use Essay Generator Priority Support ); } })} {products.map((product) => { const price = product?.prices?.find( (price) => price.id === 'price_1P3gMyGx8VbJPRgzkoB6Fp8F' ); if (product.id === 'prod_PtTJ6R3RnzmIPX') { if (!price) return null; return ( {product.name?.toString()} Save 35% $ {price.unit_amount !== null ? price.unit_amount / 100 : price.unit_amount} {version !== 'yearly' ? '/year' : '/year'} {version !== 'yearly' ? 'reg.$108' : 'reg.$108'} {/* Features */} Unlimited Premium Essays / year Access to 12+ Essay types Up to 1500 words per Essay Academic Citation formats (APA, etc) Essay Tones (Academic, etc.) Academic Levels (Master, etc.) Exceptional Essays in seconds Easy-to-use Essay Generator Priority Support ); } })} 7-Days money back Secured AES-256 Encrypted payments powered by Stripe: ); }