import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; import { useUser } from "../../contexts/user"; import useActivePlan from "../../hooks/useActivePlan"; import humanBytes from "../../lib/humanBytes"; import { ContainerLoadingIndicator } from "../LoadingIndicator"; 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 ; } if (userError || plansError) { return (

An error occurred while loading this data.

We'll retry automatically.

); } return (

{activePlan.name}

{activePlan.price === 0 && activePlan.limits && (

{humanBytes(activePlan.limits.storageLimit)} 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

))} {user.subscriptionStatus && }
); }; export default CurrentPlan;