import React from 'react' import { useMyAboStatus } from '../hooks/getAbo' type Props = { onAboChange?: (aboId: string | number | null) => void } export default function UserAbo({ onAboChange }: Props) { const { hasAbo, abonement, loading, error } = useMyAboStatus() React.useEffect(() => { if (!onAboChange) return onAboChange(abonement?.id ?? null) }, [abonement?.id, onAboChange]) if (loading) { return (

My Subscriptions

Loading subscriptions…
) } if (error) { return (

My Subscriptions

{error}
) } return (

My Subscription

{(!hasAbo || !abonement) ? (
You currently don’t have an active subscription.
) : (
{(() => { const status = (abonement.status || 'active') as 'active' | 'paused' | 'canceled' const nextBilling = abonement.nextBillingAt ? new Date(abonement.nextBillingAt).toLocaleDateString() : '—' const started = abonement.startedAt ? new Date(abonement.startedAt).toLocaleDateString() : '—' const coffees = (abonement.pack_breakdown || abonement.items || []).map((it, i) => ( {/* coffee name */} {it.coffeeName || `Coffee #${it.coffeeId}`} {/* packs pill — CHANGED COLORS TO MATCH ACTIVE BADGE */} {it.quantity} packs )) return (

{abonement.name || 'Coffee Subscription'}

Next billing: {nextBilling} {' • '}Frequency: {abonement.frequency ?? '—'} {' • '}Country: {(abonement.country ?? '').toUpperCase() || '—'} {' • '}Started: {started}

{status.charAt(0).toUpperCase() + status.slice(1)}

Coffees

{coffees}
) })()}
)}
) }