create-modoock-app 2.3.1 → 2.5.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/README.md +19 -7
- package/package.json +1 -1
- package/template/app/(main)/components/_shared.tsx +602 -0
- package/template/app/(main)/components/agenda/page.tsx +48 -0
- package/template/app/(main)/components/badges/page.tsx +42 -0
- package/template/app/(main)/components/barres-de-metrique/page.tsx +40 -0
- package/template/app/(main)/components/boutons/page.tsx +142 -0
- package/template/app/(main)/components/champs/page.tsx +175 -0
- package/template/app/(main)/components/date-picker/page.tsx +48 -0
- package/template/app/(main)/components/icones/page.tsx +96 -0
- package/template/app/(main)/components/loader/page.tsx +81 -0
- package/template/app/(main)/components/modale/page.tsx +48 -0
- package/template/app/(main)/components/onglets/page.tsx +36 -0
- package/template/app/(main)/components/page.tsx +130 -825
- package/template/app/(main)/components/selecteurs/page.tsx +49 -0
- package/template/app/(main)/components/stepper/page.tsx +69 -0
- package/template/app/(main)/components/tableau/page.tsx +67 -0
- package/template/app/(main)/design-system/page.tsx +15 -3
- package/template/app/(main)/documentation/page.tsx +413 -0
- package/template/app/(main)/layout.tsx +2 -0
- package/template/app/globals.css +3 -3
- package/template/app/layout.tsx +1 -1
- package/template/components/layout/side-nav.tsx +118 -61
- package/template/lib/scroll-to-section.ts +38 -0
- package/template/next.config.ts +0 -17
- package/template/package-lock.json +459 -314
- package/template/package.json +2 -0
- package/template/sgconfig.yml +1 -1
- package/template/tsconfig.json +41 -71
package/README.md
CHANGED
|
@@ -22,22 +22,32 @@ npm run dev
|
|
|
22
22
|
The generator creates a ready-to-develop Modooock project containing:
|
|
23
23
|
|
|
24
24
|
- Modooock project foundation
|
|
25
|
-
- Modooock UI components as
|
|
26
|
-
- Modooock Knowledge Base as an npm dependency
|
|
25
|
+
- Modooock UI components as an npm dependency (`@modoock/components`)
|
|
26
|
+
- Modooock Knowledge Base as an npm dependency (`@modoock/knowledge-base`)
|
|
27
27
|
- Required project dependencies and configuration
|
|
28
28
|
|
|
29
29
|
## Component Architecture
|
|
30
30
|
|
|
31
|
-
Modooock UI
|
|
31
|
+
Modooock UI primitives are installed from npm and resolved from `node_modules`:
|
|
32
32
|
|
|
33
33
|
```text
|
|
34
|
-
|
|
35
|
-
└──
|
|
34
|
+
node_modules/
|
|
35
|
+
└── @modoock/
|
|
36
|
+
└── components/
|
|
36
37
|
```
|
|
37
38
|
|
|
38
|
-
|
|
39
|
+
Import them with `@modoock/components` (or `@/components/ui`, which aliases to the package UI source).
|
|
39
40
|
|
|
40
|
-
|
|
41
|
+
Project-local code lives under:
|
|
42
|
+
|
|
43
|
+
```text
|
|
44
|
+
components/
|
|
45
|
+
├── layout/
|
|
46
|
+
├── shared/
|
|
47
|
+
└── ui/ # empty — only for new app-level UI after human validation
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Do not copy or edit package primitives under `node_modules/`.
|
|
41
51
|
|
|
42
52
|
## Knowledge Base
|
|
43
53
|
|
|
@@ -49,6 +59,8 @@ node_modules/
|
|
|
49
59
|
└── knowledge-base/
|
|
50
60
|
```
|
|
51
61
|
|
|
62
|
+
Agents and `sg:scan` read rules from that package path. Do not edit files under `node_modules/`.
|
|
63
|
+
|
|
52
64
|
## Development
|
|
53
65
|
|
|
54
66
|
Build the generator:
|
package/package.json
CHANGED
|
@@ -0,0 +1,602 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
Agenda,
|
|
5
|
+
AGENDA_STATUS_OPTIONS,
|
|
6
|
+
Badge,
|
|
7
|
+
ClickableButton,
|
|
8
|
+
DatePicker,
|
|
9
|
+
DateRangePicker,
|
|
10
|
+
DateTimePicker,
|
|
11
|
+
Icon,
|
|
12
|
+
Loader,
|
|
13
|
+
Modal,
|
|
14
|
+
MultiSelect,
|
|
15
|
+
MultiSelectWithSearch,
|
|
16
|
+
Select,
|
|
17
|
+
SelectFilter,
|
|
18
|
+
SelectWithSearch,
|
|
19
|
+
Tabs,
|
|
20
|
+
} from "@modoock/components";
|
|
21
|
+
import type {
|
|
22
|
+
AgendaEvent,
|
|
23
|
+
AgendaView,
|
|
24
|
+
CardAction,
|
|
25
|
+
Column,
|
|
26
|
+
DateRangeValue,
|
|
27
|
+
} from "@modoock/components";
|
|
28
|
+
import { useEffect, useMemo, useState, type ReactNode } from "react";
|
|
29
|
+
|
|
30
|
+
export const noop = () => undefined;
|
|
31
|
+
|
|
32
|
+
export const SELECT_OPTIONS = [
|
|
33
|
+
{ value: "admin", label: "Administrateur" },
|
|
34
|
+
{ value: "manager", label: "Gestionnaire" },
|
|
35
|
+
{ value: "viewer", label: "Observateur" },
|
|
36
|
+
{ value: "editor", label: "Éditeur" },
|
|
37
|
+
{ value: "analyst", label: "Analyste" },
|
|
38
|
+
];
|
|
39
|
+
|
|
40
|
+
export const STEPPER_STEPS = ["Brouillon", "Revue", "Validation", "Publié"] as const;
|
|
41
|
+
|
|
42
|
+
type UserRole = "Administrateur" | "Gestionnaire" | "Observateur";
|
|
43
|
+
type UserStatus = "Actif" | "En attente" | "Suspendu";
|
|
44
|
+
|
|
45
|
+
export interface AppUser {
|
|
46
|
+
id: number;
|
|
47
|
+
fullName: string;
|
|
48
|
+
email: string;
|
|
49
|
+
role: UserRole;
|
|
50
|
+
status: UserStatus;
|
|
51
|
+
joinedAt: string;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const ROLE_VARIANT: Record<UserRole, "primary" | "info" | "default"> = {
|
|
55
|
+
Administrateur: "primary",
|
|
56
|
+
Gestionnaire: "info",
|
|
57
|
+
Observateur: "default",
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const STATUS_VARIANT: Record<UserStatus, "success" | "warning" | "danger"> = {
|
|
61
|
+
Actif: "success",
|
|
62
|
+
"En attente": "warning",
|
|
63
|
+
Suspendu: "danger",
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
export function userRowActions(_user: AppUser): CardAction[] {
|
|
67
|
+
return [
|
|
68
|
+
{ label: "Voir", icon: "Eye", onSelect: noop },
|
|
69
|
+
{ label: "Modifier", icon: "Pencil", onSelect: noop },
|
|
70
|
+
{ label: "Valider", icon: "CircleCheck", onSelect: noop },
|
|
71
|
+
{ label: "Supprimer", icon: "Trash2", danger: true, onSelect: noop },
|
|
72
|
+
];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export const USERS: AppUser[] = [
|
|
76
|
+
{ id: 1, fullName: "Amine Berrada", email: "amine.berrada@modoock.com", role: "Administrateur", status: "Actif", joinedAt: "2024-01-12" },
|
|
77
|
+
{ id: 2, fullName: "Sarah El Fassi", email: "sarah.elfassi@modoock.com", role: "Gestionnaire", status: "Actif", joinedAt: "2024-02-03" },
|
|
78
|
+
{ id: 3, fullName: "Youssef Amrani", email: "youssef.amrani@modoock.com", role: "Observateur", status: "En attente", joinedAt: "2024-03-18" },
|
|
79
|
+
{ id: 4, fullName: "Leïla Benkirane", email: "leila.benkirane@modoock.com", role: "Gestionnaire", status: "Actif", joinedAt: "2024-04-25" },
|
|
80
|
+
{ id: 5, fullName: "Karim Tazi", email: "karim.tazi@modoock.com", role: "Observateur", status: "Suspendu", joinedAt: "2024-05-09" },
|
|
81
|
+
{ id: 6, fullName: "Nadia Chraibi", email: "nadia.chraibi@modoock.com", role: "Administrateur", status: "Actif", joinedAt: "2024-06-14" },
|
|
82
|
+
{ id: 7, fullName: "Omar Alaoui", email: "omar.alaoui@modoock.com", role: "Gestionnaire", status: "Actif", joinedAt: "2024-07-21" },
|
|
83
|
+
{ id: 8, fullName: "Imane Ait Mbarek", email: "imane.aitmbarek@modoock.com", role: "Gestionnaire", status: "En attente", joinedAt: "2024-08-02" },
|
|
84
|
+
{ id: 9, fullName: "Mehdi Ouazzani", email: "mehdi.ouazzani@modoock.com", role: "Observateur", status: "Actif", joinedAt: "2024-09-30" },
|
|
85
|
+
{ id: 10, fullName: "Salma Bennis", email: "salma.bennis@modoock.com", role: "Gestionnaire", status: "Actif", joinedAt: "2024-10-11" },
|
|
86
|
+
{ id: 11, fullName: "Reda Lahlou", email: "reda.lahlou@modoock.com", role: "Observateur", status: "Suspendu", joinedAt: "2024-11-05" },
|
|
87
|
+
{ id: 12, fullName: "Hajar Squalli", email: "hajar.squalli@modoock.com", role: "Administrateur", status: "Actif", joinedAt: "2025-01-20" },
|
|
88
|
+
{ id: 13, fullName: "Anas Belkacem", email: "anas.belkacem@modoock.com", role: "Observateur", status: "En attente", joinedAt: "2025-02-27" },
|
|
89
|
+
{ id: 14, fullName: "Meryem Haddadi", email: "meryem.haddadi@modoock.com", role: "Gestionnaire", status: "Actif", joinedAt: "2025-03-15" },
|
|
90
|
+
];
|
|
91
|
+
|
|
92
|
+
export const COLUMNS: Column<AppUser>[] = [
|
|
93
|
+
{ key: "fullName", label: "Nom", sortable: true },
|
|
94
|
+
{
|
|
95
|
+
key: "email",
|
|
96
|
+
label: "Adresse e-mail",
|
|
97
|
+
sortable: true,
|
|
98
|
+
className: "text-body text-muted-foreground",
|
|
99
|
+
},
|
|
100
|
+
{
|
|
101
|
+
key: "role",
|
|
102
|
+
label: "Rôle",
|
|
103
|
+
sortable: true,
|
|
104
|
+
render: (user) => <Badge variant={ROLE_VARIANT[user.role]}>{user.role}</Badge>,
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
key: "status",
|
|
108
|
+
label: "Statut",
|
|
109
|
+
sortable: true,
|
|
110
|
+
render: (user) => (
|
|
111
|
+
<Badge variant={STATUS_VARIANT[user.status]}>{user.status}</Badge>
|
|
112
|
+
),
|
|
113
|
+
},
|
|
114
|
+
{
|
|
115
|
+
key: "joinedAt",
|
|
116
|
+
label: "Date d'inscription",
|
|
117
|
+
sortable: true,
|
|
118
|
+
className: "whitespace-nowrap text-body-medium",
|
|
119
|
+
render: (user) =>
|
|
120
|
+
new Date(user.joinedAt).toLocaleDateString("fr-FR", {
|
|
121
|
+
day: "numeric",
|
|
122
|
+
month: "long",
|
|
123
|
+
year: "numeric",
|
|
124
|
+
}),
|
|
125
|
+
},
|
|
126
|
+
];
|
|
127
|
+
|
|
128
|
+
export function CodeBlock({ code }: { code: string }) {
|
|
129
|
+
return (
|
|
130
|
+
<pre className="mt-component overflow-x-auto rounded-large border border-border bg-surface-muted p-component text-small text-foreground">
|
|
131
|
+
<code>{code}</code>
|
|
132
|
+
</pre>
|
|
133
|
+
);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
export function DemoCard({
|
|
137
|
+
title,
|
|
138
|
+
description,
|
|
139
|
+
code,
|
|
140
|
+
children,
|
|
141
|
+
}: {
|
|
142
|
+
title: string;
|
|
143
|
+
description?: string;
|
|
144
|
+
code?: string;
|
|
145
|
+
children: ReactNode;
|
|
146
|
+
}) {
|
|
147
|
+
return (
|
|
148
|
+
<div className="rounded-large border border-border bg-surface p-card">
|
|
149
|
+
<p className="text-component-title text-foreground">{title}</p>
|
|
150
|
+
{description && (
|
|
151
|
+
<p className="mt-micro text-small text-muted-foreground">{description}</p>
|
|
152
|
+
)}
|
|
153
|
+
<div className="mt-component">{children}</div>
|
|
154
|
+
{code ? <CodeBlock code={code} /> : null}
|
|
155
|
+
</div>
|
|
156
|
+
);
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function ShowcaseShell({
|
|
160
|
+
title,
|
|
161
|
+
subtitle,
|
|
162
|
+
usage,
|
|
163
|
+
importCode,
|
|
164
|
+
children,
|
|
165
|
+
className = "",
|
|
166
|
+
}: {
|
|
167
|
+
title: string;
|
|
168
|
+
subtitle: ReactNode;
|
|
169
|
+
usage?: string;
|
|
170
|
+
importCode?: string;
|
|
171
|
+
children: ReactNode;
|
|
172
|
+
className?: string;
|
|
173
|
+
}) {
|
|
174
|
+
return (
|
|
175
|
+
<main className={`flex flex-col ${className}`.trim()}>
|
|
176
|
+
<div className="page-container py-section">
|
|
177
|
+
<div className="flex flex-wrap items-baseline justify-between gap-inline">
|
|
178
|
+
<h2 className="text-section-title text-foreground">{title}</h2>
|
|
179
|
+
<span className="text-small text-muted-foreground">{subtitle}</span>
|
|
180
|
+
</div>
|
|
181
|
+
{usage ? (
|
|
182
|
+
<p className="mt-component text-body text-muted-foreground">{usage}</p>
|
|
183
|
+
) : null}
|
|
184
|
+
{importCode ? (
|
|
185
|
+
<div className="mt-component">
|
|
186
|
+
<p className="mb-inline text-label uppercase tracking-[0.12em] text-muted-foreground">
|
|
187
|
+
Import
|
|
188
|
+
</p>
|
|
189
|
+
<CodeBlock code={importCode} />
|
|
190
|
+
</div>
|
|
191
|
+
) : null}
|
|
192
|
+
<div className="mt-section">{children}</div>
|
|
193
|
+
</div>
|
|
194
|
+
</main>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
export function FullScreenLoaderDemo() {
|
|
199
|
+
const [visible, setVisible] = useState(false);
|
|
200
|
+
|
|
201
|
+
useEffect(() => {
|
|
202
|
+
if (!visible) return;
|
|
203
|
+
const timer = setTimeout(() => setVisible(false), 2000);
|
|
204
|
+
return () => clearTimeout(timer);
|
|
205
|
+
}, [visible]);
|
|
206
|
+
|
|
207
|
+
return (
|
|
208
|
+
<>
|
|
209
|
+
<ClickableButton type="button" variant="secondary" onClick={() => setVisible(true)}>
|
|
210
|
+
Afficher (2 s)
|
|
211
|
+
</ClickableButton>
|
|
212
|
+
{visible && <Loader fullScreen message="Chargement des données…" />}
|
|
213
|
+
</>
|
|
214
|
+
);
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
export function CardLoaderDemo() {
|
|
218
|
+
const [loading, setLoading] = useState(false);
|
|
219
|
+
|
|
220
|
+
useEffect(() => {
|
|
221
|
+
if (!loading) return;
|
|
222
|
+
const timer = setTimeout(() => setLoading(false), 2000);
|
|
223
|
+
return () => clearTimeout(timer);
|
|
224
|
+
}, [loading]);
|
|
225
|
+
|
|
226
|
+
return (
|
|
227
|
+
<div className="flex flex-col gap-component">
|
|
228
|
+
<ClickableButton type="button" variant="secondary" onClick={() => setLoading(true)}>
|
|
229
|
+
Recharger (2 s)
|
|
230
|
+
</ClickableButton>
|
|
231
|
+
<div className="relative rounded-large border border-border bg-surface p-component">
|
|
232
|
+
<div className="space-y-component opacity-40" aria-hidden="true">
|
|
233
|
+
<div className="h-3 w-2/3 rounded bg-surface-muted" />
|
|
234
|
+
<div className="h-3 w-1/2 rounded bg-surface-muted" />
|
|
235
|
+
<div className="h-3 w-3/4 rounded bg-surface-muted" />
|
|
236
|
+
</div>
|
|
237
|
+
{loading && <Loader message="Rechargement…" />}
|
|
238
|
+
</div>
|
|
239
|
+
</div>
|
|
240
|
+
);
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
export function ModalLoaderDemo() {
|
|
244
|
+
const [open, setOpen] = useState(false);
|
|
245
|
+
const [loading, setLoading] = useState(false);
|
|
246
|
+
|
|
247
|
+
const handleOpen = () => {
|
|
248
|
+
setOpen(true);
|
|
249
|
+
setLoading(true);
|
|
250
|
+
};
|
|
251
|
+
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
if (!open || !loading) return;
|
|
254
|
+
const timer = setTimeout(() => setLoading(false), 2000);
|
|
255
|
+
return () => clearTimeout(timer);
|
|
256
|
+
}, [open, loading]);
|
|
257
|
+
|
|
258
|
+
return (
|
|
259
|
+
<>
|
|
260
|
+
<ClickableButton type="button" variant="secondary" onClick={handleOpen}>
|
|
261
|
+
Ouvrir la modale (2 s)
|
|
262
|
+
</ClickableButton>
|
|
263
|
+
<Modal
|
|
264
|
+
open={open}
|
|
265
|
+
title="Chargement dans une modale"
|
|
266
|
+
onClose={() => setOpen(false)}
|
|
267
|
+
primaryAction={{ label: "Fermer", onClick: () => setOpen(false) }}
|
|
268
|
+
>
|
|
269
|
+
<div className="relative min-h-40">
|
|
270
|
+
{loading ? (
|
|
271
|
+
<Loader message="Chargement des données…" />
|
|
272
|
+
) : (
|
|
273
|
+
<div className="space-y-inline">
|
|
274
|
+
{["Service importé", "Utilisateurs synchronisés", "Rapport généré"].map(
|
|
275
|
+
(item) => (
|
|
276
|
+
<div
|
|
277
|
+
key={item}
|
|
278
|
+
className="flex items-center gap-inline rounded-large border border-border bg-surface-muted px-component py-control"
|
|
279
|
+
>
|
|
280
|
+
<Icon name="CircleCheck" variant="success" aria-hidden="true" />
|
|
281
|
+
<span className="text-body-medium text-foreground">{item}</span>
|
|
282
|
+
</div>
|
|
283
|
+
),
|
|
284
|
+
)}
|
|
285
|
+
</div>
|
|
286
|
+
)}
|
|
287
|
+
</div>
|
|
288
|
+
</Modal>
|
|
289
|
+
</>
|
|
290
|
+
);
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
export function ModalDemo() {
|
|
294
|
+
const [open, setOpen] = useState(false);
|
|
295
|
+
|
|
296
|
+
return (
|
|
297
|
+
<>
|
|
298
|
+
<ClickableButton type="button" variant="secondary" onClick={() => setOpen(true)}>
|
|
299
|
+
Ouvrir la modale
|
|
300
|
+
</ClickableButton>
|
|
301
|
+
<Modal
|
|
302
|
+
open={open}
|
|
303
|
+
title="Confirmation"
|
|
304
|
+
onClose={() => setOpen(false)}
|
|
305
|
+
primaryAction={{ label: "Confirmer", onClick: () => setOpen(false) }}
|
|
306
|
+
secondaryAction={{ label: "Annuler", onClick: () => setOpen(false) }}
|
|
307
|
+
>
|
|
308
|
+
<p className="text-body text-muted-foreground">
|
|
309
|
+
Cette action enregistrera les modifications. Souhaitez-vous continuer ?
|
|
310
|
+
</p>
|
|
311
|
+
</Modal>
|
|
312
|
+
</>
|
|
313
|
+
);
|
|
314
|
+
}
|
|
315
|
+
|
|
316
|
+
export function SelectorsDemo() {
|
|
317
|
+
const [role, setRole] = useState("manager");
|
|
318
|
+
const [roles, setRoles] = useState<string[]>(["admin", "manager"]);
|
|
319
|
+
const [city, setCity] = useState("");
|
|
320
|
+
const [tags, setTags] = useState<string[]>(["viewer"]);
|
|
321
|
+
const [filters, setFilters] = useState<string[]>([]);
|
|
322
|
+
|
|
323
|
+
return (
|
|
324
|
+
<div className="grid gap-component md:grid-cols-2">
|
|
325
|
+
<DemoCard title="Select" description="Sélection simple.">
|
|
326
|
+
<Select
|
|
327
|
+
label="Rôle"
|
|
328
|
+
options={SELECT_OPTIONS}
|
|
329
|
+
value={role}
|
|
330
|
+
onChange={setRole}
|
|
331
|
+
placeholder="Choisir un rôle…"
|
|
332
|
+
/>
|
|
333
|
+
</DemoCard>
|
|
334
|
+
<DemoCard title="MultiSelect" description="Sélection multiple avec chips.">
|
|
335
|
+
<MultiSelect
|
|
336
|
+
label="Rôles"
|
|
337
|
+
options={SELECT_OPTIONS}
|
|
338
|
+
values={roles}
|
|
339
|
+
onChange={setRoles}
|
|
340
|
+
placeholder="Choisir des rôles…"
|
|
341
|
+
/>
|
|
342
|
+
</DemoCard>
|
|
343
|
+
<DemoCard title="SelectWithSearch" description="Liste longue avec recherche.">
|
|
344
|
+
<SelectWithSearch
|
|
345
|
+
label="Profil"
|
|
346
|
+
options={SELECT_OPTIONS}
|
|
347
|
+
value={city}
|
|
348
|
+
onChange={setCity}
|
|
349
|
+
placeholder="Rechercher un profil…"
|
|
350
|
+
/>
|
|
351
|
+
</DemoCard>
|
|
352
|
+
<DemoCard title="MultiSelectWithSearch" description="Multi-sélection avec recherche.">
|
|
353
|
+
<MultiSelectWithSearch
|
|
354
|
+
label="Profils"
|
|
355
|
+
options={SELECT_OPTIONS}
|
|
356
|
+
values={tags}
|
|
357
|
+
onChange={setTags}
|
|
358
|
+
placeholder="Rechercher…"
|
|
359
|
+
/>
|
|
360
|
+
</DemoCard>
|
|
361
|
+
<DemoCard title="SelectFilter" description="Filtre de colonne (table).">
|
|
362
|
+
<SelectFilter
|
|
363
|
+
label="Filtrer par rôle"
|
|
364
|
+
options={SELECT_OPTIONS}
|
|
365
|
+
values={filters}
|
|
366
|
+
onChange={setFilters}
|
|
367
|
+
placeholder="Filtrer…"
|
|
368
|
+
/>
|
|
369
|
+
</DemoCard>
|
|
370
|
+
</div>
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
|
|
374
|
+
function atDay(base: Date, dayOffset: number, hour: number, minute = 0): Date {
|
|
375
|
+
const d = new Date(base.getFullYear(), base.getMonth(), base.getDate() + dayOffset);
|
|
376
|
+
d.setHours(hour, minute, 0, 0);
|
|
377
|
+
return d;
|
|
378
|
+
}
|
|
379
|
+
|
|
380
|
+
function buildDemoAgendaEvents(anchor: Date): AgendaEvent[] {
|
|
381
|
+
return [
|
|
382
|
+
{
|
|
383
|
+
id: "1",
|
|
384
|
+
title: "Amine Berrada",
|
|
385
|
+
subtitle: "Dr. El Fassi — Salle A",
|
|
386
|
+
kind: "Consultation",
|
|
387
|
+
status: "confirmed",
|
|
388
|
+
startAt: atDay(anchor, 0, 9, 0),
|
|
389
|
+
endAt: atDay(anchor, 0, 9, 45),
|
|
390
|
+
},
|
|
391
|
+
{
|
|
392
|
+
id: "2",
|
|
393
|
+
title: "Sarah El Fassi",
|
|
394
|
+
subtitle: "Dr. Amrani — Salle B",
|
|
395
|
+
kind: "Suivi",
|
|
396
|
+
status: "planned",
|
|
397
|
+
startAt: atDay(anchor, 0, 11, 0),
|
|
398
|
+
endAt: atDay(anchor, 0, 11, 30),
|
|
399
|
+
},
|
|
400
|
+
{
|
|
401
|
+
id: "3",
|
|
402
|
+
title: "Youssef Amrani",
|
|
403
|
+
subtitle: "Dr. El Fassi — Salle A",
|
|
404
|
+
kind: "Consultation",
|
|
405
|
+
status: "delayed",
|
|
406
|
+
startAt: atDay(anchor, 1, 10, 0),
|
|
407
|
+
endAt: atDay(anchor, 1, 10, 45),
|
|
408
|
+
},
|
|
409
|
+
{
|
|
410
|
+
id: "4",
|
|
411
|
+
title: "Leïla Benkirane",
|
|
412
|
+
subtitle: "Dr. Tazi — Box 2",
|
|
413
|
+
kind: "Contrôle",
|
|
414
|
+
status: "completed",
|
|
415
|
+
startAt: atDay(anchor, -2, 14, 0),
|
|
416
|
+
endAt: atDay(anchor, -2, 14, 30),
|
|
417
|
+
},
|
|
418
|
+
{
|
|
419
|
+
id: "5",
|
|
420
|
+
title: "Karim Tazi",
|
|
421
|
+
subtitle: "Dr. Amrani — Salle B",
|
|
422
|
+
kind: "Consultation",
|
|
423
|
+
status: "cancelled",
|
|
424
|
+
startAt: atDay(anchor, 2, 15, 0),
|
|
425
|
+
endAt: atDay(anchor, 2, 15, 45),
|
|
426
|
+
},
|
|
427
|
+
{
|
|
428
|
+
id: "6",
|
|
429
|
+
title: "Nadia Chraibi",
|
|
430
|
+
subtitle: "Dr. El Fassi — Salle A",
|
|
431
|
+
kind: "Suivi",
|
|
432
|
+
status: "confirmed",
|
|
433
|
+
startAt: atDay(anchor, 3, 9, 30),
|
|
434
|
+
endAt: atDay(anchor, 3, 10, 15),
|
|
435
|
+
},
|
|
436
|
+
{
|
|
437
|
+
id: "7",
|
|
438
|
+
title: "Omar Alaoui",
|
|
439
|
+
subtitle: "Dr. Tazi — Box 1",
|
|
440
|
+
kind: "Consultation",
|
|
441
|
+
status: "planned",
|
|
442
|
+
startAt: atDay(anchor, 0, 16, 0),
|
|
443
|
+
endAt: atDay(anchor, 0, 16, 45),
|
|
444
|
+
},
|
|
445
|
+
{
|
|
446
|
+
id: "8",
|
|
447
|
+
title: "Imane Ait Mbarek",
|
|
448
|
+
subtitle: "Dr. Amrani — Salle B",
|
|
449
|
+
kind: "Contrôle",
|
|
450
|
+
status: "confirmed",
|
|
451
|
+
startAt: atDay(anchor, 5, 11, 0),
|
|
452
|
+
endAt: atDay(anchor, 5, 11, 30),
|
|
453
|
+
},
|
|
454
|
+
];
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
const AGENDA_KIND_OPTIONS = [
|
|
458
|
+
{ value: "all", label: "Tous les types" },
|
|
459
|
+
{ value: "Consultation", label: "Consultation" },
|
|
460
|
+
{ value: "Suivi", label: "Suivi" },
|
|
461
|
+
{ value: "Contrôle", label: "Contrôle" },
|
|
462
|
+
];
|
|
463
|
+
|
|
464
|
+
export function AgendaDemo() {
|
|
465
|
+
const [view, setView] = useState<AgendaView>("month");
|
|
466
|
+
const [anchorDate, setAnchorDate] = useState(() => new Date());
|
|
467
|
+
const [searchQuery, setSearchQuery] = useState("");
|
|
468
|
+
const [statusFilter, setStatusFilter] = useState<string[]>([]);
|
|
469
|
+
const [kindFilter, setKindFilter] = useState("all");
|
|
470
|
+
const [selected, setSelected] = useState<AgendaEvent | null>(null);
|
|
471
|
+
const [createdSlot, setCreatedSlot] = useState<Date | null>(null);
|
|
472
|
+
|
|
473
|
+
const allEvents = useMemo(
|
|
474
|
+
() => buildDemoAgendaEvents(new Date()),
|
|
475
|
+
[],
|
|
476
|
+
);
|
|
477
|
+
|
|
478
|
+
const events = useMemo(() => {
|
|
479
|
+
return allEvents.filter((event) => {
|
|
480
|
+
if (statusFilter.length > 0 && !statusFilter.includes(event.status ?? "")) {
|
|
481
|
+
return false;
|
|
482
|
+
}
|
|
483
|
+
if (kindFilter !== "all" && event.kind !== kindFilter) return false;
|
|
484
|
+
return true;
|
|
485
|
+
});
|
|
486
|
+
}, [allEvents, statusFilter, kindFilter]);
|
|
487
|
+
|
|
488
|
+
return (
|
|
489
|
+
<div className="flex flex-col gap-component">
|
|
490
|
+
<Agenda
|
|
491
|
+
events={events}
|
|
492
|
+
view={view}
|
|
493
|
+
onViewChange={setView}
|
|
494
|
+
anchorDate={anchorDate}
|
|
495
|
+
onAnchorDateChange={setAnchorDate}
|
|
496
|
+
searchQuery={searchQuery}
|
|
497
|
+
onSearchChange={setSearchQuery}
|
|
498
|
+
searchPlaceholder="Patient, praticien, titre…"
|
|
499
|
+
statusOptions={AGENDA_STATUS_OPTIONS}
|
|
500
|
+
onSelectEvent={setSelected}
|
|
501
|
+
onCreateSlot={setCreatedSlot}
|
|
502
|
+
filters={
|
|
503
|
+
<>
|
|
504
|
+
<div className="w-[10.5rem]">
|
|
505
|
+
<Select
|
|
506
|
+
label="Type"
|
|
507
|
+
options={AGENDA_KIND_OPTIONS}
|
|
508
|
+
value={kindFilter}
|
|
509
|
+
onChange={setKindFilter}
|
|
510
|
+
placeholder="Tous les types"
|
|
511
|
+
/>
|
|
512
|
+
</div>
|
|
513
|
+
<div className="w-[12rem]">
|
|
514
|
+
<SelectFilter
|
|
515
|
+
label="Statut"
|
|
516
|
+
options={AGENDA_STATUS_OPTIONS}
|
|
517
|
+
values={statusFilter}
|
|
518
|
+
onChange={setStatusFilter}
|
|
519
|
+
placeholder="Tous les statuts"
|
|
520
|
+
/>
|
|
521
|
+
</div>
|
|
522
|
+
</>
|
|
523
|
+
}
|
|
524
|
+
/>
|
|
525
|
+
|
|
526
|
+
{selected ? (
|
|
527
|
+
<p className="text-small text-muted-foreground">
|
|
528
|
+
Sélection : <span className="text-foreground">{selected.title}</span>
|
|
529
|
+
{selected.kind ? ` — ${selected.kind}` : ""}
|
|
530
|
+
{selected.status ? ` (${selected.status})` : ""}
|
|
531
|
+
</p>
|
|
532
|
+
) : null}
|
|
533
|
+
{createdSlot ? (
|
|
534
|
+
<p className="text-small text-muted-foreground">
|
|
535
|
+
Créneau demandé :{" "}
|
|
536
|
+
<span className="text-foreground">
|
|
537
|
+
{createdSlot.toLocaleString("fr-FR")}
|
|
538
|
+
</span>
|
|
539
|
+
</p>
|
|
540
|
+
) : null}
|
|
541
|
+
</div>
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
|
|
545
|
+
export function DatePickersDemo() {
|
|
546
|
+
const [date, setDate] = useState<Date | null>(new Date());
|
|
547
|
+
const [dateTime, setDateTime] = useState<Date | null>(() => {
|
|
548
|
+
const next = new Date();
|
|
549
|
+
next.setHours(14, 30, 0, 0);
|
|
550
|
+
return next;
|
|
551
|
+
});
|
|
552
|
+
const [range, setRange] = useState<DateRangeValue>({
|
|
553
|
+
from: null,
|
|
554
|
+
to: null,
|
|
555
|
+
});
|
|
556
|
+
|
|
557
|
+
return (
|
|
558
|
+
<div className="grid gap-component md:grid-cols-2">
|
|
559
|
+
<DemoCard title="DatePicker" description="Une seule date.">
|
|
560
|
+
<DatePicker label="Date" value={date} onChange={setDate} />
|
|
561
|
+
</DemoCard>
|
|
562
|
+
<DemoCard title="DateTimePicker" description="Date et heure.">
|
|
563
|
+
<DateTimePicker
|
|
564
|
+
label="Date et heure"
|
|
565
|
+
value={dateTime}
|
|
566
|
+
onChange={setDateTime}
|
|
567
|
+
/>
|
|
568
|
+
</DemoCard>
|
|
569
|
+
<DemoCard
|
|
570
|
+
title="DateRangePicker"
|
|
571
|
+
description="Période du… au… (deux clics)."
|
|
572
|
+
>
|
|
573
|
+
<DateRangePicker label="Période" value={range} onChange={setRange} />
|
|
574
|
+
</DemoCard>
|
|
575
|
+
</div>
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
export function TabsDemo() {
|
|
580
|
+
return (
|
|
581
|
+
<Tabs
|
|
582
|
+
tabs={[
|
|
583
|
+
{ value: "general", label: "Général" },
|
|
584
|
+
{ value: "security", label: "Sécurité" },
|
|
585
|
+
{ value: "notifications", label: "Notifications" },
|
|
586
|
+
]}
|
|
587
|
+
defaultValue="general"
|
|
588
|
+
>
|
|
589
|
+
{(active) => (
|
|
590
|
+
<p className="text-body text-muted-foreground">
|
|
591
|
+
Contenu de l'onglet «{" "}
|
|
592
|
+
{active === "general"
|
|
593
|
+
? "Général"
|
|
594
|
+
: active === "security"
|
|
595
|
+
? "Sécurité"
|
|
596
|
+
: "Notifications"}{" "}
|
|
597
|
+
».
|
|
598
|
+
</p>
|
|
599
|
+
)}
|
|
600
|
+
</Tabs>
|
|
601
|
+
);
|
|
602
|
+
}
|