@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,112 @@
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
+ };
@@ -0,0 +1,83 @@
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
+ };
@@ -0,0 +1,96 @@
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
+ };