@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.
@@ -0,0 +1,33 @@
1
+ import { c, T as l, P as m, a as u, D as v, Q as i } from "./HASRA6WW-BbBPIcpK.js";
2
+ import { z as d, B as f, D as e } from "./index-CIhvqYOt.js";
3
+ var p = (a) => {
4
+ const [r, t] = c({
5
+ prefix: "TanstackQueryDevtools"
6
+ }), n = d(), s = f(() => {
7
+ const o = r.theme_preference || l;
8
+ return o !== "system" ? o : n();
9
+ });
10
+ return e(i.Provider, {
11
+ value: a,
12
+ get children() {
13
+ return e(m, {
14
+ localStore: r,
15
+ setLocalStore: t,
16
+ get children() {
17
+ return e(u.Provider, {
18
+ value: s,
19
+ get children() {
20
+ return e(v, {
21
+ localStore: r,
22
+ setLocalStore: t
23
+ });
24
+ }
25
+ });
26
+ }
27
+ });
28
+ }
29
+ });
30
+ }, C = p;
31
+ export {
32
+ C as default
33
+ };
@@ -0,0 +1,81 @@
1
+ import { jsx as e, jsxs as m } from "react/jsx-runtime";
2
+ import { WORKFLOW_RIGHTS as N } from "@edifice.io/collect-client-rest";
3
+ import { useEdificeClient as v, useBreakpoint as I, useToast as w, useHasWorkflow as E, LoadingScreen as L, Grid as d, Flex as u, Button as p } from "@edifice.io/react";
4
+ import { useTranslation as O } from "react-i18next";
5
+ import { useParams as T, useNavigate as k } from "react-router-dom";
6
+ import { o as P, p as U, j, P as D, q as Q, k as R, r as A, s as F } from "./index-CIhvqYOt.js";
7
+ import { s as M } from "./submission.queries-D13BY7hC.js";
8
+ const q = (t) => async ({ params: o }) => {
9
+ const s = Number(o.collectionId);
10
+ return await t.ensureQueryData(R(s)), await t.prefetchInfiniteQuery(
11
+ M(s)
12
+ ), null;
13
+ }, z = () => {
14
+ const { appCode: t } = v(), { t: o } = O(t), { lg: s } = I(), g = T(), n = w(), a = k(), h = E(N.COLLECTION_CREATE), r = P(), f = U.use.usersCollection(), C = r.isPending, { data: i, isLoading: c } = j(
15
+ Number(g.collectionId)
16
+ );
17
+ if (c)
18
+ return /* @__PURE__ */ e(L, {});
19
+ if (!h || !i) return /* @__PURE__ */ e(D, {});
20
+ const b = async () => {
21
+ var l;
22
+ const y = ((l = i.sharings) == null ? void 0 : l.map(A)) ?? [], S = F(
23
+ y,
24
+ f
25
+ );
26
+ try {
27
+ await r.mutateAsync({
28
+ id: i.id,
29
+ data: S
30
+ }), n.success(o("collection.toast.success.collection.update.members"), {
31
+ duration: 1e4,
32
+ isDismissible: !0
33
+ }), a(-1);
34
+ } catch (x) {
35
+ n.error(o("collection.toast.error.collection.update.members"), {
36
+ duration: 1e4,
37
+ isDismissible: !0
38
+ }), console.log(x);
39
+ }
40
+ };
41
+ return /* @__PURE__ */ m("div", { className: "w-100", children: [
42
+ /* @__PURE__ */ e(d, { className: "flex-grow-1 gap-64 px-md-8 px-lg-48 position-relative", children: /* @__PURE__ */ e(d.Col, { sm: "4", md: "8", xl: "12", className: `${s && "ms-64"}`, children: /* @__PURE__ */ e(
43
+ u,
44
+ {
45
+ direction: "column",
46
+ gap: "16",
47
+ className: "h-100 py-24 pb-lg-48 pt-lg-32",
48
+ children: /* @__PURE__ */ e(Q, { collection: i })
49
+ }
50
+ ) }) }),
51
+ /* @__PURE__ */ m(u, { justify: "end", className: "mt-auto px-48 pb-64 gap-16", children: [
52
+ /* @__PURE__ */ e(
53
+ p,
54
+ {
55
+ variant: "outline",
56
+ color: "primary",
57
+ isLoading: c,
58
+ onClick: () => a(-1),
59
+ "data-testid": "collect-cancel-sharings-button",
60
+ children: o("collection.cancel")
61
+ }
62
+ ),
63
+ /* @__PURE__ */ e(
64
+ p,
65
+ {
66
+ variant: "filled",
67
+ color: "primary",
68
+ isLoading: C,
69
+ loadingPosition: "right",
70
+ onClick: b,
71
+ "data-testid": "collect-save-sharings-button",
72
+ children: o("collection.members.edit.save")
73
+ }
74
+ )
75
+ ] })
76
+ ] });
77
+ };
78
+ export {
79
+ z as MembersEdit,
80
+ q as loader
81
+ };
@@ -0,0 +1,27 @@
1
+ import { jsx as i } from "react/jsx-runtime";
2
+ import { useParams as a, Navigate as n } from "react-router-dom";
3
+ import { LoadingScreen as d } from "@edifice.io/react";
4
+ import { n as f, P as b } from "./index-CIhvqYOt.js";
5
+ function S() {
6
+ var t;
7
+ const { collectionId: o } = a(), s = Number(o), { data: r, isLoading: c, isError: m, error: u } = f(
8
+ isNaN(s) ? [] : [s]
9
+ );
10
+ if (c)
11
+ return /* @__PURE__ */ i(d, {});
12
+ if (m)
13
+ return console.error("Failed to fetch user submission:", u), /* @__PURE__ */ i(b, {});
14
+ const e = (t = r == null ? void 0 : r.items.find(
15
+ (l) => String(l.collectionId) === o
16
+ )) == null ? void 0 : t.submissionId;
17
+ return e ? /* @__PURE__ */ i(
18
+ n,
19
+ {
20
+ to: `/list-collections/id/${o}/submission/${e}`,
21
+ replace: !0
22
+ }
23
+ ) : /* @__PURE__ */ i(n, { to: `/list-collections/id/${o}`, replace: !0 });
24
+ }
25
+ export {
26
+ S as MineSubmission
27
+ };
@@ -0,0 +1,20 @@
1
+ import { jsx as r, jsxs as t, Fragment as c } from "react/jsx-runtime";
2
+ import { WORKFLOW_RIGHTS as f } from "@edifice.io/collect-client-rest";
3
+ import { useEdificeClient as u, useHasWorkflow as l, LoadingScreen as m, Layout as p } from "@edifice.io/react";
4
+ import { useLoaderData as L, Outlet as e, ScrollRestoration as n } from "react-router-dom";
5
+ import { P as d } from "./index-CIhvqYOt.js";
6
+ const g = async () => null;
7
+ function E() {
8
+ const { init: s } = u(), i = l(f.COLLECTION_ACCESS), o = L(), a = (o == null ? void 0 : o.header) !== !1;
9
+ return s ? i ? a ? /* @__PURE__ */ t(p, { children: [
10
+ /* @__PURE__ */ r(e, {}),
11
+ /* @__PURE__ */ r(n, {})
12
+ ] }) : /* @__PURE__ */ t(c, { children: [
13
+ /* @__PURE__ */ r(e, {}),
14
+ /* @__PURE__ */ r(n, {})
15
+ ] }) : /* @__PURE__ */ r(d, {}) : /* @__PURE__ */ r(m, { position: !1 });
16
+ }
17
+ export {
18
+ E as Root,
19
+ g as loader
20
+ };
@@ -0,0 +1,23 @@
1
+ import { jsx as e } from "react/jsx-runtime";
2
+ import { useEdificeClient as o, SearchBar as s } from "@edifice.io/react";
3
+ import { useTranslation as l } from "react-i18next";
4
+ const m = ({
5
+ setSearch: a
6
+ }) => {
7
+ const { appCode: r } = o(), { t } = l(r);
8
+ return /* @__PURE__ */ e("div", { className: "w-100 search-bar-collect", children: /* @__PURE__ */ e(
9
+ s,
10
+ {
11
+ "data-testid": "collect-submission-list-search",
12
+ isVariant: !0,
13
+ onChange: (c) => {
14
+ a(c.target.value);
15
+ },
16
+ placeholder: t("collection.search.placeholder"),
17
+ size: "md"
18
+ }
19
+ ) });
20
+ };
21
+ export {
22
+ m as S
23
+ };
@@ -0,0 +1,337 @@
1
+ import { jsxs as d, jsx as s } from "react/jsx-runtime";
2
+ import { useEdificeClient as A, Flex as u, Heading as M, IconButton as $, AddAttachments as L, Modal as I, Button as w, useToast as W, useBreakpoint as z, Grid as N, LoadingScreen as G } from "@edifice.io/react";
3
+ import { useNavigate as E, useParams as V } from "react-router-dom";
4
+ import { useState as O, useEffect as x } from "react";
5
+ import { u as T, A as J, C as K } from "./AppHeaderCollection-Bvug8wqR.js";
6
+ import { Editor as k } from "@edifice.io/react/editor";
7
+ import { IconPinOn as X, IconRafterUp as Y, IconRafterDown as Z, IconSend as _, IconTextPage as q } from "@edifice.io/react/icons";
8
+ import { useTranslation as f } from "react-i18next";
9
+ import { g as tt, m as B, i as st, j as et, P as nt, k as it } from "./index-CIhvqYOt.js";
10
+ import { ContribSubmissionStatus as ot } from "@edifice.io/collect-client-rest";
11
+ import { u as j } from "./DropdownActionTable-CcA3rys3.js";
12
+ import { b as at, c as dt, d as ct, e as mt, f as rt } from "./submission.queries-D13BY7hC.js";
13
+ const v = ({
14
+ collection: t,
15
+ isMobile: e = !1
16
+ }) => {
17
+ const { appCode: o } = A(), { t: n } = f(o), [i, m] = O(!e);
18
+ return /* @__PURE__ */ d(
19
+ "div",
20
+ {
21
+ className: `bg-white instruction-card-border rounded-4 ${e ? "p-16" : "p-24"}`,
22
+ children: [
23
+ /* @__PURE__ */ d(u, { justify: "between", children: [
24
+ /* @__PURE__ */ d(u, { gap: "8", align: "center", children: [
25
+ /* @__PURE__ */ s(
26
+ u,
27
+ {
28
+ className: "bg-secondary-200 rounded",
29
+ align: "center",
30
+ justify: "center",
31
+ style: { minWidth: "36px", height: "36px" },
32
+ children: /* @__PURE__ */ s(X, {})
33
+ }
34
+ ),
35
+ /* @__PURE__ */ s(M, { level: "h4", headingStyle: "h4", className: "text-truncate", children: n("collection.submission.instruction.title") })
36
+ ] }),
37
+ e && /* @__PURE__ */ s(
38
+ $,
39
+ {
40
+ "data-testid": "collect-submission-instruction-button-toggle",
41
+ icon: i ? /* @__PURE__ */ s(Y, {}) : /* @__PURE__ */ s(Z, {}),
42
+ color: "tertiary",
43
+ onClick: () => m(!i)
44
+ }
45
+ )
46
+ ] }),
47
+ /* @__PURE__ */ s("div", { className: `wrapper ${i ? "open" : ""}`, children: /* @__PURE__ */ d("div", { className: "inner", children: [
48
+ /* @__PURE__ */ s(
49
+ k,
50
+ {
51
+ content: t.content,
52
+ mode: "read",
53
+ toolbar: "none",
54
+ variant: "ghost"
55
+ }
56
+ ),
57
+ t.attachments && /* @__PURE__ */ s(
58
+ L,
59
+ {
60
+ attachments: B(
61
+ t.attachments
62
+ ),
63
+ getDownloadUrl: (r) => tt(
64
+ t.id,
65
+ r
66
+ ),
67
+ editMode: !1
68
+ }
69
+ )
70
+ ] }) })
71
+ ]
72
+ }
73
+ );
74
+ }, lt = ({
75
+ onClose: t,
76
+ isOpen: e,
77
+ handleUpdateSubmission: o
78
+ }) => {
79
+ const { appCode: n } = A(), { t: i } = f(n), m = T.use.submissionIsLoading();
80
+ return /* @__PURE__ */ d(
81
+ I,
82
+ {
83
+ id: "update-submission-modal",
84
+ isOpen: e,
85
+ onModalClose: t,
86
+ size: "sm",
87
+ children: [
88
+ /* @__PURE__ */ s(I.Header, { onModalClose: t, children: i("collection.modal.update.submission.title") }),
89
+ /* @__PURE__ */ d(I.Body, { children: [
90
+ /* @__PURE__ */ s("p", { children: i("collection.modal.update.submission.description.first") }),
91
+ /* @__PURE__ */ s("p", { children: i("collection.modal.update.submission.description.second") })
92
+ ] }),
93
+ /* @__PURE__ */ d(I.Footer, { children: [
94
+ /* @__PURE__ */ s(
95
+ w,
96
+ {
97
+ "data-testid": "collect-submission-modal-button-cancel",
98
+ color: "tertiary",
99
+ variant: "ghost",
100
+ onClick: t,
101
+ children: i("collection.cancel")
102
+ }
103
+ ),
104
+ /* @__PURE__ */ s(
105
+ w,
106
+ {
107
+ "data-testid": "collect-submission-modal-button-send",
108
+ onClick: () => o({
109
+ status: ot.SUBMITTED,
110
+ isRedirect: !0
111
+ }),
112
+ leftIcon: /* @__PURE__ */ s(_, {}),
113
+ isLoading: m,
114
+ children: i("collection.modal.update.submission.button.send")
115
+ }
116
+ )
117
+ ] })
118
+ ]
119
+ }
120
+ );
121
+ }, ut = ({
122
+ submission: t
123
+ }) => {
124
+ const { appCode: e } = A(), { t: o } = f(e), [n, i] = O(
125
+ () => B(t == null ? void 0 : t.attachments) ?? []
126
+ ), m = j.use.isPastDeadline(), {
127
+ setSubmissionContent: r,
128
+ setSubmissionAttachments: b,
129
+ hydrateSubmissionContent: h,
130
+ submissionPersistedAttachmentIds: C,
131
+ addSubmissionAttachmentIdToDelete: S
132
+ } = T((a) => ({
133
+ setSubmissionContent: a.setSubmissionContent,
134
+ setSubmissionAttachments: a.setSubmissionAttachments,
135
+ hydrateSubmissionContent: a.hydrateSubmissionContent,
136
+ submissionPersistedAttachmentIds: a.submissionPersistedAttachmentIds,
137
+ addSubmissionAttachmentIdToDelete: a.addSubmissionAttachmentIdToDelete
138
+ }));
139
+ x(() => {
140
+ h(t);
141
+ }, [h, t]), x(() => {
142
+ b(n);
143
+ }, [n, b]);
144
+ const g = (a) => {
145
+ const p = Number(a);
146
+ !Number.isSafeInteger(p) || !C.includes(p) || S(p);
147
+ };
148
+ return /* @__PURE__ */ d(u, { className: "p-24", direction: "column", gap: "16", children: [
149
+ /* @__PURE__ */ d(u, { gap: "8", align: "center", children: [
150
+ /* @__PURE__ */ s(
151
+ u,
152
+ {
153
+ className: "bg-secondary-200 rounded",
154
+ align: "center",
155
+ justify: "center",
156
+ style: { minWidth: "36px", height: "36px" },
157
+ children: /* @__PURE__ */ s(q, {})
158
+ }
159
+ ),
160
+ /* @__PURE__ */ s(M, { level: "h4", headingStyle: "h4", className: "text-truncate", children: o("collection.submission.edit.title") })
161
+ ] }),
162
+ /* @__PURE__ */ s("div", { className: "bg-white rounded-3", children: /* @__PURE__ */ s(
163
+ k,
164
+ {
165
+ "data-testid": "collect-submission-edit-content",
166
+ id: "submissionEdit",
167
+ content: t.content ?? "",
168
+ onContentChange: ({ editor: a }) => {
169
+ r(a.getHTML(), !a.isEmpty);
170
+ },
171
+ mode: m ? "read" : "edit"
172
+ }
173
+ ) }),
174
+ /* @__PURE__ */ s(
175
+ L,
176
+ {
177
+ "data-testid": "collect-submission-edit-attachments",
178
+ attachments: n,
179
+ editMode: !m,
180
+ onChange: i,
181
+ onRemoveAttachment: g
182
+ }
183
+ )
184
+ ] });
185
+ }, bt = ({
186
+ collection: t,
187
+ submission: e
188
+ }) => {
189
+ const { appCode: o } = A(), { t: n } = f(o), i = W(), m = E(), {
190
+ submissionContent: r,
191
+ submissionAttachments: b,
192
+ submissionAttachmentIdsToDelete: h,
193
+ isUpdateSubmissionModalOpen: C,
194
+ onCloseUpdateSubmissionModal: S,
195
+ setSubmissionIsLoading: g,
196
+ resetSubmissionAttachments: a,
197
+ setSubmissionPersistedAttachmentIds: p,
198
+ resetSubmissionAttachmentIdsToDelete: U
199
+ } = T((c) => ({
200
+ submissionContent: c.submissionContent,
201
+ submissionAttachments: c.submissionAttachments,
202
+ submissionAttachmentIdsToDelete: c.submissionAttachmentIdsToDelete,
203
+ isUpdateSubmissionModalOpen: c.isUpdateSubmissionModalOpen,
204
+ onCloseUpdateSubmissionModal: c.onCloseUpdateSubmissionModal,
205
+ setSubmissionIsLoading: c.setSubmissionIsLoading,
206
+ resetSubmissionAttachments: c.resetSubmissionAttachments,
207
+ setSubmissionPersistedAttachmentIds: c.setSubmissionPersistedAttachmentIds,
208
+ resetSubmissionAttachmentIdsToDelete: c.resetSubmissionAttachmentIdsToDelete
209
+ })), R = at(), H = dt(), Q = ct();
210
+ return {
211
+ isOpen: C,
212
+ onClose: () => {
213
+ U(), S();
214
+ },
215
+ handleUpdateSubmission: async ({
216
+ status: c,
217
+ isRedirect: F
218
+ }) => {
219
+ try {
220
+ g(!0);
221
+ const y = new Set(
222
+ (e.attachments ?? []).map(
223
+ (l) => String(l.id)
224
+ )
225
+ ), P = b.filter((l) => !y.has(l.id)).map((l) => l.file);
226
+ let D = await R.mutateAsync({
227
+ collectionId: t.id,
228
+ submissionId: e.id,
229
+ data: {
230
+ content: r,
231
+ status: c
232
+ }
233
+ });
234
+ h.length > 0 && (D = await Q.mutateAsync({
235
+ collectionId: t.id,
236
+ submissionId: e.id,
237
+ attachmentId: h
238
+ })), P.length > 0 && (D = await H.mutateAsync({
239
+ collectionId: t.id,
240
+ submissionId: e.id,
241
+ files: {
242
+ files: P
243
+ }
244
+ })), p(
245
+ (D.attachments ?? []).map(
246
+ (l) => l.id
247
+ )
248
+ ), a(), U(), i.success(n("collection.toast.success.submission.update"));
249
+ } catch (y) {
250
+ console.error("Error updating submission:", y), i.error(n("collection.toast.error.submission.update"));
251
+ } finally {
252
+ g(!1), F && m("/list-submissions"), S();
253
+ }
254
+ }
255
+ };
256
+ }, ht = ({
257
+ collection: t,
258
+ submission: e
259
+ }) => {
260
+ const o = E(), { lg: n } = z(), { isOpen: i, onClose: m, handleUpdateSubmission: r } = bt({
261
+ collection: t,
262
+ submission: e
263
+ }), b = j.use.setIsPastDeadline();
264
+ return x(() => {
265
+ b(st(t.deadline));
266
+ }, [t.deadline]), /* @__PURE__ */ d(
267
+ u,
268
+ {
269
+ className: "bg-gray-200 mx-n16 flex-fill border-bottom-0 border",
270
+ direction: "column",
271
+ children: [
272
+ /* @__PURE__ */ s(
273
+ J,
274
+ {
275
+ collection: t,
276
+ context: K.SUBMISSION,
277
+ onClickBack: () => o("/list-submissions"),
278
+ handleUpdateSubmission: r
279
+ }
280
+ ),
281
+ /* @__PURE__ */ d(N, { className: "flex-grow-1 p-16 gap-24", children: [
282
+ /* @__PURE__ */ s(
283
+ N.Col,
284
+ {
285
+ sm: "3",
286
+ md: "3",
287
+ lg: "3",
288
+ xl: "4",
289
+ className: "d-none d-lg-block",
290
+ as: "aside",
291
+ children: /* @__PURE__ */ s(v, { collection: t })
292
+ }
293
+ ),
294
+ /* @__PURE__ */ d(
295
+ N.Col,
296
+ {
297
+ sm: "4",
298
+ md: "8",
299
+ lg: "5",
300
+ xl: "8",
301
+ className: `${n ? "cancel-gap" : ""}`,
302
+ children: [
303
+ !n && /* @__PURE__ */ s(v, { collection: t, isMobile: !0 }),
304
+ /* @__PURE__ */ s(ut, { submission: e })
305
+ ]
306
+ }
307
+ )
308
+ ] }),
309
+ /* @__PURE__ */ s(
310
+ lt,
311
+ {
312
+ handleUpdateSubmission: r,
313
+ onClose: m,
314
+ isOpen: i
315
+ }
316
+ )
317
+ ]
318
+ }
319
+ );
320
+ }, Pt = (t) => async ({ params: e }) => {
321
+ const o = Number(e.collectionId), n = Number(e.submissionId);
322
+ return await t.ensureQueryData(
323
+ rt(o, n)
324
+ ), await t.ensureQueryData(it(o)), null;
325
+ }, wt = () => {
326
+ const t = V(), { isLoading: e, data: o } = mt(
327
+ Number(t.collectionId),
328
+ Number(t.submissionId)
329
+ ), { data: n, isLoading: i } = et(
330
+ Number(t.collectionId)
331
+ );
332
+ return e || i ? /* @__PURE__ */ s(G, {}) : !n || !o ? /* @__PURE__ */ s(nt, {}) : /* @__PURE__ */ s(ht, { collection: n, submission: o });
333
+ };
334
+ export {
335
+ wt as Submission,
336
+ Pt as loader
337
+ };