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

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 (36) hide show
  1. package/lib/AppHeaderCollection-CdMZTmC6.js +170 -0
  2. package/lib/{CXEL7IU7-DVs75C4a.js → CXEL7IU7-BLUeaFt5.js} +2 -2
  3. package/lib/Collection-CUCjNGrr.js +472 -0
  4. package/lib/CollectionsLayout-DVYmui3o.js +187 -0
  5. package/lib/CollectionsList-Ba1LoCCN.js +310 -0
  6. package/lib/DeleteCollectionModal-CtmfiR2H.js +71 -0
  7. package/lib/DropdownActionTable-BhSk2sde.js +84 -0
  8. package/lib/FormEdit-DZFkw7z9.js +102 -0
  9. package/lib/{HASRA6WW-qb64R1U-.js → HASRA6WW-BPaxT9L-.js} +269 -269
  10. package/lib/{I3HPI4QX-DhV4n2OZ.js → I3HPI4QX-BuVHGkjY.js} +2 -2
  11. package/lib/MembersEdit-CblCChDS.js +77 -0
  12. package/lib/Root--z47Brfh.js +17 -0
  13. package/lib/SearchBarCollect-DBKaVVDV.js +23 -0
  14. package/lib/Submission-AzDGz_dM.js +257 -0
  15. package/lib/SubmissionList-Db_nRSqg.js +197 -0
  16. package/lib/index-HU8ua_Ev.js +3297 -0
  17. package/lib/index.js +7 -43
  18. package/lib/{submission.queries-CslqTzEP.js → submission.queries-Cr0bP5uv.js} +20 -17
  19. package/lib/useGetStatusSubmission-DxHmLPxr.js +57 -0
  20. package/package.json +1 -1
  21. package/lib/AppHeaderCollection-Bglbw6q9.js +0 -188
  22. package/lib/Collection-DYHQunUI.js +0 -463
  23. package/lib/CollectionsLayout-CPYEwl1X.js +0 -361
  24. package/lib/CollectionsList-Inb9z2nB.js +0 -315
  25. package/lib/DeleteCollectionModal-Dzsn2899.js +0 -112
  26. package/lib/DropdownActionTable-BLHrdk4t.js +0 -83
  27. package/lib/FormEdit-CwVhj3_4.js +0 -96
  28. package/lib/MathsModal-D8rTl0Sb.js +0 -42
  29. package/lib/MembersEdit-DDj8IWMX.js +0 -72
  30. package/lib/Root-DbGwe5v1.js +0 -13
  31. package/lib/SearchBarCollect-BAnLCwAC.js +0 -21
  32. package/lib/Submission-DUcQiBve.js +0 -249
  33. package/lib/SubmissionList-DjQ0x7eD.js +0 -695
  34. package/lib/heic-to-DuZ6uPPi.js +0 -72
  35. package/lib/index-Dt9ykSDF.js +0 -171658
  36. package/lib/useGetStatusSubmission-D77F1XUy.js +0 -55
