// resources/js/Pages/User/Partials/upgrade-sheet.jsx import { usePage } from '@inertiajs/react'; import { SparklesText } from '@/components/magicui/sparkles-text'; import { Accordion, AccordionContent, AccordionItem, AccordionTrigger } from '@/components/ui/accordion'; import { Button } from '@/components/ui/button'; import { Sheet, SheetClose, SheetContent, SheetDescription, SheetFooter, SheetHeader, SheetTitle } from '@/components/ui/sheet'; import { Spinner } from '@/components/ui/spinner.js'; import { useMitt } from '@/plugins/MittContext'; import CartIcon from '@/reusables/cart-icon.jsx'; import CoinIcon from '@/reusables/coin-icon.jsx'; import usePricingStore from '@/stores/PricingStore.js'; import useUserStore from '@/stores/UserStore.js'; import { Download, ShieldIcon } from 'lucide-react'; import { useEffect, useState } from 'react'; import UpgradePlanCarousel from './partials/upgrade-plan-carousel.tsx'; const UpgradeSheet = () => { const { subscription, one_times, isFetchingPricing, fetchPricing, isCheckingOut, checkoutSubscribe, checkoutPurchase } = usePricingStore(); const { plan, billing, user_usage, credits, redirectBillingPortal, isRedirectingToBilling } = useUserStore(); const { auth } = usePage().props; // State to control sheet visibility const [isOpen, setIsOpen] = useState(false); // Get mitt emitter const emitter = useMitt(); useEffect(() => { fetchPricing(); }, []); // FAQ data array const faqData = [ { q: "What's included in the $4/m Personal Creator Plan?", a: 'This $4/m plan includes 50 non-watermark videos for export (8ยข per video), which is sufficient for every creator to post almost twice a day.

This plan also includes a Personal license, which allows you to use the app for personal social media, creator and non-commercial projects.

If you are a creator looking to monetize your channel, this plan is the perfect choice for you.', }, { q: 'Why are your plans extremely affordable for creators?', a: "We're glad you think this way! As creators ourselves, we know the journey of creating and monetizing your channel is not easy.

We believe that creators deserve access to high quality videos, and we're committed to making it accessible to every creator.

If one day you've made it to the top, don't forget us! We'd love to hear your growth stories.", }, { q: 'Can I use the Personal Creator Plan for my business & commercial projects?', a: "A hard NO.

The Personal Creator Plan is designed for personal social media, creator and non-commercial projects.

If you are a creator looking to monetize your channel, this plan is the right choice for you. The Personal Creator Plan is designed to empower creators, helping them to monetize their channels and grow their audience.

However, if you are a business, we recommend you to use the Business Creator Plan (coming soon), which contains a Business License that you can use for commercial projects.

Contact us if you have an urgent need for this plan, and we'll see what can be done to help you.", }, { q: 'How do I lock in my subscription price?', a: "Simple! Just subscribe to the plan before the next price change. We can't guarantee that you'll be able to purchase the same plan at the current price that you've locked in. But we'll do our best to make sure you get the best value for your money.", }, { q: 'Is the $4/month pricing permanent?', a: 'Yes, the $4/month launch pricing is a special offer for our first 1000 users. After 1000 users, the plan will be priced at a higher rate. Lock in your launch pricing by subscribing now!', }, { q: 'What can I do with credits?', a: 'You can use credits to access AI features such as AI caption generation & AI background generation.', }, // { // q: 'What is the difference of purchasing credits from a subscription vs a one-time credit pack?', // a: 'When you purchase credits from a subscription, (e.g. 500 Credits/m) you get monthly allowance of 500 credits. Unused credits will not be carry forwarded to the next month.

When you purchase credits from a credit pack, (e.g. 500 Credit Pack) the credits will not expire and you can use them anytime.', // }, { q: 'Can I cancel my subscription anytime?', a: "Yes! You can cancel your subscription at any time. Your plan will remain active until the end of your current billing period, and you'll retain access to all premium features during that time. Just know that you might not be able to purchase the same plan at the current price that you've locked in.", }, { q: 'Do you offer refunds?', a: 'Yes, we offer refunds for subscription plans. Credits are non-refundable once purchased as they do not expire.', }, ]; useEffect(() => { // Listen for open modal event const openModalListener = () => { setIsOpen(true); }; // Register listener for opening the modal emitter.on('openUpgradeSheet', openModalListener); // Cleanup return () => { emitter.off('openUpgradeSheet', openModalListener); }; }, [emitter]); // Handle sheet state changes const handleOpenChange = (open) => { setIsOpen(open); // If sheet is closing, emit the close event if (!open) { emitter.emit('closeUpgradeSheet'); } }; const handleSubscribe = (subscription) => { checkoutSubscribe(subscription.stripe_monthly_price_id); }; const handlePurchaseOneTime = (one_time) => { checkoutPurchase(one_time.stripe_price_id); }; const handleRedirectBillingPortal = () => { redirectBillingPortal(); }; return ( Store
{auth?.user ? (
{/* Non-watermark Exports */} {user_usage?.non_watermark_videos_left != null && (
Non-watermark Exports
{user_usage?.non_watermark_videos_left}
exports left
)} {/* Credits */} {credits != null && (
Credits
{credits}
available
)}
) : (
Have an account with us?
)} {subscription ? ( <> {auth.user && plan.tier != 'free' ? (
You're now in the {plan?.name} plan!
) : (
Upgrade to {subscription?.name} Plan

at only {subscription?.symbol} {subscription?.amount} {subscription?.primary_interval === 'month' ? '/m' : '/y'}*
* Launch pricing limited to first 1000 users
)} ) : ( isFetchingPricing && (
) )}
Buy Credit Packs
Unlock AI meme captions and backgrounds with credits. Perfect for overcoming creator's block and discovering new concepts.
{one_times.map((one_time, index) => (
{one_time.name}
{one_time.description}
{one_time.symbol} {one_time.amount} per pack
))}
All our billing & payments are securely processed by Stripe.
{!(auth.user && plan.tier != 'free') && (
Frequently Asked Questions
{faqData.map((faq, index) => ( {faq.q}
))}
)}
); }; export default UpgradeSheet;