@edifice.io/collect-frontend 1.0.12 → 1.0.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/AppHeaderCollection-Bvug8wqR.js +203 -0
- package/lib/CXEL7IU7-KQqTZW3I.js +42 -0
- package/lib/Collection-CMoQA79H.js +506 -0
- package/lib/CollectionsLayout-wmt1jR8l.js +100 -0
- package/lib/CollectionsList-Avkiw1Aj.js +324 -0
- package/lib/DeleteCollectionModal-CE4XaECV.js +71 -0
- package/lib/DropdownActionTable-CcA3rys3.js +84 -0
- package/lib/FormEdit-BK8fEwW4.js +111 -0
- package/lib/HASRA6WW-BbBPIcpK.js +9093 -0
- package/lib/I3HPI4QX-C5m1qr_y.js +33 -0
- package/lib/MembersEdit-79qps5R2.js +81 -0
- package/lib/MineSubmission-m_qn8e0j.js +27 -0
- package/lib/Root-DzV0pyeC.js +20 -0
- package/lib/SearchBarCollect-DBKaVVDV.js +23 -0
- package/lib/Submission-BnaHLVUo.js +337 -0
- package/lib/SubmissionList-DI5paav0.js +204 -0
- package/lib/emptyscreen-list-collection-CWGxO4Ss.js +4 -0
- package/lib/index-CIhvqYOt.js +3856 -0
- package/lib/index.js +19 -15071
- package/lib/routes/index.d.ts +13 -0
- package/lib/store/createSelectors.d.ts +1 -2
- package/lib/store/submissionActionStore.d.ts +26 -0
- package/lib/submission.queries-D13BY7hC.js +147 -0
- package/lib/useGetStatusSubmission-DxHmLPxr.js +57 -0
- package/package.json +5 -5
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
import { jsx as e, Fragment as T, jsxs as u } from "react/jsx-runtime";
|
|
2
|
+
import { useState as D, useMemo as L, useCallback as B, useEffect as E } from "react";
|
|
3
|
+
import { S as A } from "./SearchBarCollect-DBKaVVDV.js";
|
|
4
|
+
import { c as F, b as M, W as O, d as R } from "./index-CIhvqYOt.js";
|
|
5
|
+
import { useDate as $, Table as m, Flex as I, Badge as k, IconButton as S, useEdificeClient as v, EmptyScreen as G, LoadingScreen as j } from "@edifice.io/react";
|
|
6
|
+
import { useTranslation as N } from "react-i18next";
|
|
7
|
+
import { E as Q } from "./emptyscreen-list-collection-CWGxO4Ss.js";
|
|
8
|
+
import { D as W } from "./DeleteCollectionModal-CE4XaECV.js";
|
|
9
|
+
import { SortDirection as C, CollectionSortField as y } from "@edifice.io/collect-client-rest";
|
|
10
|
+
import { create as _ } from "zustand";
|
|
11
|
+
import { IconOptions as H, IconRafterLeft as z, IconRafterRight as K, IconListOrder as U, IconArrowUp as Y, IconArrowDown as Z } from "@edifice.io/react/icons";
|
|
12
|
+
import { t as q } from "i18next";
|
|
13
|
+
import { useNavigate as J } from "react-router-dom";
|
|
14
|
+
import { D as V } from "./DropdownActionTable-CcA3rys3.js";
|
|
15
|
+
const X = {
|
|
16
|
+
search: "",
|
|
17
|
+
sortBy: y.DEADLINE,
|
|
18
|
+
sortDirection: C.DESC
|
|
19
|
+
}, x = F(
|
|
20
|
+
_((n) => ({
|
|
21
|
+
...X,
|
|
22
|
+
setSearch: (o) => n({ search: o }),
|
|
23
|
+
setFilters: (o) => n(o),
|
|
24
|
+
setSortCollectionList: (o, a) => n({ sortBy: o, sortDirection: a })
|
|
25
|
+
}))
|
|
26
|
+
), ee = () => {
|
|
27
|
+
const { search: n, sortBy: o, sortDirection: a } = x(), { data: r, fetchNextPage: d, hasNextPage: s, isFetchingNextPage: i, isLoading: g } = M({
|
|
28
|
+
search: n || void 0,
|
|
29
|
+
sortBy: o,
|
|
30
|
+
sortDirection: a
|
|
31
|
+
}), [t, l] = D(1), c = L(() => {
|
|
32
|
+
var b, p;
|
|
33
|
+
const h = (b = r == null ? void 0 : r.pages) == null ? void 0 : b[r.pages.length - 1];
|
|
34
|
+
return ((p = h == null ? void 0 : h.meta) == null ? void 0 : p.totalPages) ?? 1;
|
|
35
|
+
}, [r]), f = L(() => {
|
|
36
|
+
var h;
|
|
37
|
+
if ((h = r == null ? void 0 : r.pages) != null && h.length)
|
|
38
|
+
return r.pages.find((b) => {
|
|
39
|
+
var p;
|
|
40
|
+
return ((p = b.meta) == null ? void 0 : p.currentPage) === t;
|
|
41
|
+
}) ?? r.pages[t - 1];
|
|
42
|
+
}, [r, t]);
|
|
43
|
+
return {
|
|
44
|
+
items: (f == null ? void 0 : f.items) ?? [],
|
|
45
|
+
page: t,
|
|
46
|
+
totalPages: c,
|
|
47
|
+
isLoading: g,
|
|
48
|
+
isFetchingNextPage: i,
|
|
49
|
+
handlePagePrevious: () => {
|
|
50
|
+
l((h) => Math.max(1, h - 1));
|
|
51
|
+
},
|
|
52
|
+
handlePageNext: async () => {
|
|
53
|
+
var p;
|
|
54
|
+
if (t >= c || i) return;
|
|
55
|
+
const h = t + 1;
|
|
56
|
+
!((p = r == null ? void 0 : r.pages) == null ? void 0 : p.some(
|
|
57
|
+
(w) => {
|
|
58
|
+
var P;
|
|
59
|
+
return ((P = w.meta) == null ? void 0 : P.currentPage) === h;
|
|
60
|
+
}
|
|
61
|
+
)) && s && await d(), l(h);
|
|
62
|
+
},
|
|
63
|
+
canGoPrevious: t > 1,
|
|
64
|
+
canGoNext: t < c
|
|
65
|
+
};
|
|
66
|
+
}, te = () => {
|
|
67
|
+
const [n, o] = D(
|
|
68
|
+
null
|
|
69
|
+
);
|
|
70
|
+
return {
|
|
71
|
+
isHovered: (s) => n === s.id,
|
|
72
|
+
setHoveredCollectionId: o,
|
|
73
|
+
getBgColor: (s) => n === s.id ? "bg-gray-300" : "",
|
|
74
|
+
getColorByPercentage: (s, i) => {
|
|
75
|
+
if (i === 0) return "danger";
|
|
76
|
+
const g = s / i * 100;
|
|
77
|
+
return g >= 0 && g < 33 ? "danger" : g >= 33 && g < 66 ? "warning" : g >= 66 && g <= 100 ? "success" : "warning";
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}, oe = ({
|
|
81
|
+
collections: n
|
|
82
|
+
}) => {
|
|
83
|
+
const { fromNow: o, formatDate: a } = $(), r = J(), {
|
|
84
|
+
isHovered: d,
|
|
85
|
+
setHoveredCollectionId: s,
|
|
86
|
+
getBgColor: i,
|
|
87
|
+
getColorByPercentage: g
|
|
88
|
+
} = te();
|
|
89
|
+
return /* @__PURE__ */ e(T, { children: n.map((t, l) => {
|
|
90
|
+
const c = i(t);
|
|
91
|
+
return /* @__PURE__ */ u(
|
|
92
|
+
m.Tr,
|
|
93
|
+
{
|
|
94
|
+
"data-testid": "collect-collection-list-row",
|
|
95
|
+
onMouseEnter: () => s(t.id),
|
|
96
|
+
onMouseLeave: () => s(null),
|
|
97
|
+
children: [
|
|
98
|
+
/* @__PURE__ */ e(m.Td, { className: c, style: { maxWidth: "350px" }, children: /* @__PURE__ */ e(I, { align: "center", gap: "8", children: /* @__PURE__ */ e(
|
|
99
|
+
"span",
|
|
100
|
+
{
|
|
101
|
+
className: "fw-bold text-truncate c-pointer",
|
|
102
|
+
"data-testid": "collect-collection-list-row-name",
|
|
103
|
+
onClick: () => {
|
|
104
|
+
r(`/list-collections/id/${t.id}`);
|
|
105
|
+
},
|
|
106
|
+
children: t.name
|
|
107
|
+
}
|
|
108
|
+
) }) }),
|
|
109
|
+
/* @__PURE__ */ e(m.Td, { className: c, children: /* @__PURE__ */ e("em", { className: "text-gray-700", children: o(t.createdAt) }) }),
|
|
110
|
+
/* @__PURE__ */ e(m.Td, { className: c, children: a(t.deadline, "short") }),
|
|
111
|
+
/* @__PURE__ */ e(
|
|
112
|
+
m.Td,
|
|
113
|
+
{
|
|
114
|
+
className: c,
|
|
115
|
+
"data-testid": "collect-collection-list-row-badge",
|
|
116
|
+
children: /* @__PURE__ */ u(
|
|
117
|
+
k,
|
|
118
|
+
{
|
|
119
|
+
variant: {
|
|
120
|
+
type: "notification",
|
|
121
|
+
level: g(
|
|
122
|
+
t.contribCount,
|
|
123
|
+
t.submissionCount
|
|
124
|
+
)
|
|
125
|
+
},
|
|
126
|
+
className: "fw-normal",
|
|
127
|
+
children: [
|
|
128
|
+
t.contribCount,
|
|
129
|
+
" / ",
|
|
130
|
+
t.submissionCount
|
|
131
|
+
]
|
|
132
|
+
}
|
|
133
|
+
)
|
|
134
|
+
}
|
|
135
|
+
),
|
|
136
|
+
/* @__PURE__ */ e(
|
|
137
|
+
m.Td,
|
|
138
|
+
{
|
|
139
|
+
className: c,
|
|
140
|
+
"data-testid": "collect-collection-list-row-actions",
|
|
141
|
+
children: /* @__PURE__ */ e(V, { collectionId: t.id, children: (f) => /* @__PURE__ */ e(
|
|
142
|
+
S,
|
|
143
|
+
{
|
|
144
|
+
...f,
|
|
145
|
+
"data-testid": "collect-collection-list-row-action-button",
|
|
146
|
+
className: "icon-button-hover-no-transition bg-white",
|
|
147
|
+
type: "button",
|
|
148
|
+
"aria-label": q("collection.table.th.action"),
|
|
149
|
+
color: "tertiary",
|
|
150
|
+
variant: "filled",
|
|
151
|
+
icon: /* @__PURE__ */ e(H, {}),
|
|
152
|
+
style: {
|
|
153
|
+
visibility: d(t) ? "visible" : "hidden"
|
|
154
|
+
}
|
|
155
|
+
}
|
|
156
|
+
) })
|
|
157
|
+
}
|
|
158
|
+
)
|
|
159
|
+
]
|
|
160
|
+
},
|
|
161
|
+
`${t == null ? void 0 : t.id}-${l}`
|
|
162
|
+
);
|
|
163
|
+
}) });
|
|
164
|
+
}, re = ({
|
|
165
|
+
page: n,
|
|
166
|
+
totalPages: o,
|
|
167
|
+
canGoPrevious: a,
|
|
168
|
+
canGoNext: r,
|
|
169
|
+
isLoading: d = !1,
|
|
170
|
+
isFetchingNextPage: s = !1,
|
|
171
|
+
onPagePrevious: i,
|
|
172
|
+
onPageNext: g
|
|
173
|
+
}) => /* @__PURE__ */ u(I, { justify: "center", align: "center", gap: "8", children: [
|
|
174
|
+
/* @__PURE__ */ e(
|
|
175
|
+
S,
|
|
176
|
+
{
|
|
177
|
+
variant: "ghost",
|
|
178
|
+
color: "tertiary",
|
|
179
|
+
icon: /* @__PURE__ */ e(z, {}),
|
|
180
|
+
disabled: !a || d,
|
|
181
|
+
onClick: i
|
|
182
|
+
}
|
|
183
|
+
),
|
|
184
|
+
/* @__PURE__ */ u("span", { "aria-label": `Page ${n} of ${o}`, children: [
|
|
185
|
+
n,
|
|
186
|
+
" / ",
|
|
187
|
+
o
|
|
188
|
+
] }),
|
|
189
|
+
/* @__PURE__ */ e(
|
|
190
|
+
S,
|
|
191
|
+
{
|
|
192
|
+
variant: "ghost",
|
|
193
|
+
color: "tertiary",
|
|
194
|
+
icon: /* @__PURE__ */ e(K, {}),
|
|
195
|
+
disabled: !r || d || s,
|
|
196
|
+
onClick: g
|
|
197
|
+
}
|
|
198
|
+
)
|
|
199
|
+
] }), ne = () => {
|
|
200
|
+
const { appCode: n } = v(), { t: o } = N(n), { sortBy: a, sortDirection: r, setSortCollectionList: d } = x((l) => ({
|
|
201
|
+
sortBy: l.sortBy,
|
|
202
|
+
sortDirection: l.sortDirection,
|
|
203
|
+
setSortCollectionList: l.setSortCollectionList
|
|
204
|
+
})), s = [
|
|
205
|
+
{
|
|
206
|
+
label: o("collection.table.th.collect"),
|
|
207
|
+
sortField: y.NAME
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
label: o("collection.table.th.date"),
|
|
211
|
+
sortField: y.CREATION_DATE
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: o("collection.table.th.deadline"),
|
|
215
|
+
sortField: y.DEADLINE
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
label: o("collection.table.th.render")
|
|
219
|
+
// FIXME: No sort field for render, we should add one in the backend
|
|
220
|
+
},
|
|
221
|
+
{
|
|
222
|
+
label: o("collection.table.th.action")
|
|
223
|
+
}
|
|
224
|
+
], i = (l) => l.sortField && l.sortField === a, g = (l) => {
|
|
225
|
+
let c = /* @__PURE__ */ e(U, { width: 16, height: 16 });
|
|
226
|
+
return i(l) && (r === C.ASC ? c = /* @__PURE__ */ e(Y, {}) : c = /* @__PURE__ */ e(Z, {})), c;
|
|
227
|
+
}, t = B(
|
|
228
|
+
(l) => {
|
|
229
|
+
let c = C.ASC;
|
|
230
|
+
a === l && r === C.ASC && (c = C.DESC), d(l, c);
|
|
231
|
+
},
|
|
232
|
+
[a, r, d]
|
|
233
|
+
);
|
|
234
|
+
return {
|
|
235
|
+
listHeads: s,
|
|
236
|
+
getSortIcon: g,
|
|
237
|
+
handleSort: t,
|
|
238
|
+
isSortActive: i
|
|
239
|
+
};
|
|
240
|
+
}, ie = () => {
|
|
241
|
+
const { listHeads: n, getSortIcon: o, handleSort: a, isSortActive: r } = ne(), { appCode: d } = v(), { t: s } = N(d);
|
|
242
|
+
return n.map((i) => /* @__PURE__ */ u(
|
|
243
|
+
m.Th,
|
|
244
|
+
{
|
|
245
|
+
className: i.sortField ? void 0 : "align-content-center text-center",
|
|
246
|
+
children: [
|
|
247
|
+
s(i.label),
|
|
248
|
+
i.sortField && /* @__PURE__ */ e(
|
|
249
|
+
S,
|
|
250
|
+
{
|
|
251
|
+
variant: "ghost",
|
|
252
|
+
color: "tertiary",
|
|
253
|
+
size: "sm",
|
|
254
|
+
className: `members-table-sort-btn ms-4 ${r(i) ? "text-gray-800" : "text-gray-600"}`,
|
|
255
|
+
icon: o(i),
|
|
256
|
+
onClick: () => a(i.sortField)
|
|
257
|
+
}
|
|
258
|
+
)
|
|
259
|
+
]
|
|
260
|
+
},
|
|
261
|
+
i.label
|
|
262
|
+
));
|
|
263
|
+
}, se = () => {
|
|
264
|
+
const { appCode: n } = v(), { t: o } = N(n), {
|
|
265
|
+
items: a,
|
|
266
|
+
page: r,
|
|
267
|
+
totalPages: d,
|
|
268
|
+
isLoading: s,
|
|
269
|
+
isFetchingNextPage: i,
|
|
270
|
+
handlePagePrevious: g,
|
|
271
|
+
handlePageNext: t,
|
|
272
|
+
canGoPrevious: l,
|
|
273
|
+
canGoNext: c
|
|
274
|
+
} = ee();
|
|
275
|
+
return a.length === 0 && !s ? /* @__PURE__ */ e("div", { className: "py-24", children: /* @__PURE__ */ e(
|
|
276
|
+
G,
|
|
277
|
+
{
|
|
278
|
+
imageSrc: Q,
|
|
279
|
+
title: o("collection.collectionList.emptyScreen.title"),
|
|
280
|
+
text: o("collection.collectionList.emptyScreen.description")
|
|
281
|
+
}
|
|
282
|
+
) }) : /* @__PURE__ */ u(
|
|
283
|
+
"div",
|
|
284
|
+
{
|
|
285
|
+
className: "table-collections",
|
|
286
|
+
"data-testid": "collect-collection-list-table",
|
|
287
|
+
children: [
|
|
288
|
+
/* @__PURE__ */ u(m, { children: [
|
|
289
|
+
/* @__PURE__ */ e(m.Thead, { children: /* @__PURE__ */ e(m.Tr, { children: /* @__PURE__ */ e(ie, {}) }) }),
|
|
290
|
+
/* @__PURE__ */ u(m.Tbody, { children: [
|
|
291
|
+
s && /* @__PURE__ */ e(m.Tr, { children: /* @__PURE__ */ e("td", { colSpan: 5, children: /* @__PURE__ */ e(j, {}) }) }),
|
|
292
|
+
/* @__PURE__ */ e(oe, { collections: a }),
|
|
293
|
+
d !== void 0 && d >= 1 && /* @__PURE__ */ e(m.Tr, { children: /* @__PURE__ */ e("td", { colSpan: 5, children: /* @__PURE__ */ e(
|
|
294
|
+
re,
|
|
295
|
+
{
|
|
296
|
+
page: r,
|
|
297
|
+
totalPages: d,
|
|
298
|
+
canGoPrevious: l,
|
|
299
|
+
canGoNext: c,
|
|
300
|
+
isLoading: s,
|
|
301
|
+
isFetchingNextPage: i,
|
|
302
|
+
onPagePrevious: g,
|
|
303
|
+
onPageNext: t
|
|
304
|
+
}
|
|
305
|
+
) }) })
|
|
306
|
+
] })
|
|
307
|
+
] }),
|
|
308
|
+
/* @__PURE__ */ e(W, {})
|
|
309
|
+
]
|
|
310
|
+
}
|
|
311
|
+
);
|
|
312
|
+
}, Pe = async (n) => (await n.prefetchInfiniteQuery(R({})), null), Le = () => {
|
|
313
|
+
const n = x((o) => o.setSearch);
|
|
314
|
+
return E(() => {
|
|
315
|
+
localStorage.removeItem(O);
|
|
316
|
+
}, []), /* @__PURE__ */ u(T, { children: [
|
|
317
|
+
/* @__PURE__ */ e("div", { className: "bg-gray-200 px-24 py-16", children: /* @__PURE__ */ e(A, { setSearch: n }) }),
|
|
318
|
+
/* @__PURE__ */ e(se, {})
|
|
319
|
+
] });
|
|
320
|
+
};
|
|
321
|
+
export {
|
|
322
|
+
Le as CollectionsList,
|
|
323
|
+
Pe as loader
|
|
324
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsxs as s, jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { useEdificeClient as m, useToast as f, Modal as d, Button as C } from "@edifice.io/react";
|
|
3
|
+
import { IconDelete as h } from "@edifice.io/react/icons";
|
|
4
|
+
import { useTranslation as p } from "react-i18next";
|
|
5
|
+
import { l as M } from "./index-CIhvqYOt.js";
|
|
6
|
+
import { u as D } from "./DropdownActionTable-CcA3rys3.js";
|
|
7
|
+
const y = () => {
|
|
8
|
+
const { appCode: r } = m(), { t: n } = p(r), e = f(), a = M(), { isDeleteModalOpen: l, onCloseDeleteModal: c, deleteCollectionId: i } = D((o) => ({
|
|
9
|
+
isDeleteModalOpen: o.isDeleteModalOpen,
|
|
10
|
+
onCloseDeleteModal: o.onCloseDeleteModal,
|
|
11
|
+
deleteCollectionId: o.deleteCollectionId
|
|
12
|
+
}));
|
|
13
|
+
return {
|
|
14
|
+
isOpen: l,
|
|
15
|
+
onClose: c,
|
|
16
|
+
handleDeleteCollection: async (o) => {
|
|
17
|
+
if (i != null)
|
|
18
|
+
try {
|
|
19
|
+
await a.mutateAsync(i), e.success(n("collection.toast.success.collection.delete")), o == null || o();
|
|
20
|
+
} catch (u) {
|
|
21
|
+
console.error("Error deleting collection:", u), e.error(n("collection.toast.error.collection.delete"));
|
|
22
|
+
} finally {
|
|
23
|
+
c();
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
}, k = ({
|
|
28
|
+
onDeleteSuccess: r
|
|
29
|
+
}) => {
|
|
30
|
+
const { appCode: n } = m(), { t: e } = p(n), { isOpen: a, onClose: l, handleDeleteCollection: c } = y(), i = async () => {
|
|
31
|
+
await c(r);
|
|
32
|
+
};
|
|
33
|
+
return /* @__PURE__ */ s(
|
|
34
|
+
d,
|
|
35
|
+
{
|
|
36
|
+
id: "delete-confirmation-modal",
|
|
37
|
+
isOpen: a,
|
|
38
|
+
onModalClose: l,
|
|
39
|
+
size: "sm",
|
|
40
|
+
children: [
|
|
41
|
+
/* @__PURE__ */ t(d.Header, { onModalClose: l, children: e("collection.modal.delete.title") }),
|
|
42
|
+
/* @__PURE__ */ t(d.Body, { children: e("collection.modal.delete.description") }),
|
|
43
|
+
/* @__PURE__ */ s(d.Footer, { children: [
|
|
44
|
+
/* @__PURE__ */ t(
|
|
45
|
+
C,
|
|
46
|
+
{
|
|
47
|
+
"data-testid": "collect-collection-delete-modal-button-cancel",
|
|
48
|
+
color: "tertiary",
|
|
49
|
+
variant: "ghost",
|
|
50
|
+
onClick: l,
|
|
51
|
+
children: e("collection.cancel")
|
|
52
|
+
}
|
|
53
|
+
),
|
|
54
|
+
/* @__PURE__ */ t(
|
|
55
|
+
C,
|
|
56
|
+
{
|
|
57
|
+
"data-testid": "collect-collection-delete-modal-button-delete",
|
|
58
|
+
color: "danger",
|
|
59
|
+
onClick: i,
|
|
60
|
+
leftIcon: /* @__PURE__ */ t(h, {}),
|
|
61
|
+
children: e("collection.delete")
|
|
62
|
+
}
|
|
63
|
+
)
|
|
64
|
+
] })
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
k as D
|
|
71
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as n, Fragment as c, jsxs as r } from "react/jsx-runtime";
|
|
2
|
+
import { useEdificeClient as p, useHasWorkflow as m, Dropdown as s } from "@edifice.io/react";
|
|
3
|
+
import { Fragment as u } from "react";
|
|
4
|
+
import { WORKFLOW_RIGHTS as f } from "@edifice.io/collect-client-rest";
|
|
5
|
+
import { IconExternalLink as I, IconEdit as O, IconShare as h, IconDelete as w } from "@edifice.io/react/icons";
|
|
6
|
+
import { useTranslation as D } from "react-i18next";
|
|
7
|
+
import { useNavigate as C } from "react-router-dom";
|
|
8
|
+
import { create as b } from "zustand";
|
|
9
|
+
import { c as M } from "./index-CIhvqYOt.js";
|
|
10
|
+
const T = b((e) => ({
|
|
11
|
+
isDeleteModalOpen: !1,
|
|
12
|
+
deleteCollectionId: null,
|
|
13
|
+
isInstructionModalOpen: !1,
|
|
14
|
+
isPastDeadline: !1,
|
|
15
|
+
onOpenDeleteModal: (t) => e({ isDeleteModalOpen: !0, deleteCollectionId: t }),
|
|
16
|
+
onCloseDeleteModal: () => e({ isDeleteModalOpen: !1, deleteCollectionId: null }),
|
|
17
|
+
onOpenInstructionModal: () => e({ isInstructionModalOpen: !0 }),
|
|
18
|
+
onCloseInstructionModal: () => e({ isInstructionModalOpen: !1 }),
|
|
19
|
+
setIsPastDeadline: (t) => e({ isPastDeadline: t })
|
|
20
|
+
})), g = M(
|
|
21
|
+
T
|
|
22
|
+
), E = (e, t) => {
|
|
23
|
+
const { appCode: d } = p(), { t: l } = D(d), a = C(), o = m(f.COLLECTION_CREATE), i = g.use.onOpenDeleteModal();
|
|
24
|
+
return { dropdownOptions: [
|
|
25
|
+
{
|
|
26
|
+
label: l("collection.table.dropdown.open"),
|
|
27
|
+
action: () => a(`/list-collections/id/${e}`),
|
|
28
|
+
icon: /* @__PURE__ */ n(I, {}),
|
|
29
|
+
hidden: t,
|
|
30
|
+
dataTestId: "collect-dropdown-action-open"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
label: l("collection.table.dropdown.edit"),
|
|
34
|
+
action: () => a(`/id/${e}/form`),
|
|
35
|
+
icon: /* @__PURE__ */ n(O, {}),
|
|
36
|
+
hidden: !o,
|
|
37
|
+
dataTestId: "collect-dropdown-action-edit"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
label: l("collection.table.dropdown.share"),
|
|
41
|
+
action: () => a(`/id/${e}/members`),
|
|
42
|
+
icon: /* @__PURE__ */ n(h, {}),
|
|
43
|
+
hidden: !o,
|
|
44
|
+
dataTestId: "collect-dropdown-action-share"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
label: l("collection.table.dropdown.delete"),
|
|
48
|
+
action: () => i(e),
|
|
49
|
+
icon: /* @__PURE__ */ n(w, {}),
|
|
50
|
+
className: "text-danger",
|
|
51
|
+
hidden: !o,
|
|
52
|
+
dataTestId: "collect-dropdown-action-delete"
|
|
53
|
+
}
|
|
54
|
+
] };
|
|
55
|
+
}, W = ({
|
|
56
|
+
collectionId: e,
|
|
57
|
+
isCollection: t = !1,
|
|
58
|
+
children: d
|
|
59
|
+
}) => {
|
|
60
|
+
const { dropdownOptions: l } = E(
|
|
61
|
+
e,
|
|
62
|
+
t
|
|
63
|
+
);
|
|
64
|
+
return /* @__PURE__ */ n(c, { children: /* @__PURE__ */ n(s, { children: (a) => /* @__PURE__ */ r(c, { children: [
|
|
65
|
+
d(a),
|
|
66
|
+
/* @__PURE__ */ n(s.Menu, { children: l.map((o, i) => /* @__PURE__ */ n(u, { children: !o.hidden && /* @__PURE__ */ r(
|
|
67
|
+
s.Item,
|
|
68
|
+
{
|
|
69
|
+
"data-testid": o.dataTestId,
|
|
70
|
+
className: o.className,
|
|
71
|
+
onClick: o.action,
|
|
72
|
+
children: [
|
|
73
|
+
o.icon,
|
|
74
|
+
o.label
|
|
75
|
+
]
|
|
76
|
+
},
|
|
77
|
+
o.label
|
|
78
|
+
) }, i)) })
|
|
79
|
+
] }) }) });
|
|
80
|
+
};
|
|
81
|
+
export {
|
|
82
|
+
W as D,
|
|
83
|
+
g as u
|
|
84
|
+
};
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { jsx as o, jsxs as N } from "react/jsx-runtime";
|
|
2
|
+
import { WORKFLOW_RIGHTS as F } from "@edifice.io/collect-client-rest";
|
|
3
|
+
import { useEdificeClient as L, useBreakpoint as O, useToast as R, useHasWorkflow as k, LoadingScreen as S, Grid as y, Flex as b, Button as v } from "@edifice.io/react";
|
|
4
|
+
import { useState as w } from "react";
|
|
5
|
+
import { useTranslation as j } from "react-i18next";
|
|
6
|
+
import { useParams as Q, useNavigate as W } from "react-router-dom";
|
|
7
|
+
import { t as D, v as U, w as z, j as B, P as G, F as H, k as _, m as $, x as K } from "./index-CIhvqYOt.js";
|
|
8
|
+
import { s as J } from "./submission.queries-D13BY7hC.js";
|
|
9
|
+
const nt = (c) => async ({ params: a }) => {
|
|
10
|
+
const l = Number(a.collectionId);
|
|
11
|
+
return await c.ensureQueryData(_(l)), await c.prefetchInfiniteQuery(
|
|
12
|
+
J(l)
|
|
13
|
+
), null;
|
|
14
|
+
}, it = () => {
|
|
15
|
+
const { appCode: c } = L(), { t: a } = j(c), { lg: l } = O(), d = Q(), m = W(), u = R(), x = k(F.COLLECTION_CREATE), p = D(), h = U(), g = z(), [t, I] = w(void 0), [T, P] = w(
|
|
16
|
+
[]
|
|
17
|
+
), { data: n, isLoading: r } = B(
|
|
18
|
+
Number(d.collectionId)
|
|
19
|
+
);
|
|
20
|
+
if (r)
|
|
21
|
+
return /* @__PURE__ */ o(S, {});
|
|
22
|
+
if (!x || !n) return /* @__PURE__ */ o(G, {});
|
|
23
|
+
const E = async () => {
|
|
24
|
+
const i = Number(d.collectionId);
|
|
25
|
+
if (!i) return;
|
|
26
|
+
const s = {
|
|
27
|
+
title: (t == null ? void 0 : t.title) ?? n.name ?? "",
|
|
28
|
+
description: (t == null ? void 0 : t.description) ?? n.content ?? "",
|
|
29
|
+
deadline: (t == null ? void 0 : t.deadline) ?? (n.deadline ? new Date(n.deadline) : void 0),
|
|
30
|
+
attachments: (t == null ? void 0 : t.attachments) ?? $(n.attachments) ?? [],
|
|
31
|
+
sharings: (t == null ? void 0 : t.sharings) ?? []
|
|
32
|
+
}, f = new Set(
|
|
33
|
+
(n.attachments ?? []).map((e) => String(e.id))
|
|
34
|
+
), A = T.filter((e) => f.has(e)).map((e) => Number(e)).filter((e) => !Number.isNaN(e)), C = (s.attachments ?? []).filter((e) => !f.has(e.id)).map((e) => e.file);
|
|
35
|
+
try {
|
|
36
|
+
await p.mutateAsync({
|
|
37
|
+
id: i,
|
|
38
|
+
data: {
|
|
39
|
+
name: s.title,
|
|
40
|
+
content: s.description,
|
|
41
|
+
deadline: K(s.deadline ?? /* @__PURE__ */ new Date())
|
|
42
|
+
}
|
|
43
|
+
}), C.length > 0 && await h.mutateAsync({
|
|
44
|
+
id: i,
|
|
45
|
+
files: { files: C }
|
|
46
|
+
}), A.length > 0 && await g.mutateAsync({
|
|
47
|
+
collectionId: i,
|
|
48
|
+
attachmentId: A
|
|
49
|
+
}), u.success(a("collection.toast.success.collection.update"), {
|
|
50
|
+
duration: 1e4,
|
|
51
|
+
isDismissible: !0
|
|
52
|
+
}), m(`/list-collections/id/${i}`);
|
|
53
|
+
} catch (e) {
|
|
54
|
+
u.error(a("collection.toast.error.collection.update"), {
|
|
55
|
+
duration: 1e4,
|
|
56
|
+
isDismissible: !0
|
|
57
|
+
}), console.log(e);
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
return /* @__PURE__ */ N("div", { className: "w-100", children: [
|
|
61
|
+
/* @__PURE__ */ o(y, { className: "flex-grow-1 gap-64 px-md-8 px-lg-48 position-relative", children: /* @__PURE__ */ o(y.Col, { sm: "4", md: "8", xl: "12", className: `${l && "ms-64"}`, children: /* @__PURE__ */ o(
|
|
62
|
+
b,
|
|
63
|
+
{
|
|
64
|
+
direction: "column",
|
|
65
|
+
gap: "16",
|
|
66
|
+
className: "h-100 py-24 pb-lg-48 pt-lg-32",
|
|
67
|
+
children: /* @__PURE__ */ o(
|
|
68
|
+
H,
|
|
69
|
+
{
|
|
70
|
+
collection: n,
|
|
71
|
+
updateWizardData: I,
|
|
72
|
+
onRemoveAttachment: (i) => {
|
|
73
|
+
P(
|
|
74
|
+
(s) => s.includes(i) ? s : [...s, i]
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
) }) }),
|
|
81
|
+
/* @__PURE__ */ N(b, { justify: "end", className: "mt-auto px-48 pb-64 gap-16", children: [
|
|
82
|
+
/* @__PURE__ */ o(
|
|
83
|
+
v,
|
|
84
|
+
{
|
|
85
|
+
variant: "outline",
|
|
86
|
+
color: "primary",
|
|
87
|
+
isLoading: r,
|
|
88
|
+
onClick: () => m(-1),
|
|
89
|
+
"data-testid": "collect-cancel-sharings-button",
|
|
90
|
+
children: a("collection.cancel")
|
|
91
|
+
}
|
|
92
|
+
),
|
|
93
|
+
/* @__PURE__ */ o(
|
|
94
|
+
v,
|
|
95
|
+
{
|
|
96
|
+
variant: "filled",
|
|
97
|
+
color: "primary",
|
|
98
|
+
isLoading: r || p.isPending || h.isPending || g.isPending,
|
|
99
|
+
loadingPosition: "right",
|
|
100
|
+
onClick: E,
|
|
101
|
+
"data-testid": "collect-save-sharings-button",
|
|
102
|
+
children: a("collection.form.edit.save")
|
|
103
|
+
}
|
|
104
|
+
)
|
|
105
|
+
] })
|
|
106
|
+
] });
|
|
107
|
+
};
|
|
108
|
+
export {
|
|
109
|
+
it as FormEdit,
|
|
110
|
+
nt as loader
|
|
111
|
+
};
|