@fnd-platform/cms 1.0.0-alpha.12 → 1.0.0-alpha.13
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/lib/templates/admin-content-new-route.d.ts.map +1 -1
- package/lib/templates/admin-content-new-route.js +7 -2
- package/lib/templates/admin-content-new-route.js.map +1 -1
- package/lib/templates/content-editor.d.ts.map +1 -1
- package/lib/templates/content-editor.js +38 -13
- package/lib/templates/content-editor.js.map +1 -1
- package/package.json +13 -13
- package/LICENSE +0 -21
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-content-new-route.d.ts","sourceRoot":"","sources":["../../src/templates/admin-content-new-route.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"admin-content-new-route.d.ts","sourceRoot":"","sources":["../../src/templates/admin-content-new-route.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,+BAA+B,IAAI,MAAM,CAyJxD"}
|
|
@@ -120,8 +120,13 @@ export async function action({ request, params }: ActionFunctionArgs) {
|
|
|
120
120
|
|
|
121
121
|
const created = await contentApi.create(input, token!);
|
|
122
122
|
|
|
123
|
-
//
|
|
124
|
-
|
|
123
|
+
// Return success with redirect URL for client-side navigation
|
|
124
|
+
// This works better with CloudFront/Lambda@Edge setups
|
|
125
|
+
return json<ContentActionData>({
|
|
126
|
+
success: true,
|
|
127
|
+
message: 'Content created successfully',
|
|
128
|
+
redirectTo: \`/admin/content/\${type}/\${created.id}\`,
|
|
129
|
+
});
|
|
125
130
|
} catch (error) {
|
|
126
131
|
return json<ContentActionData>(
|
|
127
132
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin-content-new-route.js","sourceRoot":"","sources":["../../src/templates/admin-content-new-route.ts"],"names":[],"mappings":";;AAOA,
|
|
1
|
+
{"version":3,"file":"admin-content-new-route.js","sourceRoot":"","sources":["../../src/templates/admin-content-new-route.ts"],"names":[],"mappings":";;AAOA,0EAyJC;AAhKD;;;;;;GAMG;AACH,SAAgB,+BAA+B;IAC7C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuJR,CAAC;AACF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-editor.d.ts","sourceRoot":"","sources":["../../src/templates/content-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,
|
|
1
|
+
{"version":3,"file":"content-editor.d.ts","sourceRoot":"","sources":["../../src/templates/content-editor.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,IAAI,MAAM,CA8WjD"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports,
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getContentEditorTemplate = getContentEditorTemplate;
|
|
4
4
|
/**
|
|
5
5
|
* Generates the content editor form component template.
|
|
@@ -10,8 +10,8 @@ exports.getContentEditorTemplate = getContentEditorTemplate;
|
|
|
10
10
|
* @returns Template string for app/components/admin/content-editor.tsx
|
|
11
11
|
*/
|
|
12
12
|
function getContentEditorTemplate() {
|
|
13
|
-
|
|
14
|
-
import {
|
|
13
|
+
return `import { useState, useEffect, useMemo } from 'react';
|
|
14
|
+
import { useNavigation, useActionData, useFetcher } from '@remix-run/react';
|
|
15
15
|
import { Save, Eye, Archive, Trash2, ArrowLeft } from 'lucide-react';
|
|
16
16
|
import type { ContentType, FieldDefinition } from '~/lib/content-types';
|
|
17
17
|
import { generateContentSchema, validateContent, getFieldError } from '~/lib/content-schema';
|
|
@@ -47,6 +47,8 @@ export interface ContentActionData {
|
|
|
47
47
|
success?: boolean;
|
|
48
48
|
errors?: Record<string, string[]>;
|
|
49
49
|
message?: string;
|
|
50
|
+
/** URL to redirect to after successful action (for client-side navigation) */
|
|
51
|
+
redirectTo?: string;
|
|
50
52
|
}
|
|
51
53
|
|
|
52
54
|
/**
|
|
@@ -77,7 +79,21 @@ export function ContentEditor({
|
|
|
77
79
|
}: ContentEditorProps) {
|
|
78
80
|
const navigation = useNavigation();
|
|
79
81
|
const actionData = useActionData<ContentActionData>();
|
|
80
|
-
const
|
|
82
|
+
const fetcher = useFetcher<ContentActionData>();
|
|
83
|
+
|
|
84
|
+
// Use fetcher state for submission tracking (more reliable with CloudFront/Lambda)
|
|
85
|
+
const isSubmitting = fetcher.state === 'submitting' || navigation.state === 'submitting';
|
|
86
|
+
|
|
87
|
+
// Use fetcher data if available, otherwise fall back to actionData
|
|
88
|
+
const responseData = fetcher.data ?? actionData;
|
|
89
|
+
|
|
90
|
+
// Handle redirect after successful action
|
|
91
|
+
useEffect(() => {
|
|
92
|
+
if (responseData?.success && responseData?.redirectTo) {
|
|
93
|
+
// Use window.location for reliable navigation with CloudFront/Lambda
|
|
94
|
+
window.location.href = responseData.redirectTo;
|
|
95
|
+
}
|
|
96
|
+
}, [responseData]);
|
|
81
97
|
|
|
82
98
|
// Initialize form data from initial data or defaults
|
|
83
99
|
const [formData, setFormData] = useState<Record<string, unknown>>(() => {
|
|
@@ -121,8 +137,8 @@ export function ContentEditor({
|
|
|
121
137
|
|
|
122
138
|
// Combine client and server errors
|
|
123
139
|
const allErrors = useMemo(() => {
|
|
124
|
-
return { ...clientErrors, ...(
|
|
125
|
-
}, [clientErrors,
|
|
140
|
+
return { ...clientErrors, ...(responseData?.errors ?? {}) };
|
|
141
|
+
}, [clientErrors, responseData?.errors]);
|
|
126
142
|
|
|
127
143
|
// Generate validation schema
|
|
128
144
|
const schema = useMemo(() => generateContentSchema(contentType), [contentType]);
|
|
@@ -190,8 +206,8 @@ export function ContentEditor({
|
|
|
190
206
|
</div>
|
|
191
207
|
</div>
|
|
192
208
|
|
|
193
|
-
{/* Form */}
|
|
194
|
-
<Form
|
|
209
|
+
{/* Form - using fetcher.Form for reliable submission with CloudFront/Lambda */}
|
|
210
|
+
<fetcher.Form
|
|
195
211
|
method="post"
|
|
196
212
|
onSubmit={(e) => {
|
|
197
213
|
if (!validateForm()) {
|
|
@@ -330,13 +346,22 @@ export function ContentEditor({
|
|
|
330
346
|
</div>
|
|
331
347
|
</div>
|
|
332
348
|
|
|
349
|
+
{/* Success Message - shows briefly before redirect */}
|
|
350
|
+
{responseData?.success && responseData?.redirectTo && (
|
|
351
|
+
<div className="mt-6 p-4 bg-green-500/10 border border-green-500 rounded-md">
|
|
352
|
+
<p className="text-sm text-green-700">
|
|
353
|
+
{responseData.message} Redirecting...
|
|
354
|
+
</p>
|
|
355
|
+
</div>
|
|
356
|
+
)}
|
|
357
|
+
|
|
333
358
|
{/* Error Summary */}
|
|
334
|
-
{
|
|
359
|
+
{responseData?.message && !responseData.success && (
|
|
335
360
|
<div className="mt-6 p-4 bg-destructive/10 border border-destructive rounded-md">
|
|
336
|
-
<p className="text-sm text-destructive">{
|
|
361
|
+
<p className="text-sm text-destructive">{responseData.message}</p>
|
|
337
362
|
</div>
|
|
338
363
|
)}
|
|
339
|
-
</Form>
|
|
364
|
+
</fetcher.Form>
|
|
340
365
|
</div>
|
|
341
366
|
);
|
|
342
367
|
}
|
|
@@ -351,4 +376,4 @@ function isMetaField(field: FieldDefinition): boolean {
|
|
|
351
376
|
}
|
|
352
377
|
`;
|
|
353
378
|
}
|
|
354
|
-
//# sourceMappingURL=content-editor.js.map
|
|
379
|
+
//# sourceMappingURL=content-editor.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"content-editor.js","sourceRoot":"","sources":["../../src/templates/content-editor.ts"],"names":[],"mappings":";;AAQA,
|
|
1
|
+
{"version":3,"file":"content-editor.js","sourceRoot":"","sources":["../../src/templates/content-editor.ts"],"names":[],"mappings":";;AAQA,4DA8WC;AAtXD;;;;;;;GAOG;AACH,SAAgB,wBAAwB;IACtC,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4WR,CAAC;AACF,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,17 +1,24 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fnd-platform/cms",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.13",
|
|
4
4
|
"description": "Projen project class for generating CMS admin packages in fnd-platform",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"types": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
8
8
|
"lib/"
|
|
9
9
|
],
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc",
|
|
12
|
+
"test": "vitest run",
|
|
13
|
+
"test:watch": "vitest",
|
|
14
|
+
"test:coverage": "vitest run --coverage",
|
|
15
|
+
"lint": "eslint src/ test/"
|
|
16
|
+
},
|
|
10
17
|
"dependencies": {
|
|
11
|
-
"
|
|
12
|
-
"@fnd-platform/
|
|
13
|
-
"@fnd-platform/
|
|
14
|
-
"
|
|
18
|
+
"@fnd-platform/api": "workspace:^",
|
|
19
|
+
"@fnd-platform/core": "workspace:^",
|
|
20
|
+
"@fnd-platform/frontend": "workspace:^",
|
|
21
|
+
"projen": "^0.91.0"
|
|
15
22
|
},
|
|
16
23
|
"peerDependencies": {
|
|
17
24
|
"projen": "^0.91.0"
|
|
@@ -41,12 +48,5 @@
|
|
|
41
48
|
"type": "git",
|
|
42
49
|
"url": "https://github.com/your-org/fnd-platform",
|
|
43
50
|
"directory": "packages/cms"
|
|
44
|
-
},
|
|
45
|
-
"scripts": {
|
|
46
|
-
"build": "tsc",
|
|
47
|
-
"test": "vitest run",
|
|
48
|
-
"test:watch": "vitest",
|
|
49
|
-
"test:coverage": "vitest run --coverage",
|
|
50
|
-
"lint": "eslint src/ test/"
|
|
51
51
|
}
|
|
52
|
-
}
|
|
52
|
+
}
|
package/LICENSE
DELETED
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2024 fnd-platform contributors
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|