@edifice.io/collect-frontend 0.2.0-develop-pedago.0 → 0.2.2-develop-pedago.2

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-qb64R1U-.js";
2
+ import { aP as d, aQ as f, aR as e } from "./index-Dt9ykSDF.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,42 @@
1
+ import { r as m, d as b, bA as f, bB as C, bC as j, j as e, ak as s, bD as $, B as u } from "./index-Dt9ykSDF.js";
2
+ const M = ({
3
+ isOpen: h,
4
+ onSuccess: n,
5
+ onCancel: r
6
+ }) => {
7
+ const i = "\\frac{-b + \\sqrt{b^2 - 4ac}}{2a}", [l, d] = m.useState(`$${i}$`), {
8
+ t: a
9
+ } = b(), t = f({
10
+ extensions: [C, j],
11
+ content: "",
12
+ editable: !1
13
+ });
14
+ m.useEffect(() => {
15
+ t == null || t.commands.setContent(l), t == null || t.commands.enter();
16
+ }, [t, l]);
17
+ const p = (x) => {
18
+ const o = x.target.value.replaceAll(`
19
+ `, "$<br/>$");
20
+ o ? (t == null || t.commands.setContent(`$${o}$`), d(`$${o}$`)) : (t == null || t.commands.setContent(""), d("")), t == null || t.commands.enter();
21
+ }, c = () => {
22
+ r == null || r();
23
+ };
24
+ return /* @__PURE__ */ e.jsxs(s, { id: "MathsModal", isOpen: h, onModalClose: c, children: [
25
+ /* @__PURE__ */ e.jsx(s.Header, { onModalClose: c, children: a("tiptap.maths.title") }),
26
+ /* @__PURE__ */ e.jsxs(s.Subtitle, { children: [
27
+ a("tiptap.maths.subtitle.1"),
28
+ /* @__PURE__ */ e.jsx("a", { href: a("https://fr.wikibooks.org/wiki/LaTeX/%C3%89crire_des_math%C3%A9matiques"), target: "_blank", children: a("tiptap.maths.subtitle.2") })
29
+ ] }),
30
+ /* @__PURE__ */ e.jsxs(s.Body, { children: [
31
+ /* @__PURE__ */ e.jsx("textarea", { id: "formulaTextArea", name: "formula", rows: 4, cols: 50, onChange: p, placeholder: `Exemple : ${i}`, className: "border rounded-3 w-100 px-16 py-12" }),
32
+ /* @__PURE__ */ e.jsx($, { editor: t, className: "pt-24 pb-0 text-center fs-1" })
33
+ ] }),
34
+ /* @__PURE__ */ e.jsxs(s.Footer, { children: [
35
+ /* @__PURE__ */ e.jsx(u, { color: "tertiary", onClick: r, type: "button", variant: "ghost", children: a("tiptap.maths.cancel") }),
36
+ /* @__PURE__ */ e.jsx(u, { color: "primary", onClick: () => n == null ? void 0 : n(l), type: "button", variant: "filled", children: a("tiptap.maths.add") })
37
+ ] })
38
+ ] });
39
+ };
40
+ export {
41
+ M as default
42
+ };
@@ -0,0 +1,72 @@
1
+ import { u as f, d as y, n as T, ar as E, h as N, a as v, W as D, aB as I, aC as c, as as L, j as s, L as O, P as S, G as l, F as u, aD as w, B as d, at as A, aE as R, aq as k } from "./index-Dt9ykSDF.js";
2
+ import { s as B } from "./submission.queries-CslqTzEP.js";
3
+ const Q = (t) => async ({ params: e }) => {
4
+ const a = Number(e.collectionId);
5
+ return await t.ensureQueryData(A(a)), await t.prefetchInfiniteQuery(
6
+ B(a)
7
+ ), null;
8
+ }, U = () => {
9
+ const { appCode: t } = f(), { t: e } = y(t), { lg: a } = T(), m = E(), n = k(), r = N(), p = v(D.COLLECTION_CREATE), g = I(), h = c.use.usersToAdd(), x = c.use.usersToDelete(), { data: o, isLoading: i } = L(
10
+ Number(m.collectionId)
11
+ );
12
+ if (i)
13
+ return /* @__PURE__ */ s.jsx(O, {});
14
+ if (!p || !o) return /* @__PURE__ */ s.jsx(S, {});
15
+ const b = async () => {
16
+ const C = R(x, h);
17
+ try {
18
+ await g.mutateAsync({
19
+ id: o.id,
20
+ data: C
21
+ }), n.success(e("collection.toast.success.collection.update.members"), {
22
+ duration: 1e4,
23
+ isDismissible: !0
24
+ }), r(-1);
25
+ } catch (j) {
26
+ n.error(e("collection.toast.error.collection.update.members"), {
27
+ duration: 1e4,
28
+ isDismissible: !0
29
+ }), console.log(j);
30
+ }
31
+ };
32
+ return /* @__PURE__ */ s.jsxs(s.Fragment, { children: [
33
+ /* @__PURE__ */ s.jsx(l, { className: "flex-grow-1 gap-64 px-md-8 px-lg-48 position-relative", children: /* @__PURE__ */ s.jsx(l.Col, { sm: "4", md: "8", xl: "12", className: `${a && "ms-64"}`, children: /* @__PURE__ */ s.jsx(
34
+ u,
35
+ {
36
+ direction: "column",
37
+ gap: "16",
38
+ className: "h-100 py-24 pb-lg-48 pt-lg-32",
39
+ children: /* @__PURE__ */ s.jsx(w, { collection: o })
40
+ }
41
+ ) }) }),
42
+ /* @__PURE__ */ s.jsxs(u, { justify: "end", className: "mt-auto px-48 pb-64 gap-16", children: [
43
+ /* @__PURE__ */ s.jsx(
44
+ d,
45
+ {
46
+ variant: "outline",
47
+ color: "primary",
48
+ isLoading: i,
49
+ onClick: () => r(-1),
50
+ "data-testid": "collect-cancel-sharings-button",
51
+ children: e("collection.cancel")
52
+ }
53
+ ),
54
+ /* @__PURE__ */ s.jsx(
55
+ d,
56
+ {
57
+ variant: "filled",
58
+ color: "primary",
59
+ isLoading: i,
60
+ loadingPosition: "right",
61
+ onClick: b,
62
+ "data-testid": "collect-save-sharings-button",
63
+ children: e("collection.members.edit.save")
64
+ }
65
+ )
66
+ ] })
67
+ ] });
68
+ };
69
+ export {
70
+ U as MembersEdit,
71
+ Q as loader
72
+ };
@@ -0,0 +1,13 @@
1
+ import { u as r, a, W as e, j as s, L as n, P as i, b as u, O as c, S as l } from "./index-Dt9ykSDF.js";
2
+ const f = async () => null;
3
+ function j() {
4
+ const { init: t } = r(), o = a(e.COLLECTION_ACCESS);
5
+ return t ? o ? /* @__PURE__ */ s.jsxs(u, { children: [
6
+ /* @__PURE__ */ s.jsx(c, {}),
7
+ /* @__PURE__ */ s.jsx(l, {})
8
+ ] }) : /* @__PURE__ */ s.jsx(i, {}) : /* @__PURE__ */ s.jsx(n, { position: !1 });
9
+ }
10
+ export {
11
+ j as Root,
12
+ f as loader
13
+ };
@@ -0,0 +1,21 @@
1
+ import { u as l, d as o, j as e, ai as i } from "./index-Dt9ykSDF.js";
2
+ const d = ({
3
+ setSearch: a
4
+ }) => {
5
+ const { appCode: s } = l(), { t } = o(s), c = (r) => {
6
+ a(r.target.value);
7
+ };
8
+ return /* @__PURE__ */ e.jsx("div", { className: "w-100 search-bar-collect", children: /* @__PURE__ */ e.jsx(
9
+ i,
10
+ {
11
+ "data-testid": "collect-submission-list-search",
12
+ isVariant: !0,
13
+ onChange: c,
14
+ placeholder: t("collection.search.placeholder"),
15
+ size: "md"
16
+ }
17
+ ) });
18
+ };
19
+ export {
20
+ d as S
21
+ };
@@ -0,0 +1,249 @@
1
+ import { u, d as m, r as x, j as s, F as d, H as I, I as U, aw as D, ag as L, al as f, ak as r, B as j, ax as M, an as O, h as y, aq as P, n as k, G as p, ar as B, as as T, L as A, P as H, at as F } from "./index-Dt9ykSDF.js";
2
+ import { a as Q, u as g, b as R, A as $, C as G } from "./AppHeaderCollection-Bglbw6q9.js";
3
+ import { u as N } from "./DropdownActionTable-BLHrdk4t.js";
4
+ import { b as W, c as z, d as V } from "./submission.queries-CslqTzEP.js";
5
+ const C = ({
6
+ collection: n,
7
+ isMobile: t = !1
8
+ }) => {
9
+ const { appCode: i } = u(), { t: o } = m(i), [e, a] = x.useState(!t);
10
+ return /* @__PURE__ */ s.jsxs("div", { className: `bg-white shadow rounded-4 ${t ? "p-16" : "p-24"}`, children: [
11
+ /* @__PURE__ */ s.jsxs(d, { justify: "between", children: [
12
+ /* @__PURE__ */ s.jsxs(d, { gap: "8", align: "center", children: [
13
+ /* @__PURE__ */ s.jsx(
14
+ d,
15
+ {
16
+ className: "bg-secondary-200 rounded",
17
+ align: "center",
18
+ justify: "center",
19
+ style: { minWidth: "36px", height: "36px" },
20
+ children: /* @__PURE__ */ s.jsx(Q, {})
21
+ }
22
+ ),
23
+ /* @__PURE__ */ s.jsx(I, { level: "h4", headingStyle: "h4", className: "text-truncate", children: o("collection.submission.instruction.title") })
24
+ ] }),
25
+ t && /* @__PURE__ */ s.jsx(
26
+ U,
27
+ {
28
+ "data-testid": "collect-submission-instruction-button-toggle",
29
+ icon: e ? /* @__PURE__ */ s.jsx(D, {}) : /* @__PURE__ */ s.jsx(L, {}),
30
+ color: "tertiary",
31
+ onClick: () => a(!e)
32
+ }
33
+ )
34
+ ] }),
35
+ /* @__PURE__ */ s.jsx("div", { className: `wrapper ${e ? "open" : ""}`, children: /* @__PURE__ */ s.jsx("div", { className: "inner", children: /* @__PURE__ */ s.jsx(
36
+ f,
37
+ {
38
+ content: n.content,
39
+ mode: "read",
40
+ toolbar: "none",
41
+ variant: "ghost"
42
+ }
43
+ ) }) })
44
+ ] });
45
+ }, q = ({
46
+ onClose: n,
47
+ isOpen: t,
48
+ handleUpdateSubmission: i
49
+ }) => {
50
+ const { appCode: o } = u(), { t: e } = m(o), a = g.use.submissionIsLoading();
51
+ return /* @__PURE__ */ s.jsxs(
52
+ r,
53
+ {
54
+ id: "update-submission-modal",
55
+ isOpen: t,
56
+ onModalClose: n,
57
+ size: "sm",
58
+ children: [
59
+ /* @__PURE__ */ s.jsx(r.Header, { onModalClose: n, children: e("collection.modal.update.submission.title") }),
60
+ /* @__PURE__ */ s.jsxs(r.Body, { children: [
61
+ /* @__PURE__ */ s.jsx("p", { children: e("collection.modal.update.submission.description.first") }),
62
+ /* @__PURE__ */ s.jsx("p", { children: e("collection.modal.update.submission.description.second") })
63
+ ] }),
64
+ /* @__PURE__ */ s.jsxs(r.Footer, { children: [
65
+ /* @__PURE__ */ s.jsx(
66
+ j,
67
+ {
68
+ "data-testid": "collect-submission-modal-button-cancel",
69
+ color: "tertiary",
70
+ variant: "ghost",
71
+ onClick: n,
72
+ children: e("collection.cancel")
73
+ }
74
+ ),
75
+ /* @__PURE__ */ s.jsx(
76
+ j,
77
+ {
78
+ "data-testid": "collect-submission-modal-button-send",
79
+ onClick: () => i({
80
+ status: M.SUBMITTED,
81
+ isRedirect: !0
82
+ }),
83
+ leftIcon: /* @__PURE__ */ s.jsx(R, {}),
84
+ isLoading: a,
85
+ children: e("collection.modal.update.submission.button.send")
86
+ }
87
+ )
88
+ ] })
89
+ ]
90
+ }
91
+ );
92
+ }, J = ({
93
+ submission: n
94
+ }) => {
95
+ const { appCode: t } = u(), { t: i } = m(t), o = N.use.isPastDeadline(), { setSubmissionData: e, hydrateSubmissionContent: a } = g((c) => ({
96
+ setSubmissionData: c.setSubmissionData,
97
+ hydrateSubmissionContent: c.hydrateSubmissionContent
98
+ }));
99
+ return x.useEffect(() => {
100
+ a(n);
101
+ }, [a, n]), /* @__PURE__ */ s.jsxs(d, { className: "p-24", direction: "column", gap: "16", children: [
102
+ /* @__PURE__ */ s.jsxs(d, { gap: "8", align: "center", children: [
103
+ /* @__PURE__ */ s.jsx(
104
+ d,
105
+ {
106
+ className: "bg-secondary-200 rounded",
107
+ align: "center",
108
+ justify: "center",
109
+ style: { minWidth: "36px", height: "36px" },
110
+ children: /* @__PURE__ */ s.jsx(O, {})
111
+ }
112
+ ),
113
+ /* @__PURE__ */ s.jsx(I, { level: "h4", headingStyle: "h4", className: "text-truncate", children: i("collection.submission.edit.title") })
114
+ ] }),
115
+ /* @__PURE__ */ s.jsx("div", { className: "bg-white rounded-3", children: /* @__PURE__ */ s.jsx(
116
+ f,
117
+ {
118
+ "data-testid": "collect-submission-edit-content",
119
+ id: "submissionEdit",
120
+ content: n.content ?? "",
121
+ onContentChange: ({ editor: c }) => {
122
+ e(c.getHTML(), !c.isEmpty);
123
+ },
124
+ mode: o ? "read" : "edit"
125
+ }
126
+ ) })
127
+ ] });
128
+ }, K = ({
129
+ collection: n,
130
+ submission: t
131
+ }) => {
132
+ const { appCode: i } = u(), { t: o } = m(i), e = P(), a = y(), {
133
+ submissionContent: c,
134
+ isUpdateSubmissionModalOpen: b,
135
+ onCloseUpdateSubmissionModal: h,
136
+ setSubmissionIsLoading: S
137
+ } = g((l) => ({
138
+ submissionContent: l.submissionContent,
139
+ isUpdateSubmissionModalOpen: l.isUpdateSubmissionModalOpen,
140
+ onCloseUpdateSubmissionModal: l.onCloseUpdateSubmissionModal,
141
+ setSubmissionIsLoading: l.setSubmissionIsLoading
142
+ })), v = W();
143
+ return {
144
+ isOpen: b,
145
+ onClose: h,
146
+ handleUpdateSubmission: async ({
147
+ status: l,
148
+ isRedirect: w
149
+ }) => {
150
+ try {
151
+ S(!0), await v.mutateAsync({
152
+ collectionId: n.id,
153
+ submissionId: t.id,
154
+ data: {
155
+ content: c,
156
+ status: l,
157
+ // FIX ME : For now, attachments are not supported in the frontend, so we send an empty array.
158
+ attachments: []
159
+ }
160
+ }), e.success(o("collection.toast.success.submission.update"));
161
+ } catch (E) {
162
+ console.error("Error updating submission:", E), e.error(o("collection.toast.error.submission.update"));
163
+ } finally {
164
+ S(!1), w && a("/list-submissions"), h();
165
+ }
166
+ }
167
+ };
168
+ }, X = ({
169
+ collection: n,
170
+ submission: t
171
+ }) => {
172
+ const i = y(), { lg: o } = k(), { isOpen: e, onClose: a, handleUpdateSubmission: c } = K({
173
+ collection: n,
174
+ submission: t
175
+ }), b = N.use.setIsPastDeadline();
176
+ return x.useEffect(() => {
177
+ b(new Date(n.deadline) < /* @__PURE__ */ new Date());
178
+ }, [n.deadline]), /* @__PURE__ */ s.jsxs(
179
+ d,
180
+ {
181
+ className: "bg-gray-200 mx-n16 flex-fill border-bottom-0 border",
182
+ direction: "column",
183
+ children: [
184
+ /* @__PURE__ */ s.jsx(
185
+ $,
186
+ {
187
+ collection: n,
188
+ context: G.SUBMISSION,
189
+ onClickBack: () => i("/list-submissions"),
190
+ handleUpdateSubmission: c
191
+ }
192
+ ),
193
+ /* @__PURE__ */ s.jsxs(p, { className: "flex-grow-1 p-16 gap-24", children: [
194
+ /* @__PURE__ */ s.jsx(
195
+ p.Col,
196
+ {
197
+ sm: "3",
198
+ md: "3",
199
+ lg: "3",
200
+ xl: "4",
201
+ className: "d-none d-lg-block",
202
+ as: "aside",
203
+ children: /* @__PURE__ */ s.jsx(C, { collection: n })
204
+ }
205
+ ),
206
+ /* @__PURE__ */ s.jsxs(
207
+ p.Col,
208
+ {
209
+ sm: "4",
210
+ md: "8",
211
+ lg: "5",
212
+ xl: "8",
213
+ className: `${o ? "cancel-gap" : ""}`,
214
+ children: [
215
+ !o && /* @__PURE__ */ s.jsx(C, { collection: n, isMobile: !0 }),
216
+ /* @__PURE__ */ s.jsx(J, { submission: t })
217
+ ]
218
+ }
219
+ )
220
+ ] }),
221
+ /* @__PURE__ */ s.jsx(
222
+ q,
223
+ {
224
+ handleUpdateSubmission: c,
225
+ onClose: a,
226
+ isOpen: e
227
+ }
228
+ )
229
+ ]
230
+ }
231
+ );
232
+ }, es = (n) => async ({ params: t }) => {
233
+ const i = Number(t.collectionId), o = Number(t.submissionId);
234
+ return await n.ensureQueryData(
235
+ V(i, o)
236
+ ), await n.ensureQueryData(F(i)), null;
237
+ }, ts = () => {
238
+ const n = B(), { isLoading: t, data: i } = z(
239
+ Number(n.collectionId),
240
+ Number(n.submissionId)
241
+ ), { data: o, isLoading: e } = T(
242
+ Number(n.collectionId)
243
+ );
244
+ return t || e ? /* @__PURE__ */ s.jsx(A, {}) : !o || !i ? /* @__PURE__ */ s.jsx(H, {}) : /* @__PURE__ */ s.jsx(X, { collection: o, submission: i });
245
+ };
246
+ export {
247
+ ts as Submission,
248
+ es as loader
249
+ };