import { Link } from '@inertiajs/react'; import BillingController from '@/actions/App/Http/Controllers/BillingController'; import { Button } from '@/components/ui/button'; import type { Usage } from '@/types'; /** Whole days from now until the given moment, never below zero. */ export function daysLeft(iso: string | null): number { if (!iso) { return 0; } return Math.max( 0, Math.ceil((new Date(iso).getTime() - Date.now()) / 86_400_000), ); } /** * A short reminder about the free trial, or that it has ended. Shows nothing for paying merchants. */ export default function PlanNotice({ usage }: { usage: Usage }) { if (usage.active && !usage.on_trial) { return null; } const days = daysLeft(usage.trial_ends_at); return (
{usage.active ? `You are on the free trial. ${days === 1 ? '1 day' : `${days} days`} left.` : 'Your free trial has ended. Your stores are offline until you choose a plan.'}