@lastbrain/app 2.0.0 → 2.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/config/version.d.ts +7 -0
- package/dist/config/version.d.ts.map +1 -0
- package/dist/config/version.js +25 -0
- package/dist/scripts/init-app.js +8 -16
- package/dist/src/__tests__/module-registry.test.d.ts +2 -0
- package/dist/src/__tests__/module-registry.test.d.ts.map +1 -0
- package/dist/src/__tests__/module-registry.test.js +53 -0
- package/dist/src/app-shell/(admin)/layout.d.ts +4 -0
- package/dist/src/app-shell/(admin)/layout.d.ts.map +1 -0
- package/dist/src/app-shell/(admin)/layout.js +5 -0
- package/dist/src/app-shell/(auth)/layout.d.ts +4 -0
- package/dist/src/app-shell/(auth)/layout.d.ts.map +1 -0
- package/dist/src/app-shell/(auth)/layout.js +5 -0
- package/dist/src/app-shell/(public)/page.d.ts +2 -0
- package/dist/src/app-shell/(public)/page.d.ts.map +1 -0
- package/dist/src/app-shell/(public)/page.js +5 -0
- package/dist/src/app-shell/layout.d.ts +3 -0
- package/dist/src/app-shell/layout.d.ts.map +1 -0
- package/dist/src/app-shell/layout.js +3 -0
- package/dist/src/app-shell/not-found.d.ts +2 -0
- package/dist/src/app-shell/not-found.d.ts.map +1 -0
- package/dist/src/app-shell/not-found.js +10 -0
- package/dist/src/auth/authHelpers.d.ts +7 -0
- package/dist/src/auth/authHelpers.d.ts.map +1 -0
- package/dist/src/auth/authHelpers.js +19 -0
- package/dist/src/auth/useAuthSession.d.ts +7 -0
- package/dist/src/auth/useAuthSession.d.ts.map +1 -0
- package/dist/src/auth/useAuthSession.js +49 -0
- package/dist/src/cli.d.ts +3 -0
- package/dist/src/cli.d.ts.map +1 -0
- package/dist/src/cli.js +143 -0
- package/dist/src/components/NotificationContainer.d.ts +2 -0
- package/dist/src/components/NotificationContainer.d.ts.map +1 -0
- package/dist/src/components/NotificationContainer.js +8 -0
- package/dist/src/hooks/useNotifications.d.ts +30 -0
- package/dist/src/hooks/useNotifications.d.ts.map +1 -0
- package/dist/src/hooks/useNotifications.js +165 -0
- package/dist/src/index.d.ts +22 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +22 -0
- package/dist/src/layouts/AdminLayout.d.ts +4 -0
- package/dist/src/layouts/AdminLayout.d.ts.map +1 -0
- package/dist/src/layouts/AdminLayout.js +4 -0
- package/dist/src/layouts/AdminLayoutWithSidebar.d.ts +10 -0
- package/dist/src/layouts/AdminLayoutWithSidebar.d.ts.map +1 -0
- package/dist/src/layouts/AdminLayoutWithSidebar.js +62 -0
- package/dist/src/layouts/AppProviders.d.ts +27 -0
- package/dist/src/layouts/AppProviders.d.ts.map +1 -0
- package/dist/src/layouts/AppProviders.js +48 -0
- package/dist/src/layouts/AuthLayout.d.ts +4 -0
- package/dist/src/layouts/AuthLayout.d.ts.map +1 -0
- package/dist/src/layouts/AuthLayout.js +4 -0
- package/dist/src/layouts/AuthLayoutWithSidebar.d.ts +12 -0
- package/dist/src/layouts/AuthLayoutWithSidebar.d.ts.map +1 -0
- package/dist/src/layouts/AuthLayoutWithSidebar.js +60 -0
- package/dist/src/layouts/PublicLayout.d.ts +8 -0
- package/dist/src/layouts/PublicLayout.d.ts.map +1 -0
- package/dist/src/layouts/PublicLayout.js +6 -0
- package/dist/src/layouts/PublicLayoutWithSidebar.d.ts +9 -0
- package/dist/src/layouts/PublicLayoutWithSidebar.d.ts.map +1 -0
- package/dist/src/layouts/PublicLayoutWithSidebar.js +60 -0
- package/dist/src/layouts/RootLayout.d.ts +6 -0
- package/dist/src/layouts/RootLayout.d.ts.map +1 -0
- package/dist/src/layouts/RootLayout.js +9 -0
- package/dist/src/modules/module-loader.d.ts +5 -0
- package/dist/src/modules/module-loader.d.ts.map +1 -0
- package/dist/src/modules/module-loader.js +10 -0
- package/dist/src/scripts/db-init.d.ts +2 -0
- package/dist/src/scripts/db-init.d.ts.map +1 -0
- package/dist/src/scripts/db-init.js +300 -0
- package/dist/src/scripts/db-migrations-sync.d.ts +2 -0
- package/dist/src/scripts/db-migrations-sync.d.ts.map +1 -0
- package/dist/src/scripts/db-migrations-sync.js +84 -0
- package/dist/src/scripts/dev-sync.d.ts +2 -0
- package/dist/src/scripts/dev-sync.d.ts.map +1 -0
- package/dist/src/scripts/dev-sync.js +194 -0
- package/dist/src/scripts/init-app.d.ts +12 -0
- package/dist/src/scripts/init-app.d.ts.map +1 -0
- package/dist/src/scripts/init-app.js +2175 -0
- package/dist/src/scripts/module-add.d.ts +2 -0
- package/dist/src/scripts/module-add.d.ts.map +1 -0
- package/dist/src/scripts/module-add.js +232 -0
- package/dist/src/scripts/module-build.d.ts +2 -0
- package/dist/src/scripts/module-build.d.ts.map +1 -0
- package/dist/src/scripts/module-build.js +1280 -0
- package/dist/src/scripts/module-create.d.ts +28 -0
- package/dist/src/scripts/module-create.d.ts.map +1 -0
- package/dist/src/scripts/module-create.js +1429 -0
- package/dist/src/scripts/module-delete.d.ts +6 -0
- package/dist/src/scripts/module-delete.d.ts.map +1 -0
- package/dist/src/scripts/module-delete.js +147 -0
- package/dist/src/scripts/module-list.d.ts +2 -0
- package/dist/src/scripts/module-list.d.ts.map +1 -0
- package/dist/src/scripts/module-list.js +61 -0
- package/dist/src/scripts/module-remove.d.ts +2 -0
- package/dist/src/scripts/module-remove.d.ts.map +1 -0
- package/dist/src/scripts/module-remove.js +311 -0
- package/dist/src/scripts/readme-build.d.ts +2 -0
- package/dist/src/scripts/readme-build.d.ts.map +1 -0
- package/dist/src/scripts/readme-build.js +39 -0
- package/dist/src/scripts/script-runner.d.ts +5 -0
- package/dist/src/scripts/script-runner.d.ts.map +1 -0
- package/dist/src/scripts/script-runner.js +25 -0
- package/dist/src/templates/AuthGuidePage.d.ts +2 -0
- package/dist/src/templates/AuthGuidePage.d.ts.map +1 -0
- package/dist/src/templates/AuthGuidePage.js +9 -0
- package/dist/src/templates/DefaultDoc.d.ts +2 -0
- package/dist/src/templates/DefaultDoc.d.ts.map +1 -0
- package/dist/src/templates/DefaultDoc.js +240 -0
- package/dist/src/templates/DocPage.d.ts +17 -0
- package/dist/src/templates/DocPage.d.ts.map +1 -0
- package/dist/src/templates/DocPage.js +193 -0
- package/dist/src/templates/DocsPageWithModules.d.ts +2 -0
- package/dist/src/templates/DocsPageWithModules.d.ts.map +1 -0
- package/dist/src/templates/DocsPageWithModules.js +8 -0
- package/dist/src/templates/MigrationsGuidePage.d.ts +2 -0
- package/dist/src/templates/MigrationsGuidePage.d.ts.map +1 -0
- package/dist/src/templates/MigrationsGuidePage.js +11 -0
- package/dist/src/templates/ModuleGuidePage.d.ts +2 -0
- package/dist/src/templates/ModuleGuidePage.d.ts.map +1 -0
- package/dist/src/templates/ModuleGuidePage.js +14 -0
- package/dist/src/templates/SimpleDocPage.d.ts +2 -0
- package/dist/src/templates/SimpleDocPage.d.ts.map +1 -0
- package/dist/src/templates/SimpleDocPage.js +28 -0
- package/dist/src/templates/SimpleHomePage.d.ts +6 -0
- package/dist/src/templates/SimpleHomePage.d.ts.map +1 -0
- package/dist/src/templates/SimpleHomePage.js +7 -0
- package/dist/src/types/menu.d.ts +23 -0
- package/dist/src/types/menu.d.ts.map +1 -0
- package/dist/src/types/menu.js +1 -0
- package/package.json +3 -4
- package/src/scripts/init-app.ts +7 -81
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { useState, useEffect, useCallback } from "react";
|
|
3
|
+
import { useTableRealtime, supabaseBrowserClient } from "@lastbrain/core";
|
|
4
|
+
export function useNotifications(user) {
|
|
5
|
+
const [data, setData] = useState({
|
|
6
|
+
notifications: [],
|
|
7
|
+
unreadCount: 0,
|
|
8
|
+
});
|
|
9
|
+
const [loading, setLoading] = useState(true);
|
|
10
|
+
const [error, setError] = useState(null);
|
|
11
|
+
const fetchNotifications = useCallback(async () => {
|
|
12
|
+
if (!user?.id) {
|
|
13
|
+
if (user === null) {
|
|
14
|
+
// Utilisateur explicitement non connecté
|
|
15
|
+
setData({ notifications: [], unreadCount: 0 });
|
|
16
|
+
setLoading(false);
|
|
17
|
+
}
|
|
18
|
+
// Si user === undefined, on est encore en train de charger l'auth, on ne fait rien
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
try {
|
|
22
|
+
setLoading(true);
|
|
23
|
+
setError(null);
|
|
24
|
+
// Utilisation directe du client Supabase côté navigateur
|
|
25
|
+
const { data: notifications, error: fetchError } = await supabaseBrowserClient
|
|
26
|
+
.from("user_notifications")
|
|
27
|
+
.select("*")
|
|
28
|
+
.eq("owner_id", user.id)
|
|
29
|
+
.order("created_at", { ascending: false });
|
|
30
|
+
if (fetchError) {
|
|
31
|
+
throw fetchError;
|
|
32
|
+
}
|
|
33
|
+
const unreadCount = notifications?.filter((n) => !n.read).length || 0;
|
|
34
|
+
setData({
|
|
35
|
+
notifications: notifications || [],
|
|
36
|
+
unreadCount,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
catch (err) {
|
|
40
|
+
setError(err instanceof Error
|
|
41
|
+
? err.message
|
|
42
|
+
: "Erreur lors du chargement des notifications");
|
|
43
|
+
console.error("[useNotifications] Erreur:", err);
|
|
44
|
+
}
|
|
45
|
+
finally {
|
|
46
|
+
setLoading(false);
|
|
47
|
+
}
|
|
48
|
+
}, [user]);
|
|
49
|
+
// Utiliser le hook realtime scalable pour les notifications
|
|
50
|
+
const { tick: realtimeTick, lastPayload } = useTableRealtime("user_notifications", {
|
|
51
|
+
eventName: "user_notifications_updated",
|
|
52
|
+
onUpdate: (payload) => {
|
|
53
|
+
console.log("🔔 Nouvelle notification détectée via realtime:", payload);
|
|
54
|
+
console.log("🔔 User ID actuel:", user?.id);
|
|
55
|
+
// Recharger immédiatement les notifications
|
|
56
|
+
if (user?.id) {
|
|
57
|
+
console.log("🔔 Rechargement des notifications...");
|
|
58
|
+
fetchNotifications();
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
// Marquer une notification comme lue
|
|
63
|
+
const markAsRead = useCallback(async (notificationId) => {
|
|
64
|
+
if (!user?.id)
|
|
65
|
+
return;
|
|
66
|
+
try {
|
|
67
|
+
const { error: updateError } = await supabaseBrowserClient
|
|
68
|
+
.from("user_notifications")
|
|
69
|
+
.update({
|
|
70
|
+
read: true,
|
|
71
|
+
updated_at: new Date().toISOString(),
|
|
72
|
+
})
|
|
73
|
+
.eq("id", notificationId)
|
|
74
|
+
.eq("owner_id", user.id);
|
|
75
|
+
if (updateError) {
|
|
76
|
+
throw updateError;
|
|
77
|
+
}
|
|
78
|
+
// Mettre à jour localement en attendant le realtime
|
|
79
|
+
setData((prev) => ({
|
|
80
|
+
...prev,
|
|
81
|
+
notifications: prev.notifications.map((n) => n.id === notificationId ? { ...n, read: true } : n),
|
|
82
|
+
unreadCount: Math.max(0, prev.unreadCount - 1),
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
catch (err) {
|
|
86
|
+
console.error("Erreur mark as read:", err);
|
|
87
|
+
throw err;
|
|
88
|
+
}
|
|
89
|
+
}, [user?.id]);
|
|
90
|
+
// Marquer toutes les notifications comme lues
|
|
91
|
+
const markAllAsRead = useCallback(async () => {
|
|
92
|
+
if (!user?.id || data.unreadCount === 0)
|
|
93
|
+
return;
|
|
94
|
+
try {
|
|
95
|
+
const { error: updateError } = await supabaseBrowserClient
|
|
96
|
+
.from("user_notifications")
|
|
97
|
+
.update({
|
|
98
|
+
read: true,
|
|
99
|
+
updated_at: new Date().toISOString(),
|
|
100
|
+
})
|
|
101
|
+
.eq("owner_id", user.id)
|
|
102
|
+
.eq("read", false);
|
|
103
|
+
if (updateError) {
|
|
104
|
+
throw updateError;
|
|
105
|
+
}
|
|
106
|
+
// Mettre à jour localement
|
|
107
|
+
setData((prev) => ({
|
|
108
|
+
...prev,
|
|
109
|
+
notifications: prev.notifications.map((n) => ({ ...n, read: true })),
|
|
110
|
+
unreadCount: 0,
|
|
111
|
+
}));
|
|
112
|
+
}
|
|
113
|
+
catch (err) {
|
|
114
|
+
console.error("Erreur mark all as read:", err);
|
|
115
|
+
throw err;
|
|
116
|
+
}
|
|
117
|
+
}, [user?.id, data.unreadCount]);
|
|
118
|
+
// Supprimer une notification
|
|
119
|
+
const deleteNotification = useCallback(async (notificationId) => {
|
|
120
|
+
if (!user?.id)
|
|
121
|
+
return;
|
|
122
|
+
try {
|
|
123
|
+
const { error: deleteError } = await supabaseBrowserClient
|
|
124
|
+
.from("user_notifications")
|
|
125
|
+
.delete()
|
|
126
|
+
.eq("id", notificationId)
|
|
127
|
+
.eq("owner_id", user.id);
|
|
128
|
+
if (deleteError) {
|
|
129
|
+
throw deleteError;
|
|
130
|
+
}
|
|
131
|
+
// Mettre à jour localement
|
|
132
|
+
setData((prev) => {
|
|
133
|
+
const notification = prev.notifications.find((n) => n.id === notificationId);
|
|
134
|
+
return {
|
|
135
|
+
notifications: prev.notifications.filter((n) => n.id !== notificationId),
|
|
136
|
+
unreadCount: notification && !notification.read
|
|
137
|
+
? Math.max(0, prev.unreadCount - 1)
|
|
138
|
+
: prev.unreadCount,
|
|
139
|
+
};
|
|
140
|
+
});
|
|
141
|
+
}
|
|
142
|
+
catch (err) {
|
|
143
|
+
console.error("Erreur delete notification:", err);
|
|
144
|
+
throw err;
|
|
145
|
+
}
|
|
146
|
+
}, [user?.id]);
|
|
147
|
+
// Charger les notifications initiales
|
|
148
|
+
useEffect(() => {
|
|
149
|
+
fetchNotifications();
|
|
150
|
+
}, [fetchNotifications]);
|
|
151
|
+
return {
|
|
152
|
+
data,
|
|
153
|
+
loading,
|
|
154
|
+
error,
|
|
155
|
+
refetch: fetchNotifications,
|
|
156
|
+
markAsRead,
|
|
157
|
+
markAllAsRead,
|
|
158
|
+
deleteNotification,
|
|
159
|
+
isEmpty: data.notifications.length === 0,
|
|
160
|
+
hasUnread: data.unreadCount > 0,
|
|
161
|
+
// Informations realtime
|
|
162
|
+
realtimeActive: realtimeTick > 0,
|
|
163
|
+
lastRealtimePayload: lastPayload,
|
|
164
|
+
};
|
|
165
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { AppProviders, useAuth, useModules, useNotifications as useNotificationsContext, } from "./layouts/AppProviders";
|
|
2
|
+
export { useNotifications } from "./hooks/useNotifications";
|
|
3
|
+
export { NotificationContainer } from "./components/NotificationContainer";
|
|
4
|
+
export { useAuthSession } from "./auth/useAuthSession";
|
|
5
|
+
export { signOut, signIn } from "./auth/authHelpers";
|
|
6
|
+
export { RootLayout } from "./layouts/RootLayout";
|
|
7
|
+
export { PublicLayout } from "./layouts/PublicLayout";
|
|
8
|
+
export { PublicLayoutWithSidebar } from "./layouts/PublicLayoutWithSidebar";
|
|
9
|
+
export { AuthLayout } from "./layouts/AuthLayout";
|
|
10
|
+
export { AuthLayoutWithSidebar, type AuthLayoutWithSidebarProps, type MenuIgnored, type MenuCustom, } from "./layouts/AuthLayoutWithSidebar";
|
|
11
|
+
export { AdminLayout } from "./layouts/AdminLayout";
|
|
12
|
+
export { AdminLayoutWithSidebar } from "./layouts/AdminLayoutWithSidebar";
|
|
13
|
+
export { getModuleConfigs } from "./modules/module-loader";
|
|
14
|
+
export { AppAside } from "@lastbrain/ui";
|
|
15
|
+
export type { AppAsideMenuItem, AppAsideMenuConfig } from "@lastbrain/ui";
|
|
16
|
+
export { SimpleHomePage } from "./templates/SimpleHomePage";
|
|
17
|
+
export { DocPage } from "./templates/DocPage";
|
|
18
|
+
export { SimpleDocPage } from "./templates/SimpleDocPage";
|
|
19
|
+
export { ModuleGuidePage } from "./templates/ModuleGuidePage";
|
|
20
|
+
export { AuthGuidePage } from "./templates/AuthGuidePage";
|
|
21
|
+
export { MigrationsGuidePage } from "./templates/MigrationsGuidePage";
|
|
22
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,YAAY,EACZ,OAAO,EACP,UAAU,EACV,gBAAgB,IAAI,uBAAuB,GAC5C,MAAM,wBAAwB,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC3E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EAAE,uBAAuB,EAAE,MAAM,mCAAmC,CAAC;AAC5E,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAClD,OAAO,EACL,qBAAqB,EACrB,KAAK,0BAA0B,EAC/B,KAAK,WAAW,EAChB,KAAK,UAAU,GAChB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kCAAkC,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAG3D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EAAE,gBAAgB,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAC;AAG1E,OAAO,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAC9C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,mBAAmB,EAAE,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export { AppProviders, useAuth, useModules, useNotifications as useNotificationsContext, } from "./layouts/AppProviders";
|
|
2
|
+
export { useNotifications } from "./hooks/useNotifications";
|
|
3
|
+
export { NotificationContainer } from "./components/NotificationContainer";
|
|
4
|
+
export { useAuthSession } from "./auth/useAuthSession";
|
|
5
|
+
export { signOut, signIn } from "./auth/authHelpers";
|
|
6
|
+
export { RootLayout } from "./layouts/RootLayout";
|
|
7
|
+
export { PublicLayout } from "./layouts/PublicLayout";
|
|
8
|
+
export { PublicLayoutWithSidebar } from "./layouts/PublicLayoutWithSidebar";
|
|
9
|
+
export { AuthLayout } from "./layouts/AuthLayout";
|
|
10
|
+
export { AuthLayoutWithSidebar, } from "./layouts/AuthLayoutWithSidebar";
|
|
11
|
+
export { AdminLayout } from "./layouts/AdminLayout";
|
|
12
|
+
export { AdminLayoutWithSidebar } from "./layouts/AdminLayoutWithSidebar";
|
|
13
|
+
export { getModuleConfigs } from "./modules/module-loader";
|
|
14
|
+
// Components
|
|
15
|
+
export { AppAside } from "@lastbrain/ui";
|
|
16
|
+
// Templates de pages (starter + docs)
|
|
17
|
+
export { SimpleHomePage } from "./templates/SimpleHomePage";
|
|
18
|
+
export { DocPage } from "./templates/DocPage";
|
|
19
|
+
export { SimpleDocPage } from "./templates/SimpleDocPage";
|
|
20
|
+
export { ModuleGuidePage } from "./templates/ModuleGuidePage";
|
|
21
|
+
export { AuthGuidePage } from "./templates/AuthGuidePage";
|
|
22
|
+
export { MigrationsGuidePage } from "./templates/MigrationsGuidePage";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/AdminLayout.tsx"],"names":[],"mappings":"AAAA,wBAAgB,WAAW,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAEtE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { type MenuConfig, type MenuItem } from "@lastbrain/ui";
|
|
2
|
+
interface AdminLayoutWithSidebarProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
menuConfig?: MenuConfig;
|
|
5
|
+
className?: string;
|
|
6
|
+
menuCustom?: MenuItem[];
|
|
7
|
+
}
|
|
8
|
+
export declare function AdminLayoutWithSidebar({ children, menuConfig, className, menuCustom, }: AdminLayoutWithSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=AdminLayoutWithSidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AdminLayoutWithSidebar.d.ts","sourceRoot":"","sources":["../../../src/layouts/AdminLayoutWithSidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAKvB,UAAU,2BAA2B;IACnC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,sBAAsB,CAAC,EACrC,QAAQ,EACR,UAAU,EACV,SAAc,EACd,UAAU,GACX,EAAE,2BAA2B,2CAkG7B"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AdminLayout } from "./AdminLayout";
|
|
4
|
+
import { AppAside, AppAsideSkeleton, } from "@lastbrain/ui";
|
|
5
|
+
import { useAuthSession } from "../auth/useAuthSession";
|
|
6
|
+
import { usePathname } from "next/navigation";
|
|
7
|
+
import { useEffect, useState } from "react";
|
|
8
|
+
export function AdminLayoutWithSidebar({ children, menuConfig, className = "", menuCustom, }) {
|
|
9
|
+
const { isSuperAdmin, loading, user } = useAuthSession();
|
|
10
|
+
const pathname = usePathname();
|
|
11
|
+
const [isCollapsed, setIsCollapsed] = useState(() => {
|
|
12
|
+
if (typeof window !== "undefined") {
|
|
13
|
+
const savedState = localStorage.getItem("aside-collapsed");
|
|
14
|
+
return savedState !== null ? JSON.parse(savedState) : false;
|
|
15
|
+
}
|
|
16
|
+
return false;
|
|
17
|
+
});
|
|
18
|
+
const [mounted, setMounted] = useState(false);
|
|
19
|
+
useEffect(() => {
|
|
20
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
21
|
+
setMounted(true);
|
|
22
|
+
}, []);
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
if (typeof window !== "undefined") {
|
|
25
|
+
// Écouter les changements du localStorage depuis le même onglet
|
|
26
|
+
const handleStorageChange = (_e) => {
|
|
27
|
+
const savedState = localStorage.getItem("aside-collapsed");
|
|
28
|
+
if (savedState !== null) {
|
|
29
|
+
// Utiliser queueMicrotask pour déférer le setState
|
|
30
|
+
queueMicrotask(() => {
|
|
31
|
+
setIsCollapsed(JSON.parse(savedState));
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
// Écouter l'événement storage (changements depuis d'autres onglets)
|
|
36
|
+
window.addEventListener("storage", handleStorageChange);
|
|
37
|
+
// Écouter l'événement custom pour les changements du même onglet
|
|
38
|
+
window.addEventListener("localStorage-changed", handleStorageChange);
|
|
39
|
+
return () => {
|
|
40
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
41
|
+
window.removeEventListener("localStorage-changed", handleStorageChange);
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
}, []);
|
|
45
|
+
// Détecter si on est dans la section admin pour le skeleton
|
|
46
|
+
const isAdminSection = pathname.startsWith("/admin");
|
|
47
|
+
// Créer un menuConfig sûr avec des valeurs par défaut
|
|
48
|
+
const safeMenuConfig = {
|
|
49
|
+
public: menuConfig?.public || [],
|
|
50
|
+
auth: menuConfig?.auth || [],
|
|
51
|
+
admin: menuConfig?.admin || [],
|
|
52
|
+
};
|
|
53
|
+
// Vérifier si menuConfig est vraiment disponible et valide
|
|
54
|
+
const hasValidMenuConfig = menuConfig &&
|
|
55
|
+
typeof menuConfig === "object" &&
|
|
56
|
+
(safeMenuConfig.admin.length > 0 ||
|
|
57
|
+
safeMenuConfig.auth.length > 0 ||
|
|
58
|
+
safeMenuConfig.public.length > 0);
|
|
59
|
+
// Afficher le skeleton pendant le chargement de la session ou si pas de menuConfig valide
|
|
60
|
+
const shouldShowSkeleton = loading || !hasValidMenuConfig;
|
|
61
|
+
return (_jsxs("div", { className: "flex min-h-screen", children: [shouldShowSkeleton ? (_jsx(AppAsideSkeleton, { className: className, isAdminSection: isAdminSection })) : (_jsx(AppAside, { menuConfig: safeMenuConfig, isSuperAdmin: isSuperAdmin, isAuthenticated: !!user, className: className, ...(menuCustom ? { menuCustom } : {}) })), _jsx("div", { className: `flex-1 transition-all duration-300 ${!mounted ? "lg:ml-72" : isCollapsed ? "lg:ml-20" : "lg:ml-72"}`, children: _jsx(AdminLayout, { children: children }) })] }));
|
|
62
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { User } from "@supabase/supabase-js";
|
|
2
|
+
import type { ModuleRealtimeConfig } from "@lastbrain/core";
|
|
3
|
+
import type { NotificationsData } from "../hooks/useNotifications";
|
|
4
|
+
export declare function useModules(): import("@lastbrain/core").ModuleBuildConfig[];
|
|
5
|
+
export declare function useNotifications(): {
|
|
6
|
+
data: NotificationsData;
|
|
7
|
+
loading: boolean;
|
|
8
|
+
error: string | null;
|
|
9
|
+
refetch: () => Promise<void>;
|
|
10
|
+
markAsRead: (id: string) => Promise<void>;
|
|
11
|
+
markAllAsRead: () => Promise<void>;
|
|
12
|
+
deleteNotification: (id: string) => Promise<void>;
|
|
13
|
+
isEmpty: boolean;
|
|
14
|
+
hasUnread: boolean;
|
|
15
|
+
realtimeActive: boolean;
|
|
16
|
+
lastRealtimePayload: unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare function useAuth(): {
|
|
19
|
+
user: User | null;
|
|
20
|
+
loading: boolean;
|
|
21
|
+
isSuperAdmin: boolean;
|
|
22
|
+
};
|
|
23
|
+
export declare function AppProviders({ children, realtimeConfig, }: {
|
|
24
|
+
children: React.ReactNode;
|
|
25
|
+
realtimeConfig?: ModuleRealtimeConfig[];
|
|
26
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
//# sourceMappingURL=AppProviders.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AppProviders.d.ts","sourceRoot":"","sources":["../../../src/layouts/AppProviders.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAuCnE,wBAAgB,UAAU,kDAEzB;AAED,wBAAgB,gBAAgB;UAvCxB,iBAAiB;aACd,OAAO;WACT,MAAM,GAAG,IAAI;aACX,MAAM,OAAO,CAAC,IAAI,CAAC;gBAChB,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;mBAC1B,MAAM,OAAO,CAAC,IAAI,CAAC;wBACd,CAAC,EAAE,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC;aACxC,OAAO;eACL,OAAO;oBACF,OAAO;yBACF,OAAO;EA+B7B;AAED,wBAAgB,OAAO;UAjBf,IAAI,GAAG,IAAI;aACR,OAAO;kBACF,OAAO;EAiBtB;AAED,wBAAgB,YAAY,CAAC,EAC3B,QAAQ,EACR,cAAmB,GACpB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACzC,2CA4BA"}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { createContext, useContext, useMemo } from "react";
|
|
4
|
+
import { getModuleConfigs } from "../modules/module-loader";
|
|
5
|
+
import { ToastProvider } from "@lastbrain/ui";
|
|
6
|
+
import { RealtimeProvider } from "@lastbrain/core";
|
|
7
|
+
import { useAuthSession } from "../auth/useAuthSession";
|
|
8
|
+
import { useNotifications as useNotificationsHook } from "../hooks/useNotifications";
|
|
9
|
+
const ModuleContext = createContext(getModuleConfigs());
|
|
10
|
+
const NotificationContext = createContext({
|
|
11
|
+
data: { notifications: [], unreadCount: 0 },
|
|
12
|
+
loading: true,
|
|
13
|
+
error: null,
|
|
14
|
+
refetch: async () => { },
|
|
15
|
+
markAsRead: async () => { },
|
|
16
|
+
markAllAsRead: async () => { },
|
|
17
|
+
deleteNotification: async () => { },
|
|
18
|
+
isEmpty: true,
|
|
19
|
+
hasUnread: false,
|
|
20
|
+
realtimeActive: false,
|
|
21
|
+
lastRealtimePayload: null,
|
|
22
|
+
});
|
|
23
|
+
const AuthContext = createContext({
|
|
24
|
+
user: null,
|
|
25
|
+
loading: true,
|
|
26
|
+
isSuperAdmin: false,
|
|
27
|
+
});
|
|
28
|
+
export function useModules() {
|
|
29
|
+
return useContext(ModuleContext);
|
|
30
|
+
}
|
|
31
|
+
export function useNotifications() {
|
|
32
|
+
return useContext(NotificationContext);
|
|
33
|
+
}
|
|
34
|
+
export function useAuth() {
|
|
35
|
+
return useContext(AuthContext);
|
|
36
|
+
}
|
|
37
|
+
export function AppProviders({ children, realtimeConfig = [], }) {
|
|
38
|
+
const modules = useMemo(() => getModuleConfigs(), []);
|
|
39
|
+
const { user, loading: authLoading, isSuperAdmin } = useAuthSession();
|
|
40
|
+
// Hook de notifications seulement quand l'auth est prête
|
|
41
|
+
const notificationsData = useNotificationsHook(user);
|
|
42
|
+
const authValue = useMemo(() => ({ user, loading: authLoading, isSuperAdmin }), [user, authLoading, isSuperAdmin]); // const handleLogout = async () => {
|
|
43
|
+
// const { signOut } = await import("../auth/authHelpers.js");
|
|
44
|
+
// await signOut();
|
|
45
|
+
// router.push("/auth/signin");
|
|
46
|
+
// };
|
|
47
|
+
return (_jsx(AuthContext.Provider, { value: authValue, children: _jsx(ModuleContext.Provider, { value: modules, children: _jsx(NotificationContext.Provider, { value: notificationsData, children: _jsxs(RealtimeProvider, { userId: user?.id, config: realtimeConfig, children: [children, _jsx(ToastProvider, { placement: "bottom-right", toastOffset: 5 })] }) }) }) }));
|
|
48
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/AuthLayout.tsx"],"names":[],"mappings":"AAAA,wBAAgB,UAAU,CAAC,EAAE,QAAQ,EAAE,EAAE;IAAE,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,2CAErE"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { type MenuConfig, type MenuItem } from "@lastbrain/ui";
|
|
2
|
+
import type { MenuIgnored, MenuCustom } from "../types/menu";
|
|
3
|
+
export type { MenuIgnored, MenuCustom };
|
|
4
|
+
export interface AuthLayoutWithSidebarProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
menuConfig?: MenuConfig;
|
|
7
|
+
className?: string;
|
|
8
|
+
menuIgnored?: MenuIgnored;
|
|
9
|
+
menuCustom?: MenuItem[];
|
|
10
|
+
}
|
|
11
|
+
export declare function AuthLayoutWithSidebar({ children, menuConfig, className, menuIgnored, menuCustom, }: AuthLayoutWithSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
//# sourceMappingURL=AuthLayoutWithSidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AuthLayoutWithSidebar.d.ts","sourceRoot":"","sources":["../../../src/layouts/AuthLayoutWithSidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAGL,KAAK,UAAU,EACf,KAAK,QAAQ,EACd,MAAM,eAAe,CAAC;AAEvB,OAAO,KAAK,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,eAAe,CAAC;AAG7D,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,CAAC;AAExC,MAAM,WAAW,0BAA0B;IACzC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,QAAQ,EAAE,CAAC;CACzB;AAED,wBAAgB,qBAAqB,CAAC,EACpC,QAAQ,EACR,UAAU,EACV,SAAc,EACd,WAAW,EACX,UAAU,GACX,EAAE,0BAA0B,2CAiG5B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { AuthLayout } from "./AuthLayout";
|
|
4
|
+
import { AppAside, AppAsideSkeleton, } from "@lastbrain/ui";
|
|
5
|
+
import { useAuthSession } from "../auth/useAuthSession";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
export function AuthLayoutWithSidebar({ children, menuConfig, className = "", menuIgnored, menuCustom, }) {
|
|
8
|
+
const { isSuperAdmin, loading, user } = useAuthSession();
|
|
9
|
+
const [isCollapsed, setIsCollapsed] = useState(() => {
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
const savedState = localStorage.getItem("aside-collapsed");
|
|
12
|
+
return savedState !== null ? JSON.parse(savedState) : false;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
16
|
+
const [mounted, setMounted] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
19
|
+
setMounted(true);
|
|
20
|
+
}, []);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (typeof window !== "undefined") {
|
|
23
|
+
// Écouter les changements du localStorage depuis le même onglet
|
|
24
|
+
const handleStorageChange = (_e) => {
|
|
25
|
+
const savedState = localStorage.getItem("aside-collapsed");
|
|
26
|
+
if (savedState !== null) {
|
|
27
|
+
// Utiliser queueMicrotask pour déférer le setState
|
|
28
|
+
queueMicrotask(() => {
|
|
29
|
+
setIsCollapsed(JSON.parse(savedState));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// Écouter l'événement storage (changements depuis d'autres onglets)
|
|
34
|
+
window.addEventListener("storage", handleStorageChange);
|
|
35
|
+
// Écouter l'événement custom pour les changements du même onglet
|
|
36
|
+
window.addEventListener("localStorage-changed", handleStorageChange);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
39
|
+
window.removeEventListener("localStorage-changed", handleStorageChange);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
// Pour la section auth, isAdminSection sera false
|
|
44
|
+
const isAdminSection = false;
|
|
45
|
+
// Créer un menuConfig sûr avec des valeurs par défaut
|
|
46
|
+
const safeMenuConfig = {
|
|
47
|
+
public: menuConfig?.public || [],
|
|
48
|
+
auth: menuConfig?.auth || [],
|
|
49
|
+
admin: menuConfig?.admin || [],
|
|
50
|
+
};
|
|
51
|
+
// Vérifier si menuConfig est vraiment disponible et valide
|
|
52
|
+
const hasValidMenuConfig = menuConfig &&
|
|
53
|
+
typeof menuConfig === "object" &&
|
|
54
|
+
(safeMenuConfig.admin.length > 0 ||
|
|
55
|
+
safeMenuConfig.auth.length > 0 ||
|
|
56
|
+
safeMenuConfig.public.length > 0);
|
|
57
|
+
// Afficher le skeleton pendant le chargement de la session ou si pas de menuConfig valide
|
|
58
|
+
const shouldShowSkeleton = loading || !hasValidMenuConfig;
|
|
59
|
+
return (_jsxs("div", { className: "flex min-h-screen", children: [shouldShowSkeleton ? (_jsx(AppAsideSkeleton, { className: className, isAdminSection: isAdminSection })) : (_jsx(AppAside, { menuConfig: safeMenuConfig, isSuperAdmin: isSuperAdmin, isAuthenticated: !!user, className: className, ...(menuIgnored ? { menuIgnored } : {}), ...(menuCustom ? { menuCustom } : {}) })), _jsx("div", { className: `flex-1 transition-all duration-300 ${!mounted ? "lg:ml-72" : isCollapsed ? "lg:ml-20" : "lg:ml-72"}`, children: _jsx(AuthLayout, { children: children }) })] }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type FooterConfig } from "@lastbrain/ui";
|
|
2
|
+
interface PublicLayoutProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
footerConfig?: FooterConfig;
|
|
5
|
+
}
|
|
6
|
+
export declare function PublicLayout({ children, footerConfig }: PublicLayoutProps): import("react/jsx-runtime").JSX.Element;
|
|
7
|
+
export {};
|
|
8
|
+
//# sourceMappingURL=PublicLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/PublicLayout.tsx"],"names":[],"mappings":"AAEA,OAAO,EAAU,KAAK,YAAY,EAAE,MAAM,eAAe,CAAC;AAE1D,UAAU,iBAAiB;IACzB,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,YAAY,CAAC,EAAE,YAAY,CAAC;CAC7B;AAED,wBAAgB,YAAY,CAAC,EAAE,QAAQ,EAAE,YAAY,EAAE,EAAE,iBAAiB,2CAOzE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { Footer } from "@lastbrain/ui";
|
|
4
|
+
export function PublicLayout({ children, footerConfig }) {
|
|
5
|
+
return (_jsxs(_Fragment, { children: [_jsx("section", { className: "pt-16 min-h-[calc(100vh)]", children: children }), footerConfig && _jsx(Footer, { config: footerConfig })] }));
|
|
6
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { type MenuConfig } from "@lastbrain/ui";
|
|
2
|
+
interface PublicLayoutWithSidebarProps {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
menuConfig?: MenuConfig;
|
|
5
|
+
className?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare function PublicLayoutWithSidebar({ children, menuConfig, className, }: PublicLayoutWithSidebarProps): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export {};
|
|
9
|
+
//# sourceMappingURL=PublicLayoutWithSidebar.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"PublicLayoutWithSidebar.d.ts","sourceRoot":"","sources":["../../../src/layouts/PublicLayoutWithSidebar.tsx"],"names":[],"mappings":"AAGA,OAAO,EAA8B,KAAK,UAAU,EAAE,MAAM,eAAe,CAAC;AAI5E,UAAU,4BAA4B;IACpC,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,wBAAgB,uBAAuB,CAAC,EACtC,QAAQ,EACR,UAAU,EACV,SAAc,GACf,EAAE,4BAA4B,2CA+F9B"}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
3
|
+
import { PublicLayout } from "./PublicLayout";
|
|
4
|
+
import { AppAside, AppAsideSkeleton } from "@lastbrain/ui";
|
|
5
|
+
import { useAuthSession } from "../auth/useAuthSession";
|
|
6
|
+
import { useEffect, useState } from "react";
|
|
7
|
+
export function PublicLayoutWithSidebar({ children, menuConfig, className = "", }) {
|
|
8
|
+
const { user, loading } = useAuthSession();
|
|
9
|
+
const [isCollapsed, setIsCollapsed] = useState(() => {
|
|
10
|
+
if (typeof window !== "undefined") {
|
|
11
|
+
const savedState = localStorage.getItem("aside-collapsed");
|
|
12
|
+
return savedState !== null ? JSON.parse(savedState) : false;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
});
|
|
16
|
+
const [mounted, setMounted] = useState(false);
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
// eslint-disable-next-line react-hooks/set-state-in-effect
|
|
19
|
+
setMounted(true);
|
|
20
|
+
}, []);
|
|
21
|
+
useEffect(() => {
|
|
22
|
+
if (typeof window !== "undefined") {
|
|
23
|
+
// Écouter les changements du localStorage depuis le même onglet
|
|
24
|
+
const handleStorageChange = (_e) => {
|
|
25
|
+
const savedState = localStorage.getItem("aside-collapsed");
|
|
26
|
+
if (savedState !== null) {
|
|
27
|
+
// Utiliser queueMicrotask pour déférer le setState
|
|
28
|
+
queueMicrotask(() => {
|
|
29
|
+
setIsCollapsed(JSON.parse(savedState));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
// Écouter l'événement storage (changements depuis d'autres onglets)
|
|
34
|
+
window.addEventListener("storage", handleStorageChange);
|
|
35
|
+
// Écouter l'événement custom pour les changements du même onglet
|
|
36
|
+
window.addEventListener("localStorage-changed", handleStorageChange);
|
|
37
|
+
return () => {
|
|
38
|
+
window.removeEventListener("storage", handleStorageChange);
|
|
39
|
+
window.removeEventListener("localStorage-changed", handleStorageChange);
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
}, []);
|
|
43
|
+
// Pour la section public, isAdminSection sera false
|
|
44
|
+
const isAdminSection = false;
|
|
45
|
+
// Créer un menuConfig sûr avec des valeurs par défaut
|
|
46
|
+
const safeMenuConfig = {
|
|
47
|
+
public: menuConfig?.public || [],
|
|
48
|
+
auth: menuConfig?.auth || [],
|
|
49
|
+
admin: menuConfig?.admin || [],
|
|
50
|
+
};
|
|
51
|
+
// Vérifier si menuConfig est vraiment disponible et valide
|
|
52
|
+
const hasValidMenuConfig = menuConfig &&
|
|
53
|
+
typeof menuConfig === "object" &&
|
|
54
|
+
(safeMenuConfig.admin.length > 0 ||
|
|
55
|
+
safeMenuConfig.auth.length > 0 ||
|
|
56
|
+
safeMenuConfig.public.length > 0);
|
|
57
|
+
// Afficher le skeleton pendant le chargement de la session ou si pas de menuConfig valide
|
|
58
|
+
const shouldShowSkeleton = loading || !hasValidMenuConfig;
|
|
59
|
+
return (_jsxs("div", { className: "flex min-h-screen", children: [shouldShowSkeleton ? (_jsx(AppAsideSkeleton, { className: className, isAdminSection: isAdminSection })) : (_jsx(AppAside, { menuConfig: safeMenuConfig, isSuperAdmin: false, isAuthenticated: !!user, className: className })), _jsx("div", { className: `flex-1 transition-all duration-300 ${!mounted ? "lg:ml-72" : isCollapsed ? "lg:ml-20" : "lg:ml-72"}`, children: _jsx(PublicLayout, { children: children }) })] }));
|
|
60
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { ModuleRealtimeConfig } from "@lastbrain/core";
|
|
2
|
+
export declare function RootLayout({ children, realtimeConfig, }: {
|
|
3
|
+
children: React.ReactNode;
|
|
4
|
+
realtimeConfig?: ModuleRealtimeConfig[];
|
|
5
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
6
|
+
//# sourceMappingURL=RootLayout.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"RootLayout.d.ts","sourceRoot":"","sources":["../../../src/layouts/RootLayout.tsx"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAI5D,wBAAgB,UAAU,CAAC,EACzB,QAAQ,EACR,cAAmB,GACpB,EAAE;IACD,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,cAAc,CAAC,EAAE,oBAAoB,EAAE,CAAC;CACzC,2CAmBA"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
3
|
+
import { ThemeProvider } from "next-themes";
|
|
4
|
+
import { AppProviders } from "./AppProviders";
|
|
5
|
+
// Note: L'app Next.js doit importer son propre globals.css dans son layout
|
|
6
|
+
// Note: La configuration realtime doit être fournie par l'app qui utilise ce layout
|
|
7
|
+
export function RootLayout({ children, realtimeConfig = [], }) {
|
|
8
|
+
return (_jsx("html", { lang: "fr", suppressHydrationWarning: true, children: _jsx("body", { className: "min-h-screen", children: _jsx(ThemeProvider, { attribute: "class", defaultTheme: "light", enableSystem: false, storageKey: "lastbrain-theme", children: _jsx(AppProviders, { realtimeConfig: realtimeConfig, children: _jsx("div", { className: " min-h-screen bg-slate-50 text-slate-900 dark:bg-slate-950 dark:text-white", children: children }) }) }) }) }));
|
|
9
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ModuleBuildConfig } from "@lastbrain/core";
|
|
2
|
+
export declare const moduleConfigs: ModuleBuildConfig[];
|
|
3
|
+
export declare function getModuleConfigs(): ModuleBuildConfig[];
|
|
4
|
+
export declare function registerModuleConfig(config: ModuleBuildConfig): void;
|
|
5
|
+
//# sourceMappingURL=module-loader.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module-loader.d.ts","sourceRoot":"","sources":["../../../src/modules/module-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAKzD,eAAO,MAAM,aAAa,EAAE,iBAAiB,EAAO,CAAC;AAErD,wBAAgB,gBAAgB,wBAE/B;AAED,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,iBAAiB,QAE7D"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// Ce fichier est utilisé côté client par AppProviders
|
|
2
|
+
// Le chargement des modules se fait uniquement au build-time dans module-build.ts
|
|
3
|
+
// Côté client, on exporte un tableau vide car les modules sont déjà compilés
|
|
4
|
+
export const moduleConfigs = [];
|
|
5
|
+
export function getModuleConfigs() {
|
|
6
|
+
return moduleConfigs;
|
|
7
|
+
}
|
|
8
|
+
export function registerModuleConfig(config) {
|
|
9
|
+
moduleConfigs.push(config);
|
|
10
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"db-init.d.ts","sourceRoot":"","sources":["../../../src/scripts/db-init.ts"],"names":[],"mappings":""}
|