create-bluecopa-react-app 1.0.5 → 1.0.7

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.
Files changed (117) hide show
  1. package/README.md +47 -10
  2. package/bin/create-bluecopa-react-app.js +257 -51
  3. package/package.json +6 -5
  4. package/templates/latest/Agent.md +254 -0
  5. package/templates/latest/Dockerfile +22 -0
  6. package/templates/latest/README.md +157 -221
  7. package/templates/latest/app/app.css +134 -0
  8. package/templates/latest/app/app.tsx +46 -0
  9. package/templates/latest/app/components/app-sidebar.tsx +174 -0
  10. package/templates/latest/app/components/chart-area-interactive.tsx +290 -0
  11. package/templates/latest/app/components/data-table.tsx +807 -0
  12. package/templates/latest/app/components/nav-documents.tsx +92 -0
  13. package/templates/latest/app/components/nav-main.tsx +56 -0
  14. package/templates/latest/app/components/nav-secondary.tsx +42 -0
  15. package/templates/latest/app/components/nav-user.tsx +112 -0
  16. package/templates/latest/app/components/section-cards.tsx +102 -0
  17. package/templates/latest/app/components/site-header.tsx +19 -0
  18. package/templates/latest/app/components/ui/avatar.tsx +53 -0
  19. package/templates/latest/app/components/ui/badge.tsx +46 -0
  20. package/templates/latest/app/components/ui/breadcrumb.tsx +109 -0
  21. package/templates/latest/app/components/ui/button.tsx +58 -0
  22. package/templates/latest/app/components/ui/card.tsx +92 -0
  23. package/templates/latest/app/components/ui/chart.tsx +352 -0
  24. package/templates/latest/app/components/ui/checkbox.tsx +30 -0
  25. package/templates/latest/app/components/ui/drawer.tsx +139 -0
  26. package/templates/latest/app/components/ui/dropdown-menu.tsx +258 -0
  27. package/templates/latest/app/components/ui/input.tsx +21 -0
  28. package/templates/latest/app/components/ui/label.tsx +24 -0
  29. package/templates/latest/app/components/ui/select.tsx +183 -0
  30. package/templates/latest/app/components/ui/separator.tsx +26 -0
  31. package/templates/latest/app/components/ui/sheet.tsx +139 -0
  32. package/templates/latest/app/components/ui/sidebar.tsx +731 -0
  33. package/templates/latest/app/components/ui/skeleton.tsx +13 -0
  34. package/templates/latest/app/components/ui/sonner.tsx +23 -0
  35. package/templates/latest/app/components/ui/table.tsx +117 -0
  36. package/templates/latest/app/components/ui/tabs.tsx +66 -0
  37. package/templates/latest/app/components/ui/toggle-group.tsx +73 -0
  38. package/templates/latest/app/components/ui/toggle.tsx +47 -0
  39. package/templates/latest/app/components/ui/tooltip.tsx +59 -0
  40. package/templates/latest/app/dashboard/data.json +614 -0
  41. package/templates/latest/app/hooks/use-bluecopa-user.ts +37 -0
  42. package/templates/latest/app/hooks/use-mobile.ts +19 -0
  43. package/templates/latest/{src → app}/lib/utils.ts +1 -1
  44. package/templates/latest/app/main.tsx +12 -0
  45. package/templates/latest/app/routes/home.tsx +40 -0
  46. package/templates/latest/app/routes.tsx +15 -0
  47. package/templates/latest/{src → app}/single-spa.tsx +5 -5
  48. package/templates/latest/components.json +22 -0
  49. package/templates/latest/dist/assets/__federation_expose_App-DsPovvoo.js +147 -0
  50. package/templates/latest/dist/assets/__federation_fn_import-CzfA7kmP.js +438 -0
  51. package/templates/latest/dist/assets/__federation_shared_react-Bp6HVBS4.js +16 -0
  52. package/templates/latest/dist/assets/__federation_shared_react-dom-BCcRGiYp.js +17 -0
  53. package/templates/latest/dist/assets/client-BZh_TW_6.js +12662 -0
  54. package/templates/latest/dist/assets/home-CAuoIW4B.js +54951 -0
  55. package/templates/latest/dist/assets/index-BzNimew1.js +69 -0
  56. package/templates/latest/dist/assets/index-Clg7n7gy.js +60 -0
  57. package/templates/latest/dist/assets/index-DMFtQdNS.js +412 -0
  58. package/templates/latest/dist/assets/remoteEntry.css +3688 -0
  59. package/templates/latest/dist/assets/remoteEntry.js +88 -0
  60. package/templates/latest/dist/avatars/shadcn.svg +6 -0
  61. package/templates/latest/dist/favicon.ico +0 -0
  62. package/templates/latest/dist/index.html +19 -0
  63. package/templates/latest/index.html +1 -1
  64. package/templates/latest/package-lock.json +1227 -3353
  65. package/templates/latest/package.json +47 -43
  66. package/templates/latest/pnpm-lock.yaml +4767 -0
  67. package/templates/latest/preview/index.html +32 -2
  68. package/templates/latest/public/avatars/shadcn.svg +6 -0
  69. package/templates/latest/public/favicon.ico +0 -0
  70. package/templates/latest/tsconfig.json +19 -12
  71. package/templates/latest/vite.config.ts +47 -40
  72. package/templates/latest/.env.example +0 -14
  73. package/templates/latest/.eslintrc.cjs +0 -42
  74. package/templates/latest/AGENT.md +0 -282
  75. package/templates/latest/clean.sh +0 -40
  76. package/templates/latest/postcss.config.cjs +0 -6
  77. package/templates/latest/public/bluecopa-logo.svg +0 -30
  78. package/templates/latest/public/favicon-32x32.png +0 -0
  79. package/templates/latest/public/favicon-96x96.png +0 -0
  80. package/templates/latest/setup.sh +0 -56
  81. package/templates/latest/src/App.tsx +0 -19
  82. package/templates/latest/src/components/charts/AreaChart.tsx +0 -80
  83. package/templates/latest/src/components/charts/DonutChart.tsx +0 -73
  84. package/templates/latest/src/components/charts/SparkAreaChart.tsx +0 -52
  85. package/templates/latest/src/components/layout/dashboard-header.tsx +0 -139
  86. package/templates/latest/src/components/layout/dashboard-layout.tsx +0 -37
  87. package/templates/latest/src/components/layout/navbar.tsx +0 -106
  88. package/templates/latest/src/components/layout/sidebar.tsx +0 -55
  89. package/templates/latest/src/components/page/dashboard/DashboardMetrics.tsx +0 -97
  90. package/templates/latest/src/components/page/dashboard/PaymentMethodsAnalysis.tsx +0 -182
  91. package/templates/latest/src/components/page/dashboard/RevenueAnalytics.tsx +0 -505
  92. package/templates/latest/src/components/page/dashboard/SalesAnalytics.tsx +0 -313
  93. package/templates/latest/src/components/page/dashboard/TransactionsTable.tsx +0 -256
  94. package/templates/latest/src/components/page/dashboard/dashboard-utils.ts +0 -147
  95. package/templates/latest/src/components/page/dashboard/dashboard.tsx +0 -185
  96. package/templates/latest/src/components/tables/data-grid.tsx +0 -439
  97. package/templates/latest/src/components/ui/alert.tsx +0 -59
  98. package/templates/latest/src/components/ui/avatar.tsx +0 -50
  99. package/templates/latest/src/components/ui/badge.tsx +0 -36
  100. package/templates/latest/src/components/ui/bluecopa-logo.tsx +0 -57
  101. package/templates/latest/src/components/ui/button.tsx +0 -58
  102. package/templates/latest/src/components/ui/card.tsx +0 -79
  103. package/templates/latest/src/components/ui/dropdown-menu.tsx +0 -200
  104. package/templates/latest/src/components/ui/input.tsx +0 -24
  105. package/templates/latest/src/components/ui/label.tsx +0 -21
  106. package/templates/latest/src/components/ui/select.tsx +0 -27
  107. package/templates/latest/src/hooks/use-api.ts +0 -55
  108. package/templates/latest/src/index.css +0 -59
  109. package/templates/latest/src/main.tsx +0 -13
  110. package/templates/latest/src/pages/Dashboard.tsx +0 -13
  111. package/templates/latest/src/pages/Home.tsx +0 -622
  112. package/templates/latest/src/providers/query-provider.tsx +0 -48
  113. package/templates/latest/src/types/api.ts +0 -78
  114. package/templates/latest/src/vite-env.d.ts +0 -11
  115. package/templates/latest/tailwind.config.js +0 -87
  116. package/templates/latest/tsconfig.app.json +0 -32
  117. package/templates/latest/tsconfig.node.json +0 -14
