create-bluecopa-react-app 1.0.2 → 1.0.4
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 +80 -222
- package/package.json +2 -2
- package/templates/latest/{Agent.md → AGENT.md} +64 -39
- package/templates/latest/README.md +23 -41
- package/templates/latest/package-lock.json +290 -142
- package/templates/latest/package.json +4 -8
- package/templates/latest/preview/index.html +330 -0
- package/templates/latest/vite.config.ts +18 -31
package/README.md
CHANGED
|
@@ -1,274 +1,132 @@
|
|
|
1
|
-
#
|
|
1
|
+
# create-bluecopa-react-app [](https://www.npmjs.com/package/create-bluecopa-react-app) [](LICENSE)
|
|
2
2
|
|
|
3
|
-
A CLI
|
|
3
|
+
## A CLI Tool for BlueCopa React Applications
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
A command-line interface for bootstrapping modern React applications with BlueCopa integration, featuring opinionated best practices and pre-configured tooling.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
- 📊 **Data Visualization**: Recharts integration for charts and analytics
|
|
9
|
-
- 🎨 **UI Components**: Radix UI primitives with custom styling
|
|
10
|
-
- 📡 **BlueCopa React Components**: Pre-configured @bluecopa/react package with hooks
|
|
11
|
-
- 🎯 **Type Safety**: Full TypeScript support
|
|
12
|
-
- 📱 **Responsive Design**: Tailwind CSS with mobile-first approach and BlueCopa design system
|
|
13
|
-
- 🛠️ **Development Tools**: ESLint, TypeScript checking, and Vite fast build system
|
|
14
|
-
- ⚡ **Fast Development**: Hot module replacement with Vite
|
|
15
|
-
- 🔄 **Client-side Routing**: React Router v6 for SPA navigation
|
|
16
|
-
|
|
17
|
-
## Quick Start
|
|
18
|
-
|
|
19
|
-
```bash
|
|
20
|
-
# Install the CLI tool globally
|
|
21
|
-
npm install -g create-bluecopa-react-app
|
|
7
|
+
## Table of Contents
|
|
22
8
|
|
|
23
|
-
#
|
|
24
|
-
|
|
9
|
+
- [Version](#version)
|
|
10
|
+
- [Installation](#installation)
|
|
11
|
+
- [Requirements](#requirements)
|
|
12
|
+
- [Configuration](#configuration)
|
|
13
|
+
- [Features](#features)
|
|
14
|
+
- [Usage](#usage)
|
|
15
|
+
- [API Documentation](#api-documentation)
|
|
16
|
+
- [Examples](#examples)
|
|
17
|
+
- [Development](#development)
|
|
18
|
+
- [Contributing](#contributing)
|
|
19
|
+
- [License](#license)
|
|
25
20
|
|
|
26
|
-
|
|
27
|
-
npx create-bluecopa-react-app my-dashboard
|
|
21
|
+
## Version
|
|
28
22
|
|
|
29
|
-
|
|
30
|
-
cd my-dashboard
|
|
23
|
+
Current version: 0.1.0
|
|
31
24
|
|
|
32
|
-
|
|
33
|
-
npm install
|
|
25
|
+
## Installation
|
|
34
26
|
|
|
35
|
-
|
|
36
|
-
npm
|
|
27
|
+
```bash
|
|
28
|
+
npm install -g create-bluecopa-react-app
|
|
29
|
+
# or
|
|
30
|
+
pnpm add -g create-bluecopa-react-app
|
|
37
31
|
```
|
|
38
32
|
|
|
39
|
-
##
|
|
33
|
+
## Requirements
|
|
40
34
|
|
|
41
|
-
|
|
35
|
+
- Node.js >= 18.0.0
|
|
36
|
+
- npm >= 9.0.0 or pnpm >= 8.0.0
|
|
42
37
|
|
|
43
|
-
|
|
38
|
+
## Configuration
|
|
44
39
|
|
|
45
|
-
|
|
46
|
-
- **BlueCopa Components**: Pre-configured @bluecopa/react component library with hooks
|
|
47
|
-
- **UI Foundation**: Radix UI primitives with custom styling system
|
|
48
|
-
- **Data Visualization**: Recharts for charts and analytics
|
|
49
|
-
- **Styling System**: Tailwind CSS with BlueCopa design tokens and navy theme
|
|
50
|
-
- **Development Setup**: ESLint, TypeScript configuration, and Vite optimization
|
|
51
|
-
- **Environment Configuration**: Ready-to-use environment variable setup
|
|
52
|
-
- **Client-side Routing**: React Router v6 for smooth SPA navigation
|
|
40
|
+
The CLI uses environment variables for configuration:
|
|
53
41
|
|
|
54
|
-
|
|
42
|
+
```bash
|
|
43
|
+
# Optional configuration
|
|
44
|
+
export BLUECOPA_BOILERPLATE_REGISTRY=https://registry.npmjs.org
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Features
|
|
55
48
|
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
49
|
+
- 🚀 **Modern React Stack**: React 18, TypeScript, React Router v6, Vite 7
|
|
50
|
+
- 🌐 **Microfrontend Support**: Single-spa compatible with module federation
|
|
51
|
+
- 📊 **Data Visualization**: Recharts integration for charts and analytics
|
|
52
|
+
- 🎨 **UI Components**: Radix UI primitives with custom styling
|
|
53
|
+
- 📡 **BlueCopa React Components**: Pre-configured [`@bluecopa/react`](packages/react:1) package with hooks (includes TanStack Query integration)
|
|
54
|
+
- 🎯 **Type Safety**: Full TypeScript support
|
|
55
|
+
- 📱 **Responsive Design**: Tailwind CSS with mobile-first approach and BlueCopa design system
|
|
56
|
+
- 🛠️ **Development Tools**: ESLint, TypeScript checking, and Vite fast build system
|
|
57
|
+
- ⚡ **Fast Development**: Hot module replacement with Vite
|
|
58
|
+
- 🔄 **Client-side Routing**: React Router v6 for SPA navigation
|
|
63
59
|
|
|
64
|
-
|
|
65
|
-
"@radix-ui/*": "Latest versions"
|
|
66
|
-
"tailwindcss": "^3.4.17"
|
|
67
|
-
"lucide-react": "^0.445.0"
|
|
60
|
+
## Usage
|
|
68
61
|
|
|
69
|
-
|
|
70
|
-
"recharts": "^2.12.0"
|
|
62
|
+
### Creating a New Application
|
|
71
63
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"@vitejs/plugin-react": "^4.3.0"
|
|
76
|
-
```
|
|
64
|
+
```bash
|
|
65
|
+
# Create new app
|
|
66
|
+
create-bluecopa-react-app my-dashboard
|
|
77
67
|
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
The generated project follows a clean, scalable structure:
|
|
81
|
-
|
|
82
|
-
```text
|
|
83
|
-
my-bluecopa-app/
|
|
84
|
-
├── src/
|
|
85
|
-
│ ├── components/ # Reusable UI components
|
|
86
|
-
│ │ ├── ui/ # Base UI components (buttons, cards, etc.)
|
|
87
|
-
│ │ └── navbar.tsx # Navigation component
|
|
88
|
-
│ ├── hooks/ # Custom React hooks
|
|
89
|
-
│ │ └── use-api.ts # Bluecopa API hooks
|
|
90
|
-
│ ├── lib/ # Utilities and helpers
|
|
91
|
-
│ │ └── utils.ts # Helper functions and utilities
|
|
92
|
-
│ ├── pages/ # Route components
|
|
93
|
-
│ │ ├── Home.tsx # Home page component
|
|
94
|
-
│ │ └── Dashboard.tsx # Dashboard page component
|
|
95
|
-
│ ├── providers/ # React context providers
|
|
96
|
-
│ │ └── query-provider.tsx # TanStack Query provider
|
|
97
|
-
│ ├── types/ # TypeScript type definitions
|
|
98
|
-
│ ├── App.tsx # Main app component with routing
|
|
99
|
-
│ ├── main.tsx # Application entry point
|
|
100
|
-
│ └── index.css # Global styles and Tailwind imports
|
|
101
|
-
├── public/ # Static assets
|
|
102
|
-
├── .env.example # Environment variables template
|
|
103
|
-
├── package.json # Dependencies and scripts
|
|
104
|
-
├── vite.config.ts # Vite configuration
|
|
105
|
-
├── tailwind.config.js # Tailwind CSS configuration
|
|
106
|
-
├── tsconfig.json # TypeScript configuration
|
|
107
|
-
├── postcss.config.js # PostCSS configuration
|
|
108
|
-
└── README.md # Project documentation
|
|
68
|
+
# Or use npx
|
|
69
|
+
npx create-bluecopa-react-app my-dashboard
|
|
109
70
|
```
|
|
110
71
|
|
|
111
|
-
|
|
72
|
+
### CLI Options
|
|
112
73
|
|
|
113
|
-
|
|
74
|
+
| Option | Description |
|
|
75
|
+
|--------|-------------|
|
|
76
|
+
| `--skip-install` | Skip dependency installation |
|
|
77
|
+
| `--template` | Specify template version (default: latest) |
|
|
78
|
+
| `--help` | Show help information |
|
|
114
79
|
|
|
115
|
-
|
|
80
|
+
## API Documentation
|
|
116
81
|
|
|
117
|
-
|
|
118
|
-
import { useUserData, useMetricDataDemo, useDatasetDataDemo } from '@/hooks/use-api';
|
|
82
|
+
### `create-bluecopa-react-app [project-name] [options]`
|
|
119
83
|
|
|
120
|
-
|
|
121
|
-
const { data: userData, isLoading, error } = useUserData();
|
|
122
|
-
const { data: metrics } = useMetricDataDemo();
|
|
123
|
-
|
|
124
|
-
if (isLoading) return <div>Loading...</div>;
|
|
125
|
-
if (error) return <div>Error: {error.message}</div>;
|
|
126
|
-
|
|
127
|
-
return (
|
|
128
|
-
<div>
|
|
129
|
-
<h1>Welcome, {userData?.user?.firstName}!</h1>
|
|
130
|
-
</div>
|
|
131
|
-
);
|
|
132
|
-
}
|
|
133
|
-
```
|
|
84
|
+
Creates a new BlueCopa React application.
|
|
134
85
|
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
```typescript
|
|
140
|
-
import { Routes, Route } from 'react-router-dom';
|
|
141
|
-
import NewPage from '@/pages/NewPage';
|
|
142
|
-
|
|
143
|
-
export default function App() {
|
|
144
|
-
return (
|
|
145
|
-
<QueryProvider>
|
|
146
|
-
<Routes>
|
|
147
|
-
<Route path="/" element={<Home />} />
|
|
148
|
-
<Route path="/dashboard" element={<Dashboard />} />
|
|
149
|
-
<Route path="/new-page" element={<NewPage />} />
|
|
150
|
-
</Routes>
|
|
151
|
-
</QueryProvider>
|
|
152
|
-
);
|
|
153
|
-
}
|
|
154
|
-
```
|
|
86
|
+
**Parameters:**
|
|
87
|
+
- `project-name`: Name of the new project directory
|
|
88
|
+
- `options`: CLI options (see above)
|
|
155
89
|
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
```typescript
|
|
161
|
-
import { Button } from '@/components/ui/button';
|
|
162
|
-
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
163
|
-
|
|
164
|
-
function Dashboard() {
|
|
165
|
-
return (
|
|
166
|
-
<Card>
|
|
167
|
-
<CardHeader>
|
|
168
|
-
<CardTitle>My Dashboard</CardTitle>
|
|
169
|
-
</CardHeader>
|
|
170
|
-
<CardContent>
|
|
171
|
-
<Button>Click me</Button>
|
|
172
|
-
</CardContent>
|
|
173
|
-
</Card>
|
|
174
|
-
);
|
|
175
|
-
}
|
|
176
|
-
```
|
|
177
|
-
|
|
178
|
-
### Adding Charts and Data Visualization
|
|
179
|
-
|
|
180
|
-
Use Recharts for data visualization:
|
|
181
|
-
|
|
182
|
-
```typescript
|
|
183
|
-
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
184
|
-
|
|
185
|
-
const data = [
|
|
186
|
-
{ name: 'Jan', value: 400 },
|
|
187
|
-
{ name: 'Feb', value: 300 },
|
|
188
|
-
{ name: 'Mar', value: 600 },
|
|
189
|
-
];
|
|
190
|
-
|
|
191
|
-
function ChartComponent() {
|
|
192
|
-
return (
|
|
193
|
-
<ResponsiveContainer width="100%" height={300}>
|
|
194
|
-
<LineChart data={data}>
|
|
195
|
-
<CartesianGrid strokeDasharray="3 3" />
|
|
196
|
-
<XAxis dataKey="name" />
|
|
197
|
-
<YAxis />
|
|
198
|
-
<Tooltip />
|
|
199
|
-
<Line type="monotone" dataKey="value" stroke="#8884d8" />
|
|
200
|
-
</LineChart>
|
|
201
|
-
</ResponsiveContainer>
|
|
202
|
-
);
|
|
203
|
-
}
|
|
204
|
-
```
|
|
90
|
+
**Returns:**
|
|
91
|
+
- Creates project structure
|
|
92
|
+
- Installs dependencies
|
|
93
|
+
- Configures environment
|
|
205
94
|
|
|
206
|
-
|
|
95
|
+
## Examples
|
|
207
96
|
|
|
208
|
-
|
|
97
|
+
### Basic Usage
|
|
209
98
|
|
|
210
99
|
```bash
|
|
211
|
-
|
|
212
|
-
# Edit .env.local with your Bluecopa credentials from dashboard → Settings → API Tokens
|
|
100
|
+
create-bluecopa-react-app my-dashboard
|
|
213
101
|
```
|
|
214
102
|
|
|
215
|
-
|
|
103
|
+
### Skipping Dependency Installation
|
|
104
|
+
|
|
216
105
|
```bash
|
|
217
|
-
|
|
218
|
-
VITE_BLUECOPA_API_URL=https://develop.bluecopa.com/api/v1
|
|
219
|
-
VITE_BLUECOPA_WORKSPACE_ID=your-workspace-id
|
|
106
|
+
create-bluecopa-react-app my-dashboard --skip-install
|
|
220
107
|
```
|
|
221
108
|
|
|
222
|
-
##
|
|
109
|
+
## Development
|
|
110
|
+
|
|
111
|
+
### Available Scripts
|
|
223
112
|
|
|
224
113
|
- `npm run dev` - Start Vite development server with hot reload
|
|
225
114
|
- `npm run build` - Build for production (TypeScript + Vite optimization)
|
|
115
|
+
- `npm run start` - Start production build locally
|
|
226
116
|
- `npm run preview` - Preview production build locally
|
|
227
117
|
- `npm run lint` - Run ESLint for code quality
|
|
118
|
+
- `npm run lint:fix` - Fix linting issues
|
|
228
119
|
- `npm run type-check` - Run TypeScript type checking without emitting files
|
|
120
|
+
- `npm run clean` - Clean build artifacts and dependencies
|
|
229
121
|
|
|
230
|
-
|
|
122
|
+
### Technologies Used
|
|
231
123
|
|
|
232
124
|
- **React 18** - Modern React with concurrent features
|
|
233
125
|
- **React Router v6** - Declarative routing for React SPAs
|
|
234
126
|
- **Vite** - Fast build tool and development server
|
|
235
127
|
- **TypeScript** - Full type safety and developer experience
|
|
236
|
-
-
|
|
237
|
-
- **TanStack Query** - Powerful data synchronization for React
|
|
128
|
+
- **[`@bluecopa/react`](packages/react:1)** - BlueCopa-specific React components and hooks
|
|
238
129
|
- **Radix UI** - Unstyled, accessible UI primitives
|
|
239
130
|
- **Recharts** - Composable charting library for React
|
|
240
131
|
- **Tailwind CSS** - Utility-first CSS framework with BlueCopa design system
|
|
241
132
|
- **Lucide React** - Beautiful, customizable icons
|
|
242
|
-
|
|
243
|
-
## CLI Usage
|
|
244
|
-
|
|
245
|
-
The CLI will prompt you for project details and automatically:
|
|
246
|
-
|
|
247
|
-
- Create the project structure
|
|
248
|
-
- Copy template files
|
|
249
|
-
- Update package.json with your project name
|
|
250
|
-
- Install dependencies (unless `--skip-install` is used)
|
|
251
|
-
- Provide next steps for development
|
|
252
|
-
|
|
253
|
-
Example output:
|
|
254
|
-
|
|
255
|
-
```bash
|
|
256
|
-
✔ Creating project structure...
|
|
257
|
-
✔ Dependencies installed
|
|
258
|
-
✔ Success! Created my-dashboard at /path/to/my-dashboard
|
|
259
|
-
|
|
260
|
-
Inside that directory, you can run several commands:
|
|
261
|
-
|
|
262
|
-
npm run dev
|
|
263
|
-
Starts the development server.
|
|
264
|
-
|
|
265
|
-
npm run build
|
|
266
|
-
Bundles the app into static files for production.
|
|
267
|
-
|
|
268
|
-
We suggest that you begin by typing:
|
|
269
|
-
|
|
270
|
-
cd my-dashboard
|
|
271
|
-
npm run dev
|
|
272
|
-
|
|
273
|
-
Happy coding with Bluecopa! 🚀
|
|
274
|
-
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "create-bluecopa-react-app",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "CLI tool to create bluecopa React applications",
|
|
5
5
|
"main": "./bin/create-bluecopa-react-app.js",
|
|
6
6
|
"bin": {
|
|
@@ -37,4 +37,4 @@
|
|
|
37
37
|
"engines": {
|
|
38
38
|
"node": ">=18.0.0"
|
|
39
39
|
}
|
|
40
|
-
}
|
|
40
|
+
}
|
|
@@ -12,21 +12,21 @@ This template is designed to work seamlessly with AI coding assistants for rapid
|
|
|
12
12
|
- **Frontend**: React 18 + TypeScript + React Router v6
|
|
13
13
|
- **Build Tool**: Vite (fast HMR and building)
|
|
14
14
|
- **Styling**: TailwindCSS with BlueCopa design system
|
|
15
|
-
- **UI Components**: Radix UI primitives
|
|
16
|
-
- **Data Fetching**: TanStack Query with @bluecopa/
|
|
15
|
+
- **UI Components**: Radix UI primitives (add via shadcn-ui for pre-styled components)
|
|
16
|
+
- **Data Fetching**: TanStack Query with @bluecopa/core hooks
|
|
17
17
|
- **Charts**: Recharts for data visualization
|
|
18
18
|
- **Icons**: Lucide React
|
|
19
19
|
|
|
20
20
|
### Key Directories
|
|
21
21
|
```
|
|
22
22
|
src/
|
|
23
|
-
├── components/ui/ # Reusable UI components (Button, Card
|
|
24
|
-
├── components/ # Business logic components (Navbar, etc.)
|
|
25
|
-
├── hooks/ # Custom React hooks
|
|
23
|
+
├── components/ui/ # Reusable UI components (e.g., Button, Card via shadcn-ui; bluecopa-logo)
|
|
24
|
+
├── components/ # Business logic components (Navbar, DashboardLayout, etc.)
|
|
25
|
+
├── hooks/ # Custom React hooks (if needed; primarily use @bluecopa/core)
|
|
26
26
|
├── pages/ # Route components (Home, Dashboard)
|
|
27
|
-
├── providers/ # React context providers
|
|
28
|
-
├── lib/ # Utility functions and helpers
|
|
29
|
-
└── types/ # TypeScript type definitions
|
|
27
|
+
├── providers/ # React context providers (e.g., QueryProvider)
|
|
28
|
+
├── lib/ # Utility functions and helpers (e.g., utils.ts with cn)
|
|
29
|
+
└── types/ # TypeScript type definitions (e.g., for API responses)
|
|
30
30
|
```
|
|
31
31
|
|
|
32
32
|
## 🔧 Development Patterns
|
|
@@ -38,8 +38,13 @@ When asked to create a new page:
|
|
|
38
38
|
1. **Create the page component** in `src/pages/NewPage.tsx`:
|
|
39
39
|
```tsx
|
|
40
40
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
41
|
+
import { useGetWorkflowInstanceStatusById } from '@bluecopa/core';
|
|
41
42
|
|
|
42
43
|
export default function NewPage() {
|
|
44
|
+
const { data: workflowStatus, isLoading } = useGetWorkflowInstanceStatusById('workflowId');
|
|
45
|
+
|
|
46
|
+
if (isLoading) return <div>Loading...</div>;
|
|
47
|
+
|
|
43
48
|
return (
|
|
44
49
|
<div className="container mx-auto py-6">
|
|
45
50
|
<Card>
|
|
@@ -48,6 +53,7 @@ export default function NewPage() {
|
|
|
48
53
|
</CardHeader>
|
|
49
54
|
<CardContent>
|
|
50
55
|
{/* Page content */}
|
|
56
|
+
<p>Workflow status: {workflowStatus?.status}</p>
|
|
51
57
|
</CardContent>
|
|
52
58
|
</Card>
|
|
53
59
|
</div>
|
|
@@ -63,8 +69,10 @@ import NewPage from '@/pages/NewPage';
|
|
|
63
69
|
<Route path="/new-page" element={<NewPage />} />
|
|
64
70
|
```
|
|
65
71
|
|
|
66
|
-
3. **Update navigation** in `src/components/navbar.tsx
|
|
72
|
+
3. **Update navigation** in `src/components/page/navbar.tsx` (import icon from lucide-react):
|
|
67
73
|
```tsx
|
|
74
|
+
import { Settings } from 'lucide-react';
|
|
75
|
+
|
|
68
76
|
const navigation = [
|
|
69
77
|
// ... existing routes
|
|
70
78
|
{ name: 'New Page', href: '/new-page', icon: Settings },
|
|
@@ -73,30 +81,36 @@ const navigation = [
|
|
|
73
81
|
|
|
74
82
|
### 2. Using BlueCopa API Hooks
|
|
75
83
|
|
|
76
|
-
|
|
84
|
+
Install @bluecopa/core if not present: `npm install @bluecopa/core`
|
|
77
85
|
|
|
86
|
+
Use the pre-configured hooks from `@bluecopa/core`:
|
|
78
87
|
```tsx
|
|
79
|
-
import {
|
|
88
|
+
import { useGetFileUrlByFileId, useGetTableById, useGetWorkflowInstanceStatusById } from '@bluecopa/core';
|
|
80
89
|
|
|
81
90
|
function DataComponent() {
|
|
82
|
-
const { data:
|
|
83
|
-
const { data:
|
|
91
|
+
const { data: fileUrlData, isLoading: fileUrlLoading } = useGetFileUrlByFileId('key', 'type', 'GET');
|
|
92
|
+
const { data: tableData } = useGetTableById('tableId');
|
|
93
|
+
const { data: workflowStatus } = useGetWorkflowInstanceStatusById('workflowId');
|
|
84
94
|
|
|
85
|
-
if (
|
|
86
|
-
if (
|
|
95
|
+
if (fileUrlLoading) return <div>Loading...</div>;
|
|
96
|
+
if (!fileUrlData) return <div>No data available</div>;
|
|
87
97
|
|
|
88
|
-
return <div>Data: {JSON.stringify(
|
|
98
|
+
return <div>Data: {JSON.stringify(fileUrlData)}</div>;
|
|
89
99
|
}
|
|
90
100
|
```
|
|
91
101
|
|
|
102
|
+
For custom hooks, create in `src/hooks/` and wrap TanStack Query.
|
|
103
|
+
|
|
92
104
|
### 3. UI Component Patterns
|
|
93
105
|
|
|
94
|
-
|
|
106
|
+
Add shadcn-ui components if needed: `npx shadcn-ui@latest add card button tabs`
|
|
95
107
|
|
|
108
|
+
Use the existing UI components from `src/components/ui/`:
|
|
96
109
|
```tsx
|
|
97
110
|
import { Button } from '@/components/ui/button';
|
|
98
111
|
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
99
112
|
import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
113
|
+
import { cn } from '@/lib/utils';
|
|
100
114
|
|
|
101
115
|
// Example usage
|
|
102
116
|
<Card>
|
|
@@ -104,7 +118,7 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
|
104
118
|
<CardTitle>Dashboard</CardTitle>
|
|
105
119
|
</CardHeader>
|
|
106
120
|
<CardContent>
|
|
107
|
-
<Tabs defaultValue="overview">
|
|
121
|
+
<Tabs defaultValue="overview" className={cn("w-full")}>
|
|
108
122
|
<TabsList>
|
|
109
123
|
<TabsTrigger value="overview">Overview</TabsTrigger>
|
|
110
124
|
<TabsTrigger value="analytics">Analytics</TabsTrigger>
|
|
@@ -119,12 +133,19 @@ import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs';
|
|
|
119
133
|
|
|
120
134
|
### 4. Chart Integration
|
|
121
135
|
|
|
122
|
-
|
|
136
|
+
Install Recharts if not present: `npm install recharts`
|
|
123
137
|
|
|
138
|
+
Use Recharts for data visualization:
|
|
124
139
|
```tsx
|
|
125
140
|
import { LineChart, Line, XAxis, YAxis, CartesianGrid, Tooltip, ResponsiveContainer } from 'recharts';
|
|
141
|
+
import { Card, CardContent, CardHeader, CardTitle } from '@/components/ui/card';
|
|
126
142
|
|
|
127
|
-
|
|
143
|
+
interface ChartData {
|
|
144
|
+
name: string;
|
|
145
|
+
value: number;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
function ChartComponent({ data }: { data: ChartData[] }) {
|
|
128
149
|
return (
|
|
129
150
|
<Card>
|
|
130
151
|
<CardHeader>
|
|
@@ -177,27 +198,28 @@ function ChartComponent({ data }: { data: any[] }) {
|
|
|
177
198
|
## 🛠️ Common Tasks for Agents
|
|
178
199
|
|
|
179
200
|
### Adding a New Dashboard Card
|
|
180
|
-
1. Create component in
|
|
181
|
-
2. Use Card component wrapper
|
|
182
|
-
3. Include loading and error states
|
|
183
|
-
4. Use
|
|
201
|
+
1. Create component in `src/components/` (e.g., NewCard.tsx)
|
|
202
|
+
2. Use Card component wrapper from ui/
|
|
203
|
+
3. Include loading and error states with TanStack Query
|
|
204
|
+
4. Use @bluecopa/core hooks for data (e.g., useGetTableById)
|
|
184
205
|
|
|
185
206
|
### Creating Forms
|
|
186
|
-
1. Use Radix UI form components
|
|
187
|
-
2. Add TypeScript types for form data
|
|
188
|
-
3. Include validation and error handling
|
|
207
|
+
1. Use Radix UI form components (add via shadcn-ui: `npx shadcn-ui@latest add form`)
|
|
208
|
+
2. Add TypeScript types for form data in `src/types/`
|
|
209
|
+
3. Include validation with Zod and error handling
|
|
189
210
|
4. Follow BlueCopa styling patterns
|
|
190
211
|
|
|
191
212
|
### Adding Data Tables
|
|
192
|
-
1.
|
|
213
|
+
1. For complex tables, install and use AG Grid (@bluecopa/aggrid)
|
|
193
214
|
2. For simple tables, use HTML table with Tailwind styling
|
|
194
215
|
3. Include sorting, filtering, and pagination as needed
|
|
216
|
+
4. Integrate with @bluecopa/core for data
|
|
195
217
|
|
|
196
218
|
### Implementing Search
|
|
197
|
-
1. Add search state management
|
|
198
|
-
2. Use debounced input for API calls
|
|
219
|
+
1. Add search state management with React state or form libraries
|
|
220
|
+
2. Use debounced input for API calls (e.g., via useGetTableById with query params)
|
|
199
221
|
3. Show loading states during search
|
|
200
|
-
4. Handle empty states gracefully
|
|
222
|
+
4. Handle empty states gracefully with conditional rendering
|
|
201
223
|
|
|
202
224
|
## 🚨 Important Notes for Agents
|
|
203
225
|
|
|
@@ -209,18 +231,20 @@ const apiUrl = import.meta.env.VITE_BLUECOPA_API_URL;
|
|
|
209
231
|
```
|
|
210
232
|
|
|
211
233
|
### Imports
|
|
212
|
-
Use path aliases consistently:
|
|
234
|
+
Use path aliases consistently (configured in tsconfig.json):
|
|
213
235
|
```tsx
|
|
214
236
|
import { Button } from '@/components/ui/button';
|
|
215
|
-
import {
|
|
237
|
+
import { useGetTableById } from '@bluecopa/core';
|
|
216
238
|
import { cn } from '@/lib/utils';
|
|
217
239
|
```
|
|
218
240
|
|
|
219
241
|
### TypeScript
|
|
220
242
|
Always include proper TypeScript types:
|
|
221
243
|
```tsx
|
|
244
|
+
import { FileUrlResponse, TableData, WorkflowStatus } from '@/types';
|
|
245
|
+
|
|
222
246
|
interface ComponentProps {
|
|
223
|
-
data:
|
|
247
|
+
data: TableData[];
|
|
224
248
|
onSelect: (id: string) => void;
|
|
225
249
|
}
|
|
226
250
|
|
|
@@ -232,19 +256,20 @@ function Component({ data, onSelect }: ComponentProps) {
|
|
|
232
256
|
### Error Handling
|
|
233
257
|
Include proper error boundaries and loading states:
|
|
234
258
|
```tsx
|
|
235
|
-
if (
|
|
259
|
+
if (fileUrlLoading) return <div className="p-4">Loading...</div>;
|
|
236
260
|
if (error) return <div className="p-4 text-red-600">Error: {error.message}</div>;
|
|
237
261
|
if (!data) return <div className="p-4 text-gray-500">No data available</div>;
|
|
238
262
|
```
|
|
239
263
|
|
|
240
264
|
## 📚 Reference Links
|
|
241
|
-
|
|
242
265
|
- [React Router Documentation](https://reactrouter.com)
|
|
243
266
|
- [TailwindCSS Documentation](https://tailwindcss.com)
|
|
244
|
-
- [Radix UI Documentation](https://radix-ui.com)
|
|
267
|
+
- [Radix UI Documentation](https://www.radix-ui.com)
|
|
268
|
+
- [shadcn/ui Documentation](https://ui.shadcn.com)
|
|
245
269
|
- [Recharts Documentation](https://recharts.org)
|
|
246
|
-
- [TanStack Query Documentation](https://tanstack.com/query)
|
|
247
|
-
- [
|
|
270
|
+
- [TanStack Query Documentation](https://tanstack.com/query/latest)
|
|
271
|
+
- [Lucide React Icons](https://lucide.dev)
|
|
272
|
+
- [BlueCopa Core Package](https://www.npmjs.com/package/@bluecopa/core)
|
|
248
273
|
|
|
249
274
|
## 🔄 Development Workflow
|
|
250
275
|
|