@mattisvensson/strapi-plugin-webatlas 0.11.7 → 0.11.9

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.
@@ -0,0 +1,244 @@
1
+ import { jsxs, jsx, Fragment } from "react/jsx-runtime";
2
+ import { useState, useEffect, useMemo } from "react";
3
+ import { g as getTranslation, u as useApi, d as debounce, p as pluginPermissions } from "./index-G7qx6Oy7.mjs";
4
+ import { Page, Layouts, useNotification } from "@strapi/strapi/admin";
5
+ import { Grid, Box, Field, Thead, Tr, Th, Typography, VisuallyHidden, Td, Flex, LinkButton, Table, Tbody, EmptyStateLayout } from "@strapi/design-system";
6
+ import "@strapi/icons/symbols";
7
+ import { F as FullLoader } from "./FullLoader-Btjb2W2p.mjs";
8
+ import { useIntl } from "react-intl";
9
+ import { useSearchParams } from "react-router-dom";
10
+ import { Cross, ChevronDown, Pencil } from "@strapi/icons";
11
+ function PageWrapper({ children }) {
12
+ const { formatMessage } = useIntl();
13
+ return /* @__PURE__ */ jsxs(Page.Main, { children: [
14
+ /* @__PURE__ */ jsx(
15
+ Layouts.Header,
16
+ {
17
+ title: formatMessage({
18
+ id: getTranslation("paths.page.title"),
19
+ defaultMessage: "Paths"
20
+ }),
21
+ subtitle: formatMessage({
22
+ id: getTranslation("paths.page.subtitle"),
23
+ defaultMessage: "Overview of all existing paths"
24
+ })
25
+ }
26
+ ),
27
+ /* @__PURE__ */ jsx(Layouts.Content, { children: /* @__PURE__ */ jsx(Fragment, { children }) })
28
+ ] });
29
+ }
30
+ function compareBy(field, direction) {
31
+ if (!field) {
32
+ return () => 0;
33
+ }
34
+ if (field === "type") {
35
+ return (a, b) => {
36
+ return direction === "asc" ? a.type.localeCompare(b.type) : b.type.localeCompare(a.type);
37
+ };
38
+ }
39
+ return (a, b) => {
40
+ const aValue = a[field];
41
+ const bValue = b[field];
42
+ if (aValue == null && bValue == null) {
43
+ return 0;
44
+ }
45
+ if (aValue == null) {
46
+ return direction === "asc" ? 1 : -1;
47
+ }
48
+ if (bValue == null) {
49
+ return direction === "asc" ? -1 : 1;
50
+ }
51
+ if (typeof aValue === "string" && typeof bValue === "string") {
52
+ return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
53
+ }
54
+ return 0;
55
+ };
56
+ }
57
+ function SearchInput({
58
+ searchQuery,
59
+ handleSearchChange
60
+ }) {
61
+ const { formatMessage } = useIntl();
62
+ return /* @__PURE__ */ jsx(Grid.Root, { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsx(Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsx(Box, { width: "100%", children: /* @__PURE__ */ jsx(Field.Root, { children: /* @__PURE__ */ jsx(
63
+ Field.Input,
64
+ {
65
+ name: "search",
66
+ placeholder: formatMessage({
67
+ id: getTranslation("paths.page.searchPlaceholder"),
68
+ defaultMessage: "Search paths"
69
+ }),
70
+ value: searchQuery,
71
+ onChange: handleSearchChange,
72
+ endAction: searchQuery ? /* @__PURE__ */ jsx(
73
+ "button",
74
+ {
75
+ type: "button",
76
+ onClick: () => handleSearchChange({
77
+ target: { value: "" }
78
+ }),
79
+ style: {
80
+ color: "inherit",
81
+ background: "none",
82
+ border: "none",
83
+ cursor: "pointer"
84
+ },
85
+ "aria-label": "Clear search",
86
+ children: /* @__PURE__ */ jsx(Cross, {})
87
+ }
88
+ ) : null
89
+ }
90
+ ) }) }) }) });
91
+ }
92
+ function TableHeader({
93
+ sortKey,
94
+ handleSort
95
+ }) {
96
+ const { formatMessage } = useIntl();
97
+ return /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
98
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
99
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
100
+ id: getTranslation("title"),
101
+ defaultMessage: "Title"
102
+ }) }),
103
+ sortKey === "title" && /* @__PURE__ */ jsx(ChevronDown, {})
104
+ ] }),
105
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("canonicalPath"), cursor: "pointer", children: [
106
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
107
+ id: getTranslation("canonicalPath"),
108
+ defaultMessage: "Canonical Path"
109
+ }) }),
110
+ sortKey === "canonicalPath" && /* @__PURE__ */ jsx(ChevronDown, {})
111
+ ] }),
112
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("path"), cursor: "pointer", children: [
113
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
114
+ id: getTranslation("path"),
115
+ defaultMessage: "Path"
116
+ }) }),
117
+ sortKey === "path" && /* @__PURE__ */ jsx(ChevronDown, {})
118
+ ] }),
119
+ /* @__PURE__ */ jsxs(Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
120
+ /* @__PURE__ */ jsx(Typography, { variant: "sigma", children: formatMessage({
121
+ id: getTranslation("paths.page.column.type"),
122
+ defaultMessage: "Type"
123
+ }) }),
124
+ sortKey === "type" && /* @__PURE__ */ jsx(ChevronDown, {})
125
+ ] }),
126
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(VisuallyHidden, { children: formatMessage({
127
+ id: getTranslation("actions"),
128
+ defaultMessage: "Actions"
129
+ }) }) })
130
+ ] }) });
131
+ }
132
+ function TableRow({ route }) {
133
+ const { formatMessage } = useIntl();
134
+ return /* @__PURE__ */ jsxs(Tr, { children: [
135
+ [route.title, route.canonicalPath, route.path].map((field, index) => /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { title: field, textColor: "neutral800", children: field || "-" }) }, index)),
136
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { title: route.type, textColor: "neutral800", children: formatMessage({
137
+ id: getTranslation(`path.type.${route.type}`),
138
+ defaultMessage: "-"
139
+ }) }) }),
140
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Flex, { gap: 2, justifyContent: "end", children: route.type === "internal" && /* @__PURE__ */ jsx(
141
+ LinkButton,
142
+ {
143
+ variant: "secondary",
144
+ startIcon: /* @__PURE__ */ jsx(Pencil, {}),
145
+ href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
146
+ children: formatMessage({
147
+ id: getTranslation("edit"),
148
+ defaultMessage: "Edit"
149
+ })
150
+ }
151
+ ) }) })
152
+ ] });
153
+ }
154
+ function PathTable({
155
+ routes,
156
+ sortKey,
157
+ handleSort
158
+ }) {
159
+ const { formatMessage } = useIntl();
160
+ const TABLE_COL_COUNT = 5;
161
+ return /* @__PURE__ */ jsxs(Table, { colCount: TABLE_COL_COUNT, rowCount: routes.length, children: [
162
+ /* @__PURE__ */ jsx(TableHeader, { sortKey, handleSort }),
163
+ /* @__PURE__ */ jsx(Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsx(Tr, { children: /* @__PURE__ */ jsx(Td, { colSpan: TABLE_COL_COUNT, children: /* @__PURE__ */ jsx(
164
+ EmptyStateLayout,
165
+ {
166
+ shadow: "none",
167
+ content: formatMessage({
168
+ id: getTranslation("paths.page.emptyPaths"),
169
+ defaultMessage: "No paths found"
170
+ })
171
+ }
172
+ ) }) }) })
173
+ ] });
174
+ }
175
+ const Paths = () => {
176
+ const { getAllRoutes } = useApi();
177
+ const { formatMessage } = useIntl();
178
+ const { toggleNotification } = useNotification();
179
+ const [allRoutes, setAllRoutes] = useState([]);
180
+ const [routes, setRoutes] = useState([]);
181
+ const [loading, setLoading] = useState(true);
182
+ const [searchParams, setSearchParams] = useSearchParams();
183
+ const initialQuery = searchParams.get("search") || "";
184
+ const [searchQuery, setSearchQuery] = useState(initialQuery);
185
+ const [sortKey, setSortKey] = useState("canonicalPath");
186
+ const [sortDirection, setSortDirection] = useState("asc");
187
+ useEffect(() => {
188
+ const query = searchQuery.toLowerCase();
189
+ setRoutes(
190
+ allRoutes.filter(
191
+ (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.path.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
192
+ )
193
+ );
194
+ }, [searchQuery, allRoutes]);
195
+ const debouncedSetSearchParams = useMemo(
196
+ () => debounce((value) => {
197
+ value ? setSearchParams({ search: value }) : setSearchParams({});
198
+ }, 300),
199
+ [setSearchParams]
200
+ );
201
+ const handleSearchChange = (e) => {
202
+ const value = e.target.value;
203
+ setSearchQuery(value);
204
+ debouncedSetSearchParams(value);
205
+ };
206
+ useEffect(() => {
207
+ async function fetchRoutes() {
208
+ try {
209
+ const data = await getAllRoutes();
210
+ setAllRoutes(data);
211
+ setRoutes(data);
212
+ } catch (err) {
213
+ strapi.log.error("Failed to fetch paths:", err);
214
+ toggleNotification({
215
+ type: "danger",
216
+ message: formatMessage({
217
+ id: getTranslation("notification.paths.fetchFailed"),
218
+ defaultMessage: "Failed to fetch paths"
219
+ })
220
+ });
221
+ } finally {
222
+ setLoading(false);
223
+ }
224
+ }
225
+ fetchRoutes();
226
+ }, []);
227
+ const handleSort = (key) => {
228
+ setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
229
+ setSortKey(key);
230
+ };
231
+ const sortedRoutes = useMemo(() => {
232
+ return sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
233
+ }, [routes, sortKey, sortDirection]);
234
+ if (loading) {
235
+ return /* @__PURE__ */ jsx(PageWrapper, { children: /* @__PURE__ */ jsx(FullLoader, {}) });
236
+ }
237
+ return /* @__PURE__ */ jsx(Page.Protect, { permissions: pluginPermissions["page.routes"], children: /* @__PURE__ */ jsxs(PageWrapper, { children: [
238
+ /* @__PURE__ */ jsx(SearchInput, { handleSearchChange, searchQuery }),
239
+ /* @__PURE__ */ jsx(PathTable, { routes: sortedRoutes, sortKey, handleSort })
240
+ ] }) });
241
+ };
242
+ export {
243
+ Paths as default
244
+ };
@@ -0,0 +1,244 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
3
+ const jsxRuntime = require("react/jsx-runtime");
4
+ const React = require("react");
5
+ const index = require("./index-CFf370lR.js");
6
+ const admin = require("@strapi/strapi/admin");
7
+ const designSystem = require("@strapi/design-system");
8
+ require("@strapi/icons/symbols");
9
+ const FullLoader = require("./FullLoader-Da2n70bJ.js");
10
+ const reactIntl = require("react-intl");
11
+ const reactRouterDom = require("react-router-dom");
12
+ const icons = require("@strapi/icons");
13
+ function PageWrapper({ children }) {
14
+ const { formatMessage } = reactIntl.useIntl();
15
+ return /* @__PURE__ */ jsxRuntime.jsxs(admin.Page.Main, { children: [
16
+ /* @__PURE__ */ jsxRuntime.jsx(
17
+ admin.Layouts.Header,
18
+ {
19
+ title: formatMessage({
20
+ id: index.getTranslation("paths.page.title"),
21
+ defaultMessage: "Paths"
22
+ }),
23
+ subtitle: formatMessage({
24
+ id: index.getTranslation("paths.page.subtitle"),
25
+ defaultMessage: "Overview of all existing paths"
26
+ })
27
+ }
28
+ ),
29
+ /* @__PURE__ */ jsxRuntime.jsx(admin.Layouts.Content, { children: /* @__PURE__ */ jsxRuntime.jsx(jsxRuntime.Fragment, { children }) })
30
+ ] });
31
+ }
32
+ function compareBy(field, direction) {
33
+ if (!field) {
34
+ return () => 0;
35
+ }
36
+ if (field === "type") {
37
+ return (a, b) => {
38
+ return direction === "asc" ? a.type.localeCompare(b.type) : b.type.localeCompare(a.type);
39
+ };
40
+ }
41
+ return (a, b) => {
42
+ const aValue = a[field];
43
+ const bValue = b[field];
44
+ if (aValue == null && bValue == null) {
45
+ return 0;
46
+ }
47
+ if (aValue == null) {
48
+ return direction === "asc" ? 1 : -1;
49
+ }
50
+ if (bValue == null) {
51
+ return direction === "asc" ? -1 : 1;
52
+ }
53
+ if (typeof aValue === "string" && typeof bValue === "string") {
54
+ return direction === "asc" ? aValue.localeCompare(bValue) : bValue.localeCompare(aValue);
55
+ }
56
+ return 0;
57
+ };
58
+ }
59
+ function SearchInput({
60
+ searchQuery,
61
+ handleSearchChange
62
+ }) {
63
+ const { formatMessage } = reactIntl.useIntl();
64
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Root, { style: { marginBottom: "16px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 4, s: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { width: "100%", children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Field.Root, { children: /* @__PURE__ */ jsxRuntime.jsx(
65
+ designSystem.Field.Input,
66
+ {
67
+ name: "search",
68
+ placeholder: formatMessage({
69
+ id: index.getTranslation("paths.page.searchPlaceholder"),
70
+ defaultMessage: "Search paths"
71
+ }),
72
+ value: searchQuery,
73
+ onChange: handleSearchChange,
74
+ endAction: searchQuery ? /* @__PURE__ */ jsxRuntime.jsx(
75
+ "button",
76
+ {
77
+ type: "button",
78
+ onClick: () => handleSearchChange({
79
+ target: { value: "" }
80
+ }),
81
+ style: {
82
+ color: "inherit",
83
+ background: "none",
84
+ border: "none",
85
+ cursor: "pointer"
86
+ },
87
+ "aria-label": "Clear search",
88
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Cross, {})
89
+ }
90
+ ) : null
91
+ }
92
+ ) }) }) }) });
93
+ }
94
+ function TableHeader({
95
+ sortKey,
96
+ handleSort
97
+ }) {
98
+ const { formatMessage } = reactIntl.useIntl();
99
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Thead, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
100
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("title"), cursor: "pointer", children: [
101
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
102
+ id: index.getTranslation("title"),
103
+ defaultMessage: "Title"
104
+ }) }),
105
+ sortKey === "title" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
106
+ ] }),
107
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("canonicalPath"), cursor: "pointer", children: [
108
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
109
+ id: index.getTranslation("canonicalPath"),
110
+ defaultMessage: "Canonical Path"
111
+ }) }),
112
+ sortKey === "canonicalPath" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
113
+ ] }),
114
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("path"), cursor: "pointer", children: [
115
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
116
+ id: index.getTranslation("path"),
117
+ defaultMessage: "Path"
118
+ }) }),
119
+ sortKey === "path" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
120
+ ] }),
121
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Th, { onClick: () => handleSort("type"), cursor: "pointer", children: [
122
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", children: formatMessage({
123
+ id: index.getTranslation("paths.page.column.type"),
124
+ defaultMessage: "Type"
125
+ }) }),
126
+ sortKey === "type" && /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronDown, {})
127
+ ] }),
128
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Th, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.VisuallyHidden, { children: formatMessage({
129
+ id: index.getTranslation("actions"),
130
+ defaultMessage: "Actions"
131
+ }) }) })
132
+ ] }) });
133
+ }
134
+ function TableRow({ route }) {
135
+ const { formatMessage } = reactIntl.useIntl();
136
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tr, { children: [
137
+ [route.title, route.canonicalPath, route.path].map((field, index2) => /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { title: field, textColor: "neutral800", children: field || "-" }) }, index2)),
138
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { title: route.type, textColor: "neutral800", children: formatMessage({
139
+ id: index.getTranslation(`path.type.${route.type}`),
140
+ defaultMessage: "-"
141
+ }) }) }),
142
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { gap: 2, justifyContent: "end", children: route.type === "internal" && /* @__PURE__ */ jsxRuntime.jsx(
143
+ designSystem.LinkButton,
144
+ {
145
+ variant: "secondary",
146
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Pencil, {}),
147
+ href: `/admin/content-manager/collection-types/${route.relatedContentType}/${route.relatedDocumentId}`,
148
+ children: formatMessage({
149
+ id: index.getTranslation("edit"),
150
+ defaultMessage: "Edit"
151
+ })
152
+ }
153
+ ) }) })
154
+ ] });
155
+ }
156
+ function PathTable({
157
+ routes,
158
+ sortKey,
159
+ handleSort
160
+ }) {
161
+ const { formatMessage } = reactIntl.useIntl();
162
+ const TABLE_COL_COUNT = 5;
163
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Table, { colCount: TABLE_COL_COUNT, rowCount: routes.length, children: [
164
+ /* @__PURE__ */ jsxRuntime.jsx(TableHeader, { sortKey, handleSort }),
165
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tbody, { children: routes.length > 0 ? routes.map((route) => /* @__PURE__ */ jsxRuntime.jsx(TableRow, { route }, route.id)) : /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tr, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Td, { colSpan: TABLE_COL_COUNT, children: /* @__PURE__ */ jsxRuntime.jsx(
166
+ designSystem.EmptyStateLayout,
167
+ {
168
+ shadow: "none",
169
+ content: formatMessage({
170
+ id: index.getTranslation("paths.page.emptyPaths"),
171
+ defaultMessage: "No paths found"
172
+ })
173
+ }
174
+ ) }) }) })
175
+ ] });
176
+ }
177
+ const Paths = () => {
178
+ const { getAllRoutes } = index.useApi();
179
+ const { formatMessage } = reactIntl.useIntl();
180
+ const { toggleNotification } = admin.useNotification();
181
+ const [allRoutes, setAllRoutes] = React.useState([]);
182
+ const [routes, setRoutes] = React.useState([]);
183
+ const [loading, setLoading] = React.useState(true);
184
+ const [searchParams, setSearchParams] = reactRouterDom.useSearchParams();
185
+ const initialQuery = searchParams.get("search") || "";
186
+ const [searchQuery, setSearchQuery] = React.useState(initialQuery);
187
+ const [sortKey, setSortKey] = React.useState("canonicalPath");
188
+ const [sortDirection, setSortDirection] = React.useState("asc");
189
+ React.useEffect(() => {
190
+ const query = searchQuery.toLowerCase();
191
+ setRoutes(
192
+ allRoutes.filter(
193
+ (route) => JSON.stringify(route.id).toLowerCase().includes(query) || route.title.toLowerCase().includes(query) || route.path.toLowerCase().includes(query) || route.relatedDocumentId.toLowerCase().includes(query) || route.relatedContentType.toLowerCase().includes(query)
194
+ )
195
+ );
196
+ }, [searchQuery, allRoutes]);
197
+ const debouncedSetSearchParams = React.useMemo(
198
+ () => index.debounce((value) => {
199
+ value ? setSearchParams({ search: value }) : setSearchParams({});
200
+ }, 300),
201
+ [setSearchParams]
202
+ );
203
+ const handleSearchChange = (e) => {
204
+ const value = e.target.value;
205
+ setSearchQuery(value);
206
+ debouncedSetSearchParams(value);
207
+ };
208
+ React.useEffect(() => {
209
+ async function fetchRoutes() {
210
+ try {
211
+ const data = await getAllRoutes();
212
+ setAllRoutes(data);
213
+ setRoutes(data);
214
+ } catch (err) {
215
+ strapi.log.error("Failed to fetch paths:", err);
216
+ toggleNotification({
217
+ type: "danger",
218
+ message: formatMessage({
219
+ id: index.getTranslation("notification.paths.fetchFailed"),
220
+ defaultMessage: "Failed to fetch paths"
221
+ })
222
+ });
223
+ } finally {
224
+ setLoading(false);
225
+ }
226
+ }
227
+ fetchRoutes();
228
+ }, []);
229
+ const handleSort = (key) => {
230
+ setSortDirection((prev) => prev === "asc" ? "desc" : "asc");
231
+ setSortKey(key);
232
+ };
233
+ const sortedRoutes = React.useMemo(() => {
234
+ return sortKey ? [...routes].sort(compareBy(sortKey, sortDirection)) : routes;
235
+ }, [routes, sortKey, sortDirection]);
236
+ if (loading) {
237
+ return /* @__PURE__ */ jsxRuntime.jsx(PageWrapper, { children: /* @__PURE__ */ jsxRuntime.jsx(FullLoader.FullLoader, {}) });
238
+ }
239
+ return /* @__PURE__ */ jsxRuntime.jsx(admin.Page.Protect, { permissions: index.pluginPermissions["page.routes"], children: /* @__PURE__ */ jsxRuntime.jsxs(PageWrapper, { children: [
240
+ /* @__PURE__ */ jsxRuntime.jsx(SearchInput, { handleSearchChange, searchQuery }),
241
+ /* @__PURE__ */ jsxRuntime.jsx(PathTable, { routes: sortedRoutes, sortKey, handleSort })
242
+ ] }) });
243
+ };
244
+ exports.default = Paths;