sitero 0.3.0 → 0.5.0

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.
Files changed (131) hide show
  1. package/dist/export/cms/client/components/index.js +1 -0
  2. package/dist/export/core/server/index.js +1 -0
  3. package/dist/prisma/generated/internal/class.js +4 -4
  4. package/dist/src/cms/client/infrastructure/i18n/messages/en-US/resources/file.js +17 -0
  5. package/dist/src/cms/client/infrastructure/i18n/messages/zh-TW/resources/file.js +17 -0
  6. package/dist/src/cms/client/interfaces/components/create-components.js +1 -0
  7. package/dist/src/cms/client/interfaces/components/create-post-contents.js +7 -4
  8. package/dist/src/cms/client/interfaces/components/resources/admin/admin-fields.js +5 -0
  9. package/dist/src/cms/client/interfaces/components/resources/file/file-card.js +1 -1
  10. package/dist/src/cms/client/interfaces/components/resources/post/content/post-create-content.js +24 -6
  11. package/dist/src/cms/client/interfaces/components/resources/post/content/post-edit-content.js +27 -7
  12. package/dist/src/cms/client/interfaces/components/resources/post/content/post-show-content.js +13 -5
  13. package/dist/src/cms/client/interfaces/components/resources/post/content/resolve-control-field-label.js +9 -0
  14. package/dist/src/cms/client/interfaces/components/resources/post/post-list.js +5 -7
  15. package/dist/src/cms/client/interfaces/components/resources/post/search/control-field-filter-state.js +20 -0
  16. package/dist/src/cms/client/interfaces/components/resources/post/search/control-fields-filters.js +28 -14
  17. package/dist/src/cms/client/interfaces/components/ui/form/containers/side-fields.js +1 -1
  18. package/dist/src/cms/client/interfaces/components/ui/form/control-fields/control-fields-display.js +19 -9
  19. package/dist/src/cms/client/interfaces/components/ui/form/control-fields/control-fields-input.js +22 -11
  20. package/dist/src/cms/client/interfaces/components/ui/form/control-fields/control-fields.js +6 -1
  21. package/dist/src/cms/client/interfaces/pages/dashboard/content/content-management/_topicSlug_/page.js +2 -0
  22. package/dist/src/cms/client/interfaces/pages/dashboard/content/content-management/tag/page.js +4 -0
  23. package/dist/src/cms/client/interfaces/pages/dashboard/content/content-management/topic/page.js +4 -0
  24. package/dist/src/cms/client/interfaces/pages/dashboard/system/access/admin/_id_/edit/page.js +17 -14
  25. package/dist/src/cms/client/interfaces/pages/dashboard/system/access/admin/_id_/page.js +17 -14
  26. package/dist/src/cms/client/interfaces/pages/dashboard/system/access/admin/create/page.js +17 -14
  27. package/dist/src/cms/client/interfaces/pages/dashboard/system/storage/file/delete-many/page.js +36 -5
  28. package/dist/src/cms/client/interfaces/pages/dashboard/system/storage/trash/page.js +54 -5
  29. package/dist/src/cms/server/resources/file/actions.js +15 -31
  30. package/dist/src/config/admin.js +17 -0
  31. package/dist/src/config/post.js +14 -0
  32. package/dist/src/core/infrastructure/prisma/admin/admin-prisma-ports.js +44 -28
  33. package/dist/src/core/infrastructure/prisma/config/config-prisma-ports.js +48 -31
  34. package/dist/src/core/infrastructure/prisma/file/file-prisma-ports.js +79 -34
  35. package/dist/src/core/infrastructure/prisma/file/include.js +32 -33
  36. package/dist/src/core/infrastructure/prisma/helpers/active-file-references.js +20 -0
  37. package/dist/src/core/infrastructure/prisma/post/post-prisma-ports.js +126 -95
  38. package/dist/src/core/sitero-server/create-sitero-server.js +1 -0
  39. package/dist/types/export/cms/client/components/index.d.ts +2 -1
  40. package/dist/types/export/cms/client/components/index.d.ts.map +1 -1
  41. package/dist/types/export/index.d.ts +1 -1
  42. package/dist/types/export/index.d.ts.map +1 -1
  43. package/dist/types/src/cms/client/infrastructure/i18n/messages/en-US/index.d.ts +45 -0
  44. package/dist/types/src/cms/client/infrastructure/i18n/messages/en-US/index.d.ts.map +1 -1
  45. package/dist/types/src/cms/client/infrastructure/i18n/messages/en-US/resources/file.d.ts +45 -0
  46. package/dist/types/src/cms/client/infrastructure/i18n/messages/en-US/resources/file.d.ts.map +1 -1
  47. package/dist/types/src/cms/client/infrastructure/i18n/messages/en-US/resources/index.d.ts +45 -0
  48. package/dist/types/src/cms/client/infrastructure/i18n/messages/en-US/resources/index.d.ts.map +1 -1
  49. package/dist/types/src/cms/client/infrastructure/i18n/messages/index.d.ts +90 -0
  50. package/dist/types/src/cms/client/infrastructure/i18n/messages/index.d.ts.map +1 -1
  51. package/dist/types/src/cms/client/infrastructure/i18n/messages/zh-TW/index.d.ts +45 -0
  52. package/dist/types/src/cms/client/infrastructure/i18n/messages/zh-TW/index.d.ts.map +1 -1
  53. package/dist/types/src/cms/client/infrastructure/i18n/messages/zh-TW/resources/file.d.ts +45 -0
  54. package/dist/types/src/cms/client/infrastructure/i18n/messages/zh-TW/resources/file.d.ts.map +1 -1
  55. package/dist/types/src/cms/client/infrastructure/i18n/messages/zh-TW/resources/index.d.ts +45 -0
  56. package/dist/types/src/cms/client/infrastructure/i18n/messages/zh-TW/resources/index.d.ts.map +1 -1
  57. package/dist/types/src/cms/client/interfaces/components/create-components.d.ts +2 -3
  58. package/dist/types/src/cms/client/interfaces/components/create-components.d.ts.map +1 -1
  59. package/dist/types/src/cms/client/interfaces/components/create-post-contents.d.ts +3 -1
  60. package/dist/types/src/cms/client/interfaces/components/create-post-contents.d.ts.map +1 -1
  61. package/dist/types/src/cms/client/interfaces/components/resources/admin/admin-fields.d.ts +7 -0
  62. package/dist/types/src/cms/client/interfaces/components/resources/admin/admin-fields.d.ts.map +1 -0
  63. package/dist/types/src/cms/client/interfaces/components/resources/admin/index.d.ts +1 -0
  64. package/dist/types/src/cms/client/interfaces/components/resources/admin/index.d.ts.map +1 -1
  65. package/dist/types/src/cms/client/interfaces/components/resources/file/file-card.d.ts.map +1 -1
  66. package/dist/types/src/cms/client/interfaces/components/resources/index.d.ts +1 -1
  67. package/dist/types/src/cms/client/interfaces/components/resources/index.d.ts.map +1 -1
  68. package/dist/types/src/cms/client/interfaces/components/resources/post/content/index.d.ts +1 -1
  69. package/dist/types/src/cms/client/interfaces/components/resources/post/content/index.d.ts.map +1 -1
  70. package/dist/types/src/cms/client/interfaces/components/resources/post/content/post-create-content.d.ts +5 -3
  71. package/dist/types/src/cms/client/interfaces/components/resources/post/content/post-create-content.d.ts.map +1 -1
  72. package/dist/types/src/cms/client/interfaces/components/resources/post/content/post-edit-content.d.ts +5 -3
  73. package/dist/types/src/cms/client/interfaces/components/resources/post/content/post-edit-content.d.ts.map +1 -1
  74. package/dist/types/src/cms/client/interfaces/components/resources/post/content/post-show-content.d.ts +5 -3
  75. package/dist/types/src/cms/client/interfaces/components/resources/post/content/post-show-content.d.ts.map +1 -1
  76. package/dist/types/src/cms/client/interfaces/components/resources/post/content/resolve-control-field-label.d.ts +3 -0
  77. package/dist/types/src/cms/client/interfaces/components/resources/post/content/resolve-control-field-label.d.ts.map +1 -0
  78. package/dist/types/src/cms/client/interfaces/components/resources/post/content/types.d.ts +9 -0
  79. package/dist/types/src/cms/client/interfaces/components/resources/post/content/types.d.ts.map +1 -1
  80. package/dist/types/src/cms/client/interfaces/components/resources/post/index.d.ts +1 -1
  81. package/dist/types/src/cms/client/interfaces/components/resources/post/index.d.ts.map +1 -1
  82. package/dist/types/src/cms/client/interfaces/components/resources/post/post-list.d.ts +5 -2
  83. package/dist/types/src/cms/client/interfaces/components/resources/post/post-list.d.ts.map +1 -1
  84. package/dist/types/src/cms/client/interfaces/components/resources/post/search/control-field-filter-state.d.ts +7 -0
  85. package/dist/types/src/cms/client/interfaces/components/resources/post/search/control-field-filter-state.d.ts.map +1 -0
  86. package/dist/types/src/cms/client/interfaces/components/resources/post/search/control-fields-filters.d.ts +4 -23
  87. package/dist/types/src/cms/client/interfaces/components/resources/post/search/control-fields-filters.d.ts.map +1 -1
  88. package/dist/types/src/cms/client/interfaces/components/ui/form/control-fields/control-fields-display.d.ts +2 -0
  89. package/dist/types/src/cms/client/interfaces/components/ui/form/control-fields/control-fields-display.d.ts.map +1 -1
  90. package/dist/types/src/cms/client/interfaces/components/ui/form/control-fields/control-fields-input.d.ts +2 -0
  91. package/dist/types/src/cms/client/interfaces/components/ui/form/control-fields/control-fields-input.d.ts.map +1 -1
  92. package/dist/types/src/cms/client/interfaces/components/ui/form/control-fields/control-fields.d.ts +2 -0
  93. package/dist/types/src/cms/client/interfaces/components/ui/form/control-fields/control-fields.d.ts.map +1 -1
  94. package/dist/types/src/cms/client/interfaces/pages/dashboard/content/content-management/[topicSlug]/page.d.ts.map +1 -1
  95. package/dist/types/src/cms/client/interfaces/pages/dashboard/content/content-management/tag/page.d.ts.map +1 -1
  96. package/dist/types/src/cms/client/interfaces/pages/dashboard/content/content-management/topic/page.d.ts.map +1 -1
  97. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/access/admin/[id]/edit/page.d.ts +3 -2
  98. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/access/admin/[id]/edit/page.d.ts.map +1 -1
  99. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/access/admin/[id]/page.d.ts +3 -2
  100. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/access/admin/[id]/page.d.ts.map +1 -1
  101. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/access/admin/create/page.d.ts +3 -2
  102. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/access/admin/create/page.d.ts.map +1 -1
  103. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/storage/file/delete-many/page.d.ts.map +1 -1
  104. package/dist/types/src/cms/client/interfaces/pages/dashboard/system/storage/trash/page.d.ts.map +1 -1
  105. package/dist/types/src/cms/contracts/resources/file/actions.d.ts +16 -4
  106. package/dist/types/src/cms/contracts/resources/file/actions.d.ts.map +1 -1
  107. package/dist/types/src/cms/server/resources/file/actions.d.ts.map +1 -1
  108. package/dist/types/src/config/admin.d.ts +7 -0
  109. package/dist/types/src/config/admin.d.ts.map +1 -0
  110. package/dist/types/src/config/index.d.ts +2 -1
  111. package/dist/types/src/config/index.d.ts.map +1 -1
  112. package/dist/types/src/config/post.d.ts +3 -1
  113. package/dist/types/src/config/post.d.ts.map +1 -1
  114. package/dist/types/src/constants/cms-locale.d.ts +1 -0
  115. package/dist/types/src/constants/cms-locale.d.ts.map +1 -1
  116. package/dist/types/src/constants/index.d.ts +1 -1
  117. package/dist/types/src/constants/index.d.ts.map +1 -1
  118. package/dist/types/src/core/infrastructure/prisma/admin/admin-prisma-ports.d.ts.map +1 -1
  119. package/dist/types/src/core/infrastructure/prisma/config/config-prisma-ports.d.ts.map +1 -1
  120. package/dist/types/src/core/infrastructure/prisma/config/types.d.ts +1 -1
  121. package/dist/types/src/core/infrastructure/prisma/config/types.d.ts.map +1 -1
  122. package/dist/types/src/core/infrastructure/prisma/file/file-prisma-ports.d.ts +2 -1
  123. package/dist/types/src/core/infrastructure/prisma/file/file-prisma-ports.d.ts.map +1 -1
  124. package/dist/types/src/core/infrastructure/prisma/file/include.d.ts +32 -168
  125. package/dist/types/src/core/infrastructure/prisma/file/include.d.ts.map +1 -1
  126. package/dist/types/src/core/infrastructure/prisma/helpers/active-file-references.d.ts +9 -0
  127. package/dist/types/src/core/infrastructure/prisma/helpers/active-file-references.d.ts.map +1 -0
  128. package/dist/types/src/core/infrastructure/prisma/post/post-prisma-ports.d.ts.map +1 -1
  129. package/dist/types/src/core/sitero-server/create-sitero-server.d.ts.map +1 -1
  130. package/dist/types/src/web/server/resources/post/actions.d.ts +1 -1
  131. package/package.json +4 -3
