import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; import { useUser } from "../../contexts/user"; import useSubscriptionPlans from "../../hooks/useSubscriptionPlans"; import LatestPayment from "./LatestPayment"; import SuggestedPlan from "./SuggestedPlan"; dayjs.extend(relativeTime); const CurrentPlan = () => { const { user, error: userError } = useUser(); const { activePlan, plans, error: plansError } = useSubscriptionPlans(user); if (!user || !activePlan) { return ( // TODO: a nicer loading indicator
An error occurred while loading this data.
We'll retry automatically.
100GB without paying a dime! 🎉
} {activePlan.price !== 0 && (user.subscriptionCancelAtPeriodEnd ? (Your subscription expires {dayjs(user.subscribedUntil).fromNow()}
) : ({dayjs(user.subscribedUntil).fromNow(true)} until the next payment
))}