create-bluecopa-react-app 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +162 -50
- package/bin/create-bluecopa-react-app.js +5 -5
- package/package.json +1 -1
- package/templates/latest/.env.example +14 -0
- package/templates/latest/.eslintrc.cjs +42 -0
- package/templates/latest/Agent.md +259 -0
- package/templates/latest/README.md +281 -0
- package/templates/latest/clean.sh +39 -0
- package/templates/latest/index.html +14 -0
- package/templates/{basic → latest}/package-lock.json +1099 -1084
- package/templates/latest/package.json +61 -0
- package/templates/{basic/postcss.config.js → latest/postcss.config.cjs} +1 -1
- package/templates/latest/public/bluecopa-logo.svg +30 -0
- package/templates/latest/public/favicon-32x32.png +0 -0
- package/templates/latest/public/favicon-96x96.png +0 -0
- package/templates/latest/public/favicon.ico +0 -0
- package/templates/latest/setup.sh +55 -0
- package/templates/latest/src/App.tsx +15 -0
- package/templates/latest/src/components/layout/dashboard-header.tsx +139 -0
- package/templates/latest/src/components/layout/dashboard-layout.tsx +29 -0
- package/templates/latest/src/components/layout/sidebar.tsx +54 -0
- package/templates/latest/src/components/page/dashboard.tsx +1506 -0
- package/templates/latest/src/components/page/navbar.tsx +104 -0
- package/templates/latest/src/components/tables/data-grid.tsx +439 -0
- package/templates/latest/src/components/ui/alert.tsx +59 -0
- package/templates/latest/src/components/ui/avatar.tsx +50 -0
- package/templates/latest/src/components/ui/badge.tsx +36 -0
- package/templates/latest/src/components/ui/bluecopa-logo.tsx +54 -0
- package/templates/{basic → latest}/src/components/ui/button.tsx +5 -11
- package/templates/latest/src/components/ui/dropdown-menu.tsx +200 -0
- package/templates/latest/src/components/ui/input.tsx +24 -0
- package/templates/latest/src/components/ui/label.tsx +23 -0
- package/templates/latest/src/components/ui/select.tsx +29 -0
- package/templates/latest/src/hooks/use-api.ts +55 -0
- package/templates/{basic → latest}/src/index.css +1 -1
- package/templates/{basic → latest}/src/main.tsx +6 -2
- package/templates/latest/src/pages/Dashboard.tsx +13 -0
- package/templates/latest/src/pages/Home.tsx +622 -0
- package/templates/latest/src/providers/query-provider.tsx +48 -0
- package/templates/latest/src/single-spa.tsx +105 -0
- package/templates/{basic/src/types/index.ts → latest/src/types/api.ts} +19 -35
- package/templates/latest/src/vite-env.d.ts +11 -0
- package/templates/{basic → latest}/tailwind.config.js +15 -4
- package/templates/{basic/tsconfig.json → latest/tsconfig.app.json} +5 -10
- package/templates/latest/tsconfig.json +19 -0
- package/templates/latest/vite.config.ts +64 -0
- package/templates/basic/.editorconfig +0 -12
- package/templates/basic/.env.example +0 -10
- package/templates/basic/README.md +0 -213
- package/templates/basic/index.html +0 -13
- package/templates/basic/package.json +0 -68
- package/templates/basic/setup.sh +0 -46
- package/templates/basic/src/App.tsx +0 -95
- package/templates/basic/src/components/dashboard/AdvancedAnalytics.tsx +0 -351
- package/templates/basic/src/components/dashboard/MetricsOverview.tsx +0 -150
- package/templates/basic/src/components/dashboard/TransactionCharts.tsx +0 -215
- package/templates/basic/src/components/dashboard/TransactionTable.tsx +0 -172
- package/templates/basic/src/components/ui/tabs.tsx +0 -53
- package/templates/basic/src/pages/Dashboard.tsx +0 -135
- package/templates/basic/vite.config.ts +0 -13
- /package/templates/{basic → latest}/src/components/ui/card.tsx +0 -0
- /package/templates/{basic → latest}/src/lib/utils.ts +0 -0
- /package/templates/{basic → latest}/tsconfig.node.json +0 -0
|
@@ -1,215 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useDatasetSample } from '@bluecopa/react';
|
|
3
|
-
import { BarChart, Bar, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer, PieChart, Pie, Cell, LineChart, Line } from 'recharts';
|
|
4
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
5
|
-
import { CategorySalesData, PaymentMethodData, StateAnalytics } from '@/types';
|
|
6
|
-
|
|
7
|
-
const COLORS = ['#0088FE', '#00C49F', '#FFBB28', '#FF8042', '#8884D8', '#82CA9D'];
|
|
8
|
-
|
|
9
|
-
export const TransactionCharts: React.FC = () => {
|
|
10
|
-
const {
|
|
11
|
-
data: datasetData,
|
|
12
|
-
isLoading,
|
|
13
|
-
error,
|
|
14
|
-
} = useDatasetSample("0UvoE3CHwqYqzrbGdgs1_large_transaction_dataset_csv");
|
|
15
|
-
|
|
16
|
-
// Process data for charts
|
|
17
|
-
const processChartData = () => {
|
|
18
|
-
if (!datasetData?.data?.data) return { categoryData: [], paymentData: [], stateData: [] };
|
|
19
|
-
|
|
20
|
-
const transactions = datasetData.data.data;
|
|
21
|
-
|
|
22
|
-
// Category sales data
|
|
23
|
-
const categoryMap = new Map<string, CategorySalesData>();
|
|
24
|
-
transactions.forEach(transaction => {
|
|
25
|
-
const category = transaction.category;
|
|
26
|
-
if (categoryMap.has(category)) {
|
|
27
|
-
const existing = categoryMap.get(category)!;
|
|
28
|
-
existing.totalSales += transaction.total_amount;
|
|
29
|
-
existing.quantity += transaction.quantity;
|
|
30
|
-
} else {
|
|
31
|
-
categoryMap.set(category, {
|
|
32
|
-
category,
|
|
33
|
-
totalSales: transaction.total_amount,
|
|
34
|
-
quantity: transaction.quantity
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
// Payment method data
|
|
40
|
-
const paymentMap = new Map<string, PaymentMethodData>();
|
|
41
|
-
transactions.forEach(transaction => {
|
|
42
|
-
const method = transaction.payment_method;
|
|
43
|
-
if (paymentMap.has(method)) {
|
|
44
|
-
const existing = paymentMap.get(method)!;
|
|
45
|
-
existing.count += 1;
|
|
46
|
-
existing.totalAmount += transaction.total_amount;
|
|
47
|
-
} else {
|
|
48
|
-
paymentMap.set(method, {
|
|
49
|
-
paymentMethod: method,
|
|
50
|
-
count: 1,
|
|
51
|
-
totalAmount: transaction.total_amount
|
|
52
|
-
});
|
|
53
|
-
}
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
// State analytics data
|
|
57
|
-
const stateMap = new Map<string, StateAnalytics>();
|
|
58
|
-
transactions.forEach(transaction => {
|
|
59
|
-
const state = transaction.state;
|
|
60
|
-
if (stateMap.has(state)) {
|
|
61
|
-
const existing = stateMap.get(state)!;
|
|
62
|
-
existing.totalTransactions += 1;
|
|
63
|
-
existing.totalAmount += transaction.total_amount;
|
|
64
|
-
existing.averageOrderValue = existing.totalAmount / existing.totalTransactions;
|
|
65
|
-
} else {
|
|
66
|
-
stateMap.set(state, {
|
|
67
|
-
state,
|
|
68
|
-
totalTransactions: 1,
|
|
69
|
-
totalAmount: transaction.total_amount,
|
|
70
|
-
averageOrderValue: transaction.total_amount
|
|
71
|
-
});
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
|
|
75
|
-
return {
|
|
76
|
-
categoryData: Array.from(categoryMap.values()).sort((a, b) => b.totalSales - a.totalSales),
|
|
77
|
-
paymentData: Array.from(paymentMap.values()).sort((a, b) => b.count - a.count),
|
|
78
|
-
stateData: Array.from(stateMap.values()).sort((a, b) => b.totalAmount - a.totalAmount)
|
|
79
|
-
};
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
if (isLoading) {
|
|
83
|
-
return (
|
|
84
|
-
<div className="grid gap-4 md:grid-cols-2">
|
|
85
|
-
{[1, 2, 3, 4].map((i) => (
|
|
86
|
-
<Card key={i}>
|
|
87
|
-
<CardHeader>
|
|
88
|
-
<div className="h-6 w-48 bg-muted animate-pulse rounded"></div>
|
|
89
|
-
</CardHeader>
|
|
90
|
-
<CardContent>
|
|
91
|
-
<div className="h-64 bg-muted animate-pulse rounded"></div>
|
|
92
|
-
</CardContent>
|
|
93
|
-
</Card>
|
|
94
|
-
))}
|
|
95
|
-
</div>
|
|
96
|
-
);
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (error) {
|
|
100
|
-
return (
|
|
101
|
-
<Card>
|
|
102
|
-
<CardHeader>
|
|
103
|
-
<CardTitle className="text-red-600">Error Loading Charts</CardTitle>
|
|
104
|
-
</CardHeader>
|
|
105
|
-
<CardContent>
|
|
106
|
-
<p className="text-muted-foreground">Failed to load chart data. Please try refreshing the page.</p>
|
|
107
|
-
</CardContent>
|
|
108
|
-
</Card>
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
const { categoryData, paymentData, stateData } = processChartData();
|
|
113
|
-
|
|
114
|
-
return (
|
|
115
|
-
<div className="grid gap-4 md:grid-cols-2">
|
|
116
|
-
{/* Category Sales Chart */}
|
|
117
|
-
<Card>
|
|
118
|
-
<CardHeader>
|
|
119
|
-
<CardTitle>Sales by Category</CardTitle>
|
|
120
|
-
<CardDescription>Revenue distribution across product categories</CardDescription>
|
|
121
|
-
</CardHeader>
|
|
122
|
-
<CardContent>
|
|
123
|
-
<ResponsiveContainer width="100%" height={300}>
|
|
124
|
-
<BarChart data={categoryData}>
|
|
125
|
-
<CartesianGrid strokeDasharray="3 3" />
|
|
126
|
-
<XAxis dataKey="category" />
|
|
127
|
-
<YAxis />
|
|
128
|
-
<Tooltip
|
|
129
|
-
formatter={(value: number, name: string) => [
|
|
130
|
-
`₹${value.toLocaleString()}`,
|
|
131
|
-
name === 'totalSales' ? 'Total Sales' : name
|
|
132
|
-
]}
|
|
133
|
-
/>
|
|
134
|
-
<Bar dataKey="totalSales" fill="#8884d8" />
|
|
135
|
-
</BarChart>
|
|
136
|
-
</ResponsiveContainer>
|
|
137
|
-
</CardContent>
|
|
138
|
-
</Card>
|
|
139
|
-
|
|
140
|
-
{/* Payment Method Distribution */}
|
|
141
|
-
<Card>
|
|
142
|
-
<CardHeader>
|
|
143
|
-
<CardTitle>Payment Method Distribution</CardTitle>
|
|
144
|
-
<CardDescription>Transaction count by payment method</CardDescription>
|
|
145
|
-
</CardHeader>
|
|
146
|
-
<CardContent>
|
|
147
|
-
<ResponsiveContainer width="100%" height={300}>
|
|
148
|
-
<PieChart>
|
|
149
|
-
<Pie
|
|
150
|
-
data={paymentData}
|
|
151
|
-
cx="50%"
|
|
152
|
-
cy="50%"
|
|
153
|
-
labelLine={false}
|
|
154
|
-
label={({ paymentMethod, percent }: any) => `${paymentMethod} ${(percent * 100).toFixed(0)}%`}
|
|
155
|
-
outerRadius={80}
|
|
156
|
-
fill="#8884d8"
|
|
157
|
-
dataKey="count"
|
|
158
|
-
>
|
|
159
|
-
{paymentData.map((_, index) => (
|
|
160
|
-
<Cell key={`cell-${index}`} fill={COLORS[index % COLORS.length]} />
|
|
161
|
-
))}
|
|
162
|
-
</Pie>
|
|
163
|
-
<Tooltip formatter={(value: number) => [value, 'Transactions']} />
|
|
164
|
-
</PieChart>
|
|
165
|
-
</ResponsiveContainer>
|
|
166
|
-
</CardContent>
|
|
167
|
-
</Card>
|
|
168
|
-
|
|
169
|
-
{/* State Analytics */}
|
|
170
|
-
<Card>
|
|
171
|
-
<CardHeader>
|
|
172
|
-
<CardTitle>Revenue by State</CardTitle>
|
|
173
|
-
<CardDescription>Total revenue and transaction count by state</CardDescription>
|
|
174
|
-
</CardHeader>
|
|
175
|
-
<CardContent>
|
|
176
|
-
<ResponsiveContainer width="100%" height={300}>
|
|
177
|
-
<BarChart data={stateData}>
|
|
178
|
-
<CartesianGrid strokeDasharray="3 3" />
|
|
179
|
-
<XAxis dataKey="state" />
|
|
180
|
-
<YAxis />
|
|
181
|
-
<Tooltip
|
|
182
|
-
formatter={(value: number, name: string) => [
|
|
183
|
-
name === 'totalAmount' ? `₹${value.toLocaleString()}` : value,
|
|
184
|
-
name === 'totalAmount' ? 'Total Revenue' : 'Transactions'
|
|
185
|
-
]}
|
|
186
|
-
/>
|
|
187
|
-
<Bar dataKey="totalAmount" fill="#82ca9d" />
|
|
188
|
-
</BarChart>
|
|
189
|
-
</ResponsiveContainer>
|
|
190
|
-
</CardContent>
|
|
191
|
-
</Card>
|
|
192
|
-
|
|
193
|
-
{/* Average Order Value Trend */}
|
|
194
|
-
<Card>
|
|
195
|
-
<CardHeader>
|
|
196
|
-
<CardTitle>Average Order Value by State</CardTitle>
|
|
197
|
-
<CardDescription>AOV comparison across different states</CardDescription>
|
|
198
|
-
</CardHeader>
|
|
199
|
-
<CardContent>
|
|
200
|
-
<ResponsiveContainer width="100%" height={300}>
|
|
201
|
-
<LineChart data={stateData}>
|
|
202
|
-
<CartesianGrid strokeDasharray="3 3" />
|
|
203
|
-
<XAxis dataKey="state" />
|
|
204
|
-
<YAxis />
|
|
205
|
-
<Tooltip
|
|
206
|
-
formatter={(value: number) => [`₹${value.toFixed(2)}`, 'Average Order Value']}
|
|
207
|
-
/>
|
|
208
|
-
<Line type="monotone" dataKey="averageOrderValue" stroke="#8884d8" strokeWidth={2} />
|
|
209
|
-
</LineChart>
|
|
210
|
-
</ResponsiveContainer>
|
|
211
|
-
</CardContent>
|
|
212
|
-
</Card>
|
|
213
|
-
</div>
|
|
214
|
-
);
|
|
215
|
-
};
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useDatasetSample } from '@bluecopa/react';
|
|
3
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
4
|
-
import { Button } from '@/components/ui/button';
|
|
5
|
-
import { RefreshCw, Search, Filter } from 'lucide-react';
|
|
6
|
-
|
|
7
|
-
export const TransactionTable: React.FC = () => {
|
|
8
|
-
const {
|
|
9
|
-
data: datasetData,
|
|
10
|
-
isLoading,
|
|
11
|
-
error,
|
|
12
|
-
refetch
|
|
13
|
-
} = useDatasetSample("0UvoE3CHwqYqzrbGdgs1_large_transaction_dataset_csv");
|
|
14
|
-
|
|
15
|
-
const formatCurrency = (amount: number) => {
|
|
16
|
-
return new Intl.NumberFormat('en-IN', {
|
|
17
|
-
style: 'currency',
|
|
18
|
-
currency: 'INR',
|
|
19
|
-
}).format(amount);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const formatDate = (dateString: string) => {
|
|
23
|
-
return new Date(dateString).toLocaleDateString('en-IN');
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
if (isLoading) {
|
|
27
|
-
return (
|
|
28
|
-
<Card>
|
|
29
|
-
<CardHeader>
|
|
30
|
-
<div className="flex items-center justify-between">
|
|
31
|
-
<div>
|
|
32
|
-
<div className="h-6 w-48 bg-muted animate-pulse rounded mb-2"></div>
|
|
33
|
-
<div className="h-4 w-64 bg-muted animate-pulse rounded"></div>
|
|
34
|
-
</div>
|
|
35
|
-
<div className="h-10 w-24 bg-muted animate-pulse rounded"></div>
|
|
36
|
-
</div>
|
|
37
|
-
</CardHeader>
|
|
38
|
-
<CardContent>
|
|
39
|
-
<div className="space-y-4">
|
|
40
|
-
{[1, 2, 3, 4, 5].map((i) => (
|
|
41
|
-
<div key={i} className="flex items-center space-x-4">
|
|
42
|
-
<div className="h-4 w-20 bg-muted animate-pulse rounded"></div>
|
|
43
|
-
<div className="h-4 w-32 bg-muted animate-pulse rounded"></div>
|
|
44
|
-
<div className="h-4 w-24 bg-muted animate-pulse rounded"></div>
|
|
45
|
-
<div className="h-4 w-28 bg-muted animate-pulse rounded"></div>
|
|
46
|
-
<div className="h-4 w-20 bg-muted animate-pulse rounded"></div>
|
|
47
|
-
</div>
|
|
48
|
-
))}
|
|
49
|
-
</div>
|
|
50
|
-
</CardContent>
|
|
51
|
-
</Card>
|
|
52
|
-
);
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
if (error) {
|
|
56
|
-
return (
|
|
57
|
-
<Card>
|
|
58
|
-
<CardHeader>
|
|
59
|
-
<CardTitle className="text-red-600">Error Loading Transaction Data</CardTitle>
|
|
60
|
-
</CardHeader>
|
|
61
|
-
<CardContent>
|
|
62
|
-
<p className="text-muted-foreground mb-4">
|
|
63
|
-
Failed to load transaction data. Please try refreshing.
|
|
64
|
-
</p>
|
|
65
|
-
<Button onClick={() => refetch()} className="flex items-center gap-2">
|
|
66
|
-
<RefreshCw className="h-4 w-4" />
|
|
67
|
-
Retry
|
|
68
|
-
</Button>
|
|
69
|
-
</CardContent>
|
|
70
|
-
</Card>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
const transactions = datasetData?.data?.data || [];
|
|
75
|
-
|
|
76
|
-
return (
|
|
77
|
-
<Card>
|
|
78
|
-
<CardHeader>
|
|
79
|
-
<div className="flex items-center justify-between">
|
|
80
|
-
<div>
|
|
81
|
-
<CardTitle>Transaction Data</CardTitle>
|
|
82
|
-
<CardDescription>
|
|
83
|
-
Recent transactions from the BlueCopa dataset ({transactions.length} records)
|
|
84
|
-
</CardDescription>
|
|
85
|
-
</div>
|
|
86
|
-
<div className="flex gap-2">
|
|
87
|
-
<Button variant="outline" size="sm" className="flex items-center gap-2">
|
|
88
|
-
<Search className="h-4 w-4" />
|
|
89
|
-
Search
|
|
90
|
-
</Button>
|
|
91
|
-
<Button variant="outline" size="sm" className="flex items-center gap-2">
|
|
92
|
-
<Filter className="h-4 w-4" />
|
|
93
|
-
Filter
|
|
94
|
-
</Button>
|
|
95
|
-
<Button onClick={() => refetch()} size="sm" className="flex items-center gap-2">
|
|
96
|
-
<RefreshCw className="h-4 w-4" />
|
|
97
|
-
Refresh
|
|
98
|
-
</Button>
|
|
99
|
-
</div>
|
|
100
|
-
</div>
|
|
101
|
-
</CardHeader>
|
|
102
|
-
<CardContent>
|
|
103
|
-
<div className="overflow-x-auto">
|
|
104
|
-
<table className="w-full border-collapse">
|
|
105
|
-
<thead>
|
|
106
|
-
<tr className="border-b">
|
|
107
|
-
<th className="text-left p-2 font-medium">Transaction ID</th>
|
|
108
|
-
<th className="text-left p-2 font-medium">Date</th>
|
|
109
|
-
<th className="text-left p-2 font-medium">City</th>
|
|
110
|
-
<th className="text-left p-2 font-medium">Category</th>
|
|
111
|
-
<th className="text-left p-2 font-medium">Product</th>
|
|
112
|
-
<th className="text-left p-2 font-medium">Quantity</th>
|
|
113
|
-
<th className="text-left p-2 font-medium">Unit Price</th>
|
|
114
|
-
<th className="text-left p-2 font-medium">Total Amount</th>
|
|
115
|
-
<th className="text-left p-2 font-medium">Payment Method</th>
|
|
116
|
-
<th className="text-left p-2 font-medium">Channel</th>
|
|
117
|
-
<th className="text-left p-2 font-medium">Status</th>
|
|
118
|
-
</tr>
|
|
119
|
-
</thead>
|
|
120
|
-
<tbody>
|
|
121
|
-
{transactions.slice(0, 10).map((transaction, index) => (
|
|
122
|
-
<tr key={transaction.transaction_id} className={index % 2 === 0 ? 'bg-muted/50' : ''}>
|
|
123
|
-
<td className="p-2 font-mono text-sm">{transaction.transaction_id}</td>
|
|
124
|
-
<td className="p-2">{formatDate(transaction.transaction_day)}</td>
|
|
125
|
-
<td className="p-2">{transaction.city}</td>
|
|
126
|
-
<td className="p-2">
|
|
127
|
-
<span className="inline-flex items-center px-2 py-1 rounded-full text-xs bg-blue-100 text-blue-800">
|
|
128
|
-
{transaction.category}
|
|
129
|
-
</span>
|
|
130
|
-
</td>
|
|
131
|
-
<td className="p-2 font-mono text-sm">{transaction.product_id}</td>
|
|
132
|
-
<td className="p-2 text-center">{transaction.quantity}</td>
|
|
133
|
-
<td className="p-2">{formatCurrency(transaction.unit_price)}</td>
|
|
134
|
-
<td className="p-2 font-semibold">{formatCurrency(transaction.total_amount)}</td>
|
|
135
|
-
<td className="p-2">
|
|
136
|
-
<span className={`inline-flex items-center px-2 py-1 rounded-full text-xs ${
|
|
137
|
-
transaction.payment_method === 'Credit Card' ? 'bg-green-100 text-green-800' :
|
|
138
|
-
transaction.payment_method === 'Debit Card' ? 'bg-yellow-100 text-yellow-800' :
|
|
139
|
-
transaction.payment_method === 'UPI' ? 'bg-purple-100 text-purple-800' :
|
|
140
|
-
'bg-gray-100 text-gray-800'
|
|
141
|
-
}`}>
|
|
142
|
-
{transaction.payment_method}
|
|
143
|
-
</span>
|
|
144
|
-
</td>
|
|
145
|
-
<td className="p-2">{transaction.channel}</td>
|
|
146
|
-
<td className="p-2">
|
|
147
|
-
<span className={`inline-flex items-center px-2 py-1 rounded-full text-xs ${
|
|
148
|
-
transaction.is_online ? 'bg-green-100 text-green-800' : 'bg-orange-100 text-orange-800'
|
|
149
|
-
}`}>
|
|
150
|
-
{transaction.is_online ? 'Online' : 'Offline'}
|
|
151
|
-
</span>
|
|
152
|
-
</td>
|
|
153
|
-
</tr>
|
|
154
|
-
))}
|
|
155
|
-
</tbody>
|
|
156
|
-
</table>
|
|
157
|
-
|
|
158
|
-
{transactions.length > 10 && (
|
|
159
|
-
<div className="mt-4 text-center">
|
|
160
|
-
<p className="text-muted-foreground text-sm">
|
|
161
|
-
Showing 10 of {transactions.length} transactions
|
|
162
|
-
</p>
|
|
163
|
-
<Button variant="outline" className="mt-2">
|
|
164
|
-
View All Transactions
|
|
165
|
-
</Button>
|
|
166
|
-
</div>
|
|
167
|
-
)}
|
|
168
|
-
</div>
|
|
169
|
-
</CardContent>
|
|
170
|
-
</Card>
|
|
171
|
-
);
|
|
172
|
-
};
|
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import * as React from "react"
|
|
2
|
-
import * as TabsPrimitive from "@radix-ui/react-tabs"
|
|
3
|
-
|
|
4
|
-
import { cn } from "@/lib/utils"
|
|
5
|
-
|
|
6
|
-
const Tabs = TabsPrimitive.Root
|
|
7
|
-
|
|
8
|
-
const TabsList = React.forwardRef<
|
|
9
|
-
React.ElementRef<typeof TabsPrimitive.List>,
|
|
10
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.List>
|
|
11
|
-
>(({ className, ...props }, ref) => (
|
|
12
|
-
<TabsPrimitive.List
|
|
13
|
-
ref={ref}
|
|
14
|
-
className={cn(
|
|
15
|
-
"inline-flex h-10 items-center justify-center rounded-md bg-muted p-1 text-muted-foreground",
|
|
16
|
-
className
|
|
17
|
-
)}
|
|
18
|
-
{...props}
|
|
19
|
-
/>
|
|
20
|
-
))
|
|
21
|
-
TabsList.displayName = TabsPrimitive.List.displayName
|
|
22
|
-
|
|
23
|
-
const TabsTrigger = React.forwardRef<
|
|
24
|
-
React.ElementRef<typeof TabsPrimitive.Trigger>,
|
|
25
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Trigger>
|
|
26
|
-
>(({ className, ...props }, ref) => (
|
|
27
|
-
<TabsPrimitive.Trigger
|
|
28
|
-
ref={ref}
|
|
29
|
-
className={cn(
|
|
30
|
-
"inline-flex items-center justify-center whitespace-nowrap rounded-sm px-3 py-1.5 text-sm font-medium ring-offset-background transition-all focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:pointer-events-none disabled:opacity-50 data-[state=active]:bg-background data-[state=active]:text-foreground data-[state=active]:shadow-sm",
|
|
31
|
-
className
|
|
32
|
-
)}
|
|
33
|
-
{...props}
|
|
34
|
-
/>
|
|
35
|
-
))
|
|
36
|
-
TabsTrigger.displayName = TabsPrimitive.Trigger.displayName
|
|
37
|
-
|
|
38
|
-
const TabsContent = React.forwardRef<
|
|
39
|
-
React.ElementRef<typeof TabsPrimitive.Content>,
|
|
40
|
-
React.ComponentPropsWithoutRef<typeof TabsPrimitive.Content>
|
|
41
|
-
>(({ className, ...props }, ref) => (
|
|
42
|
-
<TabsPrimitive.Content
|
|
43
|
-
ref={ref}
|
|
44
|
-
className={cn(
|
|
45
|
-
"mt-2 ring-offset-background focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2",
|
|
46
|
-
className
|
|
47
|
-
)}
|
|
48
|
-
{...props}
|
|
49
|
-
/>
|
|
50
|
-
))
|
|
51
|
-
TabsContent.displayName = TabsPrimitive.Content.displayName
|
|
52
|
-
|
|
53
|
-
export { Tabs, TabsList, TabsTrigger, TabsContent }
|
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useUser } from '@bluecopa/react';
|
|
3
|
-
import { MetricsOverview } from '@/components/dashboard/MetricsOverview';
|
|
4
|
-
import { TransactionCharts } from '@/components/dashboard/TransactionCharts';
|
|
5
|
-
import { TransactionTable } from '@/components/dashboard/TransactionTable';
|
|
6
|
-
import { Card, CardContent, CardDescription, CardHeader, CardTitle } from '@/components/ui/card';
|
|
7
|
-
import { Button } from '@/components/ui/button';
|
|
8
|
-
import { RefreshCw, User, Building } from 'lucide-react';
|
|
9
|
-
|
|
10
|
-
const Dashboard: React.FC = () => {
|
|
11
|
-
const {
|
|
12
|
-
data: userData,
|
|
13
|
-
isLoading: userLoading,
|
|
14
|
-
error: userError,
|
|
15
|
-
refetch: refetchUser
|
|
16
|
-
} = useUser();
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<div className="space-y-8">
|
|
20
|
-
{/* Header Section */}
|
|
21
|
-
<div className="flex items-center justify-between">
|
|
22
|
-
<div>
|
|
23
|
-
<h1 className="text-3xl font-bold tracking-tight">Dashboard</h1>
|
|
24
|
-
<p className="text-muted-foreground">
|
|
25
|
-
Welcome to your BlueCopa analytics dashboard
|
|
26
|
-
</p>
|
|
27
|
-
</div>
|
|
28
|
-
<Button onClick={() => refetchUser()} className="flex items-center gap-2">
|
|
29
|
-
<RefreshCw className="h-4 w-4" />
|
|
30
|
-
Refresh All
|
|
31
|
-
</Button>
|
|
32
|
-
</div>
|
|
33
|
-
|
|
34
|
-
{/* User Info Section */}
|
|
35
|
-
{userLoading ? (
|
|
36
|
-
<Card>
|
|
37
|
-
<CardHeader>
|
|
38
|
-
<div className="flex items-center space-x-4">
|
|
39
|
-
<div className="h-12 w-12 bg-muted animate-pulse rounded-full"></div>
|
|
40
|
-
<div>
|
|
41
|
-
<div className="h-5 w-48 bg-muted animate-pulse rounded mb-2"></div>
|
|
42
|
-
<div className="h-4 w-32 bg-muted animate-pulse rounded"></div>
|
|
43
|
-
</div>
|
|
44
|
-
</div>
|
|
45
|
-
</CardHeader>
|
|
46
|
-
</Card>
|
|
47
|
-
) : userError ? (
|
|
48
|
-
<Card>
|
|
49
|
-
<CardHeader>
|
|
50
|
-
<CardTitle className="text-red-600">Error Loading User Data</CardTitle>
|
|
51
|
-
</CardHeader>
|
|
52
|
-
<CardContent>
|
|
53
|
-
<p className="text-muted-foreground">Failed to load user information.</p>
|
|
54
|
-
</CardContent>
|
|
55
|
-
</Card>
|
|
56
|
-
) : userData ? (
|
|
57
|
-
<Card>
|
|
58
|
-
<CardHeader>
|
|
59
|
-
<div className="flex items-center space-x-4">
|
|
60
|
-
<div className="h-12 w-12 bg-primary/10 rounded-full flex items-center justify-center">
|
|
61
|
-
<User className="h-6 w-6 text-primary" />
|
|
62
|
-
</div>
|
|
63
|
-
<div>
|
|
64
|
-
<CardTitle className="text-xl">
|
|
65
|
-
{userData.user.firstName} {userData.user.lastName}
|
|
66
|
-
</CardTitle>
|
|
67
|
-
<CardDescription className="flex items-center gap-2">
|
|
68
|
-
<Building className="h-4 w-4" />
|
|
69
|
-
{userData.organization.name} • {userData.user.email}
|
|
70
|
-
</CardDescription>
|
|
71
|
-
</div>
|
|
72
|
-
</div>
|
|
73
|
-
</CardHeader>
|
|
74
|
-
</Card>
|
|
75
|
-
) : null}
|
|
76
|
-
|
|
77
|
-
{/* Query States Overview */}
|
|
78
|
-
<Card>
|
|
79
|
-
<CardHeader>
|
|
80
|
-
<CardTitle>Copa-lib Demo with TanStack Query</CardTitle>
|
|
81
|
-
<CardDescription>
|
|
82
|
-
Query States Overview - Real-time data fetching status
|
|
83
|
-
</CardDescription>
|
|
84
|
-
</CardHeader>
|
|
85
|
-
<CardContent>
|
|
86
|
-
<div className="grid gap-4 md:grid-cols-3">
|
|
87
|
-
<div className="space-y-2">
|
|
88
|
-
<h4 className="font-medium">User Query</h4>
|
|
89
|
-
<div className="flex items-center gap-2">
|
|
90
|
-
<div className={`h-2 w-2 rounded-full ${userLoading ? 'bg-yellow-500' : userError ? 'bg-red-500' : 'bg-green-500'}`}></div>
|
|
91
|
-
<span className="text-sm text-muted-foreground">
|
|
92
|
-
{userLoading ? 'Loading...' : userError ? 'Error' : 'Success'}
|
|
93
|
-
</span>
|
|
94
|
-
</div>
|
|
95
|
-
</div>
|
|
96
|
-
<div className="space-y-2">
|
|
97
|
-
<h4 className="font-medium">Metrics Query</h4>
|
|
98
|
-
<div className="flex items-center gap-2">
|
|
99
|
-
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
|
100
|
-
<span className="text-sm text-muted-foreground">Success</span>
|
|
101
|
-
</div>
|
|
102
|
-
</div>
|
|
103
|
-
<div className="space-y-2">
|
|
104
|
-
<h4 className="font-medium">Dataset Query</h4>
|
|
105
|
-
<div className="flex items-center gap-2">
|
|
106
|
-
<div className="h-2 w-2 rounded-full bg-green-500"></div>
|
|
107
|
-
<span className="text-sm text-muted-foreground">Success</span>
|
|
108
|
-
</div>
|
|
109
|
-
</div>
|
|
110
|
-
</div>
|
|
111
|
-
</CardContent>
|
|
112
|
-
</Card>
|
|
113
|
-
|
|
114
|
-
{/* Metrics Overview */}
|
|
115
|
-
<div>
|
|
116
|
-
<h2 className="text-2xl font-semibold mb-6">Key Metrics</h2>
|
|
117
|
-
<MetricsOverview />
|
|
118
|
-
</div>
|
|
119
|
-
|
|
120
|
-
{/* Charts Section */}
|
|
121
|
-
<div>
|
|
122
|
-
<h2 className="text-2xl font-semibold mb-6">Analytics Charts</h2>
|
|
123
|
-
<TransactionCharts />
|
|
124
|
-
</div>
|
|
125
|
-
|
|
126
|
-
{/* Transaction Table */}
|
|
127
|
-
<div>
|
|
128
|
-
<h2 className="text-2xl font-semibold mb-6">Transaction Data</h2>
|
|
129
|
-
<TransactionTable />
|
|
130
|
-
</div>
|
|
131
|
-
</div>
|
|
132
|
-
);
|
|
133
|
-
};
|
|
134
|
-
|
|
135
|
-
export default Dashboard;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { defineConfig } from 'vite'
|
|
2
|
-
import react from '@vitejs/plugin-react'
|
|
3
|
-
import path from 'path'
|
|
4
|
-
|
|
5
|
-
// https://vitejs.dev/config/
|
|
6
|
-
export default defineConfig({
|
|
7
|
-
plugins: [react()],
|
|
8
|
-
resolve: {
|
|
9
|
-
alias: {
|
|
10
|
-
"@": path.resolve(__dirname, "./src"),
|
|
11
|
-
},
|
|
12
|
-
},
|
|
13
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|