@nestledjs/data-browser 0.1.17 → 0.1.20
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/components/RelationFieldWrapper.js +35 -22
- package/lib/components/filters/DateRangeFilter.js +39 -48
- package/lib/components/filters/NumberRangeFilter.js +43 -48
- package/lib/components/filters/RelationComponents.js +96 -102
- package/lib/components/filters/RelationFilterField.js +50 -47
- package/lib/components/shared/AdminBreadcrumbs.js +41 -45
- package/lib/components/shared/AdminErrorStates.js +47 -93
- package/lib/components/shared/AdminStatusDisplay.js +29 -36
- package/lib/context/AdminDataContext.js +10 -14
- package/lib/layouts/AdminDataLayout.js +90 -177
- package/lib/pages/AdminDataCreatePage.js +141 -267
- package/lib/pages/AdminDataEditPage.js +258 -460
- package/lib/pages/AdminDataIndexPage.js +31 -55
- package/lib/pages/AdminDataListPage.js +583 -597
- package/package.json +3 -3
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState, useMemo, useEffect } from "react";
|
|
2
3
|
import { gql } from "@apollo/client";
|
|
3
4
|
import { useQuery, useMutation } from "@apollo/client/react";
|
|
4
5
|
import { loadDevMessages, loadErrorMessages } from "@apollo/client/dev";
|
|
@@ -9,7 +10,6 @@ import { Form } from "@nestledjs/forms";
|
|
|
9
10
|
import { useAdminDataContext } from "../context/AdminDataContext.js";
|
|
10
11
|
import { useParams, Link, useNavigate } from "react-router";
|
|
11
12
|
import { getAdminDocuments, buildFormFields, cleanFormInput } from "../utils/graphql-utils.js";
|
|
12
|
-
var _jsxFileName = "/Users/justinhandley/IdeaProjects/nestled_template/libs/data-browser/src/lib/pages/AdminDataEditPage.tsx";
|
|
13
13
|
function toLowerCamelCase(name) {
|
|
14
14
|
if (!name) return "";
|
|
15
15
|
return name.charAt(0).toLowerCase() + name.slice(1);
|
|
@@ -44,15 +44,8 @@ const validateId = (id) => {
|
|
|
44
44
|
return sanitized;
|
|
45
45
|
};
|
|
46
46
|
function AdminDataEditPage() {
|
|
47
|
-
const {
|
|
48
|
-
|
|
49
|
-
id
|
|
50
|
-
} = useParams();
|
|
51
|
-
const {
|
|
52
|
-
databaseModels,
|
|
53
|
-
basePath = "/admin/data",
|
|
54
|
-
formTheme
|
|
55
|
-
} = useAdminDataContext();
|
|
47
|
+
const { dataType, id } = useParams();
|
|
48
|
+
const { databaseModels, basePath = "/admin/data", formTheme } = useAdminDataContext();
|
|
56
49
|
const findModelByName = (name) => {
|
|
57
50
|
return databaseModels.find((model2) => model2.name === name);
|
|
58
51
|
};
|
|
@@ -73,106 +66,46 @@ function AdminDataEditPage() {
|
|
|
73
66
|
const model = validatedDataType ? findModelByName(validatedDataType) : null;
|
|
74
67
|
const shouldShowModelNotFound = validatedDataType && validatedId && !model;
|
|
75
68
|
if (shouldShowUnauthorized) {
|
|
76
|
-
return /* @__PURE__ */
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
} }
|
|
89
|
-
fileName: _jsxFileName,
|
|
90
|
-
lineNumber: 119,
|
|
91
|
-
columnNumber: 13
|
|
92
|
-
} }, /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-red-400", __self: this, __source: {
|
|
93
|
-
fileName: _jsxFileName,
|
|
94
|
-
lineNumber: 120,
|
|
95
|
-
columnNumber: 15
|
|
96
|
-
} }), /* @__PURE__ */ React.createElement("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
|
|
97
|
-
fileName: _jsxFileName,
|
|
98
|
-
lineNumber: 121,
|
|
99
|
-
columnNumber: 15
|
|
100
|
-
} }, "Unauthorized"), /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", __self: this, __source: {
|
|
101
|
-
fileName: _jsxFileName,
|
|
102
|
-
lineNumber: 122,
|
|
103
|
-
columnNumber: 15
|
|
104
|
-
} }, "Invalid data type, ID, or insufficient permissions."), /* @__PURE__ */ React.createElement("div", { className: "mt-6", __self: this, __source: {
|
|
105
|
-
fileName: _jsxFileName,
|
|
106
|
-
lineNumber: 125,
|
|
107
|
-
columnNumber: 15
|
|
108
|
-
} }, /* @__PURE__ */ React.createElement(Link, { to: basePath, className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web", __self: this, __source: {
|
|
109
|
-
fileName: _jsxFileName,
|
|
110
|
-
lineNumber: 126,
|
|
111
|
-
columnNumber: 17
|
|
112
|
-
} }, "Return to Data Browser"))))));
|
|
69
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ jsx("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
70
|
+
/* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-red-400" }),
|
|
71
|
+
/* @__PURE__ */ jsx("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", children: "Unauthorized" }),
|
|
72
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", children: "Invalid data type, ID, or insufficient permissions." }),
|
|
73
|
+
/* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(
|
|
74
|
+
Link,
|
|
75
|
+
{
|
|
76
|
+
to: basePath,
|
|
77
|
+
className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
78
|
+
children: "Return to Data Browser"
|
|
79
|
+
}
|
|
80
|
+
) })
|
|
81
|
+
] }) }) }) });
|
|
113
82
|
}
|
|
114
83
|
if (shouldShowModelNotFound) {
|
|
115
|
-
return /* @__PURE__ */
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
} }
|
|
132
|
-
fileName: _jsxFileName,
|
|
133
|
-
lineNumber: 146,
|
|
134
|
-
columnNumber: 15
|
|
135
|
-
} }), /* @__PURE__ */ React.createElement("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
|
|
136
|
-
fileName: _jsxFileName,
|
|
137
|
-
lineNumber: 147,
|
|
138
|
-
columnNumber: 15
|
|
139
|
-
} }, "Model Not Found"), /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", __self: this, __source: {
|
|
140
|
-
fileName: _jsxFileName,
|
|
141
|
-
lineNumber: 148,
|
|
142
|
-
columnNumber: 15
|
|
143
|
-
} }, 'The data model for "', validatedDataType, '" could not be found.'), /* @__PURE__ */ React.createElement("div", { className: "mt-6", __self: this, __source: {
|
|
144
|
-
fileName: _jsxFileName,
|
|
145
|
-
lineNumber: 151,
|
|
146
|
-
columnNumber: 15
|
|
147
|
-
} }, /* @__PURE__ */ React.createElement(Link, { to: basePath, className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web", __self: this, __source: {
|
|
148
|
-
fileName: _jsxFileName,
|
|
149
|
-
lineNumber: 152,
|
|
150
|
-
columnNumber: 17
|
|
151
|
-
} }, "Return to Data Browser"))))));
|
|
84
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ jsx("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
85
|
+
/* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-yellow-400" }),
|
|
86
|
+
/* @__PURE__ */ jsx("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", children: "Model Not Found" }),
|
|
87
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", children: [
|
|
88
|
+
'The data model for "',
|
|
89
|
+
validatedDataType,
|
|
90
|
+
'" could not be found.'
|
|
91
|
+
] }),
|
|
92
|
+
/* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(
|
|
93
|
+
Link,
|
|
94
|
+
{
|
|
95
|
+
to: basePath,
|
|
96
|
+
className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
97
|
+
children: "Return to Data Browser"
|
|
98
|
+
}
|
|
99
|
+
) })
|
|
100
|
+
] }) }) }) });
|
|
152
101
|
}
|
|
153
|
-
return /* @__PURE__ */
|
|
154
|
-
fileName: _jsxFileName,
|
|
155
|
-
lineNumber: 167,
|
|
156
|
-
columnNumber: 10
|
|
157
|
-
} });
|
|
102
|
+
return /* @__PURE__ */ jsx(AdminDataEditPageContent, { model, id: validatedId, basePath, formTheme });
|
|
158
103
|
}
|
|
159
|
-
function AdminDataEditPageContent({
|
|
160
|
-
model,
|
|
161
|
-
id,
|
|
162
|
-
basePath,
|
|
163
|
-
formTheme
|
|
164
|
-
}) {
|
|
104
|
+
function AdminDataEditPageContent({ model, id, basePath, formTheme }) {
|
|
165
105
|
const navigate = useNavigate();
|
|
166
|
-
const {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
} = useAdminDataContext();
|
|
170
|
-
const [submissionState, setSubmissionState] = useState({
|
|
171
|
-
status: "idle"
|
|
172
|
-
});
|
|
173
|
-
const [deleteState, setDeleteState] = useState({
|
|
174
|
-
status: "idle"
|
|
175
|
-
});
|
|
106
|
+
const { sdk, databaseModels } = useAdminDataContext();
|
|
107
|
+
const [submissionState, setSubmissionState] = useState({ status: "idle" });
|
|
108
|
+
const [deleteState, setDeleteState] = useState({ status: "idle" });
|
|
176
109
|
const [showDeleteConfirm, setShowDeleteConfirm] = useState(false);
|
|
177
110
|
const documents = useMemo(() => {
|
|
178
111
|
try {
|
|
@@ -219,38 +152,36 @@ function AdminDataEditPageContent({
|
|
|
219
152
|
}, [documents]);
|
|
220
153
|
const idVariableName = getModelIdVariableName(model.name);
|
|
221
154
|
const responseFieldName = getModelResponseFieldName(model.name);
|
|
222
|
-
const {
|
|
223
|
-
|
|
224
|
-
loading,
|
|
225
|
-
error,
|
|
226
|
-
refetch
|
|
227
|
-
} = useQuery(QUERY || gql`
|
|
155
|
+
const { data, loading, error, refetch } = useQuery(
|
|
156
|
+
QUERY || gql`
|
|
228
157
|
query PlaceholderQuery {
|
|
229
158
|
__typename
|
|
230
159
|
}
|
|
231
|
-
`,
|
|
232
|
-
|
|
233
|
-
[idVariableName]: id
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
const [updateMutation] = useMutation(
|
|
160
|
+
`,
|
|
161
|
+
{
|
|
162
|
+
variables: { [idVariableName]: id },
|
|
163
|
+
errorPolicy: "all",
|
|
164
|
+
skip: !QUERY || !id
|
|
165
|
+
}
|
|
166
|
+
);
|
|
167
|
+
const [updateMutation] = useMutation(
|
|
168
|
+
UPDATE_MUTATION || gql`
|
|
239
169
|
mutation PlaceholderUpdate {
|
|
240
170
|
__typename
|
|
241
171
|
}
|
|
242
|
-
`
|
|
243
|
-
|
|
172
|
+
`
|
|
173
|
+
);
|
|
174
|
+
const [deleteMutation] = useMutation(
|
|
175
|
+
DELETE_MUTATION || gql`
|
|
244
176
|
mutation PlaceholderDelete {
|
|
245
177
|
__typename
|
|
246
178
|
}
|
|
247
|
-
`
|
|
179
|
+
`
|
|
180
|
+
);
|
|
248
181
|
useEffect(() => {
|
|
249
182
|
if (submissionState.status === "error") {
|
|
250
183
|
const timer = setTimeout(() => {
|
|
251
|
-
setSubmissionState({
|
|
252
|
-
status: "idle"
|
|
253
|
-
});
|
|
184
|
+
setSubmissionState({ status: "idle" });
|
|
254
185
|
}, 5e3);
|
|
255
186
|
return () => clearTimeout(timer);
|
|
256
187
|
}
|
|
@@ -258,165 +189,81 @@ function AdminDataEditPageContent({
|
|
|
258
189
|
useEffect(() => {
|
|
259
190
|
if (deleteState.status === "error") {
|
|
260
191
|
const timer = setTimeout(() => {
|
|
261
|
-
setDeleteState({
|
|
262
|
-
status: "idle"
|
|
263
|
-
});
|
|
192
|
+
setDeleteState({ status: "idle" });
|
|
264
193
|
}, 5e3);
|
|
265
194
|
return () => clearTimeout(timer);
|
|
266
195
|
}
|
|
267
196
|
}, [deleteState.status]);
|
|
268
197
|
if (!documents || !QUERY || !UPDATE_MUTATION || !DELETE_MUTATION) {
|
|
269
|
-
return /* @__PURE__ */
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
} }
|
|
282
|
-
fileName: _jsxFileName,
|
|
283
|
-
lineNumber: 302,
|
|
284
|
-
columnNumber: 13
|
|
285
|
-
} }, /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-red-400", __self: this, __source: {
|
|
286
|
-
fileName: _jsxFileName,
|
|
287
|
-
lineNumber: 303,
|
|
288
|
-
columnNumber: 15
|
|
289
|
-
} }), /* @__PURE__ */ React.createElement("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
|
|
290
|
-
fileName: _jsxFileName,
|
|
291
|
-
lineNumber: 304,
|
|
292
|
-
columnNumber: 15
|
|
293
|
-
} }, "GraphQL Schema Error"), /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", __self: this, __source: {
|
|
294
|
-
fileName: _jsxFileName,
|
|
295
|
-
lineNumber: 305,
|
|
296
|
-
columnNumber: 15
|
|
297
|
-
} }, "Unable to load GraphQL documents for this model. Please ensure the API server is running and the GraphQL schema is up to date."), /* @__PURE__ */ React.createElement("div", { className: "mt-6", __self: this, __source: {
|
|
298
|
-
fileName: _jsxFileName,
|
|
299
|
-
lineNumber: 309,
|
|
300
|
-
columnNumber: 15
|
|
301
|
-
} }, /* @__PURE__ */ React.createElement(Link, { to: basePath, className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web", __self: this, __source: {
|
|
302
|
-
fileName: _jsxFileName,
|
|
303
|
-
lineNumber: 310,
|
|
304
|
-
columnNumber: 17
|
|
305
|
-
} }, "Return to Data Browser"))))));
|
|
198
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ jsx("div", { className: "mt-8 mx-auto w-full max-w-2xl", children: /* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
199
|
+
/* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-red-400" }),
|
|
200
|
+
/* @__PURE__ */ jsx("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", children: "GraphQL Schema Error" }),
|
|
201
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", children: "Unable to load GraphQL documents for this model. Please ensure the API server is running and the GraphQL schema is up to date." }),
|
|
202
|
+
/* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(
|
|
203
|
+
Link,
|
|
204
|
+
{
|
|
205
|
+
to: basePath,
|
|
206
|
+
className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
207
|
+
children: "Return to Data Browser"
|
|
208
|
+
}
|
|
209
|
+
) })
|
|
210
|
+
] }) }) }) });
|
|
306
211
|
}
|
|
307
212
|
if (error) {
|
|
308
|
-
return /* @__PURE__ */
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
columnNumber: 15
|
|
332
|
-
} }, "Error Loading Data"), /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", __self: this, __source: {
|
|
333
|
-
fileName: _jsxFileName,
|
|
334
|
-
lineNumber: 333,
|
|
335
|
-
columnNumber: 15
|
|
336
|
-
} }, error.message), /* @__PURE__ */ React.createElement("div", { className: "mt-6 space-y-3", __self: this, __source: {
|
|
337
|
-
fileName: _jsxFileName,
|
|
338
|
-
lineNumber: 334,
|
|
339
|
-
columnNumber: 15
|
|
340
|
-
} }, /* @__PURE__ */ React.createElement("button", { onClick: () => refetch(), className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web", __self: this, __source: {
|
|
341
|
-
fileName: _jsxFileName,
|
|
342
|
-
lineNumber: 335,
|
|
343
|
-
columnNumber: 17
|
|
344
|
-
} }, "Try Again"), /* @__PURE__ */ React.createElement(Link, { to: `${basePath}/${toKebabCase(model.pluralName)}`, className: "w-full flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web", __self: this, __source: {
|
|
345
|
-
fileName: _jsxFileName,
|
|
346
|
-
lineNumber: 341,
|
|
347
|
-
columnNumber: 17
|
|
348
|
-
} }, "Back to List"))))));
|
|
213
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ jsx("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
214
|
+
/* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-red-400" }),
|
|
215
|
+
/* @__PURE__ */ jsx("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", children: "Error Loading Data" }),
|
|
216
|
+
/* @__PURE__ */ jsx("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", children: error.message }),
|
|
217
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-6 space-y-3", children: [
|
|
218
|
+
/* @__PURE__ */ jsx(
|
|
219
|
+
"button",
|
|
220
|
+
{
|
|
221
|
+
onClick: () => refetch(),
|
|
222
|
+
className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
223
|
+
children: "Try Again"
|
|
224
|
+
}
|
|
225
|
+
),
|
|
226
|
+
/* @__PURE__ */ jsx(
|
|
227
|
+
Link,
|
|
228
|
+
{
|
|
229
|
+
to: `${basePath}/${toKebabCase(model.pluralName)}`,
|
|
230
|
+
className: "w-full flex justify-center py-2 px-4 border border-gray-300 rounded-md shadow-sm text-sm font-medium text-gray-700 bg-white hover:bg-gray-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
231
|
+
children: "Back to List"
|
|
232
|
+
}
|
|
233
|
+
)
|
|
234
|
+
] })
|
|
235
|
+
] }) }) }) });
|
|
349
236
|
}
|
|
350
237
|
if (loading) {
|
|
351
|
-
return /* @__PURE__ */
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
} }
|
|
360
|
-
fileName: _jsxFileName,
|
|
361
|
-
lineNumber: 360,
|
|
362
|
-
columnNumber: 11
|
|
363
|
-
} }, /* @__PURE__ */ React.createElement("div", { className: "text-center", __self: this, __source: {
|
|
364
|
-
fileName: _jsxFileName,
|
|
365
|
-
lineNumber: 361,
|
|
366
|
-
columnNumber: 13
|
|
367
|
-
} }, /* @__PURE__ */ React.createElement("div", { className: "mx-auto h-12 w-12 border-4 border-green-web border-t-transparent rounded-full animate-spin", __self: this, __source: {
|
|
368
|
-
fileName: _jsxFileName,
|
|
369
|
-
lineNumber: 362,
|
|
370
|
-
columnNumber: 15
|
|
371
|
-
} }), /* @__PURE__ */ React.createElement("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
|
|
372
|
-
fileName: _jsxFileName,
|
|
373
|
-
lineNumber: 363,
|
|
374
|
-
columnNumber: 15
|
|
375
|
-
} }, "Loading..."), /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", __self: this, __source: {
|
|
376
|
-
fileName: _jsxFileName,
|
|
377
|
-
lineNumber: 364,
|
|
378
|
-
columnNumber: 15
|
|
379
|
-
} }, "Loading ", toReadableText(model.name), " data...")))));
|
|
238
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ jsx("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
239
|
+
/* @__PURE__ */ jsx("div", { className: "mx-auto h-12 w-12 border-4 border-green-web border-t-transparent rounded-full animate-spin" }),
|
|
240
|
+
/* @__PURE__ */ jsx("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", children: "Loading..." }),
|
|
241
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", children: [
|
|
242
|
+
"Loading ",
|
|
243
|
+
toReadableText(model.name),
|
|
244
|
+
" data..."
|
|
245
|
+
] })
|
|
246
|
+
] }) }) }) });
|
|
380
247
|
}
|
|
381
248
|
const item = data == null ? void 0 : data[responseFieldName];
|
|
382
249
|
if (!item) {
|
|
383
|
-
return /* @__PURE__ */
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
} }
|
|
400
|
-
fileName: _jsxFileName,
|
|
401
|
-
lineNumber: 383,
|
|
402
|
-
columnNumber: 15
|
|
403
|
-
} }), /* @__PURE__ */ React.createElement("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
|
|
404
|
-
fileName: _jsxFileName,
|
|
405
|
-
lineNumber: 384,
|
|
406
|
-
columnNumber: 15
|
|
407
|
-
} }, "Not Found"), /* @__PURE__ */ React.createElement("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", __self: this, __source: {
|
|
408
|
-
fileName: _jsxFileName,
|
|
409
|
-
lineNumber: 385,
|
|
410
|
-
columnNumber: 15
|
|
411
|
-
} }, "The ", toReadableText(model.name), " you're looking for doesn't exist or has been deleted."), /* @__PURE__ */ React.createElement("div", { className: "mt-6", __self: this, __source: {
|
|
412
|
-
fileName: _jsxFileName,
|
|
413
|
-
lineNumber: 389,
|
|
414
|
-
columnNumber: 15
|
|
415
|
-
} }, /* @__PURE__ */ React.createElement(Link, { to: `${basePath}/${toKebabCase(model.pluralName)}`, className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web", __self: this, __source: {
|
|
416
|
-
fileName: _jsxFileName,
|
|
417
|
-
lineNumber: 390,
|
|
418
|
-
columnNumber: 17
|
|
419
|
-
} }, "Back to List"))))));
|
|
250
|
+
return /* @__PURE__ */ jsx("div", { className: "flex flex-col justify-center py-12", children: /* @__PURE__ */ jsx("div", { className: "mt-8 mx-auto w-full max-w-md", children: /* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", children: /* @__PURE__ */ jsxs("div", { className: "text-center", children: [
|
|
251
|
+
/* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-yellow-400" }),
|
|
252
|
+
/* @__PURE__ */ jsx("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", children: "Not Found" }),
|
|
253
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-2 text-sm text-gray-600 dark:text-gray-400", children: [
|
|
254
|
+
"The ",
|
|
255
|
+
toReadableText(model.name),
|
|
256
|
+
" you're looking for doesn't exist or has been deleted."
|
|
257
|
+
] }),
|
|
258
|
+
/* @__PURE__ */ jsx("div", { className: "mt-6", children: /* @__PURE__ */ jsx(
|
|
259
|
+
Link,
|
|
260
|
+
{
|
|
261
|
+
to: `${basePath}/${toKebabCase(model.pluralName)}`,
|
|
262
|
+
className: "w-full flex justify-center py-2 px-4 border border-transparent rounded-md shadow-sm text-sm font-medium text-white bg-green-web hover:bg-green-web-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web",
|
|
263
|
+
children: "Back to List"
|
|
264
|
+
}
|
|
265
|
+
) })
|
|
266
|
+
] }) }) }) });
|
|
420
267
|
}
|
|
421
268
|
const formFields = buildFormFields(sdk, model, "update", item, submissionState.status === "loading", basePath, databaseModels);
|
|
422
269
|
const initialValues = {};
|
|
@@ -495,9 +342,7 @@ function AdminDataEditPageContent({
|
|
|
495
342
|
}
|
|
496
343
|
const handleSubmit = async (formData) => {
|
|
497
344
|
try {
|
|
498
|
-
setSubmissionState({
|
|
499
|
-
status: "loading"
|
|
500
|
-
});
|
|
345
|
+
setSubmissionState({ status: "loading" });
|
|
501
346
|
const cleanedInput = cleanFormInput(formData, model);
|
|
502
347
|
const result = await updateMutation({
|
|
503
348
|
variables: {
|
|
@@ -526,9 +371,7 @@ function AdminDataEditPageContent({
|
|
|
526
371
|
};
|
|
527
372
|
const handleDelete = async () => {
|
|
528
373
|
try {
|
|
529
|
-
setDeleteState({
|
|
530
|
-
status: "loading"
|
|
531
|
-
});
|
|
374
|
+
setDeleteState({ status: "loading" });
|
|
532
375
|
const result = await deleteMutation({
|
|
533
376
|
variables: {
|
|
534
377
|
[idVariableName]: id
|
|
@@ -555,188 +398,143 @@ function AdminDataEditPageContent({
|
|
|
555
398
|
});
|
|
556
399
|
}
|
|
557
400
|
};
|
|
558
|
-
return /* @__PURE__ */
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
lineNumber: 704,
|
|
693
|
-
columnNumber: 13
|
|
694
|
-
} }, /* @__PURE__ */ React.createElement("div", { className: "flex-shrink-0", __self: this, __source: {
|
|
695
|
-
fileName: _jsxFileName,
|
|
696
|
-
lineNumber: 705,
|
|
697
|
-
columnNumber: 15
|
|
698
|
-
} }, submissionState.status === "success" || deleteState.status === "success" ? /* @__PURE__ */ React.createElement(CheckCircleIcon, { className: "h-5 w-5 text-green-400", __self: this, __source: {
|
|
699
|
-
fileName: _jsxFileName,
|
|
700
|
-
lineNumber: 707,
|
|
701
|
-
columnNumber: 19
|
|
702
|
-
} }) : submissionState.status === "error" || deleteState.status === "error" ? /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "h-5 w-5 text-red-400", __self: this, __source: {
|
|
703
|
-
fileName: _jsxFileName,
|
|
704
|
-
lineNumber: 709,
|
|
705
|
-
columnNumber: 19
|
|
706
|
-
} }) : /* @__PURE__ */ React.createElement("div", { className: "h-5 w-5 border-2 border-blue-400 border-t-transparent rounded-full animate-spin", __self: this, __source: {
|
|
707
|
-
fileName: _jsxFileName,
|
|
708
|
-
lineNumber: 711,
|
|
709
|
-
columnNumber: 19
|
|
710
|
-
} })), /* @__PURE__ */ React.createElement("div", { className: "ml-3", __self: this, __source: {
|
|
711
|
-
fileName: _jsxFileName,
|
|
712
|
-
lineNumber: 714,
|
|
713
|
-
columnNumber: 15
|
|
714
|
-
} }, /* @__PURE__ */ React.createElement("p", { className: `text-sm font-medium ${submissionState.status === "success" || deleteState.status === "success" ? "text-green-800" : submissionState.status === "error" || deleteState.status === "error" ? "text-red-800" : "text-blue-800"}`, __self: this, __source: {
|
|
715
|
-
fileName: _jsxFileName,
|
|
716
|
-
lineNumber: 715,
|
|
717
|
-
columnNumber: 17
|
|
718
|
-
} }, submissionState.status === "loading" ? `Updating ${toReadableText(model.name)}...` : deleteState.status === "loading" ? `Deleting ${toReadableText(model.name)}...` : submissionState.message || deleteState.message)))), /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 shadow-sm rounded-lg", __self: this, __source: {
|
|
719
|
-
fileName: _jsxFileName,
|
|
720
|
-
lineNumber: 736,
|
|
721
|
-
columnNumber: 9
|
|
722
|
-
} }, /* @__PURE__ */ React.createElement("div", { className: "px-6 py-8", __self: this, __source: {
|
|
723
|
-
fileName: _jsxFileName,
|
|
724
|
-
lineNumber: 737,
|
|
725
|
-
columnNumber: 11
|
|
726
|
-
} }, /* @__PURE__ */ React.createElement(Form, { id: `edit-${model.name.toLowerCase()}-form`, fields: formFields, submit: handleSubmit, disabled: submissionState.status === "loading" || deleteState.status === "loading", defaultValues: initialValues, theme: formTheme, __self: this, __source: {
|
|
727
|
-
fileName: _jsxFileName,
|
|
728
|
-
lineNumber: 738,
|
|
729
|
-
columnNumber: 13
|
|
730
|
-
} }))));
|
|
401
|
+
return /* @__PURE__ */ jsxs("div", { className: "space-y-6", children: [
|
|
402
|
+
/* @__PURE__ */ jsxs("div", { className: "mb-8", children: [
|
|
403
|
+
/* @__PURE__ */ jsx("nav", { className: "flex mb-6", "aria-label": "Breadcrumb", children: /* @__PURE__ */ jsxs("ol", { className: "flex items-center space-x-4", children: [
|
|
404
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsx(Link, { to: basePath, className: "text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", children: "Data Browser" }) }),
|
|
405
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
406
|
+
/* @__PURE__ */ jsx(
|
|
407
|
+
"svg",
|
|
408
|
+
{
|
|
409
|
+
className: "flex-shrink-0 h-5 w-5 text-gray-300 dark:text-gray-600",
|
|
410
|
+
fill: "currentColor",
|
|
411
|
+
viewBox: "0 0 20 20",
|
|
412
|
+
children: /* @__PURE__ */ jsx(
|
|
413
|
+
"path",
|
|
414
|
+
{
|
|
415
|
+
fillRule: "evenodd",
|
|
416
|
+
d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 111.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
|
|
417
|
+
clipRule: "evenodd"
|
|
418
|
+
}
|
|
419
|
+
)
|
|
420
|
+
}
|
|
421
|
+
),
|
|
422
|
+
/* @__PURE__ */ jsx(
|
|
423
|
+
Link,
|
|
424
|
+
{
|
|
425
|
+
to: `${basePath}/${toKebabCase(model.pluralName)}`,
|
|
426
|
+
className: "ml-4 text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400",
|
|
427
|
+
children: toReadableText(model.pluralName)
|
|
428
|
+
}
|
|
429
|
+
)
|
|
430
|
+
] }) }),
|
|
431
|
+
/* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
432
|
+
/* @__PURE__ */ jsx(
|
|
433
|
+
"svg",
|
|
434
|
+
{
|
|
435
|
+
className: "flex-shrink-0 h-5 w-5 text-gray-300 dark:text-gray-600",
|
|
436
|
+
fill: "currentColor",
|
|
437
|
+
viewBox: "0 0 20 20",
|
|
438
|
+
children: /* @__PURE__ */ jsx(
|
|
439
|
+
"path",
|
|
440
|
+
{
|
|
441
|
+
fillRule: "evenodd",
|
|
442
|
+
d: "M7.293 14.707a1 1 0 010-1.414L10.586 10 7.293 6.707a1 1 0 111.414-1.414l4 4a1 1 0 010 1.414l-4 4a1 1 0 01-1.414 0z",
|
|
443
|
+
clipRule: "evenodd"
|
|
444
|
+
}
|
|
445
|
+
)
|
|
446
|
+
}
|
|
447
|
+
),
|
|
448
|
+
/* @__PURE__ */ jsx("span", { className: "ml-4 text-gray-500 dark:text-gray-400", children: "Edit" })
|
|
449
|
+
] }) })
|
|
450
|
+
] }) }),
|
|
451
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between", children: [
|
|
452
|
+
/* @__PURE__ */ jsxs("h1", { className: "text-3xl font-bold text-gray-900 dark:text-gray-100", children: [
|
|
453
|
+
"Edit ",
|
|
454
|
+
toReadableText(model.name)
|
|
455
|
+
] }),
|
|
456
|
+
/* @__PURE__ */ jsxs(
|
|
457
|
+
"button",
|
|
458
|
+
{
|
|
459
|
+
onClick: () => setShowDeleteConfirm(true),
|
|
460
|
+
disabled: deleteState.status === "loading",
|
|
461
|
+
className: "inline-flex items-center px-3 py-2 border border-red-300 shadow-sm text-sm leading-4 font-medium rounded-md text-red-700 bg-white hover:bg-red-50 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 disabled:opacity-50 disabled:cursor-not-allowed",
|
|
462
|
+
children: [
|
|
463
|
+
/* @__PURE__ */ jsx(TrashIcon, { className: "h-4 w-4 mr-2" }),
|
|
464
|
+
"Delete"
|
|
465
|
+
]
|
|
466
|
+
}
|
|
467
|
+
)
|
|
468
|
+
] })
|
|
469
|
+
] }),
|
|
470
|
+
showDeleteConfirm && /* @__PURE__ */ jsx("div", { className: "fixed inset-0 bg-gray-600 dark:bg-gray-900 bg-opacity-50 dark:bg-opacity-75 overflow-y-auto h-full w-full z-50 flex items-center justify-center", children: /* @__PURE__ */ jsxs("div", { className: "bg-white dark:bg-gray-800 p-6 rounded-lg shadow-xl max-w-md w-full mx-4", children: [
|
|
471
|
+
/* @__PURE__ */ jsxs("div", { className: "flex items-center", children: [
|
|
472
|
+
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: /* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "h-6 w-6 text-red-600" }) }),
|
|
473
|
+
/* @__PURE__ */ jsxs("div", { className: "ml-3", children: [
|
|
474
|
+
/* @__PURE__ */ jsxs("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100", children: [
|
|
475
|
+
"Delete ",
|
|
476
|
+
toReadableText(model.name)
|
|
477
|
+
] }),
|
|
478
|
+
/* @__PURE__ */ jsx("div", { className: "mt-2", children: /* @__PURE__ */ jsxs("p", { className: "text-sm text-gray-500 dark:text-gray-400", children: [
|
|
479
|
+
"Are you sure you want to delete this",
|
|
480
|
+
" ",
|
|
481
|
+
toReadableText(model.name).toLowerCase(),
|
|
482
|
+
"? This action cannot be undone."
|
|
483
|
+
] }) })
|
|
484
|
+
] })
|
|
485
|
+
] }),
|
|
486
|
+
/* @__PURE__ */ jsxs("div", { className: "mt-5 sm:mt-4 sm:flex sm:flex-row-reverse", children: [
|
|
487
|
+
/* @__PURE__ */ jsx(
|
|
488
|
+
"button",
|
|
489
|
+
{
|
|
490
|
+
onClick: handleDelete,
|
|
491
|
+
disabled: deleteState.status === "loading",
|
|
492
|
+
className: "w-full inline-flex justify-center rounded-md border border-transparent shadow-sm px-4 py-2 bg-red-600 text-base font-medium text-white hover:bg-red-700 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-red-500 sm:ml-3 sm:w-auto sm:text-sm disabled:opacity-50 disabled:cursor-not-allowed",
|
|
493
|
+
children: deleteState.status === "loading" ? "Deleting..." : "Delete"
|
|
494
|
+
}
|
|
495
|
+
),
|
|
496
|
+
/* @__PURE__ */ jsx(
|
|
497
|
+
"button",
|
|
498
|
+
{
|
|
499
|
+
onClick: () => setShowDeleteConfirm(false),
|
|
500
|
+
disabled: deleteState.status === "loading",
|
|
501
|
+
className: "mt-3 w-full inline-flex justify-center rounded-md border border-gray-300 shadow-sm px-4 py-2 bg-white text-base font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:ring-2 focus:ring-offset-2 focus:ring-green-web sm:mt-0 sm:w-auto sm:text-sm disabled:opacity-50 disabled:cursor-not-allowed",
|
|
502
|
+
children: "Cancel"
|
|
503
|
+
}
|
|
504
|
+
)
|
|
505
|
+
] })
|
|
506
|
+
] }) }),
|
|
507
|
+
(submissionState.status !== "idle" || deleteState.status !== "idle") && /* @__PURE__ */ jsx(
|
|
508
|
+
"div",
|
|
509
|
+
{
|
|
510
|
+
className: `mb-6 rounded-md p-4 ${submissionState.status === "success" || deleteState.status === "success" ? "bg-green-50 border border-green-200" : submissionState.status === "error" || deleteState.status === "error" ? "bg-red-50 border border-red-200" : "bg-blue-50 border border-blue-200"}`,
|
|
511
|
+
children: /* @__PURE__ */ jsxs("div", { className: "flex", children: [
|
|
512
|
+
/* @__PURE__ */ jsx("div", { className: "flex-shrink-0", children: submissionState.status === "success" || deleteState.status === "success" ? /* @__PURE__ */ jsx(CheckCircleIcon, { className: "h-5 w-5 text-green-400" }) : submissionState.status === "error" || deleteState.status === "error" ? /* @__PURE__ */ jsx(ExclamationCircleIcon, { className: "h-5 w-5 text-red-400" }) : /* @__PURE__ */ jsx("div", { className: "h-5 w-5 border-2 border-blue-400 border-t-transparent rounded-full animate-spin" }) }),
|
|
513
|
+
/* @__PURE__ */ jsx("div", { className: "ml-3", children: /* @__PURE__ */ jsx(
|
|
514
|
+
"p",
|
|
515
|
+
{
|
|
516
|
+
className: `text-sm font-medium ${submissionState.status === "success" || deleteState.status === "success" ? "text-green-800" : submissionState.status === "error" || deleteState.status === "error" ? "text-red-800" : "text-blue-800"}`,
|
|
517
|
+
children: submissionState.status === "loading" ? `Updating ${toReadableText(model.name)}...` : deleteState.status === "loading" ? `Deleting ${toReadableText(model.name)}...` : submissionState.message || deleteState.message
|
|
518
|
+
}
|
|
519
|
+
) })
|
|
520
|
+
] })
|
|
521
|
+
}
|
|
522
|
+
),
|
|
523
|
+
/* @__PURE__ */ jsx("div", { className: "bg-white dark:bg-gray-800 shadow-sm rounded-lg", children: /* @__PURE__ */ jsx("div", { className: "px-6 py-8", children: /* @__PURE__ */ jsx(
|
|
524
|
+
Form,
|
|
525
|
+
{
|
|
526
|
+
id: `edit-${model.name.toLowerCase()}-form`,
|
|
527
|
+
fields: formFields,
|
|
528
|
+
submit: handleSubmit,
|
|
529
|
+
disabled: submissionState.status === "loading" || deleteState.status === "loading",
|
|
530
|
+
defaultValues: initialValues,
|
|
531
|
+
theme: formTheme
|
|
532
|
+
}
|
|
533
|
+
) }) })
|
|
534
|
+
] });
|
|
731
535
|
}
|
|
732
|
-
function AdminDataEditErrorBoundary({
|
|
733
|
-
error
|
|
734
|
-
}) {
|
|
735
|
-
return /* @__PURE__ */ React.createElement(ErrorBoundary, { error, __self: this, __source: {
|
|
736
|
-
fileName: _jsxFileName,
|
|
737
|
-
lineNumber: 753,
|
|
738
|
-
columnNumber: 10
|
|
739
|
-
} });
|
|
536
|
+
function AdminDataEditErrorBoundary({ error }) {
|
|
537
|
+
return /* @__PURE__ */ jsx(ErrorBoundary, { error });
|
|
740
538
|
}
|
|
741
539
|
export {
|
|
742
540
|
AdminDataEditErrorBoundary,
|