-
Notifications
You must be signed in to change notification settings - Fork 212
Expand file tree
/
Copy pathAccountBillingTab.tsx
More file actions
133 lines (117 loc) · 4 KB
/
Copy pathAccountBillingTab.tsx
File metadata and controls
133 lines (117 loc) · 4 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
/**
* Account Billing Tab
*
* A tab added to the Account panel demonstrating panel extensions.
* In a real billing extension, this would show subscription info, invoices, etc.
*/
import React, { useState } from 'react';
import {
Box,
Button,
Card,
CardContent,
Chip,
Divider,
List,
ListItem,
ListItemText,
Typography,
} from '@mui/material';
import CreditCardIcon from '@mui/icons-material/CreditCard';
import ReceiptIcon from '@mui/icons-material/Receipt';
import { PanelExtensionProps } from '../../../src/extensions';
// Mock data for demonstration
const mockSubscription = {
plan: 'Professional',
status: 'active',
nextBillingDate: '2024-02-15',
amount: '$49.00/month',
};
const mockInvoices = [
{ id: 'INV-001', date: '2024-01-15', amount: '$49.00', status: 'paid' },
{ id: 'INV-002', date: '2023-12-15', amount: '$49.00', status: 'paid' },
{ id: 'INV-003', date: '2023-11-15', amount: '$49.00', status: 'paid' },
];
const AccountBillingTab: React.FC<PanelExtensionProps> = ({ node, user, context }) => {
const [loading, setLoading] = useState(false);
const handleManageSubscription = () => {
context.notify('Opening subscription management...', 'info');
// In a real extension, this would open a modal or navigate to a billing page
context.navigate('/demo');
};
const handleViewInvoice = (invoiceId: string) => {
context.notify(`Viewing invoice ${invoiceId}`, 'info');
};
return (
<Box sx={{ p: 1 }}>
<Typography variant="h6" gutterBottom sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<CreditCardIcon />
Billing & Subscription
</Typography>
<Card variant="outlined" sx={{ mb: 2 }}>
<CardContent>
<Box sx={{ display: 'flex', justifyContent: 'space-between', alignItems: 'center', mb: 2 }}>
<Typography variant="subtitle1" fontWeight="bold">
Current Plan
</Typography>
<Chip
label={mockSubscription.status}
color={mockSubscription.status === 'active' ? 'success' : 'default'}
size="small"
/>
</Box>
<Typography variant="h5" color="primary" gutterBottom>
{mockSubscription.plan}
</Typography>
<Typography variant="body2" color="text.secondary">
{mockSubscription.amount}
</Typography>
<Typography variant="body2" color="text.secondary" sx={{ mt: 1 }}>
Next billing: {mockSubscription.nextBillingDate}
</Typography>
<Button
variant="outlined"
size="small"
sx={{ mt: 2 }}
onClick={handleManageSubscription}
>
Manage Subscription
</Button>
</CardContent>
</Card>
<Typography variant="subtitle1" gutterBottom sx={{ display: 'flex', alignItems: 'center', gap: 1 }}>
<ReceiptIcon />
Recent Invoices
</Typography>
<List dense>
{mockInvoices.map((invoice, index) => (
<React.Fragment key={invoice.id}>
<ListItem
secondaryAction={
<Button size="small" onClick={() => handleViewInvoice(invoice.id)}>
View
</Button>
}
>
<ListItemText
primary={invoice.id}
secondary={`${invoice.date} - ${invoice.amount}`}
/>
<Chip
label={invoice.status}
color={invoice.status === 'paid' ? 'success' : 'warning'}
size="small"
sx={{ mr: 1 }}
/>
</ListItem>
{index < mockInvoices.length - 1 && <Divider />}
</React.Fragment>
))}
</List>
<Typography variant="caption" color="text.secondary" sx={{ display: 'block', mt: 2 }}>
This is a demo billing tab. In a real extension, this would connect to your billing system.
</Typography>
</Box>
);
};
export default AccountBillingTab;