@atlashub/smartstack-cli 1.1.0
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/.documentation/agents.html +912 -0
- package/.documentation/apex.html +1014 -0
- package/.documentation/business-analyse.html +1074 -0
- package/.documentation/commands.html +676 -0
- package/.documentation/css/styles.css +2030 -0
- package/.documentation/efcore.html +2501 -0
- package/.documentation/gitflow.html +2053 -0
- package/.documentation/hooks.html +409 -0
- package/.documentation/index.html +319 -0
- package/.documentation/installation.html +458 -0
- package/.documentation/js/app.js +794 -0
- package/.documentation/test-web.html +509 -0
- package/README.md +90 -0
- package/config/default-config.json +86 -0
- package/config/settings.json +53 -0
- package/config/settings.local.example.json +16 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +38198 -0
- package/dist/index.js.map +1 -0
- package/package.json +86 -0
- package/templates/agents/action.md +36 -0
- package/templates/agents/efcore/conflicts.md +57 -0
- package/templates/agents/efcore/db-deploy.md +51 -0
- package/templates/agents/efcore/db-reset.md +59 -0
- package/templates/agents/efcore/db-seed.md +56 -0
- package/templates/agents/efcore/db-status.md +43 -0
- package/templates/agents/efcore/migration.md +85 -0
- package/templates/agents/efcore/rebase-snapshot.md +62 -0
- package/templates/agents/efcore/scan.md +60 -0
- package/templates/agents/efcore/squash.md +67 -0
- package/templates/agents/explore-codebase.md +65 -0
- package/templates/agents/explore-docs.md +97 -0
- package/templates/agents/fix-grammar.md +49 -0
- package/templates/agents/gitflow/abort.md +45 -0
- package/templates/agents/gitflow/cleanup.md +85 -0
- package/templates/agents/gitflow/commit.md +40 -0
- package/templates/agents/gitflow/exec.md +48 -0
- package/templates/agents/gitflow/finish.md +92 -0
- package/templates/agents/gitflow/init.md +139 -0
- package/templates/agents/gitflow/merge.md +62 -0
- package/templates/agents/gitflow/plan.md +42 -0
- package/templates/agents/gitflow/pr.md +78 -0
- package/templates/agents/gitflow/review.md +49 -0
- package/templates/agents/gitflow/start.md +61 -0
- package/templates/agents/gitflow/status.md +32 -0
- package/templates/agents/snipper.md +36 -0
- package/templates/agents/websearch.md +46 -0
- package/templates/commands/_resources/formatting-guide.md +124 -0
- package/templates/commands/ai-prompt.md +315 -0
- package/templates/commands/apex/1-analyze.md +100 -0
- package/templates/commands/apex/2-plan.md +145 -0
- package/templates/commands/apex/3-execute.md +171 -0
- package/templates/commands/apex/4-examine.md +116 -0
- package/templates/commands/apex/5-tasks.md +209 -0
- package/templates/commands/apex.md +76 -0
- package/templates/commands/application/create.md +362 -0
- package/templates/commands/application/templates-backend.md +463 -0
- package/templates/commands/application/templates-frontend.md +517 -0
- package/templates/commands/application/templates-i18n.md +478 -0
- package/templates/commands/application/templates-seed.md +362 -0
- package/templates/commands/application.md +303 -0
- package/templates/commands/business-analyse/1-init.md +269 -0
- package/templates/commands/business-analyse/2-discover.md +520 -0
- package/templates/commands/business-analyse/3-analyse.md +408 -0
- package/templates/commands/business-analyse/4-specify.md +598 -0
- package/templates/commands/business-analyse/5-validate.md +326 -0
- package/templates/commands/business-analyse/6-handoff.md +746 -0
- package/templates/commands/business-analyse/7-doc-html.md +602 -0
- package/templates/commands/business-analyse/bug.md +325 -0
- package/templates/commands/business-analyse/change-request.md +368 -0
- package/templates/commands/business-analyse/hotfix.md +200 -0
- package/templates/commands/business-analyse.md +559 -0
- package/templates/commands/controller/create.md +216 -0
- package/templates/commands/controller/postman-templates.md +528 -0
- package/templates/commands/controller/templates.md +600 -0
- package/templates/commands/controller.md +278 -0
- package/templates/commands/debug.md +95 -0
- package/templates/commands/documentation/module.md +202 -0
- package/templates/commands/documentation/templates.md +432 -0
- package/templates/commands/documentation.md +190 -0
- package/templates/commands/efcore/_env-check.md +153 -0
- package/templates/commands/efcore/conflicts.md +269 -0
- package/templates/commands/efcore/db-deploy.md +193 -0
- package/templates/commands/efcore/db-reset.md +426 -0
- package/templates/commands/efcore/db-seed.md +326 -0
- package/templates/commands/efcore/db-status.md +214 -0
- package/templates/commands/efcore/migration.md +388 -0
- package/templates/commands/efcore/rebase-snapshot.md +264 -0
- package/templates/commands/efcore/scan.md +202 -0
- package/templates/commands/efcore/squash.md +298 -0
- package/templates/commands/efcore.md +176 -0
- package/templates/commands/epct.md +69 -0
- package/templates/commands/explain.md +186 -0
- package/templates/commands/explore.md +45 -0
- package/templates/commands/feature-full.md +267 -0
- package/templates/commands/gitflow/1-init.md +1038 -0
- package/templates/commands/gitflow/10-start.md +768 -0
- package/templates/commands/gitflow/11-finish.md +323 -0
- package/templates/commands/gitflow/12-cleanup.md +276 -0
- package/templates/commands/gitflow/13-sync.md +216 -0
- package/templates/commands/gitflow/14-rebase.md +251 -0
- package/templates/commands/gitflow/2-status.md +167 -0
- package/templates/commands/gitflow/3-commit.md +194 -0
- package/templates/commands/gitflow/4-plan.md +145 -0
- package/templates/commands/gitflow/5-exec.md +147 -0
- package/templates/commands/gitflow/6-abort.md +344 -0
- package/templates/commands/gitflow/7-pull-request.md +226 -0
- package/templates/commands/gitflow/8-review.md +176 -0
- package/templates/commands/gitflow/9-merge.md +224 -0
- package/templates/commands/gitflow.md +128 -0
- package/templates/commands/implement.md +663 -0
- package/templates/commands/notification.md +129 -0
- package/templates/commands/oneshot.md +57 -0
- package/templates/commands/quick-search.md +72 -0
- package/templates/commands/review.md +106 -0
- package/templates/commands/utils/test-web-config.md +160 -0
- package/templates/commands/utils/test-web.md +151 -0
- package/templates/commands/workflow.md +193 -0
- package/templates/gitflow/config.json +138 -0
- package/templates/hooks/ef-migration-check.md +139 -0
- package/templates/hooks/hooks.json +15 -0
- package/templates/skills/ai-prompt/SKILL.md +778 -0
- package/templates/skills/application/SKILL.md +563 -0
- package/templates/skills/application/templates-backend.md +450 -0
- package/templates/skills/application/templates-frontend.md +531 -0
- package/templates/skills/application/templates-i18n.md +520 -0
- package/templates/skills/application/templates-seed.md +647 -0
- package/templates/skills/business-analyse/SKILL.md +191 -0
- package/templates/skills/business-analyse/questionnaire.md +283 -0
- package/templates/skills/business-analyse/templates-frd.md +477 -0
- package/templates/skills/business-analyse/templates-react.md +580 -0
- package/templates/skills/controller/SKILL.md +240 -0
- package/templates/skills/controller/postman-templates.md +614 -0
- package/templates/skills/controller/templates.md +1468 -0
- package/templates/skills/documentation/SKILL.md +133 -0
- package/templates/skills/documentation/templates.md +476 -0
- package/templates/skills/feature-full/SKILL.md +838 -0
- package/templates/skills/notification/SKILL.md +555 -0
- package/templates/skills/ui-components/SKILL.md +870 -0
- package/templates/skills/workflow/SKILL.md +582 -0
- package/templates/test-web/api-health.json +38 -0
- package/templates/test-web/minimal.json +19 -0
- package/templates/test-web/npm-package.json +46 -0
- package/templates/test-web/seo-check.json +54 -0
|
@@ -0,0 +1,517 @@
|
|
|
1
|
+
# Templates Frontend - Application Skill
|
|
2
|
+
|
|
3
|
+
> Ces templates génèrent le code React/TypeScript pour les nouvelles applications/modules.
|
|
4
|
+
> **RAPPEL:** Toutes les pages client sont sous `/business/...`
|
|
5
|
+
|
|
6
|
+
---
|
|
7
|
+
|
|
8
|
+
## ARCHITECTURE FRONTEND
|
|
9
|
+
|
|
10
|
+
```
|
|
11
|
+
web/smartstack-web/src/
|
|
12
|
+
├── pages/business/$APP/$MODULE/
|
|
13
|
+
│ ├── $MODULE_PASCALPage.tsx # Page principale (liste)
|
|
14
|
+
│ ├── $MODULE_PASCALDetailPage.tsx # Page détail
|
|
15
|
+
│ └── Create$MODULE_PASCALPage.tsx # Page création
|
|
16
|
+
├── components/$MODULE/
|
|
17
|
+
│ ├── $MODULE_PASCALListView.tsx # Composant liste réutilisable
|
|
18
|
+
│ ├── $MODULE_PASCALForm.tsx # Formulaire CRUD
|
|
19
|
+
│ └── $MODULE_PASCALFilters.tsx # Filtres
|
|
20
|
+
├── components/common/
|
|
21
|
+
│ └── (composants partagés)
|
|
22
|
+
├── hooks/
|
|
23
|
+
│ ├── use$MODULE_PASCALPreferences.ts # Hook préférences
|
|
24
|
+
│ └── use$MODULE_PASCAL.ts # Hook API
|
|
25
|
+
├── services/api/
|
|
26
|
+
│ └── $moduleApi.ts # Service API
|
|
27
|
+
└── i18n/locales/
|
|
28
|
+
├── fr/$module.json
|
|
29
|
+
├── en/$module.json
|
|
30
|
+
├── it/$module.json
|
|
31
|
+
└── de/$module.json
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
---
|
|
35
|
+
|
|
36
|
+
## TEMPLATE: PAGE PRINCIPALE
|
|
37
|
+
|
|
38
|
+
```tsx
|
|
39
|
+
// pages/business/$APP/$MODULE/$MODULE_PASCALPage.tsx
|
|
40
|
+
|
|
41
|
+
import { useTranslation } from 'react-i18next';
|
|
42
|
+
import { $MODULE_PASCALListView } from '@/components/$MODULE/$MODULE_PASCALListView';
|
|
43
|
+
|
|
44
|
+
export function $MODULE_PASCALPage() {
|
|
45
|
+
const { t } = useTranslation(['$module', 'common']);
|
|
46
|
+
|
|
47
|
+
return (
|
|
48
|
+
<$MODULE_PASCALListView
|
|
49
|
+
title={t('$module:title')}
|
|
50
|
+
subtitle={t('$module:subtitle')}
|
|
51
|
+
basePath="/business/$APP/$MODULE"
|
|
52
|
+
createPath="/business/$APP/$MODULE/new"
|
|
53
|
+
/>
|
|
54
|
+
);
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
---
|
|
59
|
+
|
|
60
|
+
## TEMPLATE: LISTE VIEW (Composant réutilisable)
|
|
61
|
+
|
|
62
|
+
```tsx
|
|
63
|
+
// components/$MODULE/$MODULE_PASCALListView.tsx
|
|
64
|
+
|
|
65
|
+
import { useState, useEffect } from 'react';
|
|
66
|
+
import { useNavigate } from 'react-router-dom';
|
|
67
|
+
import { useTranslation } from 'react-i18next';
|
|
68
|
+
import { Plus, Search, MoreVertical, Pencil, Trash2 } from 'lucide-react';
|
|
69
|
+
import { api } from '@/services/api/apiClient';
|
|
70
|
+
import { use$MODULE_PASCALPreferences } from '@/hooks/use$MODULE_PASCALPreferences';
|
|
71
|
+
import { Pagination } from '@/components/common/Pagination';
|
|
72
|
+
import { ColumnSelector } from '@/components/common/ColumnSelector';
|
|
73
|
+
import { ViewModeToggle } from '@/components/common/ViewModeToggle';
|
|
74
|
+
|
|
75
|
+
interface $ENTITY_PASCALDto {
|
|
76
|
+
id: string;
|
|
77
|
+
name: string;
|
|
78
|
+
description: string | null;
|
|
79
|
+
isActive: boolean;
|
|
80
|
+
createdAt: string;
|
|
81
|
+
updatedAt: string | null;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
interface PagedResult {
|
|
85
|
+
items: $ENTITY_PASCALDto[];
|
|
86
|
+
totalCount: number;
|
|
87
|
+
page: number;
|
|
88
|
+
pageSize: number;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
interface $MODULE_PASCALListViewProps {
|
|
92
|
+
title: string;
|
|
93
|
+
subtitle?: string;
|
|
94
|
+
basePath: string;
|
|
95
|
+
createPath?: string;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
const DEFAULT_COLUMNS = ['name', 'description', 'isActive', 'createdAt'];
|
|
99
|
+
|
|
100
|
+
export function $MODULE_PASCALListView({
|
|
101
|
+
title,
|
|
102
|
+
subtitle,
|
|
103
|
+
basePath,
|
|
104
|
+
createPath,
|
|
105
|
+
}: $MODULE_PASCALListViewProps) {
|
|
106
|
+
const { t } = useTranslation(['$module', 'common']);
|
|
107
|
+
const navigate = useNavigate();
|
|
108
|
+
const {
|
|
109
|
+
pageSize,
|
|
110
|
+
sortColumn,
|
|
111
|
+
sortDirection,
|
|
112
|
+
visibleColumns,
|
|
113
|
+
viewMode,
|
|
114
|
+
setPageSize,
|
|
115
|
+
setSortColumn,
|
|
116
|
+
setSortDirection,
|
|
117
|
+
setVisibleColumns,
|
|
118
|
+
setViewMode,
|
|
119
|
+
} = use$MODULE_PASCALPreferences();
|
|
120
|
+
|
|
121
|
+
const [data, setData] = useState<PagedResult | null>(null);
|
|
122
|
+
const [loading, setLoading] = useState(true);
|
|
123
|
+
const [error, setError] = useState<string | null>(null);
|
|
124
|
+
const [page, setPage] = useState(1);
|
|
125
|
+
const [searchTerm, setSearchTerm] = useState('');
|
|
126
|
+
|
|
127
|
+
useEffect(() => {
|
|
128
|
+
loadData();
|
|
129
|
+
}, [page, pageSize, sortColumn, sortDirection, searchTerm]);
|
|
130
|
+
|
|
131
|
+
const loadData = async () => {
|
|
132
|
+
try {
|
|
133
|
+
setLoading(true);
|
|
134
|
+
setError(null);
|
|
135
|
+
const params = new URLSearchParams({
|
|
136
|
+
page: page.toString(),
|
|
137
|
+
pageSize: pageSize.toString(),
|
|
138
|
+
sortColumn,
|
|
139
|
+
sortDirection,
|
|
140
|
+
...(searchTerm && { searchTerm }),
|
|
141
|
+
});
|
|
142
|
+
const result = await api.get<PagedResult>(`/api/business/$MODULE?${params}`);
|
|
143
|
+
setData(result);
|
|
144
|
+
} catch (err) {
|
|
145
|
+
setError(t('common:errors.loadFailed'));
|
|
146
|
+
console.error('Failed to load $module:', err);
|
|
147
|
+
} finally {
|
|
148
|
+
setLoading(false);
|
|
149
|
+
}
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
const handleSort = (column: string) => {
|
|
153
|
+
if (sortColumn === column) {
|
|
154
|
+
setSortDirection(sortDirection === 'asc' ? 'desc' : 'asc');
|
|
155
|
+
} else {
|
|
156
|
+
setSortColumn(column);
|
|
157
|
+
setSortDirection('asc');
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
const handleDelete = async (id: string) => {
|
|
162
|
+
if (!confirm(t('common:confirmDelete'))) return;
|
|
163
|
+
|
|
164
|
+
try {
|
|
165
|
+
await api.delete(`/api/business/$MODULE/${id}`);
|
|
166
|
+
loadData();
|
|
167
|
+
} catch (err) {
|
|
168
|
+
console.error('Failed to delete:', err);
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
|
|
172
|
+
const columns = [
|
|
173
|
+
{ key: 'name', label: t('$module:columns.name'), sortable: true },
|
|
174
|
+
{ key: 'description', label: t('$module:columns.description'), sortable: false },
|
|
175
|
+
{ key: 'isActive', label: t('$module:columns.status'), sortable: true },
|
|
176
|
+
{ key: 'createdAt', label: t('$module:columns.createdAt'), sortable: true },
|
|
177
|
+
];
|
|
178
|
+
|
|
179
|
+
return (
|
|
180
|
+
<div className="space-y-6">
|
|
181
|
+
{/* Header */}
|
|
182
|
+
<div className="flex items-center justify-between">
|
|
183
|
+
<div>
|
|
184
|
+
<h1 className="text-2xl font-bold text-[var(--text-primary)]">{title}</h1>
|
|
185
|
+
{subtitle && (
|
|
186
|
+
<p className="text-[var(--text-secondary)] mt-1">{subtitle}</p>
|
|
187
|
+
)}
|
|
188
|
+
</div>
|
|
189
|
+
{createPath && (
|
|
190
|
+
<button
|
|
191
|
+
onClick={() => navigate(createPath)}
|
|
192
|
+
className="flex items-center gap-2 px-4 py-2 bg-[var(--color-accent-500)] hover:bg-[var(--color-accent-600)] text-white font-medium transition-colors"
|
|
193
|
+
style={{ borderRadius: 'var(--radius-button)' }}
|
|
194
|
+
>
|
|
195
|
+
<Plus className="w-4 h-4" />
|
|
196
|
+
{t('common:actions.create')}
|
|
197
|
+
</button>
|
|
198
|
+
)}
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
{/* Toolbar */}
|
|
202
|
+
<div className="flex items-center justify-between gap-4">
|
|
203
|
+
<div className="relative flex-1 max-w-md">
|
|
204
|
+
<Search className="absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-[var(--text-muted)]" />
|
|
205
|
+
<input
|
|
206
|
+
type="text"
|
|
207
|
+
placeholder={t('common:search.placeholder')}
|
|
208
|
+
value={searchTerm}
|
|
209
|
+
onChange={(e) => setSearchTerm(e.target.value)}
|
|
210
|
+
className="w-full pl-10 pr-4 py-2 bg-[var(--bg-primary)] border border-[var(--border-color)] text-sm focus:outline-none focus:border-[var(--color-accent-500)]"
|
|
211
|
+
style={{ borderRadius: 'var(--radius-input)' }}
|
|
212
|
+
/>
|
|
213
|
+
</div>
|
|
214
|
+
<div className="flex items-center gap-2">
|
|
215
|
+
<ColumnSelector
|
|
216
|
+
columns={columns}
|
|
217
|
+
visibleColumns={visibleColumns}
|
|
218
|
+
onChange={setVisibleColumns}
|
|
219
|
+
/>
|
|
220
|
+
<ViewModeToggle value={viewMode} onChange={setViewMode} />
|
|
221
|
+
</div>
|
|
222
|
+
</div>
|
|
223
|
+
|
|
224
|
+
{/* Content */}
|
|
225
|
+
{loading ? (
|
|
226
|
+
<div className="flex items-center justify-center py-12">
|
|
227
|
+
<div className="animate-spin h-8 w-8 border-4 border-[var(--color-accent-500)] border-t-transparent rounded-full" />
|
|
228
|
+
</div>
|
|
229
|
+
) : error ? (
|
|
230
|
+
<div className="p-4 bg-[var(--error-bg)] border border-[var(--error-border)] text-[var(--error-text)]" style={{ borderRadius: 'var(--radius-card)' }}>
|
|
231
|
+
{error}
|
|
232
|
+
</div>
|
|
233
|
+
) : viewMode === 'list' ? (
|
|
234
|
+
<div className="bg-[var(--bg-card)] border border-[var(--item-color-border)] overflow-hidden" style={{ borderRadius: 'var(--radius-card)' }}>
|
|
235
|
+
<table className="w-full">
|
|
236
|
+
<thead>
|
|
237
|
+
<tr className="border-b border-[var(--item-color-border)]">
|
|
238
|
+
{columns.filter(col => visibleColumns.includes(col.key)).map((col) => (
|
|
239
|
+
<th
|
|
240
|
+
key={col.key}
|
|
241
|
+
className={`px-4 py-3 text-left text-sm font-medium text-[var(--text-secondary)] ${
|
|
242
|
+
col.sortable ? 'cursor-pointer hover:text-[var(--text-primary)]' : ''
|
|
243
|
+
}`}
|
|
244
|
+
onClick={() => col.sortable && handleSort(col.key)}
|
|
245
|
+
>
|
|
246
|
+
{col.label}
|
|
247
|
+
{sortColumn === col.key && (
|
|
248
|
+
<span className="ml-1">{sortDirection === 'asc' ? '↑' : '↓'}</span>
|
|
249
|
+
)}
|
|
250
|
+
</th>
|
|
251
|
+
))}
|
|
252
|
+
<th className="px-4 py-3 text-right text-sm font-medium text-[var(--text-secondary)]">
|
|
253
|
+
{t('common:actions.title')}
|
|
254
|
+
</th>
|
|
255
|
+
</tr>
|
|
256
|
+
</thead>
|
|
257
|
+
<tbody>
|
|
258
|
+
{data?.items.map((item) => (
|
|
259
|
+
<tr
|
|
260
|
+
key={item.id}
|
|
261
|
+
className="border-b border-[var(--item-color-border)] hover:bg-[var(--bg-hover)] cursor-pointer"
|
|
262
|
+
onClick={() => navigate(`${basePath}/${item.id}`)}
|
|
263
|
+
>
|
|
264
|
+
{visibleColumns.includes('name') && (
|
|
265
|
+
<td className="px-4 py-3 text-sm text-[var(--text-primary)] font-medium">
|
|
266
|
+
{item.name}
|
|
267
|
+
</td>
|
|
268
|
+
)}
|
|
269
|
+
{visibleColumns.includes('description') && (
|
|
270
|
+
<td className="px-4 py-3 text-sm text-[var(--text-secondary)]">
|
|
271
|
+
{item.description || '-'}
|
|
272
|
+
</td>
|
|
273
|
+
)}
|
|
274
|
+
{visibleColumns.includes('isActive') && (
|
|
275
|
+
<td className="px-4 py-3">
|
|
276
|
+
<span
|
|
277
|
+
className={`inline-flex items-center px-2 py-1 text-xs font-medium ${
|
|
278
|
+
item.isActive
|
|
279
|
+
? 'bg-green-100 text-green-800'
|
|
280
|
+
: 'bg-gray-100 text-gray-800'
|
|
281
|
+
}`}
|
|
282
|
+
style={{ borderRadius: 'var(--radius-badge)' }}
|
|
283
|
+
>
|
|
284
|
+
{item.isActive ? t('common:status.active') : t('common:status.inactive')}
|
|
285
|
+
</span>
|
|
286
|
+
</td>
|
|
287
|
+
)}
|
|
288
|
+
{visibleColumns.includes('createdAt') && (
|
|
289
|
+
<td className="px-4 py-3 text-sm text-[var(--text-secondary)]">
|
|
290
|
+
{new Date(item.createdAt).toLocaleDateString()}
|
|
291
|
+
</td>
|
|
292
|
+
)}
|
|
293
|
+
<td className="px-4 py-3 text-right">
|
|
294
|
+
<div className="flex items-center justify-end gap-2">
|
|
295
|
+
<button
|
|
296
|
+
onClick={(e) => {
|
|
297
|
+
e.stopPropagation();
|
|
298
|
+
navigate(`${basePath}/${item.id}/edit`);
|
|
299
|
+
}}
|
|
300
|
+
className="p-1 hover:bg-[var(--bg-tertiary)]"
|
|
301
|
+
style={{ borderRadius: 'var(--radius-button)' }}
|
|
302
|
+
>
|
|
303
|
+
<Pencil className="w-4 h-4 text-[var(--text-secondary)]" />
|
|
304
|
+
</button>
|
|
305
|
+
<button
|
|
306
|
+
onClick={(e) => {
|
|
307
|
+
e.stopPropagation();
|
|
308
|
+
handleDelete(item.id);
|
|
309
|
+
}}
|
|
310
|
+
className="p-1 hover:bg-[var(--error-bg)]"
|
|
311
|
+
style={{ borderRadius: 'var(--radius-button)' }}
|
|
312
|
+
>
|
|
313
|
+
<Trash2 className="w-4 h-4 text-[var(--error-text)]" />
|
|
314
|
+
</button>
|
|
315
|
+
</div>
|
|
316
|
+
</td>
|
|
317
|
+
</tr>
|
|
318
|
+
))}
|
|
319
|
+
</tbody>
|
|
320
|
+
</table>
|
|
321
|
+
</div>
|
|
322
|
+
) : (
|
|
323
|
+
/* Grid view */
|
|
324
|
+
<div className="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
|
|
325
|
+
{data?.items.map((item) => (
|
|
326
|
+
<div
|
|
327
|
+
key={item.id}
|
|
328
|
+
className="bg-[var(--bg-card)] border border-[var(--item-color-border)] p-4 hover:border-[var(--color-accent-500)] cursor-pointer transition-colors"
|
|
329
|
+
style={{ borderRadius: 'var(--radius-card)' }}
|
|
330
|
+
onClick={() => navigate(`${basePath}/${item.id}`)}
|
|
331
|
+
>
|
|
332
|
+
<h3 className="font-medium text-[var(--text-primary)]">{item.name}</h3>
|
|
333
|
+
<p className="text-sm text-[var(--text-secondary)] mt-1 line-clamp-2">
|
|
334
|
+
{item.description || '-'}
|
|
335
|
+
</p>
|
|
336
|
+
<div className="flex items-center justify-between mt-3">
|
|
337
|
+
<span
|
|
338
|
+
className={`inline-flex items-center px-2 py-1 text-xs font-medium ${
|
|
339
|
+
item.isActive
|
|
340
|
+
? 'bg-green-100 text-green-800'
|
|
341
|
+
: 'bg-gray-100 text-gray-800'
|
|
342
|
+
}`}
|
|
343
|
+
style={{ borderRadius: 'var(--radius-badge)' }}
|
|
344
|
+
>
|
|
345
|
+
{item.isActive ? t('common:status.active') : t('common:status.inactive')}
|
|
346
|
+
</span>
|
|
347
|
+
<span className="text-xs text-[var(--text-muted)]">
|
|
348
|
+
{new Date(item.createdAt).toLocaleDateString()}
|
|
349
|
+
</span>
|
|
350
|
+
</div>
|
|
351
|
+
</div>
|
|
352
|
+
))}
|
|
353
|
+
</div>
|
|
354
|
+
)}
|
|
355
|
+
|
|
356
|
+
{/* Pagination */}
|
|
357
|
+
{data && (
|
|
358
|
+
<Pagination
|
|
359
|
+
page={data.page}
|
|
360
|
+
pageSize={data.pageSize}
|
|
361
|
+
totalCount={data.totalCount}
|
|
362
|
+
onPageChange={setPage}
|
|
363
|
+
onPageSizeChange={setPageSize}
|
|
364
|
+
/>
|
|
365
|
+
)}
|
|
366
|
+
</div>
|
|
367
|
+
);
|
|
368
|
+
}
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
---
|
|
372
|
+
|
|
373
|
+
## TEMPLATE: HOOK PRÉFÉRENCES
|
|
374
|
+
|
|
375
|
+
```tsx
|
|
376
|
+
// hooks/use$MODULE_PASCALPreferences.ts
|
|
377
|
+
|
|
378
|
+
import { useUserPreferences } from '@/contexts/UserPreferencesContext';
|
|
379
|
+
|
|
380
|
+
const DEFAULT_COLUMNS = ['name', 'description', 'isActive', 'createdAt'];
|
|
381
|
+
|
|
382
|
+
export function use$MODULE_PASCALPreferences() {
|
|
383
|
+
const { preferences, updatePreference } = useUserPreferences();
|
|
384
|
+
const modulePrefs = preferences.$module || {};
|
|
385
|
+
|
|
386
|
+
return {
|
|
387
|
+
// Getters with defaults
|
|
388
|
+
pageSize: modulePrefs.pageSize ?? 10,
|
|
389
|
+
sortColumn: modulePrefs.sortColumn ?? 'createdAt',
|
|
390
|
+
sortDirection: modulePrefs.sortDirection ?? 'desc',
|
|
391
|
+
filters: modulePrefs.filters ?? {},
|
|
392
|
+
visibleColumns: modulePrefs.visibleColumns ?? DEFAULT_COLUMNS,
|
|
393
|
+
viewMode: modulePrefs.viewMode ?? 'list',
|
|
394
|
+
|
|
395
|
+
// Setters
|
|
396
|
+
setPageSize: (size: number) =>
|
|
397
|
+
updatePreference('$module.pageSize', size),
|
|
398
|
+
setSortColumn: (col: string) =>
|
|
399
|
+
updatePreference('$module.sortColumn', col),
|
|
400
|
+
setSortDirection: (dir: 'asc' | 'desc') =>
|
|
401
|
+
updatePreference('$module.sortDirection', dir),
|
|
402
|
+
setFilters: (filters: Record<string, unknown>) =>
|
|
403
|
+
updatePreference('$module.filters', filters),
|
|
404
|
+
setVisibleColumns: (cols: string[]) =>
|
|
405
|
+
updatePreference('$module.visibleColumns', cols),
|
|
406
|
+
setViewMode: (mode: 'list' | 'grid') =>
|
|
407
|
+
updatePreference('$module.viewMode', mode),
|
|
408
|
+
};
|
|
409
|
+
}
|
|
410
|
+
```
|
|
411
|
+
|
|
412
|
+
---
|
|
413
|
+
|
|
414
|
+
## TEMPLATE: SERVICE API
|
|
415
|
+
|
|
416
|
+
```tsx
|
|
417
|
+
// services/api/$moduleApi.ts
|
|
418
|
+
|
|
419
|
+
import { api } from './apiClient';
|
|
420
|
+
|
|
421
|
+
export interface $ENTITY_PASCALDto {
|
|
422
|
+
id: string;
|
|
423
|
+
name: string;
|
|
424
|
+
description: string | null;
|
|
425
|
+
isActive: boolean;
|
|
426
|
+
createdAt: string;
|
|
427
|
+
updatedAt: string | null;
|
|
428
|
+
}
|
|
429
|
+
|
|
430
|
+
export interface Create$ENTITY_PASCALRequest {
|
|
431
|
+
name: string;
|
|
432
|
+
description?: string;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
export interface Update$ENTITY_PASCALRequest {
|
|
436
|
+
name: string;
|
|
437
|
+
description?: string;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
export interface PagedResult<T> {
|
|
441
|
+
items: T[];
|
|
442
|
+
totalCount: number;
|
|
443
|
+
page: number;
|
|
444
|
+
pageSize: number;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
export interface QueryParameters {
|
|
448
|
+
page?: number;
|
|
449
|
+
pageSize?: number;
|
|
450
|
+
searchTerm?: string;
|
|
451
|
+
sortColumn?: string;
|
|
452
|
+
sortDirection?: 'asc' | 'desc';
|
|
453
|
+
}
|
|
454
|
+
|
|
455
|
+
export const $moduleApi = {
|
|
456
|
+
getAll: async (params: QueryParameters = {}): Promise<PagedResult<$ENTITY_PASCALDto>> => {
|
|
457
|
+
const queryParams = new URLSearchParams();
|
|
458
|
+
if (params.page) queryParams.set('page', params.page.toString());
|
|
459
|
+
if (params.pageSize) queryParams.set('pageSize', params.pageSize.toString());
|
|
460
|
+
if (params.searchTerm) queryParams.set('searchTerm', params.searchTerm);
|
|
461
|
+
if (params.sortColumn) queryParams.set('sortColumn', params.sortColumn);
|
|
462
|
+
if (params.sortDirection) queryParams.set('sortDirection', params.sortDirection);
|
|
463
|
+
|
|
464
|
+
return api.get(`/api/business/$MODULE?${queryParams}`);
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
getById: async (id: string): Promise<$ENTITY_PASCALDto> => {
|
|
468
|
+
return api.get(`/api/business/$MODULE/${id}`);
|
|
469
|
+
},
|
|
470
|
+
|
|
471
|
+
create: async (data: Create$ENTITY_PASCALRequest): Promise<$ENTITY_PASCALDto> => {
|
|
472
|
+
return api.post('/api/business/$MODULE', data);
|
|
473
|
+
},
|
|
474
|
+
|
|
475
|
+
update: async (id: string, data: Update$ENTITY_PASCALRequest): Promise<$ENTITY_PASCALDto> => {
|
|
476
|
+
return api.put(`/api/business/$MODULE/${id}`, data);
|
|
477
|
+
},
|
|
478
|
+
|
|
479
|
+
delete: async (id: string): Promise<void> => {
|
|
480
|
+
return api.delete(`/api/business/$MODULE/${id}`);
|
|
481
|
+
},
|
|
482
|
+
};
|
|
483
|
+
```
|
|
484
|
+
|
|
485
|
+
---
|
|
486
|
+
|
|
487
|
+
## TEMPLATE: ROUTES (App.tsx)
|
|
488
|
+
|
|
489
|
+
```tsx
|
|
490
|
+
// Ajouter dans App.tsx
|
|
491
|
+
|
|
492
|
+
import { $MODULE_PASCALPage } from '@/pages/business/$APP/$MODULE/$MODULE_PASCALPage';
|
|
493
|
+
import { $MODULE_PASCALDetailPage } from '@/pages/business/$APP/$MODULE/$MODULE_PASCALDetailPage';
|
|
494
|
+
import { Create$MODULE_PASCALPage } from '@/pages/business/$APP/$MODULE/Create$MODULE_PASCALPage';
|
|
495
|
+
|
|
496
|
+
// Dans les routes - TOUJOURS sous /business/
|
|
497
|
+
<Route path="/business/$APP/$MODULE" element={<$MODULE_PASCALPage />} />
|
|
498
|
+
<Route path="/business/$APP/$MODULE/new" element={<Create$MODULE_PASCALPage />} />
|
|
499
|
+
<Route path="/business/$APP/$MODULE/:id" element={<$MODULE_PASCALDetailPage />} />
|
|
500
|
+
<Route path="/business/$APP/$MODULE/:id/edit" element={<Create$MODULE_PASCALPage />} />
|
|
501
|
+
```
|
|
502
|
+
|
|
503
|
+
---
|
|
504
|
+
|
|
505
|
+
## CHECKLIST FRONTEND
|
|
506
|
+
|
|
507
|
+
| Vérification | Status |
|
|
508
|
+
|--------------|--------|
|
|
509
|
+
| ☐ Page principale créée (sous /business/) | |
|
|
510
|
+
| ☐ Composant ListView créé | |
|
|
511
|
+
| ☐ Hook préférences créé | |
|
|
512
|
+
| ☐ Service API créé (endpoint /api/business/) | |
|
|
513
|
+
| ☐ Routes ajoutées dans App.tsx (sous /business/) | |
|
|
514
|
+
| ☐ Utilise apiClient (pas d'appel direct) | |
|
|
515
|
+
| ☐ Pas d'import Infrastructure | |
|
|
516
|
+
| ☐ npm run build réussi | |
|
|
517
|
+
| ☐ npm run lint réussi | |
|