forked from StellarSend/frontend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSubscriptionList.tsx
More file actions
65 lines (59 loc) · 2.02 KB
/
Copy pathSubscriptionList.tsx
File metadata and controls
65 lines (59 loc) · 2.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import React from 'react'
import { Repeat } from 'lucide-react'
import { Card, CardHeader, CardTitle } from '@/components/ui/Card'
import { Skeleton } from '@/components/common/Skeleton'
import { NetworkError } from '@/components/common/NetworkError'
import { SubscriptionItem } from './SubscriptionItem'
import type { Subscription } from '@/types'
interface SubscriptionListProps {
subscriptions: Subscription[] | undefined
isLoading: boolean
isError: boolean
onRetry: () => void
onCancel: (id: string) => void
// A Set of every currently in-flight id, not a single scalar — two
// different subscriptions can be cancelling at once (#52).
cancellingIds?: Set<string>
}
export function SubscriptionList({
subscriptions,
isLoading,
isError,
onRetry,
onCancel,
cancellingIds,
}: SubscriptionListProps) {
return (
<Card>
<CardHeader>
<CardTitle className="flex items-center gap-2">
<Repeat size={18} className="text-stellar-400" />
Your Subscriptions
</CardTitle>
</CardHeader>
{isLoading && <Skeleton rows={3} className="h-14 w-full" />}
{!isLoading && isError && <NetworkError onRetry={onRetry} message="Failed to load subscriptions" />}
{!isLoading && !isError && (!subscriptions || subscriptions.length === 0) && (
<div className="text-center py-10">
<Repeat size={28} className="text-slate-600 mx-auto mb-3" />
<p className="text-sm font-medium text-slate-300">No subscriptions yet</p>
<p className="text-xs text-slate-500 mt-1">
Create a recurring payment above to see it listed here.
</p>
</div>
)}
{!isLoading && !isError && subscriptions && subscriptions.length > 0 && (
<div>
{subscriptions.map((s) => (
<SubscriptionItem
key={s.id}
subscription={s}
onCancel={onCancel}
isCancelling={cancellingIds?.has(s.id) ?? false}
/>
))}
</div>
)}
</Card>
)
}