'use client'; import { Slider } from '@gitroom/react/form/slider'; import React, { FC, useCallback, useEffect, useMemo, useState } from 'react'; import { Button } from '@gitroom/react/form/button'; import { sortBy } from 'lodash'; import { Track } from '@gitroom/react/form/track'; import { useFetch } from '@gitroom/helpers/utils/custom.fetch'; import { Subscription } from '@prisma/client'; import { useDebouncedCallback } from 'use-debounce'; import ReactLoading from 'react-loading'; import { deleteDialog } from '@gitroom/react/helpers/delete.dialog'; import { useToaster } from '@gitroom/react/toaster/toaster'; import dayjs from 'dayjs'; import clsx from 'clsx'; import { pricing } from '@gitroom/nestjs-libraries/database/prisma/subscriptions/pricing'; import { FAQComponent } from '@gitroom/frontend/components/billing/faq.component'; import { useSWRConfig } from 'swr'; import { useUser } from '@gitroom/frontend/components/layout/user.context'; import interClass from '@gitroom/react/helpers/inter.font'; import { useRouter } from 'next/navigation'; import { useVariables } from '@gitroom/react/helpers/variable.context'; import { useModals } from '@mantine/modals'; import { AddProviderComponent } from '@gitroom/frontend/components/launches/add.provider.component'; import { TopTitle } from '@gitroom/frontend/components/launches/helpers/top.title.component'; import { Textarea } from '@gitroom/react/form/textarea'; export interface Tiers { month: Array<{ name: 'Pro' | 'Standard'; recurring: 'month' | 'year'; price: number; }>; year: Array<{ name: 'Pro' | 'Standard'; recurring: 'month' | 'year'; price: number; }>; } export const Prorate: FC<{ period: 'MONTHLY' | 'YEARLY'; pack: 'STANDARD' | 'PRO'; }> = (props) => { const { period, pack } = props; const fetch = useFetch(); const [price, setPrice] = useState(0); const [loading, setLoading] = useState(false); const calculatePrice = useDebouncedCallback(async () => { setLoading(true); setPrice( ( await ( await fetch('/billing/prorate', { method: 'POST', body: JSON.stringify({ period, billing: pack, }), }) ).json() ).price ); setLoading(false); }, 500); useEffect(() => { setPrice(false); calculatePrice(); }, [period, pack]); if (loading) { return (
); } if (price === false) { return null; } return (
(Pay Today ${(price < 0 ? 0 : price)?.toFixed(1)})
); }; export const Features: FC<{ pack: 'FREE' | 'STANDARD' | 'PRO'; }> = (props) => { const { pack } = props; const features = useMemo(() => { const currentPricing = pricing[pack]; const channelsOr = currentPricing.channel; const list = []; list.push(`${channelsOr} ${channelsOr === 1 ? 'channel' : 'channels'}`); list.push( `${ currentPricing.posts_per_month > 10000 ? 'Unlimited' : currentPricing.posts_per_month } posts per month` ); if (currentPricing.team_members) { list.push(`Unlimited team members`); } if (currentPricing?.ai) { list.push(`AI auto-complete`); list.push(`AI copilots`); list.push(`AI Autocomplete`); } list.push(`Advanced Picture Editor`); if (currentPricing?.image_generator) { list.push( `${currentPricing?.image_generation_count} AI Images per month` ); } list.push(`Marketplace full access`); return list; }, [pack]); return (
{features.map((feature) => (
{feature}
))}
); }; const Info: FC<{ proceed: (feedback: string) => void }> = (props) => { const [feedback, setFeedback] = useState(''); const modal = useModals(); const cancel = useCallback(() => { props.proceed(feedback); modal.closeAll(); }, [modal, feedback]); return (
We are sorry to see you go :(
Would you mind shortly tell us what we could have done better?