@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.
@@ -1,4 +1,5 @@
1
- import React, { useState, useMemo, useEffect } from "react";
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
- dataType,
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__ */ React.createElement("div", { className: "flex flex-col justify-center py-12", __self: this, __source: {
77
- fileName: _jsxFileName,
78
- lineNumber: 116,
79
- columnNumber: 7
80
- } }, /* @__PURE__ */ React.createElement("div", { className: "mt-8 mx-auto w-full max-w-md", __self: this, __source: {
81
- fileName: _jsxFileName,
82
- lineNumber: 117,
83
- columnNumber: 9
84
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", __self: this, __source: {
85
- fileName: _jsxFileName,
86
- lineNumber: 118,
87
- columnNumber: 11
88
- } }, /* @__PURE__ */ React.createElement("div", { className: "text-center", __self: this, __source: {
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__ */ React.createElement("div", { className: "flex flex-col justify-center py-12", __self: this, __source: {
116
- fileName: _jsxFileName,
117
- lineNumber: 142,
118
- columnNumber: 7
119
- } }, /* @__PURE__ */ React.createElement("div", { className: "mt-8 mx-auto w-full max-w-md", __self: this, __source: {
120
- fileName: _jsxFileName,
121
- lineNumber: 143,
122
- columnNumber: 9
123
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", __self: this, __source: {
124
- fileName: _jsxFileName,
125
- lineNumber: 144,
126
- columnNumber: 11
127
- } }, /* @__PURE__ */ React.createElement("div", { className: "text-center", __self: this, __source: {
128
- fileName: _jsxFileName,
129
- lineNumber: 145,
130
- columnNumber: 13
131
- } }, /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-yellow-400", __self: this, __source: {
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__ */ React.createElement(AdminDataEditPageContent, { model, id: validatedId, basePath, formTheme, __self: this, __source: {
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
- sdk,
168
- databaseModels
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
- data,
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
- variables: {
233
- [idVariableName]: id
234
- },
235
- errorPolicy: "all",
236
- skip: !QUERY || !id
237
- });
238
- const [updateMutation] = useMutation(UPDATE_MUTATION || gql`
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
- const [deleteMutation] = useMutation(DELETE_MUTATION || gql`
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__ */ React.createElement("div", { className: "flex flex-col justify-center py-12", __self: this, __source: {
270
- fileName: _jsxFileName,
271
- lineNumber: 299,
272
- columnNumber: 7
273
- } }, /* @__PURE__ */ React.createElement("div", { className: "mt-8 mx-auto w-full max-w-2xl", __self: this, __source: {
274
- fileName: _jsxFileName,
275
- lineNumber: 300,
276
- columnNumber: 9
277
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", __self: this, __source: {
278
- fileName: _jsxFileName,
279
- lineNumber: 301,
280
- columnNumber: 11
281
- } }, /* @__PURE__ */ React.createElement("div", { className: "text-center", __self: this, __source: {
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__ */ React.createElement("div", { className: "flex flex-col justify-center py-12", __self: this, __source: {
309
- fileName: _jsxFileName,
310
- lineNumber: 327,
311
- columnNumber: 7
312
- } }, /* @__PURE__ */ React.createElement("div", { className: "mt-8 mx-auto w-full max-w-md", __self: this, __source: {
313
- fileName: _jsxFileName,
314
- lineNumber: 328,
315
- columnNumber: 9
316
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", __self: this, __source: {
317
- fileName: _jsxFileName,
318
- lineNumber: 329,
319
- columnNumber: 11
320
- } }, /* @__PURE__ */ React.createElement("div", { className: "text-center", __self: this, __source: {
321
- fileName: _jsxFileName,
322
- lineNumber: 330,
323
- columnNumber: 13
324
- } }, /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-red-400", __self: this, __source: {
325
- fileName: _jsxFileName,
326
- lineNumber: 331,
327
- columnNumber: 15
328
- } }), /* @__PURE__ */ React.createElement("h2", { className: "mt-4 text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
329
- fileName: _jsxFileName,
330
- lineNumber: 332,
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__ */ React.createElement("div", { className: "flex flex-col justify-center py-12", __self: this, __source: {
352
- fileName: _jsxFileName,
353
- lineNumber: 358,
354
- columnNumber: 7
355
- } }, /* @__PURE__ */ React.createElement("div", { className: "mt-8 mx-auto w-full max-w-md", __self: this, __source: {
356
- fileName: _jsxFileName,
357
- lineNumber: 359,
358
- columnNumber: 9
359
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", __self: this, __source: {
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__ */ React.createElement("div", { className: "flex flex-col justify-center py-12", __self: this, __source: {
384
- fileName: _jsxFileName,
385
- lineNumber: 379,
386
- columnNumber: 7
387
- } }, /* @__PURE__ */ React.createElement("div", { className: "mt-8 mx-auto w-full max-w-md", __self: this, __source: {
388
- fileName: _jsxFileName,
389
- lineNumber: 380,
390
- columnNumber: 9
391
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 py-8 px-4 shadow sm:rounded-lg sm:px-10", __self: this, __source: {
392
- fileName: _jsxFileName,
393
- lineNumber: 381,
394
- columnNumber: 11
395
- } }, /* @__PURE__ */ React.createElement("div", { className: "text-center", __self: this, __source: {
396
- fileName: _jsxFileName,
397
- lineNumber: 382,
398
- columnNumber: 13
399
- } }, /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "mx-auto h-12 w-12 text-yellow-400", __self: this, __source: {
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__ */ React.createElement("div", { className: "space-y-6", __self: this, __source: {
559
- fileName: _jsxFileName,
560
- lineNumber: 591,
561
- columnNumber: 5
562
- } }, /* @__PURE__ */ React.createElement("div", { className: "mb-8", __self: this, __source: {
563
- fileName: _jsxFileName,
564
- lineNumber: 593,
565
- columnNumber: 7
566
- } }, /* @__PURE__ */ React.createElement("nav", { className: "flex mb-6", "aria-label": "Breadcrumb", __self: this, __source: {
567
- fileName: _jsxFileName,
568
- lineNumber: 594,
569
- columnNumber: 11
570
- } }, /* @__PURE__ */ React.createElement("ol", { className: "flex items-center space-x-4", __self: this, __source: {
571
- fileName: _jsxFileName,
572
- lineNumber: 595,
573
- columnNumber: 13
574
- } }, /* @__PURE__ */ React.createElement("li", { __self: this, __source: {
575
- fileName: _jsxFileName,
576
- lineNumber: 596,
577
- columnNumber: 15
578
- } }, /* @__PURE__ */ React.createElement(Link, { to: basePath, className: "text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", __self: this, __source: {
579
- fileName: _jsxFileName,
580
- lineNumber: 597,
581
- columnNumber: 17
582
- } }, "Data Browser")), /* @__PURE__ */ React.createElement("li", { __self: this, __source: {
583
- fileName: _jsxFileName,
584
- lineNumber: 601,
585
- columnNumber: 15
586
- } }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center", __self: this, __source: {
587
- fileName: _jsxFileName,
588
- lineNumber: 602,
589
- columnNumber: 17
590
- } }, /* @__PURE__ */ React.createElement("svg", { className: "flex-shrink-0 h-5 w-5 text-gray-300 dark:text-gray-600", fill: "currentColor", viewBox: "0 0 20 20", __self: this, __source: {
591
- fileName: _jsxFileName,
592
- lineNumber: 603,
593
- columnNumber: 19
594
- } }, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", 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", clipRule: "evenodd", __self: this, __source: {
595
- fileName: _jsxFileName,
596
- lineNumber: 608,
597
- columnNumber: 21
598
- } })), /* @__PURE__ */ React.createElement(Link, { to: `${basePath}/${toKebabCase(model.pluralName)}`, className: "ml-4 text-gray-400 dark:text-gray-500 hover:text-gray-500 dark:hover:text-gray-400", __self: this, __source: {
599
- fileName: _jsxFileName,
600
- lineNumber: 614,
601
- columnNumber: 19
602
- } }, toReadableText(model.pluralName)))), /* @__PURE__ */ React.createElement("li", { __self: this, __source: {
603
- fileName: _jsxFileName,
604
- lineNumber: 622,
605
- columnNumber: 15
606
- } }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center", __self: this, __source: {
607
- fileName: _jsxFileName,
608
- lineNumber: 623,
609
- columnNumber: 17
610
- } }, /* @__PURE__ */ React.createElement("svg", { className: "flex-shrink-0 h-5 w-5 text-gray-300 dark:text-gray-600", fill: "currentColor", viewBox: "0 0 20 20", __self: this, __source: {
611
- fileName: _jsxFileName,
612
- lineNumber: 624,
613
- columnNumber: 19
614
- } }, /* @__PURE__ */ React.createElement("path", { fillRule: "evenodd", 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", clipRule: "evenodd", __self: this, __source: {
615
- fileName: _jsxFileName,
616
- lineNumber: 629,
617
- columnNumber: 21
618
- } })), /* @__PURE__ */ React.createElement("span", { className: "ml-4 text-gray-500 dark:text-gray-400", __self: this, __source: {
619
- fileName: _jsxFileName,
620
- lineNumber: 635,
621
- columnNumber: 19
622
- } }, "Edit"))))), /* @__PURE__ */ React.createElement("div", { className: "flex items-center justify-between", __self: this, __source: {
623
- fileName: _jsxFileName,
624
- lineNumber: 640,
625
- columnNumber: 11
626
- } }, /* @__PURE__ */ React.createElement("h1", { className: "text-3xl font-bold text-gray-900 dark:text-gray-100", __self: this, __source: {
627
- fileName: _jsxFileName,
628
- lineNumber: 641,
629
- columnNumber: 13
630
- } }, "Edit ", toReadableText(model.name)), /* @__PURE__ */ React.createElement("button", { onClick: () => setShowDeleteConfirm(true), disabled: deleteState.status === "loading", 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", __self: this, __source: {
631
- fileName: _jsxFileName,
632
- lineNumber: 642,
633
- columnNumber: 13
634
- } }, /* @__PURE__ */ React.createElement(TrashIcon, { className: "h-4 w-4 mr-2", __self: this, __source: {
635
- fileName: _jsxFileName,
636
- lineNumber: 647,
637
- columnNumber: 15
638
- } }), "Delete"))), showDeleteConfirm && /* @__PURE__ */ React.createElement("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", __self: this, __source: {
639
- fileName: _jsxFileName,
640
- lineNumber: 655,
641
- columnNumber: 11
642
- } }, /* @__PURE__ */ React.createElement("div", { className: "bg-white dark:bg-gray-800 p-6 rounded-lg shadow-xl max-w-md w-full mx-4", __self: this, __source: {
643
- fileName: _jsxFileName,
644
- lineNumber: 656,
645
- columnNumber: 13
646
- } }, /* @__PURE__ */ React.createElement("div", { className: "flex items-center", __self: this, __source: {
647
- fileName: _jsxFileName,
648
- lineNumber: 657,
649
- columnNumber: 15
650
- } }, /* @__PURE__ */ React.createElement("div", { className: "flex-shrink-0", __self: this, __source: {
651
- fileName: _jsxFileName,
652
- lineNumber: 658,
653
- columnNumber: 17
654
- } }, /* @__PURE__ */ React.createElement(ExclamationCircleIcon, { className: "h-6 w-6 text-red-600", __self: this, __source: {
655
- fileName: _jsxFileName,
656
- lineNumber: 659,
657
- columnNumber: 19
658
- } })), /* @__PURE__ */ React.createElement("div", { className: "ml-3", __self: this, __source: {
659
- fileName: _jsxFileName,
660
- lineNumber: 661,
661
- columnNumber: 17
662
- } }, /* @__PURE__ */ React.createElement("h3", { className: "text-lg font-medium text-gray-900 dark:text-gray-100", __self: this, __source: {
663
- fileName: _jsxFileName,
664
- lineNumber: 662,
665
- columnNumber: 19
666
- } }, "Delete ", toReadableText(model.name)), /* @__PURE__ */ React.createElement("div", { className: "mt-2", __self: this, __source: {
667
- fileName: _jsxFileName,
668
- lineNumber: 665,
669
- columnNumber: 19
670
- } }, /* @__PURE__ */ React.createElement("p", { className: "text-sm text-gray-500 dark:text-gray-400", __self: this, __source: {
671
- fileName: _jsxFileName,
672
- lineNumber: 666,
673
- columnNumber: 21
674
- } }, "Are you sure you want to delete this", " ", toReadableText(model.name).toLowerCase(), "? This action cannot be undone.")))), /* @__PURE__ */ React.createElement("div", { className: "mt-5 sm:mt-4 sm:flex sm:flex-row-reverse", __self: this, __source: {
675
- fileName: _jsxFileName,
676
- lineNumber: 673,
677
- columnNumber: 15
678
- } }, /* @__PURE__ */ React.createElement("button", { onClick: handleDelete, disabled: deleteState.status === "loading", 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", __self: this, __source: {
679
- fileName: _jsxFileName,
680
- lineNumber: 674,
681
- columnNumber: 17
682
- } }, deleteState.status === "loading" ? "Deleting..." : "Delete"), /* @__PURE__ */ React.createElement("button", { onClick: () => setShowDeleteConfirm(false), disabled: deleteState.status === "loading", 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", __self: this, __source: {
683
- fileName: _jsxFileName,
684
- lineNumber: 681,
685
- columnNumber: 17
686
- } }, "Cancel")))), (submissionState.status !== "idle" || deleteState.status !== "idle") && /* @__PURE__ */ React.createElement("div", { 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"}`, __self: this, __source: {
687
- fileName: _jsxFileName,
688
- lineNumber: 695,
689
- columnNumber: 11
690
- } }, /* @__PURE__ */ React.createElement("div", { className: "flex", __self: this, __source: {
691
- fileName: _jsxFileName,
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,