create-bw-app 0.18.3 → 0.18.5

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "create-bw-app",
3
3
  "private": false,
4
- "version": "0.18.3",
4
+ "version": "0.18.5",
5
5
  "type": "module",
6
6
  "bin": {
7
7
  "create-bw-app": "bin/create-bw-app.mjs",
package/src/constants.mjs CHANGED
@@ -61,6 +61,8 @@ export const MODULE_STARTER_FILES = {
61
61
  admin: [
62
62
  "app/api/admin/users/route.ts",
63
63
  "app/api/admin/users/roles/route.ts",
64
+ "app/api/admin/users/invitations/route.ts",
65
+ "app/api/admin/users/invitations/[invitationId]/route.ts",
64
66
  "app/(shell)/admin/users/page.tsx",
65
67
  ],
66
68
  crm: [
@@ -68,6 +70,7 @@ export const MODULE_STARTER_FILES = {
68
70
  "app/(shell)/crm/page.tsx",
69
71
  "app/(shell)/crm/report/page.tsx",
70
72
  "app/api/crm/contacts/route.ts",
73
+ "app/api/dashboard/crm/route.ts",
71
74
  "app/api/crm/organizations/route.ts",
72
75
  "app/api/crm/owners/route.ts",
73
76
  "app/api/crm/report/route.ts",
@@ -117,6 +120,8 @@ export const MODULE_STARTER_FILES = {
117
120
  "app/(shell)/account/projetos/[projectId]/page.tsx",
118
121
  "app/(shell)/account/projetos/[projectId]/loading.tsx",
119
122
  "app/api/projects/_handlers.ts",
123
+ "app/api/dashboard/projects/route.ts",
124
+ "app/api/dashboard/tasks/route.ts",
120
125
  "app/api/projects/route.ts",
121
126
  "app/api/projects/stats/route.ts",
122
127
  "app/api/projects/organizations/route.ts",
@@ -165,14 +170,14 @@ export const PLATFORM_STARTER_FILES = [
165
170
  ];
166
171
 
167
172
  export const APP_DEPENDENCY_DEFAULTS = {
168
- "@brightweblabs/app-shell": "^0.7.2",
173
+ "@brightweblabs/app-shell": "^0.7.4",
169
174
  "@brightweblabs/core-auth": "^0.7.2",
170
175
  "@brightweblabs/infra": "^0.4.0",
171
- "@brightweblabs/module-admin": "^0.5.8",
172
- "@brightweblabs/module-crm": "^0.9.3",
173
- "@brightweblabs/module-marketing": "^0.2.7",
174
- "@brightweblabs/module-orgs": "^0.3.8",
175
- "@brightweblabs/module-projects": "^0.8.1",
176
+ "@brightweblabs/module-admin": "^0.5.10",
177
+ "@brightweblabs/module-crm": "^0.10.0",
178
+ "@brightweblabs/module-marketing": "^0.2.9",
179
+ "@brightweblabs/module-orgs": "^0.3.10",
180
+ "@brightweblabs/module-projects": "^0.9.0",
176
181
  "@brightweblabs/theme": "^0.5.0",
177
182
  "@brightweblabs/ui": "^1.1.1",
178
183
  "geist": "1.7.2",
@@ -9,10 +9,9 @@ async function getJson(path: string) {
9
9
  }
10
10
 
11
11
  const dashboardClient: DashboardDataClient = {
12
- getOverview: () => Promise.reject(new Error("No aggregate dashboard endpoint configured.")),
13
- getProjects: () => getJson("/api/projects/stats"),
14
- getCrm: () => getJson("/api/crm/stats"),
15
- getTasks: () => Promise.reject(new Error("No task dashboard endpoint configured.")),
12
+ getProjects: () => getJson("/api/dashboard/projects"),
13
+ getCrm: () => getJson("/api/dashboard/crm"),
14
+ getTasks: () => getJson("/api/dashboard/tasks"),
16
15
  };
17
16
 
18
17
  export function DashboardLiveMount() {
@@ -8,7 +8,9 @@ import {
8
8
  DesktopSidebar,
9
9
  MobileNav,
10
10
  computeInitials,
11
+ isShellNavItemActive,
11
12
  useShellNavState,
13
+ type ShellContextualAction,
12
14
  type ShellNavStateGroup,
13
15
  } from "@brightweblabs/app-shell";
14
16
  import { createAuthUiClient } from "@brightweblabs/core-auth/ui";
@@ -25,6 +27,11 @@ export type ShellViewer = {
25
27
  };
26
28
 
27
29
  const authClient = createAuthUiClient();
30
+ const toolbarWindowEventByAction: Record<string, string> = {
31
+ "projects-refresh": "projects:refresh",
32
+ "projects-new-menu": "projects:open-new-project",
33
+ "crm-create-menu": "brightweb:crm:create-contact",
34
+ };
28
35
 
29
36
  export function ShellLayoutClient({
30
37
  children,
@@ -46,12 +53,43 @@ export function ShellLayoutClient({
46
53
  const { isSidebarCollapsed, isGroupOpen, toggleGroup, toggleSidebar } =
47
54
  useShellNavState({ pathname, groups: shellGroups });
48
55
  const isAdminSurface = pathname === "/admin" || pathname.startsWith("/admin/");
49
- const isActive = (href: string) =>
50
- pathname === href || (isAdminSurface && pathname.startsWith(`${href}/`));
56
+ const shellNavItems = [
57
+ ...config.primaryNav,
58
+ ...(config.adminNavItem ? [config.adminNavItem] : []),
59
+ ...config.toolsSection.items,
60
+ ...config.moduleGroups.flatMap((group) => group.children),
61
+ ];
62
+ const activeNavItem = shellNavItems.reduce<(typeof shellNavItems)[number] | undefined>(
63
+ (active, item) => isShellNavItemActive(pathname, item)
64
+ && (!active || item.href.length > active.href.length)
65
+ ? item
66
+ : active,
67
+ undefined,
68
+ );
69
+ const isActive = (href: string) => activeNavItem?.href === href;
51
70
  const displayName =
52
71
  [viewer.firstName, viewer.lastName].filter(Boolean).join(" ") ||
53
72
  viewer.email ||
54
73
  "Conta";
74
+ const projectsBaseHref = pathname.startsWith("/projects") ? "/projects" : "/projetos";
75
+
76
+ const handleToolbarAction = (item: ShellContextualAction) => {
77
+ if (item.action === "projects-back-to-portfolio") {
78
+ router.push(projectsBaseHref);
79
+ return;
80
+ }
81
+ if (item.action === "projects-open-board") {
82
+ const projectId = pathname.split("/")[2];
83
+ if (projectId) {
84
+ router.push(`${projectsBaseHref}/${projectId}/${projectsBaseHref === "/projects" ? "tasks" : "tarefas"}`);
85
+ }
86
+ return;
87
+ }
88
+
89
+ if (item.action) {
90
+ window.dispatchEvent(new Event(toolbarWindowEventByAction[item.action] ?? item.action));
91
+ }
92
+ };
55
93
 
56
94
  return (
57
95
  <AppShellFrame
@@ -100,10 +138,14 @@ export function ShellLayoutClient({
100
138
  }
101
139
  header={
102
140
  <AppHeader
141
+ title={activeNavItem?.label}
103
142
  pathname={pathname}
104
143
  toolbarRoutes={toolbarRoutes}
105
144
  toolbarActions={toolbarActions}
106
- />
145
+ onToolbarAction={handleToolbarAction}
146
+ >
147
+ {null}
148
+ </AppHeader>
107
149
  }
108
150
  mobileNav={
109
151
  <MobileNav
@@ -0,0 +1,9 @@
1
+ export async function DELETE(
2
+ request: Request,
3
+ context: { params: Promise<{ invitationId: string }> },
4
+ ) {
5
+ const { handleAdminUserInvitationDeleteRequest } = await import("@brightweblabs/module-admin");
6
+ return handleAdminUserInvitationDeleteRequest(request, context);
7
+ }
8
+
9
+ export const dynamic = "force-dynamic";
@@ -0,0 +1,11 @@
1
+ export async function GET() {
2
+ const { handleAdminUserInvitationsGetRequest } = await import("@brightweblabs/module-admin");
3
+ return handleAdminUserInvitationsGetRequest();
4
+ }
5
+
6
+ export async function POST(request: Request) {
7
+ const { handleAdminUserInvitationsPostRequest } = await import("@brightweblabs/module-admin");
8
+ return handleAdminUserInvitationsPostRequest(request);
9
+ }
10
+
11
+ export const dynamic = "force-dynamic";
@@ -0,0 +1,2 @@
1
+ export const dynamic = "force-dynamic";
2
+ export { handleCrmDashboardOverviewGetRequest as GET } from "@brightweblabs/module-crm";
@@ -0,0 +1,2 @@
1
+ export const dynamic = "force-dynamic";
2
+ export { handleProjectsDashboardOverviewGetRequest as GET } from "@brightweblabs/module-projects";
@@ -0,0 +1,2 @@
1
+ export const dynamic = "force-dynamic";
2
+ export { handleTasksDashboardGetRequest as GET } from "@brightweblabs/module-projects";