@mattisvensson/strapi-plugin-webatlas 0.3.0 → 0.4.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 (82) hide show
  1. package/dist/_chunks/{EmptyBox-7D4LrvdH.mjs → EmptyBox-BM4IscSk.mjs} +2 -6
  2. package/dist/_chunks/{EmptyBox-DT6D5gcf.js → EmptyBox-T8t29l25.js} +1 -5
  3. package/dist/_chunks/FullLoader-Cmsf8xS6.js +11 -0
  4. package/dist/_chunks/FullLoader-CrPED_dY.mjs +12 -0
  5. package/dist/_chunks/{de-C8PE3n3B.mjs → de-Dn24NwJf.mjs} +11 -1
  6. package/dist/_chunks/{de-4tL_cJTC.js → de-RiCps8UH.js} +11 -1
  7. package/dist/_chunks/{en-CR1YZvJo.mjs → en-D9Lxaugc.mjs} +11 -1
  8. package/dist/_chunks/{en-Bg4z3fR7.js → en-JLW5S3ZC.js} +11 -1
  9. package/dist/_chunks/index-B3JakJZB.mjs +126 -0
  10. package/dist/_chunks/index-BpvDMe8t.js +126 -0
  11. package/dist/_chunks/index-C1rj8TbT.js +281 -0
  12. package/dist/_chunks/{index-B0XE_zRP.js → index-CKHmlZdc.js} +1381 -363
  13. package/dist/_chunks/index-Cce7AGi-.mjs +281 -0
  14. package/dist/_chunks/{index-B85fJxGa.js → index-ChDbwEb-.js} +43 -61
  15. package/dist/_chunks/{index-C7B8QHDT.mjs → index-DJ-Du5aY.mjs} +1375 -357
  16. package/dist/_chunks/{index-CCiDvLAC.mjs → index-DUxYbDKG.mjs} +43 -61
  17. package/dist/admin/index.js +1 -1
  18. package/dist/admin/index.mjs +1 -1
  19. package/dist/admin/src/components/UI/FullLoader.d.ts +3 -0
  20. package/dist/admin/src/components/UI/index.d.ts +2 -1
  21. package/dist/admin/src/components/modals/Delete.d.ts +3 -3
  22. package/dist/admin/src/components/modals/NavEdit.d.ts +2 -2
  23. package/dist/admin/src/components/modals/externalItem/index.d.ts +10 -4
  24. package/dist/admin/src/components/modals/internalItem/internalItemCreate.d.ts +1 -1
  25. package/dist/admin/src/components/modals/wrapperItem/index.d.ts +11 -5
  26. package/dist/admin/src/hooks/useApi.d.ts +6 -5
  27. package/dist/admin/src/hooks/useNavigations.d.ts +2 -0
  28. package/dist/admin/src/hooks/usePluginConfig.d.ts +3 -3
  29. package/dist/admin/src/pages/Navigation/PageWrapper.d.ts +7 -0
  30. package/dist/admin/src/pages/Navigation/index.d.ts +1 -1
  31. package/dist/admin/src/pages/Routes/PageWrapper.d.ts +4 -0
  32. package/dist/admin/src/pages/Routes/TableHeader.d.ts +1 -0
  33. package/dist/admin/src/pages/Routes/TableRow.d.ts +4 -0
  34. package/dist/admin/src/pages/Settings/ContentTypeAccordion.d.ts +7 -0
  35. package/dist/admin/src/pages/Settings/PageWrapper.d.ts +8 -0
  36. package/dist/admin/src/utils/createTempNavItemObject.d.ts +25 -0
  37. package/dist/admin/src/utils/index.d.ts +2 -1
  38. package/dist/server/index.js +228 -177
  39. package/dist/server/index.mjs +228 -177
  40. package/dist/server/src/controllers/admin.d.ts +1 -4
  41. package/dist/server/src/controllers/index.d.ts +1 -4
  42. package/dist/server/src/index.d.ts +2 -8
  43. package/dist/server/src/services/admin.d.ts +2 -5
  44. package/dist/server/src/services/index.d.ts +1 -4
  45. package/dist/server/src/utils/navItemHandler.d.ts +5 -0
  46. package/dist/server/src/utils/routeHandler.d.ts +3 -0
  47. package/package.json +1 -1
  48. package/dist/_chunks/EmptyBox-7D4LrvdH.mjs.map +0 -1
  49. package/dist/_chunks/EmptyBox-DT6D5gcf.js.map +0 -1
  50. package/dist/_chunks/_baseConvert-B84_vf8X.js +0 -864
  51. package/dist/_chunks/_baseConvert-B84_vf8X.js.map +0 -1
  52. package/dist/_chunks/_baseConvert-C2SW1VHq.mjs +0 -865
  53. package/dist/_chunks/_baseConvert-C2SW1VHq.mjs.map +0 -1
  54. package/dist/_chunks/de-4tL_cJTC.js.map +0 -1
  55. package/dist/_chunks/de-C8PE3n3B.mjs.map +0 -1
  56. package/dist/_chunks/en-Bg4z3fR7.js.map +0 -1
  57. package/dist/_chunks/en-CR1YZvJo.mjs.map +0 -1
  58. package/dist/_chunks/index-B2Tiv3EK.mjs +0 -92
  59. package/dist/_chunks/index-B48CGofU.mjs +0 -17170
  60. package/dist/_chunks/index-B48CGofU.mjs.map +0 -1
  61. package/dist/_chunks/index-BbM9Sn1t.js +0 -17195
  62. package/dist/_chunks/index-BocSkZOu.mjs +0 -17176
  63. package/dist/_chunks/index-CXzNr2cH.mjs +0 -93
  64. package/dist/_chunks/index-CXzNr2cH.mjs.map +0 -1
  65. package/dist/_chunks/index-Cd6y6nuf.js +0 -93
  66. package/dist/_chunks/index-Cd6y6nuf.js.map +0 -1
  67. package/dist/_chunks/index-Cf9ZIBLd.js +0 -4195
  68. package/dist/_chunks/index-Cf9ZIBLd.js.map +0 -1
  69. package/dist/_chunks/index-D981K4TK.mjs +0 -4179
  70. package/dist/_chunks/index-D981K4TK.mjs.map +0 -1
  71. package/dist/_chunks/index-DGb8ESH-.js +0 -92
  72. package/dist/_chunks/index-DYiJBXKE.js +0 -10131
  73. package/dist/_chunks/index-DYiJBXKE.js.map +0 -1
  74. package/dist/_chunks/index-DjZ3ZaVB.js +0 -17189
  75. package/dist/_chunks/index-DjZ3ZaVB.js.map +0 -1
  76. package/dist/_chunks/index-DkhJl5mF.mjs +0 -10131
  77. package/dist/_chunks/index-DkhJl5mF.mjs.map +0 -1
  78. package/dist/admin/index.js.map +0 -1
  79. package/dist/admin/index.mjs.map +0 -1
  80. package/dist/admin/src/pages/Navigation/Header.d.ts +0 -6
  81. package/dist/server/index.js.map +0 -1
  82. package/dist/server/index.mjs.map +0 -1
@@ -1,13 +1,13 @@
1
1
  import { jsx, jsxs, Fragment } from "react/jsx-runtime";
2
2
  import { Trash, Pencil, Check, Drag, More, Link, OneToMany, ExternalLink, Plus } from "@strapi/icons";
3
3
  import { Dialog, Typography, Button, Modal, Flex, SingleSelect, SingleSelectOption, Grid, Box, Field, Toggle, Divider, Status, SimpleMenu, IconButton, MenuItem } from "@strapi/design-system";
4
- import { useFetchClient, Layouts } from "@strapi/strapi/admin";
5
4
  import { useState, useEffect, createContext, useRef, useContext, useReducer, useCallback, useMemo, forwardRef } from "react";
6
5
  import { createPortal } from "react-dom";
7
- import { u as useApi, g as getTranslation, d as debounce, a as duplicateCheck, t as transformToUrl, U as URLInfo } from "./index-CCiDvLAC.mjs";
8
6
  import { useIntl } from "react-intl";
9
- import { C as Center, E as EmptyBox } from "./EmptyBox-7D4LrvdH.mjs";
10
- import { c as commonjsGlobal, _ as _baseConvert } from "./_baseConvert-C2SW1VHq.mjs";
7
+ import { u as useApi, g as getTranslation, d as debounce, a as duplicateCheck, t as transformToUrl, U as URLInfo } from "./index-DUxYbDKG.mjs";
8
+ import { useFetchClient, Page, Layouts, useNotification } from "@strapi/strapi/admin";
9
+ import { C as Center, F as FullLoader } from "./FullLoader-CrPED_dY.mjs";
10
+ import { E as EmptyBox } from "./EmptyBox-BM4IscSk.mjs";
11
11
  import { MeasuringStrategy, DndContext, closestCenter, DragOverlay } from "@dnd-kit/core";
12
12
  import { arrayMove, useSortable, SortableContext, verticalListSortingStrategy } from "@dnd-kit/sortable";
13
13
  import { CSS } from "@dnd-kit/utilities";
@@ -31,36 +31,74 @@ const useAllEntities = () => {
31
31
  }, []);
32
32
  return { entities, loading, error };
33
33
  };