@@ -4,6 +4,7 @@ import { useTranslator } from 'intor/react';
4
4
  import { ShieldUser } from 'lucide-react';
5
5
  import { useParams, useRouter } from 'next/navigation';
6
6
  import { ADMIN_ROLES } from 'sitero-domain';
7
+ import { ADMIN_PREFERENCE_FIELDS, AUTHOR_FIELDS } from '../../../../../../../../../../config/admin.js';
7
8
  import { CMS_PATHS } from '../../../../../../../../../../constants/paths/cms-paths.js';
8
9
  import '../../../../../../../../../../constants/paths/redirect.js';
9
10
  import { CMS_LOCALES_ARRAY } from '../../../../../../../../../../constants/cms-locale.js';
@@ -65,7 +66,7 @@ import 'intor/next';
65
66
  import { ContentContainer } from '../../../../../../../components/ui/layouts/content-container.js';
66
67
 
67
68
  function createAdminEditPage({
68
- enableAuthor,
69
+ allowField = () => true,
69
70
  webLocales,
70
71
  useAdminUpdateFormData,
71
72
  adminFindDetailAction,
@@ -121,8 +122,10 @@ function createAdminEditPage({
121
122
  fieldErrors
122
123
  );
123
124
  const fieldErrorMessages = getCmsFieldErrorMessageMap(localizedFieldErrors);
124
- const PreferenceFieldsCard = /* @__PURE__ */ jsxs(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), children: [
125
- /* @__PURE__ */ jsx(
125
+ const PreferenceFieldsCard = ADMIN_PREFERENCE_FIELDS.some(
126
+ (field) => allowField({ field })
127
+ ) && /* @__PURE__ */ jsxs(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), children: [
128
+ allowField({ field: "preferredLocale" }) && /* @__PURE__ */ jsx(
126
129
  FormField,
127
130
  {
128
131
  controlId: "preferredLocale",
@@ -146,7 +149,7 @@ function createAdminEditPage({
146
149
  )
147
150
  }
148
151
  ),
149
- /* @__PURE__ */ jsx(
152
+ allowField({ field: "receivesInquiryNotifications" }) && /* @__PURE__ */ jsx(
150
153
  FormField,
151
154
  {
152
155
  controlId: "receivesInquiryNotifications",
@@ -254,13 +257,13 @@ function createAdminEditPage({
254
257
  }
255
258
  )
256
259
  ] }),
257
- enableAuthor && /* @__PURE__ */ jsxs(Fragment, { children: [
260
+ AUTHOR_FIELDS.some((field) => allowField({ field })) && /* @__PURE__ */ jsxs(Fragment, { children: [
258
261
  /* @__PURE__ */ jsxs("div", { className: "flex-center my-4 w-full gap-4", children: [
259
262
  /* @__PURE__ */ jsx(Separator, { className: "flex-1" }),
260
263
  /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: t("resources.admin.author-info.text") }),
261
264
  /* @__PURE__ */ jsx(Separator, { className: "flex-1" })
262
265
  ] }),
263
- /* @__PURE__ */ jsx(
266
+ allowField({ field: "authorName" }) && /* @__PURE__ */ jsx(
264
267
  I18nFormField,
265
268
  {
266
269
  fieldName: "authorName",
@@ -285,7 +288,7 @@ function createAdminEditPage({
285
288
  )
286
289
  }
287
290
  ),
288
- /* @__PURE__ */ jsx(
291
+ allowField({ field: "socialLinks" }) && /* @__PURE__ */ jsx(
289
292
  FormField,
290
293
  {
291
294
  controlId: "socialLinks",
@@ -308,7 +311,7 @@ function createAdminEditPage({
308
311
  )
309
312
  }
310
313
  ),
311
- /* @__PURE__ */ jsx(
314
+ allowField({ field: "description" }) && /* @__PURE__ */ jsx(
312
315
  I18nFormField,
313
316
  {
314
317
  fieldName: "description",
@@ -332,7 +335,7 @@ function createAdminEditPage({
332
335
  )
333
336
  }
334
337
  ),
335
- /* @__PURE__ */ jsx(
338
+ allowField({ field: "jobTitle" }) && /* @__PURE__ */ jsx(
336
339
  I18nFormField,
337
340
  {
338
341
  fieldName: "jobTitle",
@@ -357,7 +360,7 @@ function createAdminEditPage({
357
360
  )
358
361
  }
359
362
  ),
360
- /* @__PURE__ */ jsx(
363
+ allowField({ field: "url" }) && /* @__PURE__ */ jsx(
361
364
  I18nFormField,
362
365
  {
363
366
  fieldName: "url",
@@ -379,7 +382,7 @@ function createAdminEditPage({
379
382
  )
380
383
  }
381
384
  ),
382
- /* @__PURE__ */ jsx(
385
+ allowField({ field: "worksFor" }) && /* @__PURE__ */ jsx(
383
386
  I18nFormField,
384
387
  {
385
388
  fieldName: "worksFor",
@@ -404,7 +407,7 @@ function createAdminEditPage({
404
407
  )
405
408
  }
406
409
  ),
407
- /* @__PURE__ */ jsx(
410
+ allowField({ field: "knowsAbout" }) && /* @__PURE__ */ jsx(
408
411
  I18nFormField,
409
412
  {
410
413
  fieldName: "knowsAbout",
@@ -433,7 +436,7 @@ function createAdminEditPage({
433
436
  )
434
437
  }
435
438
  ),
436
- /* @__PURE__ */ jsx(
439
+ allowField({ field: "homeLocation" }) && /* @__PURE__ */ jsx(
437
440
  I18nFormField,
438
441
  {
439
442
  fieldName: "homeLocation",
@@ -458,7 +461,7 @@ function createAdminEditPage({
458
461
  )
459
462
  }
460
463
  ),
461
- /* @__PURE__ */ jsx(
464
+ allowField({ field: "nationality" }) && /* @__PURE__ */ jsx(
462
465
  I18nFormField,
463
466
  {
464
467
  fieldName: "nationality",
@@ -7,6 +7,7 @@ import { ADMIN_ROLES } from 'sitero-domain';
7
7
  import 'zod';
8
8
  import { useCmsCommand } from '../../../../../../../infrastructure/operation-result/use-cms-command.js';
9
9
  import { useCmsQuery } from '../../../../../../../infrastructure/operation-result/use-cms-query.js';
10
+ import { ADMIN_PREFERENCE_FIELDS, AUTHOR_FIELDS } from '../../../../../../../../../config/admin.js';
10
11
  import { CMS_PATHS } from '../../../../../../../../../constants/paths/cms-paths.js';
11
12
  import '../../../../../../../../../constants/paths/redirect.js';
12
13
  import { DATE_FORMAT_OPTIONS } from '../../../../../../../../../constants/date.js';
@@ -61,7 +62,7 @@ import { ContentContainer } from '../../../../../../components/ui/layouts/conten
61
62
  import { I18nDisplayField } from '../../../../../../components/ui/i18n/i18n-display-field.js';
62
63
 
63
64
  function createAdminShowPage({
64
- enableAuthor,
65
+ allowField = () => true,
65
66
  webLocales,
66
67
  adminFindDetailAction,
67
68
  adminDeleteAction,
@@ -90,9 +91,11 @@ function createAdminShowPage({
90
91
  );
91
92
  const isSuperAdmin = admin?.role === ADMIN_ROLES.SUPER_ADMIN;
92
93
  const preferredLanguage = getLocaleLanguageCode(admin?.preferredLocale);
93
- const PreferenceFieldsCard = /* @__PURE__ */ jsxs(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), children: [
94
- /* @__PURE__ */ jsx(Field, { label: t("resources.admin.preferred-locale.text"), children: /* @__PURE__ */ jsx(FieldBody, { isLoading: isFetching, children: preferredLanguage ? format.displayName(preferredLanguage, { type: "language" }) : "" }) }),
95
- /* @__PURE__ */ jsx(
94
+ const PreferenceFieldsCard = ADMIN_PREFERENCE_FIELDS.some(
95
+ (field) => allowField({ field })
96
+ ) && /* @__PURE__ */ jsxs(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), children: [
97
+ allowField({ field: "preferredLocale" }) && /* @__PURE__ */ jsx(Field, { label: t("resources.admin.preferred-locale.text"), children: /* @__PURE__ */ jsx(FieldBody, { isLoading: isFetching, children: preferredLanguage ? format.displayName(preferredLanguage, { type: "language" }) : "" }) }),
98
+ allowField({ field: "receivesInquiryNotifications" }) && /* @__PURE__ */ jsx(
96
99
  Field,
97
100
  {
98
101
  htmlFor: "receivesInquiryNotifications",
@@ -224,13 +227,13 @@ function createAdminShowPage({
224
227
  }
225
228
  ) })
226
229
  ] }),
227
- enableAuthor && /* @__PURE__ */ jsxs(Fragment, { children: [
230
+ AUTHOR_FIELDS.some((field) => allowField({ field })) && /* @__PURE__ */ jsxs(Fragment, { children: [
228
231
  /* @__PURE__ */ jsxs("div", { className: "flex-center my-4 w-full gap-4", children: [
229
232
  /* @__PURE__ */ jsx(Separator, { className: "flex-1" }),
230
233
  /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: t("resources.admin.author-info.text") }),
231
234
  /* @__PURE__ */ jsx(Separator, { className: "flex-1" })
232
235
  ] }),
233
- /* @__PURE__ */ jsx(
236
+ allowField({ field: "authorName" }) && /* @__PURE__ */ jsx(
234
237
  I18nDisplayField,
235
238
  {
236
239
  fieldName: "authorName",
@@ -248,7 +251,7 @@ function createAdminShowPage({
248
251
  )
249
252
  }
250
253
  ),
251
- /* @__PURE__ */ jsx(Field, { label: t("resources.admin.social-links.text"), children: /* @__PURE__ */ jsx(
254
+ allowField({ field: "socialLinks" }) && /* @__PURE__ */ jsx(Field, { label: t("resources.admin.social-links.text"), children: /* @__PURE__ */ jsx(
252
255
  ArrayList,
253
256
  {
254
257
  isLink: true,
@@ -256,7 +259,7 @@ function createAdminShowPage({
256
259
  isLoading: isFetching
257
260
  }
258
261
  ) }),
259
- /* @__PURE__ */ jsx(
262
+ allowField({ field: "description" }) && /* @__PURE__ */ jsx(
260
263
  I18nDisplayField,
261
264
  {
262
265
  fieldName: "description",
@@ -274,7 +277,7 @@ function createAdminShowPage({
274
277
  )
275
278
  }
276
279
  ),
277
- /* @__PURE__ */ jsx(
280
+ allowField({ field: "jobTitle" }) && /* @__PURE__ */ jsx(
278
281
  I18nDisplayField,
279
282
  {
280
283
  fieldName: "jobTitle",
@@ -292,7 +295,7 @@ function createAdminShowPage({
292
295
  )
293
296
  }
294
297
  ),
295
- /* @__PURE__ */ jsx(
298
+ allowField({ field: "url" }) && /* @__PURE__ */ jsx(
296
299
  I18nDisplayField,
297
300
  {
298
301
  fieldName: "url",
@@ -310,7 +313,7 @@ function createAdminShowPage({
310
313
  )
311
314
  }
312
315
  ),
313
- /* @__PURE__ */ jsx(
316
+ allowField({ field: "worksFor" }) && /* @__PURE__ */ jsx(
314
317
  I18nDisplayField,
315
318
  {
316
319
  fieldName: "worksFor",
@@ -328,7 +331,7 @@ function createAdminShowPage({
328
331
  )
329
332
  }
330
333
  ),
331
- /* @__PURE__ */ jsx(
334
+ allowField({ field: "knowsAbout" }) && /* @__PURE__ */ jsx(
332
335
  I18nDisplayField,
333
336
  {
334
337
  fieldName: "knowsAbout",
@@ -344,7 +347,7 @@ function createAdminShowPage({
344
347
  )
345
348
  }
346
349
  ),
347
- /* @__PURE__ */ jsx(
350
+ allowField({ field: "homeLocation" }) && /* @__PURE__ */ jsx(
348
351
  I18nDisplayField,
349
352
  {
350
353
  fieldName: "homeLocation",
@@ -362,7 +365,7 @@ function createAdminShowPage({
362
365
  )
363
366
  }
364
367
  ),
365
- /* @__PURE__ */ jsx(
368
+ allowField({ field: "nationality" }) && /* @__PURE__ */ jsx(
366
369
  I18nDisplayField,
367
370
  {
368
371
  fieldName: "nationality",
@@ -4,6 +4,7 @@ import { useTranslator } from 'intor/react';
4
4
  import { ShieldUser } from 'lucide-react';
5
5
  import { useRouter } from 'next/navigation';
6
6
  import { ADMIN_ROLE_ARRAY, ADMIN_ROLES } from 'sitero-domain';
7
+ import { ADMIN_PREFERENCE_FIELDS, AUTHOR_FIELDS } from '../../../../../../../../../config/admin.js';
7
8
  import { CMS_PATHS } from '../../../../../../../../../constants/paths/cms-paths.js';
8
9
  import '../../../../../../../../../constants/paths/redirect.js';
9
10
  import { CMS_LOCALES_ARRAY } from '../../../../../../../../../constants/cms-locale.js';
@@ -62,7 +63,7 @@ import 'intor/next';
62
63
  import { ContentContainer } from '../../../../../../components/ui/layouts/content-container.js';
63
64
 
64
65
  function createAdminCreatePage({
65
- enableAuthor,
66
+ allowField = () => true,
66
67
  webLocales,
67
68
  useAdminCreateFormData,
68
69
  adminCreateAction,
@@ -101,8 +102,10 @@ function createAdminCreatePage({
101
102
  fieldErrors
102
103
  );
103
104
  const fieldErrorMessages = getCmsFieldErrorMessageMap(localizedFieldErrors);
104
- const PreferenceFieldsCard = /* @__PURE__ */ jsxs(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), children: [
105
- /* @__PURE__ */ jsx(
105
+ const PreferenceFieldsCard = ADMIN_PREFERENCE_FIELDS.some(
106
+ (field) => allowField({ field })
107
+ ) && /* @__PURE__ */ jsxs(Card, { className: cn("flex flex-col gap-6", "bg-base-100 p-4"), children: [
108
+ allowField({ field: "preferredLocale" }) && /* @__PURE__ */ jsx(
106
109
  FormField,
107
110
  {
108
111
  controlId: "preferredLocale",
@@ -125,7 +128,7 @@ function createAdminCreatePage({
125
128
  )
126
129
  }
127
130
  ),
128
- /* @__PURE__ */ jsx(
131
+ allowField({ field: "receivesInquiryNotifications" }) && /* @__PURE__ */ jsx(
129
132
  FormField,
130
133
  {
131
134
  controlId: "receivesInquiryNotifications",
@@ -281,13 +284,13 @@ function createAdminCreatePage({
281
284
  }
282
285
  )
283
286
  ] }),
284
- enableAuthor && /* @__PURE__ */ jsxs(Fragment, { children: [
287
+ AUTHOR_FIELDS.some((field) => allowField({ field })) && /* @__PURE__ */ jsxs(Fragment, { children: [
285
288
  /* @__PURE__ */ jsxs("div", { className: "flex-center my-4 w-full gap-4", children: [
286
289
  /* @__PURE__ */ jsx(Separator, { className: "flex-1" }),
287
290
  /* @__PURE__ */ jsx("p", { className: "text-muted-foreground text-sm", children: t("resources.admin.author-info.text") }),
288
291
  /* @__PURE__ */ jsx(Separator, { className: "flex-1" })
289
292
  ] }),
290
- /* @__PURE__ */ jsx(
293
+ allowField({ field: "authorName" }) && /* @__PURE__ */ jsx(
291
294
  I18nFormField,
292
295
  {
293
296
  fieldName: "authorName",
@@ -312,7 +315,7 @@ function createAdminCreatePage({
312
315
  )
313
316
  }
314
317
  ),
315
- /* @__PURE__ */ jsx(
318
+ allowField({ field: "socialLinks" }) && /* @__PURE__ */ jsx(
316
319
  FormField,
317
320
  {
318
321
  controlId: "socialLinks",
@@ -335,7 +338,7 @@ function createAdminCreatePage({
335
338
  )
336
339
  }
337
340
  ),
338
- /* @__PURE__ */ jsx(
341
+ allowField({ field: "description" }) && /* @__PURE__ */ jsx(
339
342
  I18nFormField,
340
343
  {
341
344
  fieldName: "description",
@@ -359,7 +362,7 @@ function createAdminCreatePage({
359
362
  )
360
363
  }
361
364
  ),
362
- /* @__PURE__ */ jsx(
365
+ allowField({ field: "jobTitle" }) && /* @__PURE__ */ jsx(
363
366
  I18nFormField,
364
367
  {
365
368
  fieldName: "jobTitle",
@@ -384,7 +387,7 @@ function createAdminCreatePage({
384
387
  )
385
388
  }
386
389
  ),
387
- /* @__PURE__ */ jsx(
390
+ allowField({ field: "url" }) && /* @__PURE__ */ jsx(
388
391
  I18nFormField,
389
392
  {
390
393
  fieldName: "url",
@@ -406,7 +409,7 @@ function createAdminCreatePage({
406
409
  )
407
410
  }
408
411
  ),
409
- /* @__PURE__ */ jsx(
412
+ allowField({ field: "worksFor" }) && /* @__PURE__ */ jsx(
410
413
  I18nFormField,
411
414
  {
412
415
  fieldName: "worksFor",
@@ -431,7 +434,7 @@ function createAdminCreatePage({
431
434
  )
432
435
  }
433
436
  ),
434
- /* @__PURE__ */ jsx(
437
+ allowField({ field: "knowsAbout" }) && /* @__PURE__ */ jsx(
435
438
  I18nFormField,
436
439
  {
437
440
  fieldName: "knowsAbout",
@@ -460,7 +463,7 @@ function createAdminCreatePage({
460
463
  )
461
464
  }
462
465
  ),
463
- /* @__PURE__ */ jsx(
466
+ allowField({ field: "homeLocation" }) && /* @__PURE__ */ jsx(
464
467
  I18nFormField,
465
468
  {
466
469
  fieldName: "homeLocation",
@@ -485,7 +488,7 @@ function createAdminCreatePage({
485
488
  )
486
489
  }
487
490
  ),
488
- /* @__PURE__ */ jsx(
491
+ allowField({ field: "nationality" }) && /* @__PURE__ */ jsx(
489
492
  I18nFormField,
490
493
  {
491
494
  fieldName: "nationality",
@@ -64,13 +64,44 @@ function createFileDeleteManyPage({
64
64
  formData: { ids: pickedItems.map((i) => i.id) }
65
65
  }),
66
66
  {
67
- onSuccess: () => {
68
- cancelAll();
67
+ onSuccess: (result) => {
68
+ if (!result) return;
69
+ setPickedItems(
70
+ (items) => items.filter(
71
+ (item) => result.failed.some((failure) => failure.id === item.id)
72
+ )
73
+ );
74
+ if (result.failed.length || result.skipped.length) {
75
+ const skippedMessages = {
76
+ FILE_NOT_FOUND: t("resources.file.delete-not-found.text"),
77
+ FILE_DELETE_ALREADY_DELETED: t(
78
+ "resources.file.delete-already-deleted.text"
79
+ ),
80
+ FILE_DELETE_LOCKED: t("resources.file.file-locked-warning.text"),
81
+ FILE_DELETE_IN_USE: t("resources.file.file-in-use-warning.text")
82
+ };
83
+ const reasons = [
84
+ ...new Set(
85
+ result.skipped.map((item) => skippedMessages[item.code])
86
+ )
87
+ ];
88
+ toast.warning(
89
+ [
90
+ result.deletedIds.length > 0 && `${t("resources.file.delete-completed.text")}: ${result.deletedIds.length}`,
91
+ result.skipped.length > 0 && `${t("resources.file.delete-skipped.text")}: ${result.skipped.length}`,
92
+ result.failed.length > 0 && `${t("resources.file.delete-failed.text")}: ${result.failed.length}`,
93
+ ...reasons
94
+ ].filter(Boolean).join(" \xB7 ")
95
+ );
96
+ }
97
+ },
98
+ onSettled: () => {
69
99
  void itemStates.refetch?.();
70
100
  }
71
101
  }
72
102
  );
73
103
  const handleClick = (file) => {
104
+ if (isPending) return;
74
105
  if (file.isLocked || file.isInUse) {
75
106
  toast.error(
76
107
  t(
@@ -99,7 +130,7 @@ function createFileDeleteManyPage({
99
130
  variant: "outline",
100
131
  icon: CopyCheck,
101
132
  onClick: pickAll,
102
- isDisabled: !canPickAll
133
+ isDisabled: isPending || !canPickAll
103
134
  }
104
135
  ),
105
136
  /* @__PURE__ */ jsx(
@@ -109,7 +140,7 @@ function createFileDeleteManyPage({
109
140
  variant: "outline",
110
141
  icon: CopyX,
111
142
  onClick: cancelAll,
112
- isDisabled: !canCancelAll
143
+ isDisabled: isPending || !canCancelAll
113
144
  }
114
145
  ),
115
146
  /* @__PURE__ */ jsx(
@@ -122,7 +153,7 @@ function createFileDeleteManyPage({
122
153
  void execute();
123
154
  },
124
155
  isLoading: isPending,
125
- isDisabled: pickedItems.length === 0,
156
+ isDisabled: isPending || pickedItems.length === 0,
126
157
  children: t("ui.destroy.text")
127
158
  }
128
159
  )
@@ -65,8 +65,38 @@ function createTrashPage({
65
65
  formData: { ids: pickedItems.map((i) => i.id) }
66
66
  }),
67
67
  {
68
- onSuccess: () => {
69
- cancelAll();
68
+ onSuccess: (result) => {
69
+ if (!result) return;
70
+ setPickedItems(
71
+ (items) => items.filter(
72
+ (item) => result.failed.some((failure) => failure.id === item.id)
73
+ )
74
+ );
75
+ if (result.failed.length || result.skipped.length) {
76
+ const skippedMessages = {
77
+ FILE_NOT_FOUND: t("resources.file.restore-not-found.text"),
78
+ FILE_RESTORE_NOT_DELETED: t(
79
+ "resources.file.restore-not-deleted.text"
80
+ ),
81
+ FILE_RESTORE_PURGE_STARTED: t(
82
+ "resources.file.restore-purge-started.text"
83
+ )
84
+ };
85
+ const reasons = [
86
+ ...new Set(
87
+ result.skipped.map((item) => skippedMessages[item.code])
88
+ )
89
+ ];
90
+ const message = [
91
+ result.restoredIds.length > 0 && `${t("resources.file.restore-completed.text")}: ${result.restoredIds.length}`,
92
+ result.skipped.length > 0 && `${t("resources.file.restore-skipped.text")}: ${result.skipped.length}`,
93
+ result.failed.length > 0 && `${t("resources.file.restore-failed.text")}: ${result.failed.length}`,
94
+ ...reasons
95
+ ].filter(Boolean).join(" \xB7 ");
96
+ toast.warning(message);
97
+ }
98
+ },
99
+ onSettled: () => {
70
100
  void itemStates.refetch?.();
71
101
  }
72
102
  }
@@ -76,8 +106,23 @@ function createTrashPage({
76
106
  formData: { ids: pickedItems.map((i) => i.id) }
77
107
  }),
78
108
  {
79
- onSuccess: () => {
80
- cancelAll();
109
+ onSuccess: (result) => {
110
+ if (!result) return;
111
+ setPickedItems(
112
+ (items) => items.filter(
113
+ (item) => result.failed.some((failure) => failure.id === item.id)
114
+ )
115
+ );
116
+ if (result.failed.length || result.skipped.length) {
117
+ const message = [
118
+ result.purgedIds.length > 0 && `${t("resources.file.purge-completed.text")}: ${result.purgedIds.length}`,
119
+ result.skipped.length > 0 && `${t("resources.file.purge-skipped.text")}: ${result.skipped.length}`,
120
+ result.failed.length > 0 && `${t("resources.file.purge-failed.text")}: ${result.failed.length}`
121
+ ].filter(Boolean).join(" \xB7 ");
122
+ toast.warning(message);
123
+ }
124
+ },
125
+ onSettled: () => {
81
126
  void itemStates.refetch?.();
82
127
  }
83
128
  }
@@ -135,7 +180,11 @@ function createTrashPage({
135
180
  void restoreFn();
136
181
  },
137
182
  isLoading: isRestoring,
138
- isDisabled: isProcessing || pickedItems.length === 0,
183
+ isDisabled: isProcessing || pickedItems.length === 0 || pickedItems.some(
184
+ (item) => files.some(
185
+ (file) => file.id === item.id && !!file.purgeStartedAt
186
+ )
187
+ ),
139
188
  children: t("ui.restore.text")
140
189
  }
141
190
  ),
@@ -32,12 +32,6 @@ function toFileUpdateInput(input) {
32
32
  translations: input.formData.translations
33
33
  };
34
34
  }
35
- function hasBatchMutationFailure(input) {
36
- return input.failed.length > 0 && input.completed.length === 0;
37
- }
38
- function getFirstSkippedCode(input) {
39
- return input[0]?.code ?? "INTERNAL_ERROR";
40
- }
41
35
  function createFileActions({
42
36
  resolveExecutionContext,
43
37
  siteroServer
@@ -120,15 +114,11 @@ function createFileActions({
120
114
  contextResult.data
121
115
  );
122
116
  if (!result.success) return result;
123
- if (hasBatchMutationFailure({
124
- failed: result.data.failed,
125
- completed: result.data.deleted
126
- }) || result.data.deleted.length === 0) {
127
- return operationResult.failure({
128
- code: result.data.skipped.length > 0 ? getFirstSkippedCode(result.data.skipped) : "INTERNAL_ERROR"
129
- });
130
- }
131
- return operationResult.success(void 0);
117
+ return operationResult.success({
118
+ deletedIds: result.data.deleted.map((file) => file.id),
119
+ skipped: result.data.skipped,
120
+ failed: result.data.failed
121
+ });
132
122
  };
133
123
  const fileRestoreManyAction = async (input) => {
134
124
  const contextResult = await resolveExecutionContext();
@@ -139,13 +129,11 @@ function createFileActions({
139
129
  contextResult.data
140
130
  );
141
131
  if (!result.success) return result;
142
- if (hasBatchMutationFailure({
143
- failed: result.data.failed,
144
- completed: result.data.restored
145
- }) || result.data.restored.length === 0) {
146
- return operationResult.failure({ code: "INTERNAL_ERROR" });
147
- }
148
- return operationResult.success(void 0);
132
+ return operationResult.success({
133
+ restoredIds: result.data.restored.map((file) => file.id),
134
+ skipped: result.data.skipped,
135
+ failed: result.data.failed
136
+ });
149
137
  };
150
138
  const filePurgeManyAction = async (input) => {
151
139
  const contextResult = await resolveExecutionContext();
@@ -156,15 +144,11 @@ function createFileActions({
156
144
  contextResult.data
157
145
  );
158
146
  if (!result.success) return result;
159
- if (hasBatchMutationFailure({
160
- failed: result.data.failed,
161
- completed: result.data.purged
162
- }) || result.data.purged.length === 0) {
163
- return operationResult.failure({
164
- code: result.data.skipped.length > 0 ? getFirstSkippedCode(result.data.skipped) : "INTERNAL_ERROR"
165
- });
166
- }
167
- return operationResult.success(void 0);
147
+ return operationResult.success({
148
+ purgedIds: result.data.purged.map((file) => file.id),
149
+ skipped: result.data.skipped,
150
+ failed: result.data.failed
151
+ });
168
152
  };
169
153
  const fileFindDetailAction = async (input) => {
170
154
  const contextResult = await resolveExecutionContext();
@@ -0,0 +1,17 @@
1
+ const AUTHOR_FIELDS = [
2
+ "authorName",
3
+ "socialLinks",
4
+ "description",
5
+ "jobTitle",
6
+ "url",
7
+ "worksFor",
8
+ "knowsAbout",
9
+ "homeLocation",
10
+ "nationality"
11
+ ];
12
+ const ADMIN_PREFERENCE_FIELDS = [
13
+ "preferredLocale",
14
+ "receivesInquiryNotifications"
15
+ ];
16
+
17
+ export { ADMIN_PREFERENCE_FIELDS, AUTHOR_FIELDS };
@@ -0,0 +1,14 @@
1
+ const POST_CUSTOM_STATE_FIELDS = [
2
+ "state1",
3
+ "state2",
4
+ "state3",
5
+ "state4",
6
+ "state5",
7
+ "state6",
8
+ "state7",
9
+ "state8",
10
+ "state9",
11
+ "state10"
12
+ ];
13
+
14
+ export { POST_CUSTOM_STATE_FIELDS };