Make the subscriptions card expandable and collapsible.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
parent
9720daea05
commit
c886802cd6
|
|
@ -155,27 +155,42 @@ function ActiveSubscriptionsCard({
|
|||
onGrant: () => void
|
||||
onCancel: (subscription: UserSubscriptionRecord) => void
|
||||
}) {
|
||||
const [expanded, setExpanded] = useState(true)
|
||||
const anyActive = subscriptions.some(
|
||||
(subscription) =>
|
||||
subscription.is_currently_active || subscription.status.toUpperCase() === "ACTIVE",
|
||||
)
|
||||
|
||||
return (
|
||||
<div className="rounded-2xl border border-grayScale-200 bg-white p-5 shadow-sm sm:p-6">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div>
|
||||
<div className="rounded-2xl border border-grayScale-200 bg-white shadow-sm">
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-start justify-between gap-3 px-5 py-4 text-left sm:px-6 sm:py-5"
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
<div className="min-w-0 flex-1">
|
||||
<h3 className="text-base font-bold text-grayScale-900">Subscriptions</h3>
|
||||
<p className="mt-0.5 text-xs text-grayScale-500">
|
||||
{subscriptions.length} active plan{subscriptions.length === 1 ? "" : "s"}
|
||||
</p>
|
||||
</div>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<ActiveStatusBadge
|
||||
label={anyActive ? "Active" : formatStatusLabel(subscriptions[0]?.status || "Inactive")}
|
||||
tone={anyActive ? "active" : "inactive"}
|
||||
/>
|
||||
{expanded ? (
|
||||
<ChevronDown className="h-4 w-4 text-grayScale-400" />
|
||||
) : (
|
||||
<ChevronRight className="h-4 w-4 text-grayScale-400" />
|
||||
)}
|
||||
</div>
|
||||
</button>
|
||||
|
||||
<div className="mt-4 space-y-3 border-t border-grayScale-100 pt-4">
|
||||
{expanded ? (
|
||||
<div className="space-y-6 border-t border-grayScale-100 px-5 pb-5 pt-4 sm:px-6 sm:pb-6">
|
||||
<div className="space-y-3">
|
||||
{subscriptions.map((subscription) => {
|
||||
const daysLeft = getDaysLeft(subscription)
|
||||
const statusUpper = subscription.status.toUpperCase()
|
||||
|
|
@ -235,7 +250,7 @@ function ActiveSubscriptionsCard({
|
|||
})}
|
||||
</div>
|
||||
|
||||
<div className="mt-6 flex flex-col gap-2">
|
||||
<div className="flex flex-col gap-2">
|
||||
{canExtend ? (
|
||||
<Button
|
||||
type="button"
|
||||
|
|
@ -270,6 +285,8 @@ function ActiveSubscriptionsCard({
|
|||
) : null}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -288,23 +305,37 @@ function EmptySubscriptionCard({
|
|||
grantEnabled: boolean
|
||||
onGrant: () => void
|
||||
}) {
|
||||
const [expanded, setExpanded] = useState(true)
|
||||
const upper = displayStatus.toUpperCase()
|
||||
const tone =
|
||||
upper === "ACTIVE" ? "active" : upper === "PENDING" ? "pending" : "inactive"
|
||||
|
||||
return (
|
||||
<div className="rounded-2xl border border-grayScale-200 bg-white p-5 shadow-sm sm:p-6">
|
||||
<div className="flex items-start justify-between gap-3">
|
||||
<div className="rounded-2xl border border-grayScale-200 bg-white shadow-sm">
|
||||
<button
|
||||
type="button"
|
||||
className="flex w-full items-start justify-between gap-3 px-5 py-4 text-left sm:px-6 sm:py-5"
|
||||
onClick={() => setExpanded((value) => !value)}
|
||||
aria-expanded={expanded}
|
||||
>
|
||||
<h3 className="text-base font-bold text-grayScale-900">Subscriptions</h3>
|
||||
<div className="flex shrink-0 items-center gap-2">
|
||||
<ActiveStatusBadge
|
||||
label={formatStatusLabel(displayStatus || "Unsubscribed")}
|
||||
tone={tone}
|
||||
/>
|
||||
{expanded ? (
|
||||
<ChevronDown className="h-4 w-4 text-grayScale-400" />
|
||||
) : (
|
||||
<ChevronRight className="h-4 w-4 text-grayScale-400" />
|
||||
)}
|
||||
</div>
|
||||
<div className="mt-4 border-t border-grayScale-100 pt-4">
|
||||
</button>
|
||||
|
||||
{expanded ? (
|
||||
<div className="space-y-6 border-t border-grayScale-100 px-5 pb-5 pt-4 sm:px-6 sm:pb-6">
|
||||
<p className="text-sm text-grayScale-500">No active subscription for this learner.</p>
|
||||
</div>
|
||||
<div className="mt-6 flex flex-col gap-2">
|
||||
<div className="flex flex-col gap-2">
|
||||
{canExtend ? (
|
||||
<Button
|
||||
type="button"
|
||||
|
|
@ -348,6 +379,8 @@ function EmptySubscriptionCard({
|
|||
)}
|
||||
</div>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user