import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; import { useUser } from "../../contexts/user"; import useActivePlan from "../../hooks/useActivePlan"; import LatestPayment from "./LatestPayment"; import SuggestedPlan from "./SuggestedPlan"; dayjs.extend(relativeTime); const CurrentPlan = () => { const { user, error: userError } = useUser(); const { plans, activePlan, error: plansError } = useActivePlan(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
))}