@@ -1,147 +0,0 @@
1
- // Helper function to render query state
2
- export const renderQueryState = (query: any, title: string) => {
3
- if (query.isLoading) {
4
- return {
5
- status: 'loading',
6
- message: `${title}: Loading...`
7
- };
8
- }
9
-
10
- if (query.isError) {
11
- return {
12
- status: 'error',
13
- message: `${title}: Error`
14
- };
15
- }
16
-
17
- if (query.isSuccess) {
18
- return {
19
- status: 'success',
20
- message: `${title}: Success`
21
- };
22
- }
23
-
24
- return {
25
- status: 'idle',
26
- message: `${title}: Idle`
27
- };
28
- };
29
-
30
- // Process data for ecommerce metrics and charts
31
- export const processOrderData = (rawData: any[]) => {
32
- return rawData.reduce((acc: any, transaction: any) => {
33
- const existing = acc.find((item: any) => item.category === transaction.category);
34
- if (existing) {
35
- existing.total += transaction.total_amount;
36
- existing.count += 1;
37
- } else {
38
- acc.push({
39
- category: transaction.category,
40
- total: transaction.total_amount,
41
- count: 1
42
- });
43
- }
44
- return acc;
45
- }, []);
46
- };
47
-
48
- export const processPaymentMethodData = (rawData: any[]) => {
49
- return rawData.reduce((acc: any, transaction: any) => {
50
- const existing = acc.find((item: any) => item.method === transaction.payment_method);
51
- if (existing) {
52
- existing.total += transaction.total_amount;
53
- existing.count += 1;
54
- } else {
55
- acc.push({
56
- method: transaction.payment_method,
57
- total: transaction.total_amount,
58
- count: 1
59
- });
60
- }
61
- return acc;
62
- }, []);
63
- };
64
-
65
- export const processMonthlyRevenueData = (rawData: any[]) => {
66
- return rawData.reduce((acc: any, transaction: any) => {
67
- if (!transaction.transaction_date) return acc;
68
-
69
- const date = new Date(transaction.transaction_date);
70
- const monthKey = `${date.getFullYear()}-${String(date.getMonth() + 1).padStart(2, '0')}`;
71
-
72
- const existing = acc.find((item: any) => item.month === monthKey);
73
- if (existing) {
74
- existing.revenue += transaction.total_amount;
75
- existing.orders += 1;
76
- } else {
77
- acc.push({
78
- month: monthKey,
79
- revenue: transaction.total_amount,
80
- orders: 1
81
- });
82
- }
83
- return acc;
84
- }, []).sort((a: any, b: any) => a.month.localeCompare(b.month));
85
- };
86
-
87
- export const processRecentTransactions = (rawData: any[]) => {
88
- return rawData
89
- .slice(0, 10)
90
- .map((transaction: any) => ({
91
- id: transaction.transaction_id,
92
- customer: transaction.customer_name || 'N/A',
93
- amount: transaction.total_amount,
94
- category: transaction.category,
95
- payment_method: transaction.payment_method,
96
- date: transaction.transaction_date ? new Date(transaction.transaction_date).toLocaleDateString() : 'N/A'
97
- }));
98
- };
99
-
100
- export const calculateMetrics = (rawData: any[]) => {
101
- const totalOrders = rawData.length || 0;
102
- const totalRevenue = rawData.reduce((sum: number, t: any) => sum + t.total_amount, 0);
103
- const averageOrderValue = totalOrders > 0 ? totalRevenue / totalOrders : 0;
104
-
105
- return {
106
- totalOrders,
107
- totalRevenue,
108
- averageOrderValue
109
- };
110
- };
111
-
112
- export const createEcommerceMetrics = (totalRevenue: number, totalOrders: number, averageOrderValue: number) => {
113
- return [
114
- {
115
- title: 'Total Revenue',
116
- value: `$${totalRevenue.toLocaleString()}`,
117
- change: '+12.5%',
118
- trend: 'up' as const,
119
- icon: 'DollarSign',
120
- color: 'text-green-600'
121
- },
122
- {
123
- title: 'Orders',
124
- value: totalOrders.toLocaleString(),
125
- change: '+8.2%',
126
- trend: 'up' as const,
127
- icon: 'ShoppingCart',
128
- color: 'text-blue-600'
129
- },
130
- {
131
- title: 'Average Order Value',
132
- value: `$${averageOrderValue.toFixed(2)}`,
133
- change: '+3.1%',
134
- trend: 'up' as const,
135
- icon: 'TrendingUp',
136
- color: 'text-purple-600'
137
- },
138
- {
139
- title: 'Total Customers',
140
- value: '2,847',
141
- change: '+15.3%',
142
- trend: 'up' as const,
143
- icon: 'Users',
144
- color: 'text-orange-600'
145
- }
146
- ];
147
- };
@@ -1,185 +0,0 @@
1
- 'use client'
2
-
3
- import { Button } from '@/components/ui/button'
4
- import { Alert, AlertDescription } from '@/components/ui/alert'
5
- import { useMetricDataDemo, useDatasetDataDemo, useUserData } from '@/hooks/use-api'
6
- import {
7
- RefreshCw,
8
- Loader2,
9
- AlertCircle,
10
- CheckCircle,
11
- Clock
12
- } from 'lucide-react'
13
- import { DashboardMetrics } from './DashboardMetrics'
14
- import { SalesAnalytics } from './SalesAnalytics'
15
- import { PaymentMethodsAnalysis } from './PaymentMethodsAnalysis'
16
- import { TransactionsTable } from './TransactionsTable'
17
- import { RevenueAnalytics } from './RevenueAnalytics'
18
- import {
19
- processOrderData,
20
- processPaymentMethodData,
21
- processMonthlyRevenueData,
22
- processRecentTransactions,
23
- calculateMetrics,
24
- createEcommerceMetrics,
25
- renderQueryState as renderQueryStateUtil
26
- } from './dashboard-utils'
27
-
28
-
29
- export default function Dashboard() {
30
- const metricQuery = useMetricDataDemo()
31
- const datasetQuery = useDatasetDataDemo()
32
- const userQuery = useUserData()
33
-
34
- // Process data for ecommerce metrics and charts
35
- const rawApiData = datasetQuery.data?.data?.data || []
36
-
37
- // Fallback sample data when API returns empty data
38
- const sampleTransactionData = [
39
- { transaction_id: '001', customer_name: 'John Doe', total_amount: 1250, category: 'Electronics', payment_method: 'Credit Card', transaction_date: '2024-01-15', state: 'CA' },
40
- { transaction_id: '002', customer_name: 'Jane Smith', total_amount: 780, category: 'Clothing', payment_method: 'PayPal', transaction_date: '2024-01-18', state: 'NY' },
41
- { transaction_id: '003', customer_name: 'Mike Johnson', total_amount: 2100, category: 'Electronics', payment_method: 'Credit Card', transaction_date: '2024-02-02', state: 'TX' },
42
- { transaction_id: '004', customer_name: 'Sarah Wilson', total_amount: 450, category: 'Books', payment_method: 'Debit Card', transaction_date: '2024-02-05', state: 'FL' },
43
- { transaction_id: '005', customer_name: 'David Brown', total_amount: 890, category: 'Sports', payment_method: 'Credit Card', transaction_date: '2024-02-10', state: 'CA' },
44
- { transaction_id: '006', customer_name: 'Lisa Garcia', total_amount: 1650, category: 'Electronics', payment_method: 'PayPal', transaction_date: '2024-02-15', state: 'WA' },
45
- { transaction_id: '007', customer_name: 'Robert Lee', total_amount: 320, category: 'Books', payment_method: 'Cash', transaction_date: '2024-02-20', state: 'OR' },
46
- { transaction_id: '008', customer_name: 'Emily Davis', total_amount: 950, category: 'Clothing', payment_method: 'Credit Card', transaction_date: '2024-03-01', state: 'NY' },
47
- { transaction_id: '009', customer_name: 'Alex Rodriguez', total_amount: 1480, category: 'Sports', payment_method: 'Debit Card', transaction_date: '2024-03-05', state: 'TX' },
48
- { transaction_id: '010', customer_name: 'Maria Martinez', total_amount: 670, category: 'Beauty', payment_method: 'PayPal', transaction_date: '2024-03-08', state: 'FL' },
49
- { transaction_id: '011', customer_name: 'Chris Anderson', total_amount: 2200, category: 'Electronics', payment_method: 'Credit Card', transaction_date: '2024-03-12', state: 'CA' },
50
- { transaction_id: '012', customer_name: 'Amanda White', total_amount: 520, category: 'Clothing', payment_method: 'Debit Card', transaction_date: '2024-03-15', state: 'WA' },
51
- { transaction_id: '013', customer_name: 'James Taylor', total_amount: 1100, category: 'Sports', payment_method: 'Credit Card', transaction_date: '2024-03-18', state: 'OR' },
52
- { transaction_id: '014', customer_name: 'Jennifer Moore', total_amount: 380, category: 'Books', payment_method: 'Cash', transaction_date: '2024-03-22', state: 'NY' },
53
- { transaction_id: '015', customer_name: 'Kevin Jackson', total_amount: 1850, category: 'Electronics', payment_method: 'PayPal', transaction_date: '2024-03-25', state: 'TX' },
54
- { transaction_id: '016', customer_name: 'Nicole Thompson', total_amount: 760, category: 'Beauty', payment_method: 'Credit Card', transaction_date: '2024-04-01', state: 'FL' },
55
- { transaction_id: '017', customer_name: 'Brian Wilson', total_amount: 1320, category: 'Sports', payment_method: 'Debit Card', transaction_date: '2024-04-05', state: 'CA' },
56
- { transaction_id: '018', customer_name: 'Jessica Clark', total_amount: 590, category: 'Clothing', payment_method: 'Credit Card', transaction_date: '2024-04-08', state: 'WA' },
57
- { transaction_id: '019', customer_name: 'Michael Lewis', total_amount: 2400, category: 'Electronics', payment_method: 'PayPal', transaction_date: '2024-04-12', state: 'OR' },
58
- { transaction_id: '020', customer_name: 'Ashley Hall', total_amount: 450, category: 'Books', payment_method: 'Cash', transaction_date: '2024-04-15', state: 'NY' }
59
- ]
60
-
61
- // Use real data if available, otherwise use sample data
62
- const rawData = rawApiData.length > 0 ? rawApiData : sampleTransactionData
63
-
64
- const orderData = processOrderData(rawData)
65
- const paymentMethodData = processPaymentMethodData(rawData)
66
- const monthlyRevenueData = processMonthlyRevenueData(rawData)
67
- const recentTransactions = processRecentTransactions(rawData)
68
- const { totalOrders, totalRevenue, averageOrderValue } = calculateMetrics(rawData)
69
- const ecommerceMetrics = createEcommerceMetrics(totalRevenue, totalOrders, averageOrderValue)
70
-
71
- // Helper function to render query state
72
- const renderQueryState = (query: any, title: string) => {
73
- const result = renderQueryStateUtil(query, title)
74
-
75
- if (result.status === 'loading') {
76
- return (
77
- <div className="flex items-center gap-2 text-blue-600">
78
- <Loader2 className="h-4 w-4 animate-spin" />
79
- <span className="text-sm">{result.message}</span>
80
- </div>
81
- )
82
- }
83
-
84
- if (result.status === 'error') {
85
- return (
86
- <div className="flex items-center gap-2 text-red-600">
87
- <AlertCircle className="h-4 w-4" />
88
- <span className="text-sm">{result.message}</span>
89
- </div>
90
- )
91
- }
92
-
93
- if (result.status === 'success') {
94
- return (
95
- <div className="flex items-center gap-2 text-green-600">
96
- <CheckCircle className="h-4 w-4" />
97
- <span className="text-sm">{result.message}</span>
98
- </div>
99
- )
100
- }
101
-
102
- return (
103
- <div className="flex items-center gap-2 text-gray-500">
104
- <Clock className="h-4 w-4" />
105
- <span className="text-sm">{result.message}</span>
106
- </div>
107
- )
108
- }
109
-
110
- return (
111
- <div className="space-y-6">
112
- {/* API Status */}
113
- <div className="flex items-center justify-between">
114
- <div className="flex items-center space-x-4">
115
- {renderQueryState(metricQuery, 'Metrics API')}
116
- {renderQueryState(datasetQuery, 'Dataset API')}
117
- {renderQueryState(userQuery, 'User API')}
118
- </div>
119
- <Button
120
- variant="outline"
121
- size="sm"
122
- onClick={() => {
123
- metricQuery.refetch()
124
- datasetQuery.refetch()
125
- userQuery.refetch()
126
- }}
127
- disabled={metricQuery.isLoading || datasetQuery.isLoading || userQuery.isLoading ||
128
- metricQuery.isFetching || datasetQuery.isFetching || userQuery.isFetching}
129
- >
130
- {(metricQuery.isFetching || datasetQuery.isFetching || userQuery.isFetching) ? (
131
- <Loader2 className="h-4 w-4 mr-2 animate-spin" />
132
- ) : (
133
- <RefreshCw className="h-4 w-4 mr-2" />
134
- )}
135
- Refresh Data
136
- </Button>
137
- </div>
138
-
139
- {/* Key Metrics */}
140
- <DashboardMetrics
141
- ecommerceMetrics={ecommerceMetrics}
142
- monthlyRevenueData={monthlyRevenueData}
143
- />
144
-
145
- {/* Sales Analytics */}
146
- <SalesAnalytics
147
- orderData={orderData}
148
- totalOrders={totalOrders}
149
- totalRevenue={totalRevenue}
150
- averageOrderValue={averageOrderValue}
151
- />
152
-
153
- {/* Payment Methods Analysis */}
154
- <PaymentMethodsAnalysis
155
- paymentMethodData={paymentMethodData}
156
- />
157
-
158
- {/* Recent Transactions */}
159
- <TransactionsTable
160
- recentTransactions={recentTransactions}
161
- totalOrders={totalOrders}
162
- />
163
-
164
- {/* Revenue Analytics */}
165
- <RevenueAnalytics
166
- orderData={orderData}
167
- monthlyRevenueData={monthlyRevenueData}
168
- totalOrders={totalOrders}
169
- totalRevenue={totalRevenue}
170
- averageOrderValue={averageOrderValue}
171
- />
172
-
173
- {/* Data Source Info */}
174
- {userQuery.data?.user && (
175
- <Alert>
176
- <AlertCircle className="h-4 w-4" />
177
- <AlertDescription>
178
- Data is being fetched from Copa-lib APIs. Current user: {userQuery.data.user.name}
179
- ({userQuery.data.user.organization || 'No organization'})
180
- </AlertDescription>
181
- </Alert>
182
- )}
183
- </div>
184
- )
185
- }