@carlonicora/nextjs-jsonapi 1.19.0 → 1.19.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/scripts/generate-web-module/generator.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/generator.js +5 -71
- package/dist/scripts/generate-web-module/generator.js.map +1 -1
- package/dist/scripts/generate-web-module/templates/index.d.ts +0 -8
- package/dist/scripts/generate-web-module/templates/index.d.ts.map +1 -1
- package/dist/scripts/generate-web-module/templates/index.js +1 -18
- package/dist/scripts/generate-web-module/templates/index.js.map +1 -1
- package/dist/testing/index.js +1 -1
- package/dist/testing/index.js.map +1 -1
- package/dist/testing/index.mjs +1 -1
- package/dist/testing/index.mjs.map +1 -1
- package/package.json +1 -1
- package/scripts/generate-web-module/generator.ts +23 -111
- package/scripts/generate-web-module/templates/index.ts +0 -10
- package/src/testing/factories/createMockApiData.ts +1 -1
- package/dist/scripts/generate-web-module/templates/project/bootstrapper.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/bootstrapper.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/bootstrapper.template.js +0 -141
- package/dist/scripts/generate-web-module/templates/project/bootstrapper.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/env.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/env.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/env.template.js +0 -110
- package/dist/scripts/generate-web-module/templates/project/env.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/main-layout.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/main-layout.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/main-layout.template.js +0 -101
- package/dist/scripts/generate-web-module/templates/project/main-layout.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/middleware-env.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/middleware-env.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/middleware-env.template.js +0 -66
- package/dist/scripts/generate-web-module/templates/project/middleware-env.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-container.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/settings-container.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-container.template.js +0 -257
- package/dist/scripts/generate-web-module/templates/project/settings-container.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-context.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/settings-context.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-context.template.js +0 -124
- package/dist/scripts/generate-web-module/templates/project/settings-context.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.js +0 -78
- package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.js.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-page.template.d.ts +0 -7
- package/dist/scripts/generate-web-module/templates/project/settings-page.template.d.ts.map +0 -1
- package/dist/scripts/generate-web-module/templates/project/settings-page.template.js +0 -75
- package/dist/scripts/generate-web-module/templates/project/settings-page.template.js.map +0 -1
- package/scripts/generate-web-module/templates/project/bootstrapper.template.ts +0 -108
- package/scripts/generate-web-module/templates/project/env.template.ts +0 -77
- package/scripts/generate-web-module/templates/project/main-layout.template.tsx +0 -68
- package/scripts/generate-web-module/templates/project/middleware-env.template.ts +0 -33
- package/scripts/generate-web-module/templates/project/settings-container.template.tsx +0 -224
- package/scripts/generate-web-module/templates/project/settings-context.template.tsx +0 -91
- package/scripts/generate-web-module/templates/project/settings-module-page.template.tsx +0 -45
- package/scripts/generate-web-module/templates/project/settings-page.template.tsx +0 -42
package/dist/scripts/generate-web-module/templates/project/settings-container.template.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-container.template.d.ts","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-container.template.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,wBAAgB,iCAAiC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAsNpF"}
|
|
@@ -1,257 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Settings Container Template
|
|
4
|
-
*
|
|
5
|
-
* Generates SettingsContainer with company and billing sections (including Stripe)
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.generateSettingsContainerTemplate = generateSettingsContainerTemplate;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
function generateSettingsContainerTemplate(webBasePath) {
|
|
45
|
-
const outputPath = path.join(webBasePath, "apps/web/src/features/common/components/containers/SettingsContainer.tsx");
|
|
46
|
-
if (fs.existsSync(outputPath)) {
|
|
47
|
-
return null; // Skip if exists
|
|
48
|
-
}
|
|
49
|
-
return `"use client";
|
|
50
|
-
|
|
51
|
-
import { useSettingsContext } from "@/features/common/contexts/SettingsContext";
|
|
52
|
-
import { cn } from "@/utils/cn";
|
|
53
|
-
import { Action, ModuleWithPermissions, Modules, getRoleId } from "@carlonicora/nextjs-jsonapi";
|
|
54
|
-
import { usePageUrlGenerator } from "@carlonicora/nextjs-jsonapi/client";
|
|
55
|
-
import {
|
|
56
|
-
CompanyContainer,
|
|
57
|
-
ContentTitle,
|
|
58
|
-
InvoicesContainer,
|
|
59
|
-
PaymentMethodsContainer,
|
|
60
|
-
ProductsAdminContainer,
|
|
61
|
-
SubscriptionsContainer,
|
|
62
|
-
UsageContainer,
|
|
63
|
-
UsersListContainer,
|
|
64
|
-
isStripeConfigured,
|
|
65
|
-
} from "@carlonicora/nextjs-jsonapi/components";
|
|
66
|
-
import { useCurrentUserContext } from "@carlonicora/nextjs-jsonapi/contexts";
|
|
67
|
-
|
|
68
|
-
import { Activity, Building2Icon, CreditCard, LucideIcon, Package, Receipt, UsersIcon, Wallet } from "lucide-react";
|
|
69
|
-
import { useLocale, useTranslations } from "next-intl";
|
|
70
|
-
import { ReactNode, useEffect, useState } from "react";
|
|
71
|
-
|
|
72
|
-
type SidebarItem = {
|
|
73
|
-
id: string;
|
|
74
|
-
icon: LucideIcon;
|
|
75
|
-
label?: string;
|
|
76
|
-
container: ReactNode;
|
|
77
|
-
module: ModuleWithPermissions;
|
|
78
|
-
singleItem?: boolean;
|
|
79
|
-
requiredPermission?: Action;
|
|
80
|
-
requiredRole?: string;
|
|
81
|
-
hidden?: boolean;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export default function SettingsContainer() {
|
|
85
|
-
const { module, setModule } = useSettingsContext();
|
|
86
|
-
const t = useTranslations();
|
|
87
|
-
const locale = useLocale();
|
|
88
|
-
const { hasPermissionToModule, hasRole } = useCurrentUserContext();
|
|
89
|
-
const [selectedComponent, setSelectedComponent] = useState<SidebarItem | null>(null);
|
|
90
|
-
const [subscriptions, setSubscriptions] = useState<any[]>([]);
|
|
91
|
-
const generateUrl = usePageUrlGenerator();
|
|
92
|
-
|
|
93
|
-
// Helper function to check if company has metered subscriptions
|
|
94
|
-
const hasMeteredSubscriptions = (): boolean => {
|
|
95
|
-
return subscriptions.some((sub) => sub.price?.recurring?.usageType === "metered");
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
// Build sidebars array - only include billing if Stripe is configured
|
|
99
|
-
const billingSection = isStripeConfigured()
|
|
100
|
-
? !hasRole(getRoleId().Administrator)
|
|
101
|
-
? {
|
|
102
|
-
name: "billing",
|
|
103
|
-
label: t("billing.title"),
|
|
104
|
-
items: [
|
|
105
|
-
{
|
|
106
|
-
id: "billing-subscriptions",
|
|
107
|
-
icon: CreditCard,
|
|
108
|
-
label: t("billing.subscriptions.title"),
|
|
109
|
-
container: <SubscriptionsContainer />,
|
|
110
|
-
module: Modules.Billing,
|
|
111
|
-
requiredPermission: Action.Read,
|
|
112
|
-
},
|
|
113
|
-
{
|
|
114
|
-
id: "billing-payment-methods",
|
|
115
|
-
icon: Wallet,
|
|
116
|
-
label: t("billing.payment_methods.title"),
|
|
117
|
-
container: <PaymentMethodsContainer />,
|
|
118
|
-
module: Modules.Billing,
|
|
119
|
-
requiredPermission: Action.Read,
|
|
120
|
-
},
|
|
121
|
-
{
|
|
122
|
-
id: "billing-invoices",
|
|
123
|
-
icon: Receipt,
|
|
124
|
-
label: t("billing.invoices.title"),
|
|
125
|
-
container: <InvoicesContainer />,
|
|
126
|
-
module: Modules.Billing,
|
|
127
|
-
requiredPermission: Action.Read,
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
id: "billing-usage",
|
|
131
|
-
icon: Activity,
|
|
132
|
-
label: t("billing.usage.title"),
|
|
133
|
-
container: <UsageContainer />,
|
|
134
|
-
module: Modules.Billing,
|
|
135
|
-
requiredPermission: Action.Read,
|
|
136
|
-
hidden: !hasMeteredSubscriptions(),
|
|
137
|
-
},
|
|
138
|
-
],
|
|
139
|
-
}
|
|
140
|
-
: {
|
|
141
|
-
name: \`billing\`,
|
|
142
|
-
label: t("billing.title"),
|
|
143
|
-
items: [
|
|
144
|
-
{
|
|
145
|
-
id: "billing-admin-products",
|
|
146
|
-
icon: Package,
|
|
147
|
-
label: t("billing.admin.products.title"),
|
|
148
|
-
container: <ProductsAdminContainer />,
|
|
149
|
-
module: Modules.Billing,
|
|
150
|
-
requiredRole: getRoleId().Administrator,
|
|
151
|
-
},
|
|
152
|
-
],
|
|
153
|
-
}
|
|
154
|
-
: null;
|
|
155
|
-
|
|
156
|
-
const companySection = !hasRole(getRoleId().Administrator)
|
|
157
|
-
? {
|
|
158
|
-
name: \`company\`,
|
|
159
|
-
items: [
|
|
160
|
-
{
|
|
161
|
-
id: "company",
|
|
162
|
-
icon: Building2Icon,
|
|
163
|
-
container: <CompanyContainer />,
|
|
164
|
-
module: Modules.Company,
|
|
165
|
-
singleItem: true,
|
|
166
|
-
},
|
|
167
|
-
{ id: "user", icon: UsersIcon, container: <UsersListContainer />, module: Modules.User },
|
|
168
|
-
],
|
|
169
|
-
}
|
|
170
|
-
: null;
|
|
171
|
-
|
|
172
|
-
const sidebars: {
|
|
173
|
-
name: string;
|
|
174
|
-
label?: string;
|
|
175
|
-
items: SidebarItem[];
|
|
176
|
-
}[] = [...(companySection ? [companySection] : []), ...(billingSection ? [billingSection] : [])];
|
|
177
|
-
|
|
178
|
-
useEffect(() => {
|
|
179
|
-
if (module) {
|
|
180
|
-
const found = sidebars
|
|
181
|
-
.map((sidebar) => sidebar.items.find((item) => item.module.name === module.name))
|
|
182
|
-
.find((item) => item !== undefined);
|
|
183
|
-
if (found) {
|
|
184
|
-
setSelectedComponent(found);
|
|
185
|
-
} else {
|
|
186
|
-
setSelectedComponent(null);
|
|
187
|
-
setModule(undefined);
|
|
188
|
-
}
|
|
189
|
-
} else {
|
|
190
|
-
setSelectedComponent(null);
|
|
191
|
-
}
|
|
192
|
-
}, [module]);
|
|
193
|
-
|
|
194
|
-
return (
|
|
195
|
-
<div className="flex w-full gap-x-4">
|
|
196
|
-
<div className="sticky top-16 flex h-[calc(100vh-theme(spacing.20))] w-2xl flex-col justify-between border-r pr-4">
|
|
197
|
-
<div className="flex min-h-0 flex-1 overflow-y-auto">
|
|
198
|
-
<div className="flex w-full flex-col">
|
|
199
|
-
<ContentTitle element={t(\`generic.settings\`)} />
|
|
200
|
-
<nav className="space-y-4">
|
|
201
|
-
{sidebars.map((sidebar) => (
|
|
202
|
-
<div key={sidebar.name} className="">
|
|
203
|
-
<h3 className="text-muted-foreground mb-2 text-lg font-light">
|
|
204
|
-
{sidebar.label || t(\`generic.settings_sidebar\`, { item: sidebar.name })}
|
|
205
|
-
</h3>
|
|
206
|
-
{sidebar.items.map((item) => {
|
|
207
|
-
// Check if item is hidden
|
|
208
|
-
if (item.hidden) return null;
|
|
209
|
-
|
|
210
|
-
// Check permission-based access
|
|
211
|
-
if (item.requiredPermission) {
|
|
212
|
-
if (!hasPermissionToModule({ module: item.module, action: item.requiredPermission })) return null;
|
|
213
|
-
} else if (!hasPermissionToModule({ module: item.module, action: Action.Read })) {
|
|
214
|
-
return null;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
// Check role-based access
|
|
218
|
-
if (item.requiredRole && !hasRole(item.requiredRole)) return null;
|
|
219
|
-
|
|
220
|
-
const Icon = item.icon;
|
|
221
|
-
return (
|
|
222
|
-
<button
|
|
223
|
-
key={item.id}
|
|
224
|
-
onClick={() => {
|
|
225
|
-
setModule(item.module);
|
|
226
|
-
setSelectedComponent(item);
|
|
227
|
-
window.history.replaceState(
|
|
228
|
-
null,
|
|
229
|
-
"",
|
|
230
|
-
generateUrl({ page: \`/settings\`, id: item.module.name, language: locale }),
|
|
231
|
-
);
|
|
232
|
-
}}
|
|
233
|
-
className={cn(
|
|
234
|
-
"flex w-full items-center gap-3 rounded-md px-3 py-2 text-sm transition-colors",
|
|
235
|
-
selectedComponent?.id === item.id
|
|
236
|
-
? "bg-secondary text-secondary-foreground"
|
|
237
|
-
: "text-muted-foreground hover:text-foreground hover:bg-secondary/50",
|
|
238
|
-
)}
|
|
239
|
-
>
|
|
240
|
-
<Icon className="h-4 w-4" />
|
|
241
|
-
{item.label || t(\`types.\${item.module.name}\`, { count: item.singleItem ? 1 : 2 })}
|
|
242
|
-
</button>
|
|
243
|
-
);
|
|
244
|
-
})}
|
|
245
|
-
</div>
|
|
246
|
-
))}
|
|
247
|
-
</nav>
|
|
248
|
-
</div>
|
|
249
|
-
</div>
|
|
250
|
-
</div>
|
|
251
|
-
<div className="flex w-full flex-col gap-y-4 pb-20">{selectedComponent ? selectedComponent.container : null}</div>
|
|
252
|
-
</div>
|
|
253
|
-
);
|
|
254
|
-
}
|
|
255
|
-
`;
|
|
256
|
-
}
|
|
257
|
-
//# sourceMappingURL=settings-container.template.js.map
|
package/dist/scripts/generate-web-module/templates/project/settings-container.template.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-container.template.js","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-container.template.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKH,8EAsNC;AAzND,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,iCAAiC,CAAC,WAAmB;IACnE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,0EAA0E,CAAC,CAAC;IAEtH,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,CAAC,iBAAiB;IAChC,CAAC;IAED,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8MR,CAAC;AACF,CAAC"}
|
package/dist/scripts/generate-web-module/templates/project/settings-context.template.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-context.template.d.ts","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-context.template.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,wBAAgB,+BAA+B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAiFlF"}
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Settings Context Template
|
|
4
|
-
*
|
|
5
|
-
* Generates SettingsContext with module-based navigation
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.generateSettingsContextTemplate = generateSettingsContextTemplate;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
function generateSettingsContextTemplate(webBasePath) {
|
|
45
|
-
const outputPath = path.join(webBasePath, "apps/web/src/features/common/contexts/SettingsContext.tsx");
|
|
46
|
-
if (fs.existsSync(outputPath)) {
|
|
47
|
-
return null; // Skip if exists
|
|
48
|
-
}
|
|
49
|
-
return `"use client";
|
|
50
|
-
|
|
51
|
-
import { BreadcrumbItemData, Modules, ModuleWithPermissions } from "@carlonicora/nextjs-jsonapi";
|
|
52
|
-
import { usePageUrlGenerator } from "@carlonicora/nextjs-jsonapi/client";
|
|
53
|
-
import { SharedProvider } from "@carlonicora/nextjs-jsonapi/contexts";
|
|
54
|
-
import { useTranslations } from "next-intl";
|
|
55
|
-
import { createContext, ReactNode, useContext, useState } from "react";
|
|
56
|
-
|
|
57
|
-
interface SettingsContextType {
|
|
58
|
-
module?: ModuleWithPermissions;
|
|
59
|
-
setModule: (module: ModuleWithPermissions | undefined) => void;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
const SettingsContext = createContext<SettingsContextType | undefined>(undefined);
|
|
63
|
-
|
|
64
|
-
type SettingsProviderProps = {
|
|
65
|
-
children: ReactNode;
|
|
66
|
-
moduleName?: string;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export const SettingsProvider = ({ children, moduleName }: SettingsProviderProps) => {
|
|
70
|
-
const [module, setModule] = useState<ModuleWithPermissions | undefined>(
|
|
71
|
-
moduleName ? Modules.findByName(moduleName) : undefined,
|
|
72
|
-
);
|
|
73
|
-
const generateUrl = usePageUrlGenerator();
|
|
74
|
-
const t = useTranslations();
|
|
75
|
-
|
|
76
|
-
const breadcrumb = () => {
|
|
77
|
-
const response: BreadcrumbItemData[] = [];
|
|
78
|
-
|
|
79
|
-
response.push({
|
|
80
|
-
name: t(\`generic.settings\`),
|
|
81
|
-
href: generateUrl({ page: \`/settings\` }),
|
|
82
|
-
});
|
|
83
|
-
|
|
84
|
-
if (module)
|
|
85
|
-
response.push({
|
|
86
|
-
name: t(\`types.\${module.name}\`, { count: 2 }),
|
|
87
|
-
href: generateUrl({ page: \`/settings\`, id: module.name }),
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
return response;
|
|
91
|
-
};
|
|
92
|
-
|
|
93
|
-
const title = () => {
|
|
94
|
-
const response: any = {
|
|
95
|
-
type: t(\`generic.settings\`),
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
return response;
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
return (
|
|
102
|
-
<SharedProvider value={{ breadcrumbs: breadcrumb(), title: title() }}>
|
|
103
|
-
<SettingsContext.Provider
|
|
104
|
-
value={{
|
|
105
|
-
module: module,
|
|
106
|
-
setModule: setModule,
|
|
107
|
-
}}
|
|
108
|
-
>
|
|
109
|
-
{children}
|
|
110
|
-
</SettingsContext.Provider>
|
|
111
|
-
</SharedProvider>
|
|
112
|
-
);
|
|
113
|
-
};
|
|
114
|
-
|
|
115
|
-
export const useSettingsContext = (): SettingsContextType => {
|
|
116
|
-
const context = useContext(SettingsContext);
|
|
117
|
-
if (context === undefined) {
|
|
118
|
-
throw new Error("useSettingsContext must be used within a SettingsProvider");
|
|
119
|
-
}
|
|
120
|
-
return context;
|
|
121
|
-
};
|
|
122
|
-
`;
|
|
123
|
-
}
|
|
124
|
-
//# sourceMappingURL=settings-context.template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-context.template.js","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-context.template.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKH,0EAiFC;AApFD,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,+BAA+B,CAAC,WAAmB;IACjE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,2DAA2D,CAAC,CAAC;IAEvG,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,CAAC,iBAAiB;IAChC,CAAC;IAED,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAyER,CAAC;AACF,CAAC"}
|
package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.d.ts
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Settings Module Page Template
|
|
3
|
-
*
|
|
4
|
-
* Generates module-specific settings page with module selection
|
|
5
|
-
*/
|
|
6
|
-
export declare function generateSettingsModulePageTemplate(webBasePath: string): string | null;
|
|
7
|
-
//# sourceMappingURL=settings-module-page.template.d.ts.map
|
package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-module-page.template.d.ts","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-module-page.template.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,wBAAgB,kCAAkC,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAmCrF"}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Settings Module Page Template
|
|
4
|
-
*
|
|
5
|
-
* Generates module-specific settings page with module selection
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.generateSettingsModulePageTemplate = generateSettingsModulePageTemplate;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
function generateSettingsModulePageTemplate(webBasePath) {
|
|
45
|
-
const outputPath = path.join(webBasePath, "apps/web/src/app/[locale]/(main)/(features)/settings/[module]/page.tsx");
|
|
46
|
-
if (fs.existsSync(outputPath)) {
|
|
47
|
-
return null; // Skip if exists
|
|
48
|
-
}
|
|
49
|
-
return `import SettingsContainer from "@/features/common/components/containers/SettingsContainer";
|
|
50
|
-
import { SettingsProvider } from "@/features/common/contexts/SettingsContext";
|
|
51
|
-
import { generateSpecificMetadata } from "@/utils/metadata";
|
|
52
|
-
import { PageContainer } from "@carlonicora/nextjs-jsonapi/components";
|
|
53
|
-
import { Metadata } from "next";
|
|
54
|
-
import { getTranslations } from "next-intl/server";
|
|
55
|
-
|
|
56
|
-
export async function generateMetadata(): Promise<Metadata> {
|
|
57
|
-
const t = await getTranslations();
|
|
58
|
-
|
|
59
|
-
const title = t(\`generic.settings\`);
|
|
60
|
-
|
|
61
|
-
return await generateSpecificMetadata({ title: title });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default async function SettingsModulePage(props: {
|
|
65
|
-
params: Promise<{ module: string }>;
|
|
66
|
-
}) {
|
|
67
|
-
const params = await props.params;
|
|
68
|
-
return (
|
|
69
|
-
<SettingsProvider moduleName={params.module}>
|
|
70
|
-
<PageContainer>
|
|
71
|
-
<SettingsContainer />
|
|
72
|
-
</PageContainer>
|
|
73
|
-
</SettingsProvider>
|
|
74
|
-
);
|
|
75
|
-
}
|
|
76
|
-
`;
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=settings-module-page.template.js.map
|
package/dist/scripts/generate-web-module/templates/project/settings-module-page.template.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-module-page.template.js","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-module-page.template.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKH,gFAmCC;AAtCD,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,kCAAkC,CAAC,WAAmB;IACpE,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,wEAAwE,CAAC,CAAC;IAEpH,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,CAAC,iBAAiB;IAChC,CAAC;IAED,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2BR,CAAC;AACF,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-page.template.d.ts","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-page.template.tsx"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,wBAAgB,4BAA4B,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAgC/E"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Settings Page Template
|
|
4
|
-
*
|
|
5
|
-
* Generates base settings page without module selection
|
|
6
|
-
*/
|
|
7
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
8
|
-
if (k2 === undefined) k2 = k;
|
|
9
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
10
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
11
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
12
|
-
}
|
|
13
|
-
Object.defineProperty(o, k2, desc);
|
|
14
|
-
}) : (function(o, m, k, k2) {
|
|
15
|
-
if (k2 === undefined) k2 = k;
|
|
16
|
-
o[k2] = m[k];
|
|
17
|
-
}));
|
|
18
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
19
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
20
|
-
}) : function(o, v) {
|
|
21
|
-
o["default"] = v;
|
|
22
|
-
});
|
|
23
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
24
|
-
var ownKeys = function(o) {
|
|
25
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
26
|
-
var ar = [];
|
|
27
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
28
|
-
return ar;
|
|
29
|
-
};
|
|
30
|
-
return ownKeys(o);
|
|
31
|
-
};
|
|
32
|
-
return function (mod) {
|
|
33
|
-
if (mod && mod.__esModule) return mod;
|
|
34
|
-
var result = {};
|
|
35
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
36
|
-
__setModuleDefault(result, mod);
|
|
37
|
-
return result;
|
|
38
|
-
};
|
|
39
|
-
})();
|
|
40
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
|
-
exports.generateSettingsPageTemplate = generateSettingsPageTemplate;
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
const path = __importStar(require("path"));
|
|
44
|
-
function generateSettingsPageTemplate(webBasePath) {
|
|
45
|
-
const outputPath = path.join(webBasePath, "apps/web/src/app/[locale]/(main)/(features)/settings/page.tsx");
|
|
46
|
-
if (fs.existsSync(outputPath)) {
|
|
47
|
-
return null; // Skip if exists
|
|
48
|
-
}
|
|
49
|
-
return `import SettingsContainer from "@/features/common/components/containers/SettingsContainer";
|
|
50
|
-
import { SettingsProvider } from "@/features/common/contexts/SettingsContext";
|
|
51
|
-
import { generateSpecificMetadata } from "@/utils/metadata";
|
|
52
|
-
import { PageContainer } from "@carlonicora/nextjs-jsonapi/components";
|
|
53
|
-
import { Metadata } from "next";
|
|
54
|
-
import { getTranslations } from "next-intl/server";
|
|
55
|
-
|
|
56
|
-
export async function generateMetadata(): Promise<Metadata> {
|
|
57
|
-
const t = await getTranslations();
|
|
58
|
-
|
|
59
|
-
const title = t(\`generic.settings\`);
|
|
60
|
-
|
|
61
|
-
return await generateSpecificMetadata({ title: title });
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default async function SettingsPage() {
|
|
65
|
-
return (
|
|
66
|
-
<SettingsProvider>
|
|
67
|
-
<PageContainer>
|
|
68
|
-
<SettingsContainer />
|
|
69
|
-
</PageContainer>
|
|
70
|
-
</SettingsProvider>
|
|
71
|
-
);
|
|
72
|
-
}
|
|
73
|
-
`;
|
|
74
|
-
}
|
|
75
|
-
//# sourceMappingURL=settings-page.template.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"settings-page.template.js","sourceRoot":"","sources":["../../../../../scripts/generate-web-module/templates/project/settings-page.template.tsx"],"names":[],"mappings":";AAAA;;;;GAIG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKH,oEAgCC;AAnCD,uCAAyB;AACzB,2CAA6B;AAE7B,SAAgB,4BAA4B,CAAC,WAAmB;IAC9D,MAAM,UAAU,GAAG,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,+DAA+D,CAAC,CAAC;IAE3G,IAAI,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC,EAAE,CAAC;QAC9B,OAAO,IAAI,CAAC,CAAC,iBAAiB;IAChC,CAAC;IAED,OAAO;;;;;;;;;;;;;;;;;;;;;;;;CAwBR,CAAC;AACF,CAAC"}
|