@@ -1,112 +0,0 @@
1
- import { j as t, r as p, u as C, d as h, au as T, aq as b, ak as a, B as i, av as j } from "./index-Dt9ykSDF.js";
2
- import { u as x } from "./DropdownActionTable-BLHrdk4t.js";
3
- const m = (l) => {
4
- const {
5
- children: o,
6
- ...e
7
- } = l;
8
- return /* @__PURE__ */ t.jsx("tbody", { ...e, children: o });
9
- }, y = (l) => {
10
- const {
11
- children: o,
12
- ...e
13
- } = l;
14
- return /* @__PURE__ */ t.jsx("td", { ...e, children: o });
15
- }, f = (l) => {
16
- const {
17
- children: o,
18
- ...e
19
- } = l;
20
- return /* @__PURE__ */ t.jsx("th", { ...e, children: o });
21
- }, M = (l) => {
22
- const {
23
- children: o,
24
- ...e
25
- } = l;
26
- return /* @__PURE__ */ t.jsx("thead", { ...e, children: o });
27
- }, D = (l) => {
28
- const {
29
- children: o,
30
- ...e
31
- } = l;
32
- return /* @__PURE__ */ t.jsx("tr", { ...e, children: o });
33
- }, v = /* @__PURE__ */ p.forwardRef(({
34
- children: l,
35
- maxHeight: o
36
- }, e) => /* @__PURE__ */ t.jsx("div", { className: "table-responsive", style: o ? {
37
- maxHeight: o,
38
- overflowY: "auto"
39
- } : {}, children: /* @__PURE__ */ t.jsx("table", { ref: e, className: "table align-middle mb-0", style: {
40
- overflow: o ? "visible" : "hidden"
41
- }, children: l }) })), g = /* @__PURE__ */ Object.assign(v, {
42
- Thead: M,
43
- Th: f,
44
- Tbody: m,
45
- Tr: D,
46
- Td: y
47
- }), O = () => {
48
- const { appCode: l } = C(), { t: o } = h(l), e = b(), d = T(), { isDeleteModalOpen: s, onCloseDeleteModal: c, deleteCollectionId: r } = x((n) => ({
49
- isDeleteModalOpen: n.isDeleteModalOpen,
50
- onCloseDeleteModal: n.onCloseDeleteModal,
51
- deleteCollectionId: n.deleteCollectionId
52
- }));
53
- return {
54
- isOpen: s,
55
- onClose: c,
56
- handleDeleteCollection: async (n) => {
57
- if (r != null)
58
- try {
59
- await d.mutateAsync(r), e.success(o("collection.toast.success.collection.delete")), n == null || n();
60
- } catch (u) {
61
- console.error("Error deleting collection:", u), e.error(o("collection.toast.error.collection.delete"));
62
- } finally {
63
- c();
64
- }
65
- }
66
- };
67
- }, E = ({
68
- onDeleteSuccess: l
69
- }) => {
70
- const { appCode: o } = C(), { t: e } = h(o), { isOpen: d, onClose: s, handleDeleteCollection: c } = O(), r = async () => {
71
- await c(l);
72
- };
73
- return /* @__PURE__ */ t.jsxs(
74
- a,
75
- {
76
- id: "delete-confirmation-modal",
77
- isOpen: d,
78
- onModalClose: s,
79
- size: "sm",
80
- children: [
81
- /* @__PURE__ */ t.jsx(a.Header, { onModalClose: s, children: e("collection.modal.delete.title") }),
82
- /* @__PURE__ */ t.jsx(a.Body, { children: e("collection.modal.delete.description") }),
83
- /* @__PURE__ */ t.jsxs(a.Footer, { children: [
84
- /* @__PURE__ */ t.jsx(
85
- i,
86
- {
87
- "data-testid": "collect-collection-delete-modal-button-cancel",
88
- color: "tertiary",
89
- variant: "ghost",
90
- onClick: s,
91
- children: e("collection.cancel")
92
- }
93
- ),
94
- /* @__PURE__ */ t.jsx(
95
- i,
96
- {
97
- "data-testid": "collect-collection-delete-modal-button-delete",
98
- color: "danger",
99
- onClick: r,
100
- leftIcon: /* @__PURE__ */ t.jsx(j, {}),
101
- children: e("collection.delete")
102
- }
103
- )
104
- ] })
105
- ]
106
- }
107
- );
108
- };
109
- export {
110
- E as D,
111
- g as T
112
- };
@@ -1,83 +0,0 @@
1
- import { j as n, k as i, l as r, u as p, d as u, h, a as w, W as x, aA as m, am as I, av as O, D as c, r as C } from "./index-Dt9ykSDF.js";
2
- const D = ({
3
- title: e,
4
- titleId: o,
5
- ...s
6
- }) => /* @__PURE__ */ n.jsxs("svg", { xmlns: "http://www.w3.org/2000/svg", width: "24", height: "24", fill: "none", viewBox: "0 0 24 24", "aria-hidden": "true", "aria-labelledby": o, ...s, children: [
7
- e ? /* @__PURE__ */ n.jsx("title", { id: o, children: e }) : null,
8
- /* @__PURE__ */ n.jsx("path", { fill: "currentColor", fillRule: "evenodd", d: "M18.3 2.59c-1.16 0-2.1.937-2.1 2.092a2.07 2.07 0 0 0 .316 1.103 2.1 2.1 0 0 0 1.784.988c1.16 0 2.1-.936 2.1-2.091s-.94-2.091-2.1-2.091m-2.984 5.035A4.2 4.2 0 0 0 18.3 8.864c2.32 0 4.2-1.873 4.2-4.182S20.62.5 18.3.5s-4.2 1.872-4.2 4.182c0 .394.055.775.157 1.137L8.684 9.057A4.2 4.2 0 0 0 5.7 7.818C3.38 7.818 1.5 9.69 1.5 12s1.88 4.182 4.2 4.182a4.2 4.2 0 0 0 2.984-1.24l5.575 3.234a4.2 4.2 0 0 0-.159 1.142c0 2.31 1.88 4.182 4.2 4.182s4.2-1.872 4.2-4.182-1.88-4.182-4.2-4.182c-1.165 0-2.22.473-2.98 1.236l-5.577-3.235a4.17 4.17 0 0 0 0-2.274zm-7.831 3.273a1 1 0 0 0 .058.1 2.075 2.075 0 0 1-.059 2.105 2.1 2.1 0 0 1-1.784.988c-1.16 0-2.1-.936-2.1-2.091s.94-2.09 2.1-2.09a2.1 2.1 0 0 1 1.785.988m8.715 8.42c0-.34.081-.66.226-.944a1 1 0 0 0 .129-.219 2.1 2.1 0 0 1 1.745-.928c1.16 0 2.1.936 2.1 2.091s-.94 2.091-2.1 2.091-2.1-.936-2.1-2.09", clipRule: "evenodd" })
9
- ] }), b = r((e) => ({
10
- isDeleteModalOpen: !1,
11
- deleteCollectionId: null,
12
- isInstructionModalOpen: !1,
13
- isPastDeadline: !1,
14
- onOpenDeleteModal: (o) => e({ isDeleteModalOpen: !0, deleteCollectionId: o }),
15
- onCloseDeleteModal: () => e({ isDeleteModalOpen: !1, deleteCollectionId: null }),
16
- onOpenInstructionModal: () => e({ isInstructionModalOpen: !0 }),
17
- onCloseInstructionModal: () => e({ isInstructionModalOpen: !1 }),
18
- setIsPastDeadline: (o) => e({ isPastDeadline: o })
19
- })), g = i(
20
- b
21
- ), j = (e, o) => {
22
- const { appCode: s } = p(), { t: l } = u(s), t = h(), a = w(x.COLLECTION_CREATE), d = g.use.onOpenDeleteModal();
23
- return { dropdownOptions: [
24
- {
25
- label: l("collection.table.dropdown.open"),
26
- action: () => t(`/list-collections/id/${e}`),
27
- icon: /* @__PURE__ */ n.jsx(m, {}),
28
- hidden: o,
29
- dataTestId: "collect-dropdown-action-open"
30
- },
31
- {
32
- label: l("collection.table.dropdown.edit"),
33
- action: () => t(`/id/${e}/form`),
34
- icon: /* @__PURE__ */ n.jsx(I, {}),
35
- hidden: !a,
36
- dataTestId: "collect-dropdown-action-edit"
37
- },
38
- {
39
- label: l("collection.table.dropdown.share"),
40
- action: () => t(`/id/${e}/members`),
41
- icon: /* @__PURE__ */ n.jsx(D, {}),
42
- hidden: !a,
43
- dataTestId: "collect-dropdown-action-share"
44
- },
45
- {
46
- label: l("collection.table.dropdown.delete"),
47
- action: () => d(e),
48
- icon: /* @__PURE__ */ n.jsx(O, {}),
49
- className: "text-danger",
50
- hidden: !a,
51
- dataTestId: "collect-dropdown-action-share"
52
- }
53
- ] };
54
- }, v = ({
55
- collectionId: e,
56
- isCollection: o = !1,
57
- children: s
58
- }) => {
59
- const { dropdownOptions: l } = j(
60
- e,
61
- o
62
- );
63
- return /* @__PURE__ */ n.jsx(n.Fragment, { children: /* @__PURE__ */ n.jsx(c, { children: (t) => /* @__PURE__ */ n.jsxs(n.Fragment, { children: [
64
- s(t),
65
- /* @__PURE__ */ n.jsx(c.Menu, { children: l.map((a, d) => /* @__PURE__ */ n.jsx(C.Fragment, { children: !a.hidden && /* @__PURE__ */ n.jsxs(
66
- c.Item,
67
- {
68
- "data-testid": a.dataTestId,
69
- className: a.className,
70
- onClick: a.action,
71
- children: [
72
- a.icon,
73
- a.label
74
- ]
75
- },
76
- a.label
77
- ) }, d)) })
78
- ] }) }) });
79
- };
80
- export {
81
- v as D,
82
- g as u
83
- };
@@ -1,96 +0,0 @@
1
- import { u as T, d as b, n as N, ar as v, h as E, a as I, W as F, aF as w, r as L, as as f, j as t, L as O, P, G as g, F as h, aG as R, B as x, at as W, aH as k, aq as A } from "./index-Dt9ykSDF.js";
2
- import { s as G } from "./submission.queries-CslqTzEP.js";
3
- const B = (i) => async ({ params: s }) => {
4
- const o = Number(s.collectionId);
5
- return await i.ensureQueryData(W(o)), await i.prefetchInfiniteQuery(
6
- G(o)
7
- ), null;
8
- }, S = () => {
9
- const { appCode: i } = T(), { t: s } = b(i), { lg: o } = N(), d = v(), u = E(), p = A(), y = I(F.COLLECTION_CREATE), m = w(), [e, C] = L.useState(void 0), { data: a, isLoading: l } = f(
10
- Number(d.collectionId)
11
- );
12
- if (l)
13
- return /* @__PURE__ */ t.jsx(O, {});
14
- if (!y || !a) return /* @__PURE__ */ t.jsx(P, {});
15
- const j = async () => {
16
- const r = Number(d.collectionId);
17
- if (!r) return;
18
- const c = {
19
- title: (e == null ? void 0 : e.title) ?? a.name ?? "",
20
- description: (e == null ? void 0 : e.description) ?? a.content ?? "",
21
- deadline: (e == null ? void 0 : e.deadline) ?? (a.deadline ? new Date(a.deadline) : void 0),
22
- attachments: (e == null ? void 0 : e.attachments) ?? [],
23
- sharings: (e == null ? void 0 : e.sharings) ?? []
24
- };
25
- try {
26
- await m.mutateAsync({
27
- id: r,
28
- data: {
29
- name: c.title,
30
- content: c.description,
31
- deadline: c.deadline ?? /* @__PURE__ */ new Date(),
32
- attachments: c.attachments.map((n) => ({
33
- name: n.name,
34
- type: k.ATTACHMENT,
35
- uri: n.filename,
36
- mimeType: n.contentType
37
- }))
38
- }
39
- }), p.success(s("collection.toast.success.collection.update"), {
40
- duration: 1e4,
41
- isDismissible: !0
42
- }), u(`/list-collections/id/${r}`);
43
- } catch (n) {
44
- p.error(s("collection.toast.error.collection.update"), {
45
- duration: 1e4,
46
- isDismissible: !0
47
- }), console.log(n);
48
- }
49
- };
50
- return /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
51
- /* @__PURE__ */ t.jsx(g, { className: "flex-grow-1 gap-64 px-md-8 px-lg-48 position-relative", children: /* @__PURE__ */ t.jsx(g.Col, { sm: "4", md: "8", xl: "12", className: `${o && "ms-64"}`, children: /* @__PURE__ */ t.jsx(
52
- h,
53
- {
54
- direction: "column",
55
- gap: "16",
56
- className: "h-100 py-24 pb-lg-48 pt-lg-32",
57
- children: /* @__PURE__ */ t.jsx(
58
- R,
59
- {
60
- collection: a,
61
- updateWizardData: C
62
- }
63
- )
64
- }
65
- ) }) }),
66
- /* @__PURE__ */ t.jsxs(h, { justify: "end", className: "mt-auto px-48 pb-64 gap-16", children: [
67
- /* @__PURE__ */ t.jsx(
68
- x,
69
- {
70
- variant: "outline",
71
- color: "primary",
72
- isLoading: l,
73
- onClick: () => u(-1),
74
- "data-testid": "collect-cancel-sharings-button",
75
- children: s("collection.cancel")
76
- }
77
- ),
78
- /* @__PURE__ */ t.jsx(
79
- x,
80
- {
81
- variant: "filled",
82
- color: "primary",
83
- isLoading: l || m.isPending,
84
- loadingPosition: "right",
85
- onClick: j,
86
- "data-testid": "collect-save-sharings-button",
87
- children: s("collection.form.edit.save")
88
- }
89
- )
90
- ] })
91
- ] });
92
- };
93
- export {
94
- S as FormEdit,
95
- B as loader
96
- };
@@ -1,42 +0,0 @@
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
- };
@@ -1,72 +0,0 @@
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
- };
@@ -1,13 +0,0 @@
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
- };
@@ -1,21 +0,0 @@
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
- };
@@ -1,249 +0,0 @@
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
- };