34
- function useNavigations() {
35
- const { get } = useFetchClient();
36
- const [navigations, setNavigations] = useState([]);
37
- const fetchNavigations = async () => {
38
- const { data } = await get("/webatlas/navigation");
39
- setNavigations(data || []);
34
+ function createTempNavItemObject({
35
+ parentId,
36
+ entityRoute,
37
+ selectedNavigation,
38
+ navItemState,
39
+ selectedEntity,
40
+ selectedContentType,
41
+ path,
42
+ wrapper = false,
43
+ internal = true
44
+ }) {
45
+ const tempNavItem = {
46
+ id: Math.floor(Math.random() * -1e6),
47
+ // Temporary negative ID
48
+ documentId: `temp-${Date.now()}`,
49
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
50
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
51
+ depth: 0,
52
+ status: null,
53
+ order: 0,
54
+ parent: parentId ? { documentId: parentId } : null,
55
+ items: [],
56
+ isNew: {
57
+ route: entityRoute?.documentId ?? null,
58
+ parent: parentId ?? null,
59
+ navigation: selectedNavigation?.documentId ?? null
60
+ },
61
+ route: {
62
+ active: navItemState.active || false,
63
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
64
+ documentId: "",
65
+ documentIdPath: selectedEntity ? selectedEntity.documentId : "",
66
+ fullPath: path?.value || "",
67
+ id: 0,
68
+ internal,
69
+ isOverride: navItemState.isOverride || false,
70
+ relatedContentType: selectedContentType ? JSON.stringify(selectedContentType.contentType) : "",
71
+ relatedDocumentId: selectedEntity ? selectedEntity.documentId : "",
72
+ relatedId: selectedEntity ? selectedEntity.id : 0,
73
+ slug: path?.value || "",
74
+ title: navItemState.title || "",
75
+ uidPath: path?.uidPath || "",
76
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
77
+ wrapper,
78
+ navitem: null
79
+ }
40
80
  };
41
- useEffect(() => {
42
- fetchNavigations();
43
- }, []);
44
- return { navigations, fetchNavigations };
81
+ return tempNavItem;
45
82
  }
46
83
  const ModalContext = createContext({ modalType: "", setModalType: () => {
47
84
  } });
48
85
  const SelectedNavigationContext = createContext({ selectedNavigation: void 0, setSelectedNavigation: () => {
49
86
  } });
50
- function Delete({ variant, item, fetchNavigations }) {
51
- const { deleteNavigation, deleteNavItem } = useApi();
87
+ function Delete({ variant, item, onDelete }) {
52
88
  const itemName = useRef(variant === "NavDelete" ? item.name : item.route.title);
53
89
  const closeModalState = useRef(variant === "NavDelete" ? "NavOverview" : "");
54
90
  const { setModalType } = useContext(ModalContext);
55
91
  const { formatMessage } = useIntl();
56
92
  const handleDelete = async () => {
57
93
  try {
58
- if (variant === "NavDelete") await deleteNavigation(item.documentId);
59
- else await deleteNavItem(item.documentId);
94
+ if (variant === "NavDelete") {
95
+ } else if (variant === "ItemDelete") {
96
+ const editedItem = { ...item, deleted: true };
97
+ onDelete(editedItem);
98
+ }
60
99
  } catch (err) {
61
100
  console.log(err);
62
101
  }
63
- fetchNavigations();
64
102
  setModalType(closeModalState.current);
65
103
  };
66
104
  return /* @__PURE__ */ jsx(Dialog.Root, { defaultOpen: true, onClose: () => setModalType(closeModalState.current), children: /* @__PURE__ */ jsxs(Dialog.Content, { children: [
@@ -216,7 +254,7 @@ function NavCreate() {
216
254
  }
217
255
  );
218
256
  }
219
- function NavEdit({ item, fetchNavigations }) {
257
+ function NavEdit({ item, onEdit }) {
220
258
  const { setModalType } = useContext(ModalContext);
221
259
  const [name, setName] = useState(item.name);
222
260
  const [visible, setVisible] = useState(item.visible);
@@ -227,8 +265,8 @@ function NavEdit({ item, fetchNavigations }) {
227
265
  setLoading(true);
228
266
  try {
229
267
  await updateNavigation(item.documentId, { name, visible });
230
- fetchNavigations();
231
268
  setModalType("NavOverview");
269
+ onEdit();
232
270
  } catch (err) {
233
271
  console.log(err);
234
272
  } finally {
@@ -373,6 +411,7 @@ function NavOverview({ navigations, setActionItem }) {
373
411
  }
374
412
  );
375
413
  }
414
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
376
415
  var lodash_min = { exports: {} };
377
416
  /**
378
417
  * @license
@@ -3488,6 +3527,829 @@ lodash_min.exports;
3488
3527
  }).call(commonjsGlobal);
3489
3528
  })(lodash_min, lodash_min.exports);
3490
3529
  var lodash_minExports = lodash_min.exports;
3530
+ var _mapping = {};
3531
+ (function(exports) {
3532
+ exports.aliasToReal = {
3533
+ // Lodash aliases.
3534
+ "each": "forEach",
3535
+ "eachRight": "forEachRight",
3536
+ "entries": "toPairs",
3537
+ "entriesIn": "toPairsIn",
3538
+ "extend": "assignIn",
3539
+ "extendAll": "assignInAll",
3540
+ "extendAllWith": "assignInAllWith",
3541
+ "extendWith": "assignInWith",
3542
+ "first": "head",
3543
+ // Methods that are curried variants of others.
3544
+ "conforms": "conformsTo",
3545
+ "matches": "isMatch",
3546
+ "property": "get",
3547
+ // Ramda aliases.
3548
+ "__": "placeholder",
3549
+ "F": "stubFalse",
3550
+ "T": "stubTrue",
3551
+ "all": "every",
3552
+ "allPass": "overEvery",
3553
+ "always": "constant",
3554
+ "any": "some",
3555
+ "anyPass": "overSome",
3556
+ "apply": "spread",
3557
+ "assoc": "set",
3558
+ "assocPath": "set",
3559
+ "complement": "negate",
3560
+ "compose": "flowRight",
3561
+ "contains": "includes",
3562
+ "dissoc": "unset",
3563
+ "dissocPath": "unset",
3564
+ "dropLast": "dropRight",
3565
+ "dropLastWhile": "dropRightWhile",
3566
+ "equals": "isEqual",
3567
+ "identical": "eq",
3568
+ "indexBy": "keyBy",
3569
+ "init": "initial",
3570
+ "invertObj": "invert",
3571
+ "juxt": "over",
3572
+ "omitAll": "omit",
3573
+ "nAry": "ary",
3574
+ "path": "get",
3575
+ "pathEq": "matchesProperty",
3576
+ "pathOr": "getOr",
3577
+ "paths": "at",
3578
+ "pickAll": "pick",
3579
+ "pipe": "flow",
3580
+ "pluck": "map",
3581
+ "prop": "get",
3582
+ "propEq": "matchesProperty",
3583
+ "propOr": "getOr",
3584
+ "props": "at",
3585
+ "symmetricDifference": "xor",
3586
+ "symmetricDifferenceBy": "xorBy",
3587
+ "symmetricDifferenceWith": "xorWith",
3588
+ "takeLast": "takeRight",
3589
+ "takeLastWhile": "takeRightWhile",
3590
+ "unapply": "rest",
3591
+ "unnest": "flatten",
3592
+ "useWith": "overArgs",
3593
+ "where": "conformsTo",
3594
+ "whereEq": "isMatch",
3595
+ "zipObj": "zipObject"
3596
+ };
3597
+ exports.aryMethod = {
3598
+ "1": [
3599
+ "assignAll",
3600
+ "assignInAll",
3601
+ "attempt",
3602
+ "castArray",
3603
+ "ceil",
3604
+ "create",
3605
+ "curry",
3606
+ "curryRight",
3607
+ "defaultsAll",
3608
+ "defaultsDeepAll",
3609
+ "floor",
3610
+ "flow",
3611
+ "flowRight",
3612
+ "fromPairs",
3613
+ "invert",
3614
+ "iteratee",
3615
+ "memoize",
3616
+ "method",
3617
+ "mergeAll",
3618
+ "methodOf",
3619
+ "mixin",
3620
+ "nthArg",
3621
+ "over",
3622
+ "overEvery",
3623
+ "overSome",
3624
+ "rest",
3625
+ "reverse",
3626
+ "round",
3627
+ "runInContext",
3628
+ "spread",
3629
+ "template",
3630
+ "trim",
3631
+ "trimEnd",
3632
+ "trimStart",
3633
+ "uniqueId",
3634
+ "words",
3635
+ "zipAll"
3636
+ ],
3637
+ "2": [
3638
+ "add",
3639
+ "after",
3640
+ "ary",
3641
+ "assign",
3642
+ "assignAllWith",
3643
+ "assignIn",
3644
+ "assignInAllWith",
3645
+ "at",
3646
+ "before",
3647
+ "bind",
3648
+ "bindAll",
3649
+ "bindKey",
3650
+ "chunk",
3651
+ "cloneDeepWith",
3652
+ "cloneWith",
3653
+ "concat",
3654
+ "conformsTo",
3655
+ "countBy",
3656
+ "curryN",
3657
+ "curryRightN",
3658
+ "debounce",
3659
+ "defaults",
3660
+ "defaultsDeep",
3661
+ "defaultTo",
3662
+ "delay",
3663
+ "difference",
3664
+ "divide",
3665
+ "drop",
3666
+ "dropRight",
3667
+ "dropRightWhile",
3668
+ "dropWhile",
3669
+ "endsWith",
3670
+ "eq",
3671
+ "every",
3672
+ "filter",
3673
+ "find",
3674
+ "findIndex",
3675
+ "findKey",
3676
+ "findLast",
3677
+ "findLastIndex",
3678
+ "findLastKey",
3679
+ "flatMap",
3680
+ "flatMapDeep",
3681
+ "flattenDepth",
3682
+ "forEach",
3683
+ "forEachRight",
3684
+ "forIn",
3685
+ "forInRight",
3686
+ "forOwn",
3687
+ "forOwnRight",
3688
+ "get",
3689
+ "groupBy",
3690
+ "gt",
3691
+ "gte",
3692
+ "has",
3693
+ "hasIn",
3694
+ "includes",
3695
+ "indexOf",
3696
+ "intersection",
3697
+ "invertBy",
3698
+ "invoke",
3699
+ "invokeMap",
3700
+ "isEqual",
3701
+ "isMatch",
3702
+ "join",
3703
+ "keyBy",
3704
+ "lastIndexOf",
3705
+ "lt",
3706
+ "lte",
3707
+ "map",
3708
+ "mapKeys",
3709
+ "mapValues",
3710
+ "matchesProperty",
3711
+ "maxBy",
3712
+ "meanBy",
3713
+ "merge",
3714
+ "mergeAllWith",
3715
+ "minBy",
3716
+ "multiply",
3717
+ "nth",
3718
+ "omit",
3719
+ "omitBy",
3720
+ "overArgs",
3721
+ "pad",
3722
+ "padEnd",
3723
+ "padStart",
3724
+ "parseInt",
3725
+ "partial",
3726
+ "partialRight",
3727
+ "partition",
3728
+ "pick",
3729
+ "pickBy",
3730
+ "propertyOf",
3731
+ "pull",
3732
+ "pullAll",
3733
+ "pullAt",
3734
+ "random",
3735
+ "range",
3736
+ "rangeRight",
3737
+ "rearg",
3738
+ "reject",
3739
+ "remove",
3740
+ "repeat",
3741
+ "restFrom",
3742
+ "result",
3743
+ "sampleSize",
3744
+ "some",
3745
+ "sortBy",
3746
+ "sortedIndex",
3747
+ "sortedIndexOf",
3748
+ "sortedLastIndex",
3749
+ "sortedLastIndexOf",
3750
+ "sortedUniqBy",
3751
+ "split",
3752
+ "spreadFrom",
3753
+ "startsWith",
3754
+ "subtract",
3755
+ "sumBy",
3756
+ "take",
3757
+ "takeRight",
3758
+ "takeRightWhile",
3759
+ "takeWhile",
3760
+ "tap",
3761
+ "throttle",
3762
+ "thru",
3763
+ "times",
3764
+ "trimChars",
3765
+ "trimCharsEnd",
3766
+ "trimCharsStart",
3767
+ "truncate",
3768
+ "union",
3769
+ "uniqBy",
3770
+ "uniqWith",
3771
+ "unset",
3772
+ "unzipWith",
3773
+ "without",
3774
+ "wrap",
3775
+ "xor",
3776
+ "zip",
3777
+ "zipObject",
3778
+ "zipObjectDeep"
3779
+ ],
3780
+ "3": [
3781
+ "assignInWith",
3782
+ "assignWith",
3783
+ "clamp",
3784
+ "differenceBy",
3785
+ "differenceWith",
3786
+ "findFrom",
3787
+ "findIndexFrom",
3788
+ "findLastFrom",
3789
+ "findLastIndexFrom",
3790
+ "getOr",
3791
+ "includesFrom",
3792
+ "indexOfFrom",
3793
+ "inRange",
3794
+ "intersectionBy",
3795
+ "intersectionWith",
3796
+ "invokeArgs",
3797
+ "invokeArgsMap",
3798
+ "isEqualWith",
3799
+ "isMatchWith",
3800
+ "flatMapDepth",
3801
+ "lastIndexOfFrom",
3802
+ "mergeWith",
3803
+ "orderBy",
3804
+ "padChars",
3805
+ "padCharsEnd",
3806
+ "padCharsStart",
3807
+ "pullAllBy",
3808
+ "pullAllWith",
3809
+ "rangeStep",
3810
+ "rangeStepRight",
3811
+ "reduce",
3812
+ "reduceRight",
3813
+ "replace",
3814
+ "set",
3815
+ "slice",
3816
+ "sortedIndexBy",
3817
+ "sortedLastIndexBy",
3818
+ "transform",
3819
+ "unionBy",
3820
+ "unionWith",
3821
+ "update",
3822
+ "xorBy",
3823
+ "xorWith",
3824
+ "zipWith"
3825
+ ],
3826
+ "4": [
3827
+ "fill",
3828
+ "setWith",
3829
+ "updateWith"
3830
+ ]
3831
+ };
3832
+ exports.aryRearg = {
3833
+ "2": [1, 0],
3834
+ "3": [2, 0, 1],
3835
+ "4": [3, 2, 0, 1]
3836
+ };
3837
+ exports.iterateeAry = {
3838
+ "dropRightWhile": 1,
3839
+ "dropWhile": 1,
3840
+ "every": 1,
3841
+ "filter": 1,
3842
+ "find": 1,
3843
+ "findFrom": 1,
3844
+ "findIndex": 1,
3845
+ "findIndexFrom": 1,
3846
+ "findKey": 1,
3847
+ "findLast": 1,
3848
+ "findLastFrom": 1,
3849
+ "findLastIndex": 1,
3850
+ "findLastIndexFrom": 1,
3851
+ "findLastKey": 1,
3852
+ "flatMap": 1,
3853
+ "flatMapDeep": 1,
3854
+ "flatMapDepth": 1,
3855
+ "forEach": 1,
3856
+ "forEachRight": 1,
3857
+ "forIn": 1,
3858
+ "forInRight": 1,
3859
+ "forOwn": 1,
3860
+ "forOwnRight": 1,
3861
+ "map": 1,
3862
+ "mapKeys": 1,
3863
+ "mapValues": 1,
3864
+ "partition": 1,
3865
+ "reduce": 2,
3866
+ "reduceRight": 2,
3867
+ "reject": 1,
3868
+ "remove": 1,
3869
+ "some": 1,
3870
+ "takeRightWhile": 1,
3871
+ "takeWhile": 1,
3872
+ "times": 1,
3873
+ "transform": 2
3874
+ };
3875
+ exports.iterateeRearg = {
3876
+ "mapKeys": [1],
3877
+ "reduceRight": [1, 0]
3878
+ };
3879
+ exports.methodRearg = {
3880
+ "assignInAllWith": [1, 0],
3881
+ "assignInWith": [1, 2, 0],
3882
+ "assignAllWith": [1, 0],
3883
+ "assignWith": [1, 2, 0],
3884
+ "differenceBy": [1, 2, 0],
3885
+ "differenceWith": [1, 2, 0],
3886
+ "getOr": [2, 1, 0],
3887
+ "intersectionBy": [1, 2, 0],
3888
+ "intersectionWith": [1, 2, 0],
3889
+ "isEqualWith": [1, 2, 0],
3890
+ "isMatchWith": [2, 1, 0],
3891
+ "mergeAllWith": [1, 0],
3892
+ "mergeWith": [1, 2, 0],
3893
+ "padChars": [2, 1, 0],
3894
+ "padCharsEnd": [2, 1, 0],
3895
+ "padCharsStart": [2, 1, 0],
3896
+ "pullAllBy": [2, 1, 0],
3897
+ "pullAllWith": [2, 1, 0],
3898
+ "rangeStep": [1, 2, 0],
3899
+ "rangeStepRight": [1, 2, 0],
3900
+ "setWith": [3, 1, 2, 0],
3901
+ "sortedIndexBy": [2, 1, 0],
3902
+ "sortedLastIndexBy": [2, 1, 0],
3903
+ "unionBy": [1, 2, 0],
3904
+ "unionWith": [1, 2, 0],
3905
+ "updateWith": [3, 1, 2, 0],
3906
+ "xorBy": [1, 2, 0],
3907
+ "xorWith": [1, 2, 0],
3908
+ "zipWith": [1, 2, 0]
3909
+ };
3910
+ exports.methodSpread = {
3911
+ "assignAll": { "start": 0 },
3912
+ "assignAllWith": { "start": 0 },
3913
+ "assignInAll": { "start": 0 },
3914
+ "assignInAllWith": { "start": 0 },
3915
+ "defaultsAll": { "start": 0 },
3916
+ "defaultsDeepAll": { "start": 0 },
3917
+ "invokeArgs": { "start": 2 },
3918
+ "invokeArgsMap": { "start": 2 },
3919
+ "mergeAll": { "start": 0 },
3920
+ "mergeAllWith": { "start": 0 },
3921
+ "partial": { "start": 1 },
3922
+ "partialRight": { "start": 1 },
3923
+ "without": { "start": 1 },
3924
+ "zipAll": { "start": 0 }
3925
+ };
3926
+ exports.mutate = {
3927
+ "array": {
3928
+ "fill": true,
3929
+ "pull": true,
3930
+ "pullAll": true,
3931
+ "pullAllBy": true,
3932
+ "pullAllWith": true,
3933
+ "pullAt": true,
3934
+ "remove": true,
3935
+ "reverse": true
3936
+ },
3937
+ "object": {
3938
+ "assign": true,
3939
+ "assignAll": true,
3940
+ "assignAllWith": true,
3941
+ "assignIn": true,
3942
+ "assignInAll": true,
3943
+ "assignInAllWith": true,
3944
+ "assignInWith": true,
3945
+ "assignWith": true,
3946
+ "defaults": true,
3947
+ "defaultsAll": true,
3948
+ "defaultsDeep": true,
3949
+ "defaultsDeepAll": true,
3950
+ "merge": true,
3951
+ "mergeAll": true,
3952
+ "mergeAllWith": true,
3953
+ "mergeWith": true
3954
+ },
3955
+ "set": {
3956
+ "set": true,
3957
+ "setWith": true,
3958
+ "unset": true,
3959
+ "update": true,
3960
+ "updateWith": true
3961
+ }
3962
+ };
3963
+ exports.realToAlias = function() {
3964
+ var hasOwnProperty = Object.prototype.hasOwnProperty, object = exports.aliasToReal, result = {};
3965
+ for (var key in object) {
3966
+ var value = object[key];
3967
+ if (hasOwnProperty.call(result, value)) {
3968
+ result[value].push(key);
3969
+ } else {
3970
+ result[value] = [key];
3971
+ }
3972
+ }
3973
+ return result;
3974
+ }();
3975
+ exports.remap = {
3976
+ "assignAll": "assign",
3977
+ "assignAllWith": "assignWith",
3978
+ "assignInAll": "assignIn",
3979
+ "assignInAllWith": "assignInWith",
3980
+ "curryN": "curry",
3981
+ "curryRightN": "curryRight",
3982
+ "defaultsAll": "defaults",
3983
+ "defaultsDeepAll": "defaultsDeep",
3984
+ "findFrom": "find",
3985
+ "findIndexFrom": "findIndex",
3986
+ "findLastFrom": "findLast",
3987
+ "findLastIndexFrom": "findLastIndex",
3988
+ "getOr": "get",
3989
+ "includesFrom": "includes",
3990
+ "indexOfFrom": "indexOf",
3991
+ "invokeArgs": "invoke",
3992
+ "invokeArgsMap": "invokeMap",
3993
+ "lastIndexOfFrom": "lastIndexOf",
3994
+ "mergeAll": "merge",
3995
+ "mergeAllWith": "mergeWith",
3996
+ "padChars": "pad",
3997
+ "padCharsEnd": "padEnd",
3998
+ "padCharsStart": "padStart",
3999
+ "propertyOf": "get",
4000
+ "rangeStep": "range",
4001
+ "rangeStepRight": "rangeRight",
4002
+ "restFrom": "rest",
4003
+ "spreadFrom": "spread",
4004
+ "trimChars": "trim",
4005
+ "trimCharsEnd": "trimEnd",
4006
+ "trimCharsStart": "trimStart",
4007
+ "zipAll": "zip"
4008
+ };
4009
+ exports.skipFixed = {
4010
+ "castArray": true,
4011
+ "flow": true,
4012
+ "flowRight": true,
4013
+ "iteratee": true,
4014
+ "mixin": true,
4015
+ "rearg": true,
4016
+ "runInContext": true
4017
+ };
4018
+ exports.skipRearg = {
4019
+ "add": true,
4020
+ "assign": true,
4021
+ "assignIn": true,
4022
+ "bind": true,
4023
+ "bindKey": true,
4024
+ "concat": true,
4025
+ "difference": true,
4026
+ "divide": true,
4027
+ "eq": true,
4028
+ "gt": true,
4029
+ "gte": true,
4030
+ "isEqual": true,
4031
+ "lt": true,
4032
+ "lte": true,
4033
+ "matchesProperty": true,
4034
+ "merge": true,
4035
+ "multiply": true,
4036
+ "overArgs": true,
4037
+ "partial": true,
4038
+ "partialRight": true,
4039
+ "propertyOf": true,
4040
+ "random": true,
4041
+ "range": true,
4042
+ "rangeRight": true,
4043
+ "subtract": true,
4044
+ "zip": true,
4045
+ "zipObject": true,
4046
+ "zipObjectDeep": true
4047
+ };
4048
+ })(_mapping);
4049
+ var placeholder = {};
4050
+ var mapping = _mapping, fallbackHolder = placeholder;
4051
+ var push = Array.prototype.push;
4052
+ function baseArity(func, n) {
4053
+ return n == 2 ? function(a, b) {
4054
+ return func.apply(void 0, arguments);
4055
+ } : function(a) {
4056
+ return func.apply(void 0, arguments);
4057
+ };
4058
+ }
4059
+ function baseAry(func, n) {
4060
+ return n == 2 ? function(a, b) {
4061
+ return func(a, b);
4062
+ } : function(a) {
4063
+ return func(a);
4064
+ };
4065
+ }
4066
+ function cloneArray(array) {
4067
+ var length = array ? array.length : 0, result = Array(length);
4068
+ while (length--) {
4069
+ result[length] = array[length];
4070
+ }
4071
+ return result;
4072
+ }
4073
+ function createCloner(func) {
4074
+ return function(object) {
4075
+ return func({}, object);
4076
+ };
4077
+ }
4078
+ function flatSpread(func, start) {
4079
+ return function() {
4080
+ var length = arguments.length, lastIndex = length - 1, args = Array(length);
4081
+ while (length--) {
4082
+ args[length] = arguments[length];
4083
+ }
4084
+ var array = args[start], otherArgs = args.slice(0, start);
4085
+ if (array) {
4086
+ push.apply(otherArgs, array);
4087
+ }
4088
+ if (start != lastIndex) {
4089
+ push.apply(otherArgs, args.slice(start + 1));
4090
+ }
4091
+ return func.apply(this, otherArgs);
4092
+ };
4093
+ }
4094
+ function wrapImmutable(func, cloner) {
4095
+ return function() {
4096
+ var length = arguments.length;
4097
+ if (!length) {
4098
+ return;
4099
+ }
4100
+ var args = Array(length);
4101
+ while (length--) {
4102
+ args[length] = arguments[length];
4103
+ }
4104
+ var result = args[0] = cloner.apply(void 0, args);
4105
+ func.apply(void 0, args);
4106
+ return result;
4107
+ };
4108
+ }
4109
+ function baseConvert(util, name, func, options) {
4110
+ var isLib = typeof name == "function", isObj = name === Object(name);
4111
+ if (isObj) {
4112
+ options = func;
4113
+ func = name;
4114
+ name = void 0;
4115
+ }
4116
+ if (func == null) {
4117
+ throw new TypeError();
4118
+ }
4119
+ options || (options = {});
4120
+ var config = {
4121
+ "cap": "cap" in options ? options.cap : true,
4122
+ "curry": "curry" in options ? options.curry : true,
4123
+ "fixed": "fixed" in options ? options.fixed : true,
4124
+ "immutable": "immutable" in options ? options.immutable : true,
4125
+ "rearg": "rearg" in options ? options.rearg : true
4126
+ };
4127
+ var defaultHolder = isLib ? func : fallbackHolder, forceCurry = "curry" in options && options.curry, forceFixed = "fixed" in options && options.fixed, forceRearg = "rearg" in options && options.rearg, pristine = isLib ? func.runInContext() : void 0;
4128
+ var helpers = isLib ? func : {
4129
+ "ary": util.ary,
4130
+ "assign": util.assign,
4131
+ "clone": util.clone,
4132
+ "curry": util.curry,
4133
+ "forEach": util.forEach,
4134
+ "isArray": util.isArray,
4135
+ "isError": util.isError,
4136
+ "isFunction": util.isFunction,
4137
+ "isWeakMap": util.isWeakMap,
4138
+ "iteratee": util.iteratee,
4139
+ "keys": util.keys,
4140
+ "rearg": util.rearg,
4141
+ "toInteger": util.toInteger,
4142
+ "toPath": util.toPath
4143
+ };
4144
+ var ary = helpers.ary, assign = helpers.assign, clone = helpers.clone, curry = helpers.curry, each = helpers.forEach, isArray = helpers.isArray, isError = helpers.isError, isFunction = helpers.isFunction, isWeakMap = helpers.isWeakMap, keys = helpers.keys, rearg = helpers.rearg, toInteger = helpers.toInteger, toPath = helpers.toPath;
4145
+ var aryMethodKeys = keys(mapping.aryMethod);
4146
+ var wrappers = {
4147
+ "castArray": function(castArray) {
4148
+ return function() {
4149
+ var value = arguments[0];
4150
+ return isArray(value) ? castArray(cloneArray(value)) : castArray.apply(void 0, arguments);
4151
+ };
4152
+ },
4153
+ "iteratee": function(iteratee) {
4154
+ return function() {
4155
+ var func2 = arguments[0], arity = arguments[1], result = iteratee(func2, arity), length = result.length;
4156
+ if (config.cap && typeof arity == "number") {
4157
+ arity = arity > 2 ? arity - 2 : 1;
4158
+ return length && length <= arity ? result : baseAry(result, arity);
4159
+ }
4160
+ return result;
4161
+ };
4162
+ },
4163
+ "mixin": function(mixin) {
4164
+ return function(source) {
4165
+ var func2 = this;
4166
+ if (!isFunction(func2)) {
4167
+ return mixin(func2, Object(source));
4168
+ }
4169
+ var pairs2 = [];
4170
+ each(keys(source), function(key) {
4171
+ if (isFunction(source[key])) {
4172
+ pairs2.push([key, func2.prototype[key]]);
4173
+ }
4174
+ });
4175
+ mixin(func2, Object(source));
4176
+ each(pairs2, function(pair) {
4177
+ var value = pair[1];
4178
+ if (isFunction(value)) {
4179
+ func2.prototype[pair[0]] = value;
4180
+ } else {
4181
+ delete func2.prototype[pair[0]];
4182
+ }
4183
+ });
4184
+ return func2;
4185
+ };
4186
+ },
4187
+ "nthArg": function(nthArg) {
4188
+ return function(n) {
4189
+ var arity = n < 0 ? 1 : toInteger(n) + 1;
4190
+ return curry(nthArg(n), arity);
4191
+ };
4192
+ },
4193
+ "rearg": function(rearg2) {
4194
+ return function(func2, indexes) {
4195
+ var arity = indexes ? indexes.length : 0;
4196
+ return curry(rearg2(func2, indexes), arity);
4197
+ };
4198
+ },
4199
+ "runInContext": function(runInContext) {
4200
+ return function(context) {
4201
+ return baseConvert(util, runInContext(context), options);
4202
+ };
4203
+ }
4204
+ };
4205
+ function castCap(name2, func2) {
4206
+ if (config.cap) {
4207
+ var indexes = mapping.iterateeRearg[name2];
4208
+ if (indexes) {
4209
+ return iterateeRearg(func2, indexes);
4210
+ }
4211
+ var n = !isLib && mapping.iterateeAry[name2];
4212
+ if (n) {
4213
+ return iterateeAry(func2, n);
4214
+ }
4215
+ }
4216
+ return func2;
4217
+ }
4218
+ function castCurry(name2, func2, n) {
4219
+ return forceCurry || config.curry && n > 1 ? curry(func2, n) : func2;
4220
+ }
4221
+ function castFixed(name2, func2, n) {
4222
+ if (config.fixed && (forceFixed || !mapping.skipFixed[name2])) {
4223
+ var data = mapping.methodSpread[name2], start = data && data.start;
4224
+ return start === void 0 ? ary(func2, n) : flatSpread(func2, start);
4225
+ }
4226
+ return func2;
4227
+ }
4228
+ function castRearg(name2, func2, n) {
4229
+ return config.rearg && n > 1 && (forceRearg || !mapping.skipRearg[name2]) ? rearg(func2, mapping.methodRearg[name2] || mapping.aryRearg[n]) : func2;
4230
+ }
4231
+ function cloneByPath(object, path) {
4232
+ path = toPath(path);
4233
+ var index = -1, length = path.length, lastIndex = length - 1, result = clone(Object(object)), nested = result;
4234
+ while (nested != null && ++index < length) {
4235
+ var key = path[index], value = nested[key];
4236
+ if (value != null && !(isFunction(value) || isError(value) || isWeakMap(value))) {
4237
+ nested[key] = clone(index == lastIndex ? value : Object(value));
4238
+ }
4239
+ nested = nested[key];
4240
+ }
4241
+ return result;
4242
+ }
4243
+ function convertLib(options2) {
4244
+ return _2.runInContext.convert(options2)(void 0);
4245
+ }
4246
+ function createConverter(name2, func2) {
4247
+ var realName = mapping.aliasToReal[name2] || name2, methodName = mapping.remap[realName] || realName, oldOptions = options;
4248
+ return function(options2) {
4249
+ var newUtil = isLib ? pristine : helpers, newFunc = isLib ? pristine[methodName] : func2, newOptions = assign(assign({}, oldOptions), options2);
4250
+ return baseConvert(newUtil, realName, newFunc, newOptions);
4251
+ };
4252
+ }
4253
+ function iterateeAry(func2, n) {
4254
+ return overArg(func2, function(func3) {
4255
+ return typeof func3 == "function" ? baseAry(func3, n) : func3;
4256
+ });
4257
+ }
4258
+ function iterateeRearg(func2, indexes) {
4259
+ return overArg(func2, function(func3) {
4260
+ var n = indexes.length;
4261
+ return baseArity(rearg(baseAry(func3, n), indexes), n);
4262
+ });
4263
+ }
4264
+ function overArg(func2, transform) {
4265
+ return function() {
4266
+ var length = arguments.length;
4267
+ if (!length) {
4268
+ return func2();
4269
+ }
4270
+ var args = Array(length);
4271
+ while (length--) {
4272
+ args[length] = arguments[length];
4273
+ }
4274
+ var index = config.rearg ? 0 : length - 1;
4275
+ args[index] = transform(args[index]);
4276
+ return func2.apply(void 0, args);
4277
+ };
4278
+ }
4279
+ function wrap(name2, func2, placeholder2) {
4280
+ var result, realName = mapping.aliasToReal[name2] || name2, wrapped = func2, wrapper = wrappers[realName];
4281
+ if (wrapper) {
4282
+ wrapped = wrapper(func2);
4283
+ } else if (config.immutable) {
4284
+ if (mapping.mutate.array[realName]) {
4285
+ wrapped = wrapImmutable(func2, cloneArray);
4286
+ } else if (mapping.mutate.object[realName]) {
4287
+ wrapped = wrapImmutable(func2, createCloner(func2));
4288
+ } else if (mapping.mutate.set[realName]) {
4289
+ wrapped = wrapImmutable(func2, cloneByPath);
4290
+ }
4291
+ }
4292
+ each(aryMethodKeys, function(aryKey) {
4293
+ each(mapping.aryMethod[aryKey], function(otherName) {
4294
+ if (realName == otherName) {
4295
+ var data = mapping.methodSpread[realName], afterRearg = data && data.afterRearg;
4296
+ result = afterRearg ? castFixed(realName, castRearg(realName, wrapped, aryKey), aryKey) : castRearg(realName, castFixed(realName, wrapped, aryKey), aryKey);
4297
+ result = castCap(realName, result);
4298
+ result = castCurry(realName, result, aryKey);
4299
+ return false;
4300
+ }
4301
+ });
4302
+ return !result;
4303
+ });
4304
+ result || (result = wrapped);
4305
+ if (result == func2) {
4306
+ result = forceCurry ? curry(result, 1) : function() {
4307
+ return func2.apply(this, arguments);
4308
+ };
4309
+ }
4310
+ result.convert = createConverter(realName, func2);
4311
+ result.placeholder = func2.placeholder = placeholder2;
4312
+ return result;
4313
+ }
4314
+ if (!isObj) {
4315
+ return wrap(name, func, defaultHolder);
4316
+ }
4317
+ var _2 = func;
4318
+ var pairs = [];
4319
+ each(aryMethodKeys, function(aryKey) {
4320
+ each(mapping.aryMethod[aryKey], function(key) {
4321
+ var func2 = _2[mapping.remap[key] || key];
4322
+ if (func2) {
4323
+ pairs.push([key, wrap(key, func2, _2)]);
4324
+ }
4325
+ });
4326
+ });
4327
+ each(keys(_2), function(key) {
4328
+ var func2 = _2[key];
4329
+ if (typeof func2 == "function") {
4330
+ var length = pairs.length;
4331
+ while (length--) {
4332
+ if (pairs[length][0] == key) {
4333
+ return;
4334
+ }
4335
+ }
4336
+ func2.convert = createConverter(key, func2);
4337
+ pairs.push([key, func2]);
4338
+ }
4339
+ });
4340
+ each(pairs, function(pair) {
4341
+ _2[pair[0]] = pair[1];
4342
+ });
4343
+ _2.convert = convertLib;
4344
+ _2.placeholder = _2;
4345
+ each(keys(_2), function(key) {
4346
+ each(mapping.realToAlias[key] || [], function(alias) {
4347
+ _2[alias] = _2[key];
4348
+ });
4349
+ });
4350
+ return _2;
4351
+ }
4352
+ var _baseConvert = baseConvert;
3491
4353
  var _ = lodash_minExports.runInContext();
3492
4354
  _baseConvert(_, _);
3493
4355
  function itemStateReducer(navItemState, action) {
@@ -3547,7 +4409,7 @@ function useModalSharedLogic() {
3547
4409
  const [replacement, setReplacement] = useState("");
3548
4410
  const [validationState, setValidationState] = useState("initial");
3549
4411
  const { entities } = useAllEntities();
3550
- const { createNavItem, updateRoute, getRelatedRoute, createExternalRoute } = useApi();
4412
+ const { updateRoute, getRelatedRoute } = useApi();
3551
4413
  const initialState = useRef({
3552
4414
  title: "",
3553
4415
  slug: "",
@@ -3585,8 +4447,6 @@ function useModalSharedLogic() {
3585
4447
  entityRoute,
3586
4448
  setEntityRoute,
3587
4449
  entities,
3588
- createNavItem,
3589
- createExternalRoute,
3590
4450
  updateRoute,
3591
4451
  getRelatedRoute,
3592
4452
  replacement,
@@ -3611,47 +4471,58 @@ function withModalSharedLogic(Component) {
3611
4471
  return /* @__PURE__ */ jsx(Component, { ...props, ...sharedLogic });
3612
4472
  };
3613
4473
  }
3614
- function ExternalItemComponent({
3615
- variant,
3616
- item,
3617
- createNavItem,
3618
- navItemState,
3619
- dispatchItemState,
3620
- createExternalRoute,
3621
- updateRoute,
3622
- path,
3623
- dispatchPath,
3624
- setModalType,
3625
- selectedNavigation,
3626
- parentDocumentId
3627
- }) {
4474
+ function isExternalEditProps(props) {
4475
+ return props.variant === "ExternalEdit";
4476
+ }
4477
+ function isExternalCreateProps(props) {
4478
+ return props.variant === "ExternalCreate";
4479
+ }
4480
+ function ExternalItemComponent(props) {
4481
+ const {
4482
+ variant,
4483
+ navItemState,
4484
+ dispatchItemState,
4485
+ path,
4486
+ dispatchPath,
4487
+ setModalType,
4488
+ selectedNavigation
4489
+ } = props;
4490
+ const parentId = isExternalCreateProps(props) ? props.parentId : void 0;
4491
+ const onCreate = isExternalCreateProps(props) ? props.onCreate : void 0;
4492
+ const onSave = isExternalEditProps(props) ? props.onSave : void 0;
4493
+ const item = isExternalEditProps(props) ? props.item : void 0;
3628
4494
  const { formatMessage } = useIntl();
3629
4495
  useEffect(() => {
3630
4496
  if (variant !== "ExternalEdit" || !item) return;
3631
4497
  dispatchItemState({ type: "SET_TITLE", payload: item.route.title });
3632
4498
  dispatchItemState({ type: "SET_ACTIVE", payload: item.route.active });
3633
4499
  dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: item.route.fullPath });
3634
- }, []);
3635
- const addItem = async () => {
4500
+ }, [variant, item, dispatchItemState, dispatchPath]);
4501
+ const handleConfirm = async () => {
3636
4502
  try {
3637
4503
  if (!path || !navItemState.title || !selectedNavigation) return;
3638
- const data = {
3639
- title: navItemState.title,
3640
- fullPath: path.value,
3641
- active: navItemState.active,
3642
- internal: false
3643
- };
3644
- if (variant === "ExternalEdit" && item) {
3645
- await updateRoute(data, item.route.documentId);
3646
- } else {
3647
- const route = await createExternalRoute(data);
3648
- if (!route) return;
3649
- const settings = {
3650
- route: route.documentId,
3651
- parent: parentDocumentId ?? null,
3652
- navigation: selectedNavigation.documentId
3653
- };
3654
- await createNavItem(settings);
4504
+ if (variant === "ExternalEdit" && item && onSave) {
4505
+ onSave({
4506
+ ...item,
4507
+ update: {
4508
+ title: navItemState.title,
4509
+ fullPath: path.value
4510
+ // internal: false,
4511
+ // active: navItemState.active,
4512
+ }
4513
+ });
4514
+ } else if (onCreate) {
4515
+ const newItem = createTempNavItemObject({
4516
+ parentId,
4517
+ entityRoute: null,
4518
+ selectedNavigation,
4519
+ navItemState,
4520
+ selectedEntity: null,
4521
+ selectedContentType: null,
4522
+ path,
4523
+ internal: false
4524
+ });
4525
+ onCreate(newItem);
3655
4526
  }
3656
4527
  setModalType("");
3657
4528
  } catch (err) {
@@ -3665,7 +4536,7 @@ function ExternalItemComponent({
3665
4536
  closeText: formatMessage({ id: getTranslation("cancel"), defaultMessage: "Cancel" }),
3666
4537
  titleText: variant === "ExternalCreate" ? formatMessage({ id: getTranslation("modal.externalItem.titleText.create"), defaultMessage: "Create new external item" }) : formatMessage({ id: getTranslation("modal.externalItem.titleText.edit"), defaultMessage: `Edit external route "${navItemState.title}"` }),
3667
4538
  loadingText: variant === "ExternalCreate" ? formatMessage({ id: getTranslation("modal.externalItem.loadingText.create"), defaultMessage: "Adding" }) : formatMessage({ id: getTranslation("modal.externalItem.loadingText.edit"), defaultMessage: "Saving" }),
3668
- onConfirm: addItem,
4539
+ onConfirm: handleConfirm,
3669
4540
  modalToOpen: "",
3670
4541
  currentModalType: "ExternalCreate",
3671
4542
  currentModalMode: variant === "ExternalCreate" ? "create" : "edit",
@@ -3723,8 +4594,6 @@ function ItemCreateComponent({
3723
4594
  entityRoute,
3724
4595
  setEntityRoute,
3725
4596
  entities,
3726
- createNavItem,
3727
- updateRoute,
3728
4597
  getRelatedRoute,
3729
4598
  replacement,
3730
4599
  validationState,
@@ -3736,7 +4605,8 @@ function ItemCreateComponent({
3736
4605
  debouncedCheckUrl,
3737
4606
  setModalType,
3738
4607
  selectedNavigation,
3739
- parentId
4608
+ parentId,
4609
+ onCreate
3740
4610
  }) {
3741
4611
  const [loading, setLoading] = useState(false);
3742
4612
  const { formatMessage } = useIntl();
@@ -3783,16 +4653,16 @@ function ItemCreateComponent({
3783
4653
  try {
3784
4654
  setLoading(true);
3785
4655
  if (!entityRoute || !selectedNavigation) return;
3786
- const settings = {
3787
- route: entityRoute.documentId ?? null,
3788
- parent: parentId ?? null,
3789
- navigation: selectedNavigation.documentId ?? null
3790
- };
3791
- if (path.value !== path.initialPath) {
3792
- if (navItemState.slug !== entityRoute.fullPath) navItemState.isOverride = true;
3793
- await updateRoute({ fullPath: path.value }, entityRoute.documentId);
3794
- }
3795
- await createNavItem(settings);
4656
+ const newItem = createTempNavItemObject({
4657
+ parentId,
4658
+ entityRoute,
4659
+ selectedNavigation,
4660
+ navItemState,
4661
+ selectedEntity,
4662
+ selectedContentType,
4663
+ path
4664
+ });
4665
+ onCreate(newItem);
3796
4666
  setModalType("");
3797
4667
  } catch (err) {
3798
4668
  console.log(err);
@@ -4509,10 +5379,10 @@ lodash.exports;
4509
5379
  }
4510
5380
  return index;
4511
5381
  }
4512
- function countHolders(array, placeholder) {
5382
+ function countHolders(array, placeholder2) {
4513
5383
  var length = array.length, result = 0;
4514
5384
  while (length--) {
4515
- if (array[length] === placeholder) {
5385
+ if (array[length] === placeholder2) {
4516
5386
  ++result;
4517
5387
  }
4518
5388
  }
@@ -4551,11 +5421,11 @@ lodash.exports;
4551
5421
  return func(transform(arg));
4552
5422
  };
4553
5423
  }
4554
- function replaceHolders(array, placeholder) {
5424
+ function replaceHolders(array, placeholder2) {
4555
5425
  var index = -1, length = array.length, resIndex = 0, result = [];
4556
5426
  while (++index < length) {
4557
5427
  var value = array[index];
4558
- if (value === placeholder || value === PLACEHOLDER) {
5428
+ if (value === placeholder2 || value === PLACEHOLDER) {
4559
5429
  array[index] = PLACEHOLDER;
4560
5430
  result[resIndex++] = index;
4561
5431
  }
@@ -4622,7 +5492,7 @@ lodash.exports;
4622
5492
  }
4623
5493
  var runInContext = function runInContext2(context) {
4624
5494
  context = context == null ? root : _2.defaults(root.Object(), context, _2.pick(root, contextProps));
4625
- var Array2 = context.Array, Date = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String = context.String, TypeError = context.TypeError;
5495
+ var Array2 = context.Array, Date2 = context.Date, Error2 = context.Error, Function2 = context.Function, Math2 = context.Math, Object2 = context.Object, RegExp2 = context.RegExp, String = context.String, TypeError2 = context.TypeError;
4626
5496
  var arrayProto = Array2.prototype, funcProto = Function2.prototype, objectProto = Object2.prototype;
4627
5497
  var coreJsData = context["__core-js_shared__"];
4628
5498
  var funcToString = funcProto.toString;
@@ -4647,8 +5517,8 @@ lodash.exports;
4647
5517
  } catch (e) {
4648
5518
  }
4649
5519
  }();
4650
- var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date && Date.now !== root.Date.now && Date.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
4651
- var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
5520
+ var ctxClearTimeout = context.clearTimeout !== root.clearTimeout && context.clearTimeout, ctxNow = Date2 && Date2.now !== root.Date.now && Date2.now, ctxSetTimeout = context.setTimeout !== root.setTimeout && context.setTimeout;
5521
+ var nativeCeil = Math2.ceil, nativeFloor = Math2.floor, nativeGetSymbols = Object2.getOwnPropertySymbols, nativeIsBuffer = Buffer ? Buffer.isBuffer : undefined$1, nativeIsFinite = context.isFinite, nativeJoin = arrayProto.join, nativeKeys = overArg(Object2.keys, Object2), nativeMax = Math2.max, nativeMin = Math2.min, nativeNow = Date2.now, nativeParseInt = context.parseInt, nativeRandom = Math2.random, nativeReverse = arrayProto.reverse;
4652
5522
  var DataView = getNative(context, "DataView"), Map = getNative(context, "Map"), Promise2 = getNative(context, "Promise"), Set = getNative(context, "Set"), WeakMap = getNative(context, "WeakMap"), nativeCreate = getNative(Object2, "create");
4653
5523
  var metaMap = WeakMap && new WeakMap();
4654
5524
  var realNames = {};
@@ -5145,7 +6015,7 @@ lodash.exports;
5145
6015
  }
5146
6016
  function baseDelay(func, wait, args) {
5147
6017
  if (typeof func != "function") {
5148
- throw new TypeError(FUNC_ERROR_TEXT);
6018
+ throw new TypeError2(FUNC_ERROR_TEXT);
5149
6019
  }
5150
6020
  return setTimeout(function() {
5151
6021
  func.apply(undefined$1, args);
@@ -6152,11 +7022,11 @@ lodash.exports;
6152
7022
  function createCurry(func, bitmask, arity) {
6153
7023
  var Ctor = createCtor(func);
6154
7024
  function wrapper() {
6155
- var length = arguments.length, args = Array2(length), index = length, placeholder = getHolder(wrapper);
7025
+ var length = arguments.length, args = Array2(length), index = length, placeholder2 = getHolder(wrapper);
6156
7026
  while (index--) {
6157
7027
  args[index] = arguments[index];
6158
7028
  }
6159
- var holders = length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder ? [] : replaceHolders(args, placeholder);
7029
+ var holders = length < 3 && args[0] !== placeholder2 && args[length - 1] !== placeholder2 ? [] : replaceHolders(args, placeholder2);
6160
7030
  length -= holders.length;
6161
7031
  if (length < arity) {
6162
7032
  return createRecurry(
@@ -6200,7 +7070,7 @@ lodash.exports;
6200
7070
  while (index--) {
6201
7071
  var func = funcs[index];
6202
7072
  if (typeof func != "function") {
6203
- throw new TypeError(FUNC_ERROR_TEXT);
7073
+ throw new TypeError2(FUNC_ERROR_TEXT);
6204
7074
  }
6205
7075
  if (prereq && !wrapper && getFuncName(func) == "wrapper") {
6206
7076
  var wrapper = new LodashWrapper([], true);
@@ -6237,7 +7107,7 @@ lodash.exports;
6237
7107
  args[index] = arguments[index];
6238
7108
  }
6239
7109
  if (isCurried) {
6240
- var placeholder = getHolder(wrapper), holdersCount = countHolders(args, placeholder);
7110
+ var placeholder2 = getHolder(wrapper), holdersCount = countHolders(args, placeholder2);
6241
7111
  }
6242
7112
  if (partials) {
6243
7113
  args = composeArgs(args, partials, holders, isCurried);
@@ -6247,7 +7117,7 @@ lodash.exports;
6247
7117
  }
6248
7118
  length -= holdersCount;
6249
7119
  if (isCurried && length < arity) {
6250
- var newHolders = replaceHolders(args, placeholder);
7120
+ var newHolders = replaceHolders(args, placeholder2);
6251
7121
  return createRecurry(
6252
7122
  func,
6253
7123
  bitmask,
@@ -6367,7 +7237,7 @@ lodash.exports;
6367
7237
  return operator(value, other);
6368
7238
  };
6369
7239
  }
6370
- function createRecurry(func, bitmask, wrapFunc, placeholder, thisArg, partials, holders, argPos, ary2, arity) {
7240
+ function createRecurry(func, bitmask, wrapFunc, placeholder2, thisArg, partials, holders, argPos, ary2, arity) {
6371
7241
  var isCurry = bitmask & WRAP_CURRY_FLAG, newHolders = isCurry ? holders : undefined$1, newHoldersRight = isCurry ? undefined$1 : holders, newPartials = isCurry ? partials : undefined$1, newPartialsRight = isCurry ? undefined$1 : partials;
6372
7242
  bitmask |= isCurry ? WRAP_PARTIAL_FLAG : WRAP_PARTIAL_RIGHT_FLAG;
6373
7243
  bitmask &= ~(isCurry ? WRAP_PARTIAL_RIGHT_FLAG : WRAP_PARTIAL_FLAG);
@@ -6390,7 +7260,7 @@ lodash.exports;
6390
7260
  if (isLaziable(func)) {
6391
7261
  setData(result2, newData);
6392
7262
  }
6393
- result2.placeholder = placeholder;
7263
+ result2.placeholder = placeholder2;
6394
7264
  return setWrapToString(result2, func, bitmask);
6395
7265
  }
6396
7266
  function createRound(methodName) {
@@ -6424,7 +7294,7 @@ lodash.exports;
6424
7294
  function createWrap(func, bitmask, thisArg, partials, holders, argPos, ary2, arity) {
6425
7295
  var isBindKey = bitmask & WRAP_BIND_KEY_FLAG;
6426
7296
  if (!isBindKey && typeof func != "function") {
6427
- throw new TypeError(FUNC_ERROR_TEXT);
7297
+ throw new TypeError2(FUNC_ERROR_TEXT);
6428
7298
  }
6429
7299
  var length = partials ? partials.length : 0;
6430
7300
  if (!length) {
@@ -7691,7 +8561,7 @@ lodash.exports;
7691
8561
  };
7692
8562
  function after(n, func) {
7693
8563
  if (typeof func != "function") {
7694
- throw new TypeError(FUNC_ERROR_TEXT);
8564
+ throw new TypeError2(FUNC_ERROR_TEXT);
7695
8565
  }
7696
8566
  n = toInteger(n);
7697
8567
  return function() {
@@ -7708,7 +8578,7 @@ lodash.exports;
7708
8578
  function before(n, func) {
7709
8579
  var result2;
7710
8580
  if (typeof func != "function") {
7711
- throw new TypeError(FUNC_ERROR_TEXT);
8581
+ throw new TypeError2(FUNC_ERROR_TEXT);
7712
8582
  }
7713
8583
  n = toInteger(n);
7714
8584
  return function() {
@@ -7752,7 +8622,7 @@ lodash.exports;
7752
8622
  function debounce2(func, wait, options) {
7753
8623
  var lastArgs, lastThis, maxWait, result2, timerId, lastCallTime, lastInvokeTime = 0, leading = false, maxing = false, trailing = true;
7754
8624
  if (typeof func != "function") {
7755
- throw new TypeError(FUNC_ERROR_TEXT);
8625
+ throw new TypeError2(FUNC_ERROR_TEXT);
7756
8626
  }
7757
8627
  wait = toNumber(wait) || 0;
7758
8628
  if (isObject(options)) {
@@ -7841,7 +8711,7 @@ lodash.exports;
7841
8711
  }
7842
8712
  function memoize(func, resolver) {
7843
8713
  if (typeof func != "function" || resolver != null && typeof resolver != "function") {
7844
- throw new TypeError(FUNC_ERROR_TEXT);
8714
+ throw new TypeError2(FUNC_ERROR_TEXT);
7845
8715
  }
7846
8716
  var memoized = function() {
7847
8717
  var args = arguments, key = resolver ? resolver.apply(this, args) : args[0], cache = memoized.cache;
@@ -7858,7 +8728,7 @@ lodash.exports;
7858
8728
  memoize.Cache = MapCache;
7859
8729
  function negate(predicate) {
7860
8730
  if (typeof predicate != "function") {
7861
- throw new TypeError(FUNC_ERROR_TEXT);
8731
+ throw new TypeError2(FUNC_ERROR_TEXT);
7862
8732
  }
7863
8733
  return function() {
7864
8734
  var args = arguments;
@@ -7902,14 +8772,14 @@ lodash.exports;
7902
8772
  });
7903
8773
  function rest(func, start) {
7904
8774
  if (typeof func != "function") {
7905
- throw new TypeError(FUNC_ERROR_TEXT);
8775
+ throw new TypeError2(FUNC_ERROR_TEXT);
7906
8776
  }
7907
8777
  start = start === undefined$1 ? start : toInteger(start);
7908
8778
  return baseRest(func, start);
7909
8779
  }
7910
8780
  function spread(func, start) {
7911
8781
  if (typeof func != "function") {
7912
- throw new TypeError(FUNC_ERROR_TEXT);
8782
+ throw new TypeError2(FUNC_ERROR_TEXT);
7913
8783
  }
7914
8784
  start = start == null ? 0 : nativeMax(toInteger(start), 0);
7915
8785
  return baseRest(function(args) {
@@ -7923,7 +8793,7 @@ lodash.exports;
7923
8793
  function throttle(func, wait, options) {
7924
8794
  var leading = true, trailing = true;
7925
8795
  if (typeof func != "function") {
7926
- throw new TypeError(FUNC_ERROR_TEXT);
8796
+ throw new TypeError2(FUNC_ERROR_TEXT);
7927
8797
  }
7928
8798
  if (isObject(options)) {
7929
8799
  leading = "leading" in options ? !!options.leading : leading;
@@ -8739,7 +9609,7 @@ lodash.exports;
8739
9609
  var length = pairs == null ? 0 : pairs.length, toIteratee = getIteratee();
8740
9610
  pairs = !length ? [] : arrayMap(pairs, function(pair) {
8741
9611
  if (typeof pair[1] != "function") {
8742
- throw new TypeError(FUNC_ERROR_TEXT);
9612
+ throw new TypeError2(FUNC_ERROR_TEXT);
8743
9613
  }
8744
9614
  return [toIteratee(pair[0]), pair[1]];
8745
9615
  });
@@ -9410,7 +10280,6 @@ function ItemEditComponent({
9410
10280
  selectedContentType,
9411
10281
  setSelectedContentType,
9412
10282
  entities,
9413
- updateRoute,
9414
10283
  replacement,
9415
10284
  validationState,
9416
10285
  initialState,
@@ -9419,7 +10288,8 @@ function ItemEditComponent({
9419
10288
  path,
9420
10289
  dispatchPath,
9421
10290
  debouncedCheckUrl,
9422
- setModalType
10291
+ setModalType,
10292
+ onEdit
9423
10293
  }) {
9424
10294
  const { formatMessage } = useIntl();
9425
10295
  useEffect(() => {
@@ -9465,12 +10335,15 @@ function ItemEditComponent({
9465
10335
  try {
9466
10336
  if (lodashExports.isEqual(navItemState, initialState.current) && path.value === path.initialPath) return;
9467
10337
  const isOverride = path.value !== item.route.fullPath ? true : navItemState.isOverride;
9468
- await updateRoute({
9469
- ...navItemState,
9470
- slug: path.value,
9471
- fullPath: path.value,
9472
- isOverride
9473
- }, item.route.documentId);
10338
+ onEdit({
10339
+ ...item,
10340
+ update: {
10341
+ title: navItemState.title,
10342
+ slug: navItemState.slug,
10343
+ fullPath: path.value,
10344
+ isOverride
10345
+ }
10346
+ });
9474
10347
  setModalType("");
9475
10348
  } catch (err) {
9476
10349
  console.log(err);
@@ -9569,19 +10442,25 @@ function ItemEditComponent({
9569
10442
  );
9570
10443
  }
9571
10444
  const ItemEdit = withModalSharedLogic(ItemEditComponent);
9572
- function WrapperItemComponent({
9573
- variant,
9574
- item,
9575
- createNavItem,
9576
- navItemState,
9577
- dispatchItemState,
9578
- createExternalRoute,
9579
- updateRoute,
9580
- dispatchPath,
9581
- setModalType,
9582
- selectedNavigation,
9583
- parentDocumentId
9584
- }) {
10445
+ function isWrapperEditProps(props) {
10446
+ return props.variant === "WrapperEdit";
10447
+ }
10448
+ function isWrapperCreateProps(props) {
10449
+ return props.variant === "WrapperCreate";
10450
+ }
10451
+ function WrapperItemComponent(props) {
10452
+ const {
10453
+ variant,
10454
+ navItemState,
10455
+ dispatchItemState,
10456
+ dispatchPath,
10457
+ setModalType,
10458
+ selectedNavigation
10459
+ } = props;
10460
+ const parentId = isWrapperCreateProps(props) ? props.parentId : void 0;
10461
+ const onCreate = isWrapperCreateProps(props) ? props.onCreate : void 0;
10462
+ const onSave = isWrapperEditProps(props) ? props.onSave : void 0;
10463
+ const item = isWrapperEditProps(props) ? props.item : void 0;
9585
10464
  const { formatMessage } = useIntl();
9586
10465
  useEffect(() => {
9587
10466
  if (variant !== "WrapperEdit" || !item) return;
@@ -9589,7 +10468,7 @@ function WrapperItemComponent({
9589
10468
  dispatchItemState({ type: "SET_ACTIVE", payload: item.route.active });
9590
10469
  dispatchPath({ type: "NO_TRANSFORM_AND_CHECK", payload: item.route.fullPath });
9591
10470
  }, []);
9592
- const addItem = async () => {
10471
+ const onConfirm = async () => {
9593
10472
  try {
9594
10473
  if (!navItemState.title || !selectedNavigation) return;
9595
10474
  const data = {
@@ -9598,17 +10477,24 @@ function WrapperItemComponent({
9598
10477
  internal: false,
9599
10478
  wrapper: true
9600
10479
  };
9601
- if (variant === "WrapperEdit" && item) {
9602
- await updateRoute(data, item.route.documentId);
9603
- } else {
9604
- const route = await createExternalRoute(data);
9605
- if (!route) return;
9606
- const settings = {
9607
- route: route.documentId,
9608
- parent: parentDocumentId ?? null,
9609
- navigation: selectedNavigation.documentId
9610
- };
9611
- await createNavItem(settings);
10480
+ if (variant === "WrapperEdit" && item && onSave) {
10481
+ onSave({
10482
+ ...item,
10483
+ update: {
10484
+ ...data
10485
+ }
10486
+ });
10487
+ } else if (onCreate) {
10488
+ const newItem = createTempNavItemObject({
10489
+ parentId,
10490
+ entityRoute: null,
10491
+ selectedNavigation,
10492
+ navItemState,
10493
+ selectedEntity: null,
10494
+ selectedContentType: null,
10495
+ wrapper: true
10496
+ });
10497
+ onCreate(newItem);
9612
10498
  }
9613
10499
  setModalType("");
9614
10500
  } catch (err) {
@@ -9622,7 +10508,7 @@ function WrapperItemComponent({
9622
10508
  closeText: formatMessage({ id: getTranslation("cancel"), defaultMessage: "Cancel" }),
9623
10509
  titleText: variant === "WrapperCreate" ? formatMessage({ id: getTranslation("modal.wrapperItem.titleText.create"), defaultMessage: "Create new wrapper item" }) : formatMessage({ id: getTranslation("modal.wrapperItem.titleText.edit"), defaultMessage: "Edit wrapper item:" }) + ` "${navItemState.title}"`,
9624
10510
  loadingText: variant === "WrapperCreate" ? formatMessage({ id: getTranslation("modal.wrapperItem.loadingText.create"), defaultMessage: "Adding" }) : formatMessage({ id: getTranslation("modal.wrapperItem.loadingText.edit"), defaultMessage: "Saving" }),
9625
- onConfirm: addItem,
10511
+ onConfirm,
9626
10512
  modalToOpen: "",
9627
10513
  currentModalType: "WrapperCreate",
9628
10514
  currentModalMode: variant === "WrapperCreate" ? "create" : "edit",
@@ -9649,35 +10535,6 @@ function WrapperItemComponent({
9649
10535
  );
9650
10536
  }
9651
10537
  const WrapperItem = withModalSharedLogic(WrapperItemComponent);
9652
- function Header({ navigations }) {
9653
- const { setModalType } = useContext(ModalContext);
9654
- const { selectedNavigation, setSelectedNavigation } = useContext(SelectedNavigationContext);
9655
- const { formatMessage } = useIntl();
9656
- return /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
9657
- /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => setModalType("NavOverview"), children: formatMessage({
9658
- id: getTranslation("manage"),
9659
- defaultMessage: "Manage"
9660
- }) }),
9661
- /* @__PURE__ */ jsx(
9662
- SingleSelect,
9663
- {
9664
- value: selectedNavigation ? selectedNavigation.slug : "",
9665
- placeholder: formatMessage({
9666
- id: getTranslation("navigation.page.selectNavigation"),
9667
- defaultMessage: "Select Navigation"
9668
- }),
9669
- onChange: (value) => {
9670
- const navItem = navigations.find((nav) => nav.slug === value);
9671
- if (navItem) {
9672
- setSelectedNavigation(navItem);
9673
- }
9674
- },
9675
- disabled: navigations.length === 0,
9676
- children: navigations.map((nav) => /* @__PURE__ */ jsx(SingleSelectOption, { value: nav.slug, children: nav.name }, nav.id))
9677
- }
9678
- )
9679
- ] });
9680
- }
9681
10538
  const measuring = {
9682
10539
  droppable: {
9683
10540
  strategy: MeasuringStrategy.Always
@@ -9734,13 +10591,30 @@ function RouteIcon({ type, color = "neutral800" }) {
9734
10591
  const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth, style, wrapperRef, handleProps }, ref) => {
9735
10592
  if (!item || !item.route) return null;
9736
10593
  const { setModalType } = useContext(ModalContext);
9737
- const { get } = useFetchClient();
9738
10594
  const { formatMessage } = useIntl();
9739
- const [itemStatus, setItemStatus] = useState({
9740
- status: "published",
9741
- variant: "primary",
9742
- textColor: "primary700"
9743
- });
10595
+ const itemStatusOptions = {
10596
+ published: {
10597
+ status: formatMessage({
10598
+ id: getTranslation("published"),
10599
+ defaultMessage: "Published"
10600
+ }),
10601
+ variant: "primary"
10602
+ },
10603
+ draft: {
10604
+ status: formatMessage({
10605
+ id: getTranslation("draft"),
10606
+ defaultMessage: "Draft"
10607
+ }),
10608
+ variant: "secondary"
10609
+ },
10610
+ modified: {
10611
+ status: formatMessage({
10612
+ id: getTranslation("modified"),
10613
+ defaultMessage: "Modified"
10614
+ }),
10615
+ variant: "alternative"
10616
+ }
10617
+ };
9744
10618
  const [type, setType] = useState();
9745
10619
  useEffect(() => {
9746
10620
  if (!item.route.internal && !item.route.wrapper) {
@@ -9751,41 +10625,6 @@ const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth,
9751
10625
  setType("internal");
9752
10626
  }
9753
10627
  }, [item]);
9754
- useEffect(() => {
9755
- const ct = item.route.relatedContentType;
9756
- const id = item.route.relatedDocumentId;
9757
- if (!ct || !id) return;
9758
- async function fetchRelated() {
9759
- try {
9760
- const { data } = await get(`/content-manager/collection-types/${ct}/${id}`);
9761
- switch (data.data.status) {
9762
- case "modified":
9763
- setItemStatus({
9764
- status: "Modified",
9765
- variant: "alternative",
9766
- textColor: "alternative700"
9767
- });
9768
- break;
9769
- case "draft":
9770
- setItemStatus({
9771
- status: "Draft",
9772
- variant: "secondary",
9773
- textColor: "secondary700"
9774
- });
9775
- break;
9776
- default:
9777
- setItemStatus({
9778
- status: "Published",
9779
- variant: "primary",
9780
- textColor: "primary700"
9781
- });
9782
- }
9783
- } catch (err) {
9784
- console.log(err);
9785
- }
9786
- }
9787
- fetchRelated();
9788
- }, []);
9789
10628
  const handleAddChildren = () => {
9790
10629
  setParentId(item.documentId);
9791
10630
  setModalType("ItemCreate");
@@ -9803,7 +10642,7 @@ const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth,
9803
10642
  };
9804
10643
  const elStyle = {
9805
10644
  marginLeft: depth !== void 0 ? depth * 48 : 0,
9806
- opacity: ghost ? 0.5 : 1,
10645
+ opacity: ghost || item.deleted ? 0.5 : 1,
9807
10646
  ...style
9808
10647
  };
9809
10648
  return /* @__PURE__ */ jsx(
@@ -9824,29 +10663,39 @@ const RouteItem = forwardRef(({ item, setParentId, setActionItem, ghost, depth,
9824
10663
  shadow: "tableShadow",
9825
10664
  ref,
9826
10665
  children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", gap: 4, children: [
9827
- /* @__PURE__ */ jsxs(Flex, { children: [
10666
+ /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
9828
10667
  /* @__PURE__ */ jsx(Drag, { color: "neutral800", ...handleProps }),
9829
10668
  /* @__PURE__ */ jsx(
9830
10669
  Box,
9831
10670
  {
9832
- marginLeft: 4,
9833
- marginRight: 4,
9834
10671
  width: "1px",
9835
10672
  height: "32px",
9836
10673
  background: "neutral150"
9837
10674
  }
9838
10675
  ),
9839
10676
  /* @__PURE__ */ jsx(RouteIcon, { type }),
9840
- /* @__PURE__ */ jsxs(Flex, { gap: 2, marginLeft: 4, children: [
9841
- /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: item.route.title }),
10677
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
10678
+ /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: item.update?.title ? item.update.title : item.route.title }),
9842
10679
  /* @__PURE__ */ jsxs(Typography, { textColor: "neutral400", children: [
9843
10680
  type === "internal" && "/",
9844
- item.route.fullPath
10681
+ item.update?.fullPath ? item.update.fullPath : item.route.fullPath
9845
10682
  ] })
9846
- ] })
10683
+ ] }),
10684
+ item.isNew && !item.deleted && /* @__PURE__ */ jsx(Status, { variant: "alternative", size: "S", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
10685
+ id: getTranslation("new"),
10686
+ defaultMessage: "New"
10687
+ }) }) }),
10688
+ item.update && !item.deleted && /* @__PURE__ */ jsx(Status, { variant: "alternative", size: "S", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: formatMessage({
10689
+ id: getTranslation("updated"),
10690
+ defaultMessage: "Updated"
10691
+ }) }) }),
10692
+ item.deleted && /* @__PURE__ */ jsx(Status, { size: "S", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "danger500", children: formatMessage({
10693
+ id: getTranslation("deleted"),
10694
+ defaultMessage: "Deleted"
10695
+ }) }) })
9847
10696
  ] }),
9848
10697
  /* @__PURE__ */ jsxs(Flex, { direction: "row", gap: 4, children: [
9849
- type === "internal" && /* @__PURE__ */ jsx(Status, { variant: itemStatus.variant, size: "S", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: itemStatus.textColor, children: itemStatus.status }) }),
10698
+ type === "internal" && item.status && /* @__PURE__ */ jsx(Status, { variant: itemStatusOptions[item.status].variant, size: "S", children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", children: itemStatusOptions[item.status].status }) }),
9850
10699
  /* @__PURE__ */ jsxs(SimpleMenu, { label: "Notifications", tag: IconButton, icon: /* @__PURE__ */ jsx(More, {}), children: [
9851
10700
  /* @__PURE__ */ jsx(MenuItem, { onClick: () => handleEdit(), children: formatMessage({
9852
10701
  id: getTranslation("edit"),
@@ -9900,50 +10749,176 @@ function SortableRouteItem({ item, depth, ...props }) {
9900
10749
  }
9901
10750
  );
9902
10751
  }
10752
+ function PageWrapper({ navigations, loading = false, children }) {
10753
+ const { formatMessage } = useIntl();
10754
+ const { selectedNavigation, setSelectedNavigation } = useContext(SelectedNavigationContext);
10755
+ const { setModalType } = useContext(ModalContext);
10756
+ return /* @__PURE__ */ jsxs(Page.Main, { children: [
10757
+ /* @__PURE__ */ jsx(
10758
+ Layouts.Header,
10759
+ {
10760
+ title: formatMessage({
10761
+ id: getTranslation("navigation.page.title"),
10762
+ defaultMessage: "Navigation"
10763
+ }) + (selectedNavigation ? `: ${selectedNavigation.name}` : ""),
10764
+ subtitle: /* @__PURE__ */ jsx(Typography, { textColor: "neutral500", children: selectedNavigation ? `ID: ${selectedNavigation.id} | DocumentID : ${selectedNavigation.documentId}` : formatMessage({
10765
+ id: getTranslation("navigation.page.subtitle.noNavigationSelected"),
10766
+ defaultMessage: "No navigation selected"
10767
+ }) }),
10768
+ primaryAction: !loading && /* @__PURE__ */ jsxs(Flex, { gap: 4, children: [
10769
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => setModalType("NavOverview"), children: formatMessage({
10770
+ id: getTranslation("manage"),
10771
+ defaultMessage: "Manage"
10772
+ }) }),
10773
+ /* @__PURE__ */ jsx(
10774
+ SingleSelect,
10775
+ {
10776
+ value: selectedNavigation ? selectedNavigation.slug : "",
10777
+ placeholder: formatMessage({
10778
+ id: getTranslation("navigation.page.selectNavigation"),
10779
+ defaultMessage: "Select Navigation"
10780
+ }),
10781
+ onChange: (value) => {
10782
+ const navItem = navigations.find((nav) => nav.slug === value);
10783
+ console.log("switched navigation to: ", navItem);
10784
+ if (navItem) {
10785
+ setSelectedNavigation(navItem);
10786
+ }
10787
+ },
10788
+ disabled: navigations.length === 0,
10789
+ children: navigations.map((nav) => /* @__PURE__ */ jsx(SingleSelectOption, { value: nav.slug, children: nav.name }, nav.id))
10790
+ }
10791
+ )
10792
+ ] })
10793
+ }
10794
+ ),
10795
+ /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Box, { children }) })
10796
+ ] });
10797
+ }
9903
10798
  const Navigation = () => {
9904
- const { navigations, fetchNavigations } = useNavigations();
10799
+ const [navigations, setNavigations] = useState([]);
9905
10800
  const [modalType, setModalType] = useState("");
9906
10801
  const [selectedNavigation, setSelectedNavigation] = useState();
9907
10802
  const [navigationItems, setNavigationItems] = useState();
9908
10803
  const [initialNavigationItems, setInitialNavigationItems] = useState();
9909
10804
  const [actionItem, setActionItem] = useState();
9910
10805
  const [parentId, setParentId] = useState();
9911
- const { getStructuredNavigation, updateNavItem } = useApi();
10806
+ const { getNavigation, updateNavigationItemStructure } = useApi();
10807
+ const [isSavingNavigation, setIsSavingNavigation] = useState(false);
10808
+ const [loading, setLoading] = useState(false);
9912
10809
  const [projected, setProjected] = useState(null);
9913
10810
  const [activeItem, setActiveItem] = useState();
9914
10811
  const [activeId, setActiveId] = useState(null);
9915
10812
  const [overId, setOverId] = useState(null);
9916
10813
  const [offsetLeft, setOffsetLeft] = useState(0);
9917
10814
  const { formatMessage } = useIntl();
9918
- if (!navigations) return null;
10815
+ const { toggleNotification } = useNotification();
10816
+ const { get } = useFetchClient();
10817
+ async function loadNavigations() {
10818
+ try {
10819
+ const data = await getNavigation({ variant: "flat" });
10820
+ const updatedNavigations = await Promise.all(
10821
+ data.map(async (nav) => {
10822
+ const updatedItems = await Promise.all(
10823
+ nav.items.map(async (item) => {
10824
+ const ct = item.route.relatedContentType;
10825
+ const id = item.route.relatedDocumentId;
10826
+ if (!ct || !id) return item;
10827
+ try {
10828
+ const { data: data2 } = await get(`/content-manager/collection-types/${ct}/${id}`);
10829
+ return { ...item, status: data2.data.status };
10830
+ } catch (err) {
10831
+ console.error(err);
10832
+ return item;
10833
+ }
10834
+ })
10835
+ );
10836
+ return { ...nav, items: updatedItems };
10837
+ })
10838
+ );
10839
+ setNavigations(updatedNavigations);
10840
+ setSelectedNavigation(updatedNavigations[0]);
10841
+ } catch (error) {
10842
+ console.error("Error fetching navigations: ", error);
10843
+ toggleNotification({
10844
+ type: "danger",
10845
+ message: formatMessage({
10846
+ id: getTranslation("notification.navigation.fetchFailed"),
10847
+ defaultMessage: "Failed to fetch navigations"
10848
+ })
10849
+ });
10850
+ }
10851
+ }
10852
+ useEffect(() => {
10853
+ async function fetchNavigations() {
10854
+ setLoading(true);
10855
+ await loadNavigations();
10856
+ setLoading(false);
10857
+ }
10858
+ fetchNavigations();
10859
+ }, []);
9919
10860
  useEffect(() => {
9920
10861
  if (modalType === "NavOverview" || modalType === "") {
9921
10862
  setActionItem(void 0);
9922
10863
  setParentId(void 0);
9923
- fetchNavigations();
9924
10864
  }
9925
10865
  }, [modalType]);
9926
10866
  useEffect(() => {
9927
- async function fetchNestedNavigation() {
9928
- if (!selectedNavigation && (!navigations || navigations.length === 0)) return;
9929
- const documentId = selectedNavigation?.documentId ?? navigations?.[0]?.documentId;
9930
- if (!documentId) return;
9931
- const { items } = await getStructuredNavigation(documentId, "flat");
9932
- setNavigationItems(items);
9933
- }
9934
- if (Array.isArray(navigations) && navigations?.length > 0)
9935
- fetchNestedNavigation();
9936
- }, [navigations, selectedNavigation]);
9937
- useEffect(() => {
9938
- if (navigations.length > 0 && (!selectedNavigation || !navigations.find((nav) => nav.id === selectedNavigation.id))) {
9939
- setSelectedNavigation(navigations[0]);
9940
- }
9941
- }, [navigations]);
10867
+ setNavigationItems(selectedNavigation?.items || []);
10868
+ }, [selectedNavigation]);
9942
10869
  useEffect(() => {
9943
- if (navigationItems && !initialNavigationItems) {
10870
+ if (selectedNavigation?.items && !initialNavigationItems) {
9944
10871
  setInitialNavigationItems(navigationItems);
9945
10872
  }
9946
10873
  }, [navigationItems]);
10874
+ useEffect(() => {
10875
+ if (!activeId || !navigationItems) return;
10876
+ const item = navigationItems.find(({ id }) => id === activeId);
10877
+ setActiveItem(item);
10878
+ }, [navigationItems, activeId]);
10879
+ function handleSoftAddedItem(newItem) {
10880
+ if (newItem.isNew?.parent) {
10881
+ const parentIndex = navigationItems?.findIndex((item) => item.documentId === newItem.isNew?.parent);
10882
+ if (parentIndex !== void 0 && parentIndex >= 0) {
10883
+ const parentDepth = navigationItems ? navigationItems[parentIndex].depth || 0 : 0;
10884
+ newItem.depth = parentDepth + 1;
10885
+ const updatedItems = navigationItems ? [
10886
+ ...navigationItems.slice(0, parentIndex + 1),
10887
+ newItem,
10888
+ ...navigationItems.slice(parentIndex + 1)
10889
+ ] : [newItem];
10890
+ setNavigationItems(updatedItems);
10891
+ return;
10892
+ }
10893
+ }
10894
+ setNavigationItems((items) => items ? [...items, newItem] : [newItem]);
10895
+ }
10896
+ async function saveNavigation() {
10897
+ if (!navigationItems || !selectedNavigation) return;
10898
+ setIsSavingNavigation(true);
10899
+ try {
10900
+ await updateNavigationItemStructure(selectedNavigation.documentId, navigationItems);
10901
+ toggleNotification({
10902
+ type: "success",
10903
+ message: formatMessage({
10904
+ id: getTranslation("notification.navigation.navigationSaved"),
10905
+ defaultMessage: "Navigation updated successfully"
10906
+ })
10907
+ });
10908
+ } catch (e) {
10909
+ console.error(e);
10910
+ toggleNotification({
10911
+ type: "danger",
10912
+ message: formatMessage({
10913
+ id: getTranslation("notification.navigation.saveNavigationFailed"),
10914
+ defaultMessage: "Error updating navigation item"
10915
+ })
10916
+ });
10917
+ } finally {
10918
+ loadNavigations();
10919
+ setIsSavingNavigation(false);
10920
+ }
10921
+ }
9947
10922
  function handleDragStart({ active: { id: activeId2 } }) {
9948
10923
  if (!navigationItems) return;
9949
10924
  setActiveId(activeId2);
@@ -9978,41 +10953,6 @@ const Navigation = () => {
9978
10953
  setOffsetLeft(0);
9979
10954
  document.body.style.setProperty("cursor", "");
9980
10955
  }
9981
- function saveOrder() {
9982
- if (!navigationItems || !selectedNavigation) return;
9983
- let groupIndices = [0];
9984
- let parentIds = [];
9985
- navigationItems.forEach((item, index) => {
9986
- const previousItem = navigationItems[index - 1];
9987
- if (typeof item.depth !== "number") return;
9988
- if (item.depth === 0) {
9989
- groupIndices[0] = (groupIndices[0] || 0) + 1;
9990
- parentIds = [];
9991
- } else if (typeof previousItem.depth === "number" && item.depth === previousItem.depth + 1) {
9992
- parentIds.push(previousItem.documentId);
9993
- groupIndices[item.depth] = 0;
9994
- } else if (typeof previousItem.depth === "number" && item.depth <= previousItem.depth) {
9995
- const diff = previousItem.depth - item.depth;
9996
- for (let i = 0; i < diff; i++) {
9997
- parentIds.pop();
9998
- groupIndices.pop();
9999
- }
10000
- groupIndices[item.depth] = (groupIndices[item.depth] || 0) + 1;
10001
- }
10002
- updateNavItem(item.documentId, {
10003
- order: groupIndices[item.depth],
10004
- parent: parentIds.at(-1) || "",
10005
- route: item?.route?.documentId || "",
10006
- navigation: selectedNavigation?.documentId || ""
10007
- });
10008
- });
10009
- setInitialNavigationItems(navigationItems);
10010
- }
10011
- useEffect(() => {
10012
- if (!activeId || !navigationItems) return;
10013
- const item = navigationItems.find(({ id }) => id === activeId);
10014
- setActiveItem(item);
10015
- }, [navigationItems, activeId]);
10016
10956
  useEffect(() => {
10017
10957
  const projection = activeId && overId ? getProjection(
10018
10958
  navigationItems,
@@ -10022,107 +10962,185 @@ const Navigation = () => {
10022
10962
  ) : null;
10023
10963
  setProjected(projection);
10024
10964
  }, [activeId, overId, offsetLeft, navigationItems]);
10965
+ if (loading) {
10966
+ return /* @__PURE__ */ jsx(PageWrapper, { navigations, loading, children: /* @__PURE__ */ jsx(FullLoader, {}) });
10967
+ }
10025
10968
  return /* @__PURE__ */ jsx(ModalContext.Provider, { value: { modalType, setModalType }, children: /* @__PURE__ */ jsxs(SelectedNavigationContext.Provider, { value: { selectedNavigation, setSelectedNavigation }, children: [
10026
- /* @__PURE__ */ jsxs(Fragment, { children: [
10027
- /* @__PURE__ */ jsx(
10028
- Layouts.Header,
10029
- {
10030
- title: formatMessage({
10031
- id: getTranslation("navigation.page.title"),
10032
- defaultMessage: "Navigation"
10033
- }) + (selectedNavigation ? `: ${selectedNavigation.name}` : ""),
10034
- subtitle: /* @__PURE__ */ jsx(Typography, { textColor: "neutral500", children: selectedNavigation ? `ID: ${selectedNavigation.id} | DocumentID : ${selectedNavigation.documentId}` : formatMessage({
10035
- id: getTranslation("navigation.page.subtitle.noNavigationSelected"),
10036
- defaultMessage: "No navigation selected"
10037
- }) }),
10038
- primaryAction: /* @__PURE__ */ jsx(Header, { navigations })
10039
- }
10040
- ),
10041
- /* @__PURE__ */ jsxs(Layouts.Content, { children: [
10042
- selectedNavigation && /* @__PURE__ */ jsxs(Flex, { gap: 4, paddingBottom: 6, justifyContent: "flex-end", children: [
10043
- /* @__PURE__ */ jsx(Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(Plus, {}), onClick: () => setModalType("ItemCreate"), children: formatMessage({
10044
- id: getTranslation("navigation.page.newItemButton"),
10045
- defaultMessage: "New Item"
10046
- }) }),
10047
- /* @__PURE__ */ jsx(
10048
- Button,
10049
- {
10050
- startIcon: /* @__PURE__ */ jsx(Check, {}),
10051
- onClick: () => saveOrder(),
10052
- disabled: JSON.stringify(navigationItems) === JSON.stringify(initialNavigationItems),
10053
- children: formatMessage({
10054
- id: getTranslation("save"),
10055
- defaultMessage: "Save"
10056
- })
10057
- }
10058
- )
10059
- ] }),
10060
- navigationItems && navigationItems.length > 0 && /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: /* @__PURE__ */ jsx(
10061
- DndContext,
10969
+ /* @__PURE__ */ jsxs(PageWrapper, { navigations, children: [
10970
+ selectedNavigation && /* @__PURE__ */ jsxs(Flex, { gap: 4, paddingBottom: 6, justifyContent: "flex-end", children: [
10971
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", startIcon: /* @__PURE__ */ jsx(Plus, {}), onClick: () => setModalType("ItemCreate"), children: formatMessage({
10972
+ id: getTranslation("navigation.page.newItemButton"),
10973
+ defaultMessage: "New Item"
10974
+ }) }),
10975
+ /* @__PURE__ */ jsx(
10976
+ Button,
10062
10977
  {
10063
- collisionDetection: (e) => closestCenter(e),
10064
- onDragStart: (e) => handleDragStart(e),
10065
- onDragMove: (e) => handleDragMove(e),
10066
- onDragOver: (e) => handleDragOver(e),
10067
- onDragEnd: (e) => handleDragEnd(e),
10068
- onDragCancel: () => handleDragCancel(),
10069
- measuring,
10070
- children: /* @__PURE__ */ jsxs(SortableContext, { items: navigationItems, strategy: verticalListSortingStrategy, children: [
10071
- navigationItems.map((item, index) => /* @__PURE__ */ jsx(
10978
+ onClick: () => saveNavigation(),
10979
+ loading: isSavingNavigation,
10980
+ variant: "primary",
10981
+ children: formatMessage({
10982
+ id: getTranslation("save"),
10983
+ defaultMessage: "Save"
10984
+ })
10985
+ }
10986
+ )
10987
+ ] }),
10988
+ selectedNavigation && navigationItems && navigationItems.length > 0 && /* @__PURE__ */ jsx(Flex, { direction: "column", alignItems: "stretch", gap: 4, children: /* @__PURE__ */ jsx(
10989
+ DndContext,
10990
+ {
10991
+ collisionDetection: (e) => closestCenter(e),
10992
+ onDragStart: (e) => handleDragStart(e),
10993
+ onDragMove: (e) => handleDragMove(e),
10994
+ onDragOver: (e) => handleDragOver(e),
10995
+ onDragEnd: (e) => handleDragEnd(e),
10996
+ onDragCancel: () => handleDragCancel(),
10997
+ measuring,
10998
+ children: /* @__PURE__ */ jsxs(SortableContext, { items: navigationItems, strategy: verticalListSortingStrategy, children: [
10999
+ navigationItems.map((item, index) => /* @__PURE__ */ jsx(
11000
+ SortableRouteItem,
11001
+ {
11002
+ item,
11003
+ setParentId,
11004
+ setActionItem,
11005
+ indentationWidth,
11006
+ depth: item.id === activeId && projected ? projected.depth : item.depth
11007
+ },
11008
+ item.documentId || index
11009
+ )),
11010
+ createPortal(
11011
+ /* @__PURE__ */ jsx(DragOverlay, { children: activeId && activeItem ? /* @__PURE__ */ jsx(
10072
11012
  SortableRouteItem,
10073
11013
  {
10074
- item,
11014
+ item: activeItem,
10075
11015
  setParentId,
10076
- setActionItem,
10077
- indentationWidth,
10078
- depth: item.id === activeId && projected ? projected.depth : item.depth
10079
- },
10080
- index
10081
- )),
10082
- createPortal(
10083
- /* @__PURE__ */ jsx(DragOverlay, { children: activeId && activeItem ? /* @__PURE__ */ jsx(
10084
- SortableRouteItem,
10085
- {
10086
- item: activeItem,
10087
- setParentId,
10088
- setActionItem
10089
- }
10090
- ) : null }),
10091
- document.body
10092
- )
10093
- ] })
10094
- }
10095
- ) }),
10096
- navigations?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
10097
- /* @__PURE__ */ jsx(EmptyBox, { msg: formatMessage({
10098
- id: getTranslation("navigation.page.emptyNavigation"),
10099
- defaultMessage: "You have no navigations yet..."
10100
- }) }),
10101
- /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => setModalType("NavCreate"), children: formatMessage({
10102
- id: getTranslation("navigation.page.createNewNavigation"),
10103
- defaultMessage: "Create new navigation"
10104
- }) })
10105
- ] }),
10106
- navigationItems?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
10107
- /* @__PURE__ */ jsx(EmptyBox, { msg: "Your navigation is empty..." }),
10108
- /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => setModalType("ItemCreate"), children: formatMessage({
10109
- id: getTranslation("navigation.page.createNewItem"),
10110
- defaultMessage: "Create new item"
10111
- }) })
10112
- ] })
11016
+ setActionItem
11017
+ }
11018
+ ) : null }),
11019
+ document.body
11020
+ )
11021
+ ] })
11022
+ }
11023
+ ) }),
11024
+ navigations?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
11025
+ /* @__PURE__ */ jsx(EmptyBox, { msg: formatMessage({
11026
+ id: getTranslation("navigation.page.emptyNavigation"),
11027
+ defaultMessage: "You have no navigations yet..."
11028
+ }) }),
11029
+ /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => setModalType("NavCreate"), children: formatMessage({
11030
+ id: getTranslation("navigation.page.createNewNavigation"),
11031
+ defaultMessage: "Create new navigation"
11032
+ }) })
11033
+ ] }),
11034
+ navigationItems?.length === 0 && /* @__PURE__ */ jsxs(Center, { height: 400, children: [
11035
+ /* @__PURE__ */ jsx(EmptyBox, { msg: "Your navigation is empty..." }),
11036
+ /* @__PURE__ */ jsx(Button, { variant: "primary", onClick: () => setModalType("ItemCreate"), children: formatMessage({
11037
+ id: getTranslation("navigation.page.createNewItem"),
11038
+ defaultMessage: "Create new item"
11039
+ }) })
10113
11040
  ] })
10114
11041
  ] }),
10115
- modalType === "NavOverview" && /* @__PURE__ */ jsx(NavOverview, { navigations, setActionItem }),
11042
+ modalType === "NavOverview" && /* @__PURE__ */ jsx(
11043
+ NavOverview,
11044
+ {
11045
+ navigations,
11046
+ setActionItem
11047
+ }
11048
+ ),
10116
11049
  modalType === "NavCreate" && /* @__PURE__ */ jsx(NavCreate, {}),
10117
- modalType === "NavDelete" && /* @__PURE__ */ jsx(Delete, { variant: "NavDelete", item: actionItem, fetchNavigations }),
10118
- modalType === "NavEdit" && /* @__PURE__ */ jsx(NavEdit, { item: actionItem, fetchNavigations }),
10119
- modalType === "ItemCreate" && /* @__PURE__ */ jsx(ItemCreate, { parentId }),
10120
- modalType === "ItemDelete" && /* @__PURE__ */ jsx(Delete, { variant: "ItemDelete", item: actionItem, fetchNavigations }),
10121
- modalType === "ItemEdit" && /* @__PURE__ */ jsx(ItemEdit, { item: actionItem }),
10122
- modalType === "ExternalCreate" && /* @__PURE__ */ jsx(ExternalItem, { variant: modalType, parentDocumentId: parentId }),
10123
- modalType === "ExternalEdit" && /* @__PURE__ */ jsx(ExternalItem, { variant: modalType, item: actionItem }),
10124
- modalType === "WrapperCreate" && /* @__PURE__ */ jsx(WrapperItem, { variant: modalType, parentDocumentId: parentId }),
10125
- modalType === "WrapperEdit" && /* @__PURE__ */ jsx(WrapperItem, { variant: modalType, item: actionItem })
11050
+ modalType === "NavDelete" && /* @__PURE__ */ jsx(
11051
+ Delete,
11052
+ {
11053
+ variant: "NavDelete",
11054
+ item: actionItem,
11055
+ onDelete: () => {
11056
+ }
11057
+ }
11058
+ ),
11059
+ modalType === "NavEdit" && /* @__PURE__ */ jsx(
11060
+ NavEdit,
11061
+ {
11062
+ item: actionItem,
11063
+ onEdit: () => {
11064
+ }
11065
+ }
11066
+ ),
11067
+ modalType === "ItemCreate" && /* @__PURE__ */ jsx(
11068
+ ItemCreate,
11069
+ {
11070
+ parentId,
11071
+ onCreate: (newItem) => {
11072
+ handleSoftAddedItem(newItem);
11073
+ }
11074
+ }
11075
+ ),
11076
+ modalType === "ItemDelete" && /* @__PURE__ */ jsx(
11077
+ Delete,
11078
+ {
11079
+ variant: "ItemDelete",
11080
+ item: actionItem,
11081
+ onDelete: (editedItem) => {
11082
+ setNavigationItems(
11083
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11084
+ );
11085
+ }
11086
+ }
11087
+ ),
11088
+ modalType === "ItemEdit" && /* @__PURE__ */ jsx(
11089
+ ItemEdit,
11090
+ {
11091
+ item: actionItem,
11092
+ onEdit: (editedItem) => {
11093
+ console.log(editedItem);
11094
+ setNavigationItems(
11095
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11096
+ );
11097
+ }
11098
+ }
11099
+ ),
11100
+ modalType === "ExternalCreate" && /* @__PURE__ */ jsx(
11101
+ ExternalItem,
11102
+ {
11103
+ variant: modalType,
11104
+ parentId,
11105
+ onCreate: (newItem) => {
11106
+ handleSoftAddedItem(newItem);
11107
+ }
11108
+ }
11109
+ ),
11110
+ modalType === "ExternalEdit" && /* @__PURE__ */ jsx(
11111
+ ExternalItem,
11112
+ {
11113
+ variant: modalType,
11114
+ item: actionItem,
11115
+ onSave: (editedItem) => {
11116
+ setNavigationItems(
11117
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11118
+ );
11119
+ }
11120
+ }
11121
+ ),
11122
+ modalType === "WrapperCreate" && /* @__PURE__ */ jsx(
11123
+ WrapperItem,
11124
+ {
11125
+ variant: modalType,
11126
+ parentId,
11127
+ onCreate: (newItem) => {
11128
+ handleSoftAddedItem(newItem);
11129
+ }
11130
+ }
11131
+ ),
11132
+ modalType === "WrapperEdit" && /* @__PURE__ */ jsx(
11133
+ WrapperItem,
11134
+ {
11135
+ variant: modalType,
11136
+ item: actionItem,
11137
+ onSave: (editedItem) => {
11138
+ setNavigationItems(
11139
+ (items) => items?.map((item) => item.id === editedItem.id ? editedItem : item)
11140
+ );
11141
+ }
11142
+ }
11143
+ )
10126
11144
  ] }) });
10127
11145
  };
10128
11146
  export {