create-bw-app 0.18.3 → 0.18.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/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.4",
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: [
@@ -165,14 +167,14 @@ export const PLATFORM_STARTER_FILES = [
165
167
  ];
166
168
 
167
169
  export const APP_DEPENDENCY_DEFAULTS = {
168
- "@brightweblabs/app-shell": "^0.7.2",
170
+ "@brightweblabs/app-shell": "^0.7.3",
169
171
  "@brightweblabs/core-auth": "^0.7.2",
170
172
  "@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",
173
+ "@brightweblabs/module-admin": "^0.5.9",
174
+ "@brightweblabs/module-crm": "^0.9.4",
175
+ "@brightweblabs/module-marketing": "^0.2.8",
176
+ "@brightweblabs/module-orgs": "^0.3.9",
177
+ "@brightweblabs/module-projects": "^0.8.2",
176
178
  "@brightweblabs/theme": "^0.5.0",
177
179
  "@brightweblabs/ui": "^1.1.1",
178
180
  "geist": "1.7.2",
@@ -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";