mario-core 2.0.41-stage → 2.0.42-stage

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 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("react"),p=require("react-redux"),n=require("reactstrap"),s=require("./index-PBOiT9KR.js"),g=require("react-router-dom"),j=()=>e.jsxs("div",{className:`${s.styles["content-quote"]}`,children:[e.jsxs("div",{className:`${s.styles["title-quote"]} d-block`,children:[e.jsx("p",{children:"Powerful"}),e.jsx("p",{children:"Personalized"}),e.jsx("p",{children:"Learning"})]}),e.jsxs("div",{className:`${s.styles["descriptions-quote"]} d-block`,children:[e.jsx("p",{children:"Focus on what matters most to you and"}),e.jsx("p",{children:"make learning meaningful."})]})]}),x=({srcIcon:t,content:a})=>e.jsxs("div",{className:`${s.styles["content-icon"]}`,children:[e.jsx("div",{className:`${s.styles["title-icon"]}`,children:e.jsx("img",{src:s.getStaticFileUrl(t),alt:"icon"})}),e.jsx("div",{className:`${s.styles["descriptions-icon"]}`,dangerouslySetInnerHTML:{__html:a}})]},a),v=[{scrIcon:"/images/ChatsTeardrop.svg",content:"<p>Understand yourself better through <span>helpful feedback</span>.</p>"},{scrIcon:"/images/Student.svg",content:"<p>Create, explore, and share exciting <span>personalized</span> learning journeys.</p>"},{scrIcon:"/images/Confetti.svg",content:"<p>Set, monitor, and achieve <span>your goals</span>.</p>"}],y=({})=>e.jsxs(n.Row,{className:`${s.styles["page-not-login"]}`,children:[e.jsx(n.Col,{md:12,children:e.jsx(j,{})}),e.jsx(n.Col,{md:12,className:`${s.styles["box-content-home-page"]} d-flex align-items-center`,children:v.map(t=>e.jsx(x,{srcIcon:t.scrIcon,content:t.content},t.scrIcon))})]});function N(t){return s.GenIcon({attr:{viewBox:"0 0 512 512"},child:[{tag:"path",attr:{d:"M32 96v64h448V96H32zm0 128v64h448v-64H32zm0 128v64h448v-64H32z"}}]})(t)}const b=1e4,f=({data:t,duration:a=b})=>{const[i,o]=c.useState(t.length),r=c.useRef(null),d=c.useCallback(l=>l===i?`${s.styles.active} ${s.styles.show}`:"",[i]),h=c.useCallback(l=>i===0&&l===t.length-1||l===i-1?s.styles.behind:"",[i,t.length]),u=c.useCallback(()=>{r&&r.current&&clearInterval(r.current),r.current=setInterval(()=>{o(l=>l>=t.length-1?0:l+1)},a)},[a,t.length]);return c.useEffect(()=>(u(),()=>{r&&r.current&&clearInterval(r.current)}),[t.length,a]),e.jsx("div",{className:`${s.styles["bg-animate"]} position-absolute`,children:t.map((l,m)=>e.jsx("img",{alt:`Image ${m+1}`,className:`${h(m)} ${d(m)}`,src:s.getStaticFileUrl(l)},m))})},I="/admin/users/user-list",$="/home",k="/home",C="Dashboard",T="Mario Education",S=["images/landing-page.jpg","images/landing-page2.jpg","images/landing-page3.jpg"],E=({version:t})=>{const[a,i]=c.useState(!1),o=p.useSelector(d=>d.common.user),r=()=>i(!a);return c.useEffect(()=>{o?document.title=C:document.title=T},[o]),e.jsxs("div",{className:`${s.styles.login} ${s.styles["red-background"]} position-relative`,children:[e.jsx("span",{className:`${s.styles["version-prod"]}`,children:`v ${t}`}),e.jsx(f,{data:S}),e.jsxs("div",{className:`${s.styles["login-content"]}`,children:[e.jsxs(n.Navbar,{light:!0,expand:"md",children:[e.jsx(n.NavbarBrand,{href:"/",className:`${s.styles["logo-home"]}`,children:e.jsx("img",{src:s.getStaticFileUrl("/images/logo-white.svg"),alt:"mario"})}),e.jsx(N,{onClick:r,className:`${s.styles["hide-in-desktop"]} ${s.styles["hamburger-menu"]}`}),e.jsxs(n.Collapse,{isOpen:a,navbar:!0,className:`${s.styles["collapse-box"]}`,children:[e.jsxs(n.Nav,{className:`${s.styles["nav-home"]} d-md-flex w-100 justify-content-center mr-auto`,navbar:!0,children:[e.jsx(n.NavItem,{children:e.jsx(n.NavLink,{className:`${s.styles["learn-more"]} align-self-md-center`,href:"https://marioframework.com/software",target:"blank",children:"Learn More"})}),e.jsx(n.NavItem,{children:e.jsx(n.NavLink,{className:`${s.styles["learn-more"]} align-self-md-center`,href:"mailto: Info@marioeducation.com",target:"blank",children:"Contact"})}),e.jsx(n.NavItem,{children:e.jsx(n.NavLink,{className:`${s.styles["learn-more"]} align-self-md-center`,href:"/privacy-policy",target:"blank",children:"Privacy Policy"})})]}),e.jsx("div",{className:`${s.styles["hide-in-mobile"]} d-flex justify-content-end`,children:o?e.jsx(g.Link,{to:o.roles.includes("Admin")?I:o.roles.includes("Teacher")?$:k,className:`${s.styles["btn-trans-border"]}`,children:"Dashboard"}):e.jsx(g.Link,{to:"/login",className:`${s.styles["btn-trans-border"]}`,children:"Login"})})]})]}),e.jsx("div",{className:"",children:e.jsx(y,{})}),e.jsx("div",{className:`${s.styles["digital-privacy-icon"]}`,children:e.jsx("a",{href:"https://cert.privo.com/#/companies/marioFrameworkLlc",target:"blank",children:e.jsx("img",{src:s.getStaticFileUrl("/images/STUDENT.png"),alt:"icon"})})})]})]})};exports.default=E;
@@ -0,0 +1,206 @@
1
+ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
+ import { useState as N, useRef as I, useCallback as h, useEffect as f } from "react";
3
+ import { useSelector as k } from "react-redux";
4
+ import { Row as T, Col as u, Navbar as C, NavbarBrand as y, Collapse as E, Nav as A, NavItem as g, NavLink as p } from "reactstrap";
5
+ import { s as n, h as m, G as H } from "./index-CRPiwFOF.mjs";
6
+ import { Link as v } from "react-router-dom";
7
+ const M = () => /* @__PURE__ */ a("div", { className: `${n["content-quote"]}`, children: [
8
+ /* @__PURE__ */ a("div", { className: `${n["title-quote"]} d-block`, children: [
9
+ /* @__PURE__ */ e("p", { children: "Powerful" }),
10
+ /* @__PURE__ */ e("p", { children: "Personalized" }),
11
+ /* @__PURE__ */ e("p", { children: "Learning" })
12
+ ] }),
13
+ /* @__PURE__ */ a(
14
+ "div",
15
+ {
16
+ className: `${n["descriptions-quote"]} d-block`,
17
+ children: [
18
+ /* @__PURE__ */ e("p", { children: "Focus on what matters most to you and" }),
19
+ /* @__PURE__ */ e("p", { children: "make learning meaningful." })
20
+ ]
21
+ }
22
+ )
23
+ ] }), w = ({ srcIcon: r, content: t }) => /* @__PURE__ */ a("div", { className: `${n["content-icon"]}`, children: [
24
+ /* @__PURE__ */ e("div", { className: `${n["title-icon"]}`, children: /* @__PURE__ */ e("img", { src: m(r), alt: "icon" }) }),
25
+ /* @__PURE__ */ e(
26
+ "div",
27
+ {
28
+ className: `${n["descriptions-icon"]}`,
29
+ dangerouslySetInnerHTML: { __html: t }
30
+ }
31
+ )
32
+ ] }, t), D = [
33
+ {
34
+ scrIcon: "/images/ChatsTeardrop.svg",
35
+ content: "<p>Understand yourself better through <span>helpful feedback</span>.</p>"
36
+ },
37
+ {
38
+ scrIcon: "/images/Student.svg",
39
+ content: "<p>Create, explore, and share exciting <span>personalized</span> learning journeys.</p>"
40
+ },
41
+ {
42
+ scrIcon: "/images/Confetti.svg",
43
+ content: "<p>Set, monitor, and achieve <span>your goals</span>.</p>"
44
+ }
45
+ ], L = ({}) => /* @__PURE__ */ a(T, { className: `${n["page-not-login"]}`, children: [
46
+ /* @__PURE__ */ e(u, { md: 12, children: /* @__PURE__ */ e(M, {}) }),
47
+ /* @__PURE__ */ e(u, { md: 12, className: `${n["box-content-home-page"]} d-flex align-items-center`, children: D.map((r) => /* @__PURE__ */ e(
48
+ w,
49
+ {
50
+ srcIcon: r.scrIcon,
51
+ content: r.content
52
+ },
53
+ r.scrIcon
54
+ )) })
55
+ ] });
56
+ function O(r) {
57
+ return H({ attr: { viewBox: "0 0 512 512" }, child: [{ tag: "path", attr: { d: "M32 96v64h448V96H32zm0 128v64h448v-64H32zm0 128v64h448v-64H32z" } }] })(r);
58
+ }
59
+ const S = 1e4, _ = ({
60
+ data: r,
61
+ duration: t = S
62
+ }) => {
63
+ const [o, l] = N(r.length), s = I(null), d = h((c) => c === o ? `${n.active} ${n.show}` : "", [o]), $ = h((c) => o === 0 && c === r.length - 1 || c === o - 1 ? n.behind : "", [o, r.length]), b = h(() => {
64
+ s && s.current && clearInterval(s.current), s.current = setInterval(() => {
65
+ l((c) => c >= r.length - 1 ? 0 : c + 1);
66
+ }, t);
67
+ }, [t, r.length]);
68
+ return f(() => (b(), () => {
69
+ s && s.current && clearInterval(s.current);
70
+ }), [r.length, t]), /* @__PURE__ */ e("div", { className: `${n["bg-animate"]} position-absolute`, children: r.map((c, i) => /* @__PURE__ */ e(
71
+ "img",
72
+ {
73
+ alt: `Image ${i + 1}`,
74
+ className: `${$(i)} ${d(i)}`,
75
+ src: m(c)
76
+ },
77
+ i
78
+ )) });
79
+ }, j = "/admin/users/user-list", x = "/home", B = "/home", R = "Dashboard", U = "Mario Education", z = [
80
+ "images/landing-page.jpg",
81
+ "images/landing-page2.jpg",
82
+ "images/landing-page3.jpg"
83
+ ], J = ({ version: r }) => {
84
+ const [t, o] = N(!1), l = k((d) => d.common.user), s = () => o(!t);
85
+ return f(() => {
86
+ l ? document.title = R : document.title = U;
87
+ }, [l]), /* @__PURE__ */ a(
88
+ "div",
89
+ {
90
+ className: `${n.login} ${n["red-background"]} position-relative`,
91
+ children: [
92
+ /* @__PURE__ */ e(
93
+ "span",
94
+ {
95
+ className: `${n["version-prod"]}`,
96
+ children: `v ${r}`
97
+ }
98
+ ),
99
+ /* @__PURE__ */ e(_, { data: z }),
100
+ /* @__PURE__ */ a("div", { className: `${n["login-content"]}`, children: [
101
+ /* @__PURE__ */ a(C, { light: !0, expand: "md", children: [
102
+ /* @__PURE__ */ e(y, { href: "/", className: `${n["logo-home"]}`, children: /* @__PURE__ */ e(
103
+ "img",
104
+ {
105
+ src: m("/images/logo-white.svg"),
106
+ alt: "mario"
107
+ }
108
+ ) }),
109
+ /* @__PURE__ */ e(
110
+ O,
111
+ {
112
+ onClick: s,
113
+ className: `${n["hide-in-desktop"]} ${n["hamburger-menu"]}`
114
+ }
115
+ ),
116
+ /* @__PURE__ */ a(
117
+ E,
118
+ {
119
+ isOpen: t,
120
+ navbar: !0,
121
+ className: `${n["collapse-box"]}`,
122
+ children: [
123
+ /* @__PURE__ */ a(
124
+ A,
125
+ {
126
+ className: `${n["nav-home"]} d-md-flex w-100 justify-content-center mr-auto`,
127
+ navbar: !0,
128
+ children: [
129
+ /* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(
130
+ p,
131
+ {
132
+ className: `${n["learn-more"]} align-self-md-center`,
133
+ href: "https://marioframework.com/software",
134
+ target: "blank",
135
+ children: "Learn More"
136
+ }
137
+ ) }),
138
+ /* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(
139
+ p,
140
+ {
141
+ className: `${n["learn-more"]} align-self-md-center`,
142
+ href: "mailto: Info@marioeducation.com",
143
+ target: "blank",
144
+ children: "Contact"
145
+ }
146
+ ) }),
147
+ /* @__PURE__ */ e(g, { children: /* @__PURE__ */ e(
148
+ p,
149
+ {
150
+ className: `${n["learn-more"]} align-self-md-center`,
151
+ href: "/privacy-policy",
152
+ target: "blank",
153
+ children: "Privacy Policy"
154
+ }
155
+ ) })
156
+ ]
157
+ }
158
+ ),
159
+ /* @__PURE__ */ e(
160
+ "div",
161
+ {
162
+ className: `${n["hide-in-mobile"]} d-flex justify-content-end`,
163
+ children: l ? /* @__PURE__ */ e(
164
+ v,
165
+ {
166
+ to: l.roles.includes("Admin") ? j : l.roles.includes("Teacher") ? x : B,
167
+ className: `${n["btn-trans-border"]}`,
168
+ children: "Dashboard"
169
+ }
170
+ ) : /* @__PURE__ */ e(
171
+ v,
172
+ {
173
+ to: "/login",
174
+ className: `${n["btn-trans-border"]}`,
175
+ children: "Login"
176
+ }
177
+ )
178
+ }
179
+ )
180
+ ]
181
+ }
182
+ )
183
+ ] }),
184
+ /* @__PURE__ */ e("div", { className: "", children: /* @__PURE__ */ e(L, {}) }),
185
+ /* @__PURE__ */ e("div", { className: `${n["digital-privacy-icon"]}`, children: /* @__PURE__ */ e(
186
+ "a",
187
+ {
188
+ href: "https://cert.privo.com/#/companies/marioFrameworkLlc",
189
+ target: "blank",
190
+ children: /* @__PURE__ */ e(
191
+ "img",
192
+ {
193
+ src: m("/images/STUDENT.png"),
194
+ alt: "icon"
195
+ }
196
+ )
197
+ }
198
+ ) })
199
+ ] })
200
+ ]
201
+ }
202
+ );
203
+ };
204
+ export {
205
+ J as default
206
+ };
@@ -0,0 +1,443 @@
1
+ import { jsx as e, jsxs as c } from "react/jsx-runtime";
2
+ import { Table as J, Row as D, Col as h, Input as K, FormGroup as Y, Label as H, Button as ee } from "reactstrap";
3
+ import { useNavigate as te, useParams as ae } from "react-router-dom";
4
+ import { Editor as se } from "@tinymce/tinymce-react";
5
+ import { Formik as ne } from "formik";
6
+ import { R as ie, H as le, b as C, c as k, S as oe, T as ce, U as P, E as U, V as re, W as me } from "./index-CRPiwFOF.mjs";
7
+ import { useTranslation as W } from "react-i18next";
8
+ import { useEffect as L, Fragment as de, useState as R, useCallback as z } from "react";
9
+ import ue from "react-select";
10
+ import { useDispatch as Q, useSelector as X } from "react-redux";
11
+ import { a as he, b as pe, u as fe, c as ge, d as ye } from "./mailCategoryService-Dzuji6G_.mjs";
12
+ import * as w from "yup";
13
+ const be = ({ onClick: s }) => /* @__PURE__ */ e("div", { className: "d-inline text-center cursor-pointer hover-opacity", title: "Delete", onClick: s, children: /* @__PURE__ */ e(ie, {}) }), G = [
14
+ { label: "$USER_FIRST_NAME$", meaning: "user_first_name" },
15
+ { label: "$USER_LAST_NAME$", meaning: "user_last_name" },
16
+ { label: "$PASSWORD$", meaning: "password" },
17
+ { label: "$USER_NAME$", meaning: "user_name" },
18
+ { label: "$USER_EMAIL$", meaning: "user_email" },
19
+ { label: "$MESSAGE$", meaning: "message" },
20
+ { label: "$DOMAIN$", meaning: "domain" }
21
+ ], Ee = ({
22
+ onClick: s,
23
+ isResetPasswordTemplate: n
24
+ }) => {
25
+ const { t: i } = W();
26
+ let b = n ? [...G, { label: "$RESET_LINK$", meaning: "Reset link" }] : G;
27
+ return /* @__PURE__ */ c(J, { bordered: !0, hover: !0, striped: !0, responsive: !0, size: "sm", children: [
28
+ /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ c("tr", { children: [
29
+ /* @__PURE__ */ e("th", { className: "align-top", children: i("params") }),
30
+ /* @__PURE__ */ e("th", { className: "align-top", children: i("meaning") }),
31
+ /* @__PURE__ */ e("th", {})
32
+ ] }) }),
33
+ /* @__PURE__ */ e("tbody", { children: b.map((d) => /* @__PURE__ */ c("tr", { children: [
34
+ /* @__PURE__ */ e("td", { className: "align-middle", children: d.label }),
35
+ /* @__PURE__ */ e("td", { className: "align-middle", children: i(d.meaning) }),
36
+ /* @__PURE__ */ e("td", { className: "text-center align-middle", children: /* @__PURE__ */ e(be, { onClick: () => s(d) }) })
37
+ ] }, d.label)) })
38
+ ] });
39
+ }, Ie = (s) => {
40
+ const n = Q(), i = X(
41
+ (o) => o.mailCategory.mailCategoryList
42
+ );
43
+ L(() => {
44
+ b();
45
+ }, []);
46
+ const b = async () => {
47
+ try {
48
+ const o = await he();
49
+ n(le(o.data.items));
50
+ } catch (o) {
51
+ console.error(o);
52
+ }
53
+ }, { id: d } = s, I = i.map((o) => ({
54
+ id: o.id,
55
+ value: o.id,
56
+ label: o.name
57
+ })), T = d && I.find((o) => o.value === d) || null;
58
+ return /* @__PURE__ */ e(ue, { options: I, value: T, ...s });
59
+ }, O = ({ label: s, onRemove: n }) => /* @__PURE__ */ c(de, { children: [
60
+ /* @__PURE__ */ e("span", { className: "mr-2", children: s }),
61
+ /* @__PURE__ */ e(
62
+ "i",
63
+ {
64
+ className: "fa fa-times text-danger cursor-pointer hover-opacity",
65
+ onClick: n
66
+ }
67
+ )
68
+ ] }), _e = {
69
+ id: 0,
70
+ subject: "",
71
+ categoryId: 0,
72
+ body: "",
73
+ attachments: [],
74
+ isDisabled: !1
75
+ }, Ce = "/admin/email-template", Te = "Email template detail", Se = 4194304, ve = (s) => {
76
+ let n;
77
+ const i = Q(), b = te(), [d, I] = R(_e), [T, o] = R(!1), M = async () => {
78
+ localStorage.setItem(window.location.href, "true"), o(!0);
79
+ }, [p, x] = R([]), [u, $] = R([]), [j, F] = R("");
80
+ L(() => {
81
+ s && S();
82
+ }, [s]);
83
+ const S = z(async () => {
84
+ i(C(!0));
85
+ try {
86
+ const t = await pe(s);
87
+ I({
88
+ id: t.data.id,
89
+ subject: t.data.subject,
90
+ categoryId: t.data.category.id,
91
+ body: t.data.body,
92
+ attachments: t.data.attachments || [],
93
+ isDisabled: t.data.isDisabled
94
+ }), document.title = t.data.subject, n && n.editor.execCommand(
95
+ "mceSetContent",
96
+ !1,
97
+ t.data.body
98
+ );
99
+ } catch (t) {
100
+ i(
101
+ k({
102
+ type: "danger",
103
+ message: t.response?.data?.title || t.message
104
+ })
105
+ );
106
+ }
107
+ i(C(!1));
108
+ }, [s]), E = async () => {
109
+ i(C(!0));
110
+ try {
111
+ const a = (await ye()).data;
112
+ a && F(a.key);
113
+ } catch (t) {
114
+ i(
115
+ k({
116
+ type: "danger",
117
+ message: t.response?.data?.title || "Get key failed"
118
+ })
119
+ );
120
+ }
121
+ i(C(!1));
122
+ }, f = (t) => n = t, v = (t) => {
123
+ n && n.editor.execCommand(
124
+ "mceInsertContent",
125
+ !1,
126
+ ` ${t.label}`
127
+ );
128
+ }, g = z(() => {
129
+ b(Ce);
130
+ }, []), _ = z(
131
+ async (t) => {
132
+ i(C(!0));
133
+ try {
134
+ if (u && u.length) {
135
+ const m = (await l()).map((r) => ({
136
+ key: r.data.key,
137
+ name: r.data.name
138
+ }));
139
+ t.attachments = [...t.attachments, ...m];
140
+ }
141
+ await (s ? fe : ge)(t), i(
142
+ k({
143
+ type: "success",
144
+ message: `${s ? "Update" : "Create"} template successfully`
145
+ })
146
+ ), g();
147
+ } catch (a) {
148
+ i(
149
+ k({
150
+ type: "danger",
151
+ message: a.response?.data?.title || a.message
152
+ })
153
+ );
154
+ }
155
+ i(C(!1));
156
+ },
157
+ [s, u]
158
+ ), B = () => {
159
+ const t = document.getElementsByClassName("input-attachment"), a = document.createElement("input");
160
+ document.getElementById("email-detail")?.append(a), a.className = "input-attachment", a.id = `inputAttachment-${t.length + 1}`, a.type = "file", a.style.display = "none", a.setAttribute("multiple", "multiple"), a.addEventListener("change", A), a.click();
161
+ }, A = () => {
162
+ const t = [];
163
+ let a = 0;
164
+ const y = document.getElementsByClassName("input-attachment");
165
+ for (const m of y)
166
+ for (const r of m.files)
167
+ a += r.size, a > Se && (i(
168
+ k({
169
+ type: "danger",
170
+ message: "Max attachment size is 4MB"
171
+ })
172
+ ), a -= r.size, m.remove());
173
+ for (const m of y)
174
+ for (const r of m.files) {
175
+ const { name: N } = r;
176
+ !p.includes(r) && !t.some((Z) => Z.name === N) && t.push({ name: N, inputId: m.id });
177
+ }
178
+ $(t);
179
+ }, q = (t, a) => {
180
+ if (u.filter((y) => y.inputId === t).length === 1) {
181
+ document.getElementById(t)?.remove();
182
+ let m = u.filter(
183
+ (r) => r.inputId === t
184
+ );
185
+ u.filter(
186
+ (r) => r.inputId !== m.inputId
187
+ ), p.push(m), x([...p]), $([...u]);
188
+ return;
189
+ }
190
+ x([...p, a]);
191
+ };
192
+ L(() => {
193
+ A();
194
+ }, [p]);
195
+ const l = async () => {
196
+ const t = document.getElementsByClassName("input-attachment"), a = [];
197
+ for (const y of t)
198
+ for (const m of y.files) {
199
+ const { name: r } = m, N = new FormData();
200
+ N.append("file", m, r), a.push(oe(N));
201
+ }
202
+ return Promise.all(a);
203
+ };
204
+ return L(() => {
205
+ document.title = Te, E(), o(!1), localStorage.getItem(window.location.href) && localStorage.removeItem(window.location.href);
206
+ }, []), {
207
+ emailTemplateDetail: d,
208
+ setEditorRef: f,
209
+ addParams: v,
210
+ backToList: g,
211
+ confirmData: _,
212
+ edited: T,
213
+ setEdited: o,
214
+ setEditedTrue: M,
215
+ onAttachFile: B,
216
+ updateAttachment: A,
217
+ fileUpload: u,
218
+ removeAttachment: q,
219
+ tinyMCEKey: j
220
+ };
221
+ }, Ae = w.object({
222
+ subject: w.string().required("Template subject is required"),
223
+ categoryId: w.number().required("Template category is required").test(
224
+ "test category id",
225
+ "Template category is required",
226
+ (s) => s >= 1
227
+ ),
228
+ comment: w.string(),
229
+ body: w.string().required("Template body is required")
230
+ }), V = {
231
+ "detail-header": "_detail-header_oasq7_1",
232
+ "form-check-disabled": "_form-check-disabled_oasq7_8",
233
+ "active-status": "_active-status_oasq7_14"
234
+ }, Ne = "create_email_template", De = "edit_email_template", Pe = () => {
235
+ const { id: s } = ae(), { t: n } = W(), {
236
+ emailTemplateDetail: i,
237
+ setEditorRef: b,
238
+ addParams: d,
239
+ backToList: I,
240
+ confirmData: T,
241
+ edited: o,
242
+ setEdited: M,
243
+ setEditedTrue: p,
244
+ onAttachFile: x,
245
+ fileUpload: u,
246
+ removeAttachment: $
247
+ } = ve(parseInt(s || "0")), j = n(s ? De : Ne), F = n(s ? "update" : "create"), S = X(
248
+ (E) => E.mailCategory.mailCategoryList
249
+ );
250
+ return /* @__PURE__ */ e(
251
+ ne,
252
+ {
253
+ initialValues: i,
254
+ enableReinitialize: !0,
255
+ validationSchema: Ae,
256
+ onSubmit: (E) => {
257
+ T(E), M(!1), localStorage.getItem(window.location.href) && localStorage.removeItem(window.location.href);
258
+ },
259
+ children: (E) => {
260
+ const {
261
+ values: f,
262
+ touched: v,
263
+ errors: g,
264
+ setFieldValue: _,
265
+ handleChange: B,
266
+ handleBlur: A,
267
+ handleSubmit: q
268
+ } = E;
269
+ return /* @__PURE__ */ c(
270
+ "div",
271
+ {
272
+ className: "animated fadeIn detail-buttons-padding",
273
+ id: "email-detail",
274
+ children: [
275
+ /* @__PURE__ */ e(ce, { when: o }),
276
+ /* @__PURE__ */ e(
277
+ "h5",
278
+ {
279
+ className: "mb-2",
280
+ style: { textTransform: "capitalize" },
281
+ children: j
282
+ }
283
+ ),
284
+ /* @__PURE__ */ c(D, { className: "my-2", children: [
285
+ /* @__PURE__ */ c(h, { md: 8, children: [
286
+ /* @__PURE__ */ e(P, { text: n("mail_subject") }),
287
+ /* @__PURE__ */ c("div", { className: `${V["detail-header"]}`, children: [
288
+ /* @__PURE__ */ e(
289
+ K,
290
+ {
291
+ placeholder: n("mail_subject_nm"),
292
+ name: "subject",
293
+ value: f.subject,
294
+ onChange: (l) => {
295
+ B(l), p();
296
+ },
297
+ onBlur: A("subject"),
298
+ className: "selector-input"
299
+ }
300
+ ),
301
+ /* @__PURE__ */ c(Y, { check: !0, className: `${V["form-check-disabled"]}`, children: [
302
+ /* @__PURE__ */ e(
303
+ K,
304
+ {
305
+ type: "checkbox",
306
+ id: "disable-checkbox",
307
+ checked: !f.isDisabled,
308
+ onChange: () => {
309
+ _(
310
+ "isDisabled",
311
+ !f.isDisabled
312
+ );
313
+ },
314
+ className: ` ${V["active-status"]}`
315
+ }
316
+ ),
317
+ /* @__PURE__ */ e(H, { check: !0, for: "di-default-checkbox", children: n("enabled") })
318
+ ] })
319
+ ] }),
320
+ v.subject && g.subject && /* @__PURE__ */ e(U, { text: g.subject })
321
+ ] }),
322
+ /* @__PURE__ */ c(h, { md: 4, children: [
323
+ /* @__PURE__ */ e(P, { text: n("category") }),
324
+ /* @__PURE__ */ e(
325
+ Ie,
326
+ {
327
+ onChange: (l) => {
328
+ _("categoryId", l.value), p();
329
+ },
330
+ id: f.categoryId
331
+ }
332
+ ),
333
+ v.categoryId && g.categoryId && /* @__PURE__ */ e(U, { text: g.categoryId })
334
+ ] })
335
+ ] }),
336
+ /* @__PURE__ */ c(D, { className: "mb-2", children: [
337
+ /* @__PURE__ */ e(h, { md: 8, children: /* @__PURE__ */ c(D, { children: [
338
+ /* @__PURE__ */ c(h, { md: 12, className: "mb-2", children: [
339
+ /* @__PURE__ */ e(P, { text: n("mail_body") }),
340
+ (i.body || !s) && /* @__PURE__ */ e(
341
+ se,
342
+ {
343
+ tinymceScriptSrc: "/tinymce/tinymce.min.js",
344
+ ref: (l) => b(l),
345
+ initialValue: i.body,
346
+ init: re.email,
347
+ onEditorChange: (l) => {
348
+ _(
349
+ "body",
350
+ l
351
+ ), p();
352
+ }
353
+ }
354
+ ),
355
+ v.body && g.body && /* @__PURE__ */ e(U, { text: g.body })
356
+ ] }),
357
+ /* @__PURE__ */ e(h, { md: 12, children: /* @__PURE__ */ c(D, { children: [
358
+ /* @__PURE__ */ e(h, { md: 3, children: /* @__PURE__ */ e(
359
+ ee,
360
+ {
361
+ color: "link",
362
+ size: "sm",
363
+ className: "pl-0",
364
+ onClick: x,
365
+ children: n("add_attachment")
366
+ }
367
+ ) }),
368
+ /* @__PURE__ */ e(h, { md: 12, children: /* @__PURE__ */ c(D, { children: [
369
+ f.attachments.map(
370
+ (l) => /* @__PURE__ */ e(
371
+ h,
372
+ {
373
+ md: 2,
374
+ children: /* @__PURE__ */ e(
375
+ O,
376
+ {
377
+ label: l.name,
378
+ onRemove: () => _(
379
+ "attachments",
380
+ f.attachments.filter(
381
+ (t) => t.name !== l.name
382
+ )
383
+ )
384
+ }
385
+ )
386
+ },
387
+ l.key
388
+ )
389
+ ),
390
+ u.map(
391
+ (l, t) => /* @__PURE__ */ e(
392
+ h,
393
+ {
394
+ md: 2,
395
+ className: "d-flex align-items-center",
396
+ children: /* @__PURE__ */ e(
397
+ O,
398
+ {
399
+ label: l.name,
400
+ onRemove: () => $(
401
+ l.inputId,
402
+ l.name
403
+ )
404
+ }
405
+ )
406
+ },
407
+ t
408
+ )
409
+ )
410
+ ] }) })
411
+ ] }) })
412
+ ] }) }),
413
+ /* @__PURE__ */ c(h, { md: 4, children: [
414
+ /* @__PURE__ */ e(H, { children: n("mail_params") }),
415
+ /* @__PURE__ */ e(
416
+ Ee,
417
+ {
418
+ onClick: (l) => d(l),
419
+ isResetPasswordTemplate: f.categoryId == (S && S.length > 0 && S.filter(
420
+ (l) => l.name == "Reset password"
421
+ )[0].id)
422
+ }
423
+ )
424
+ ] })
425
+ ] }),
426
+ /* @__PURE__ */ e(
427
+ me,
428
+ {
429
+ confirmText: F,
430
+ onConfirm: q,
431
+ onCancel: I
432
+ }
433
+ )
434
+ ]
435
+ }
436
+ );
437
+ }
438
+ }
439
+ );
440
+ };
441
+ export {
442
+ Pe as default
443
+ };
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),c=require("reactstrap"),U=require("react-router-dom"),H=require("@tinymce/tinymce-react"),K=require("formik"),l=require("./index-PBOiT9KR.js"),z=require("react-i18next"),u=require("react"),V=require("react-select"),k=require("react-redux"),A=require("./mailCategoryService-DK0zFSbc.js"),G=require("yup");function Q(a){const s=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(a){for(const n in a)if(n!=="default"){const p=Object.getOwnPropertyDescriptor(a,n);Object.defineProperty(s,n,p.get?p:{enumerable:!0,get:()=>a[n]})}}return s.default=a,Object.freeze(s)}const v=Q(G),W=({onClick:a})=>e.jsx("div",{className:"d-inline text-center cursor-pointer hover-opacity",title:"Delete",onClick:a,children:e.jsx(l.FaPlus,{})}),P=[{label:"$USER_FIRST_NAME$",meaning:"user_first_name"},{label:"$USER_LAST_NAME$",meaning:"user_last_name"},{label:"$PASSWORD$",meaning:"password"},{label:"$USER_NAME$",meaning:"user_name"},{label:"$USER_EMAIL$",meaning:"user_email"},{label:"$MESSAGE$",meaning:"message"},{label:"$DOMAIN$",meaning:"domain"}],X=({onClick:a,isResetPasswordTemplate:s})=>{const{t:n}=z.useTranslation();let p=s?[...P,{label:"$RESET_LINK$",meaning:"Reset link"}]:P;return e.jsxs(c.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[e.jsx("thead",{children:e.jsxs("tr",{children:[e.jsx("th",{className:"align-top",children:n("params")}),e.jsx("th",{className:"align-top",children:n("meaning")}),e.jsx("th",{})]})}),e.jsx("tbody",{children:p.map(h=>e.jsxs("tr",{children:[e.jsx("td",{className:"align-middle",children:h.label}),e.jsx("td",{className:"align-middle",children:n(h.meaning)}),e.jsx("td",{className:"text-center align-middle",children:e.jsx(W,{onClick:()=>a(h)})})]},h.label))})]})},Z=a=>{const s=k.useDispatch(),n=k.useSelector(r=>r.mailCategory.mailCategoryList);u.useEffect(()=>{p()},[]);const p=async()=>{try{const r=await A.get$1();s(l.setMailCategory(r.data.items))}catch(r){console.error(r)}},{id:h}=a,E=n.map(r=>({id:r.id,value:r.id,label:r.name})),I=h&&E.find(r=>r.value===h)||null;return e.jsx(V,{options:E,value:I,...a})},B=({label:a,onRemove:s})=>e.jsxs(u.Fragment,{children:[e.jsx("span",{className:"mr-2",children:a}),e.jsx("i",{className:"fa fa-times text-danger cursor-pointer hover-opacity",onClick:s})]}),J={id:0,subject:"",categoryId:0,body:"",attachments:[],isDisabled:!1},Y="/admin/email-template",ee="Email template detail",te=4194304,ae=a=>{let s;const n=k.useDispatch(),p=U.useNavigate(),[h,E]=u.useState(J),[I,r]=u.useState(!1),w=async()=>{localStorage.setItem(window.location.href,"true"),r(!0)},[f,D]=u.useState([]),[g,N]=u.useState([]),[L,q]=u.useState("");u.useEffect(()=>{a&&_()},[a]);const _=u.useCallback(async()=>{n(l.setLoading(!0));try{const t=await A.getById(a);E({id:t.data.id,subject:t.data.subject,categoryId:t.data.category.id,body:t.data.body,attachments:t.data.attachments||[],isDisabled:t.data.isDisabled}),document.title=t.data.subject,s&&s.editor.execCommand("mceSetContent",!1,t.data.body)}catch(t){n(l.setAlert({type:"danger",message:t.response?.data?.title||t.message}))}n(l.setLoading(!1))},[a]),j=async()=>{n(l.setLoading(!0));try{const i=(await A.getTinyMCEKeyApi()).data;i&&q(i.key)}catch(t){n(l.setAlert({type:"danger",message:t.response?.data?.title||"Get key failed"}))}n(l.setLoading(!1))},y=t=>s=t,S=t=>{s&&s.editor.execCommand("mceInsertContent",!1,` ${t.label}`)},b=u.useCallback(()=>{p(Y)},[]),C=u.useCallback(async t=>{n(l.setLoading(!0));try{if(g&&g.length){const m=(await o()).map(d=>({key:d.data.key,name:d.data.name}));t.attachments=[...t.attachments,...m]}await(a?A.update:A.create)(t),n(l.setAlert({type:"success",message:`${a?"Update":"Create"} template successfully`})),b()}catch(i){n(l.setAlert({type:"danger",message:i.response?.data?.title||i.message}))}n(l.setLoading(!1))},[a,g]),M=()=>{const t=document.getElementsByClassName("input-attachment"),i=document.createElement("input");document.getElementById("email-detail")?.append(i),i.className="input-attachment",i.id=`inputAttachment-${t.length+1}`,i.type="file",i.style.display="none",i.setAttribute("multiple","multiple"),i.addEventListener("change",T),i.click()},T=()=>{const t=[];let i=0;const x=document.getElementsByClassName("input-attachment");for(const m of x)for(const d of m.files)i+=d.size,i>te&&(n(l.setAlert({type:"danger",message:"Max attachment size is 4MB"})),i-=d.size,m.remove());for(const m of x)for(const d of m.files){const{name:R}=d;!f.includes(d)&&!t.some(O=>O.name===R)&&t.push({name:R,inputId:m.id})}N(t)},$=(t,i)=>{if(g.filter(x=>x.inputId===t).length===1){document.getElementById(t)?.remove();let m=g.filter(d=>d.inputId===t);g.filter(d=>d.inputId!==m.inputId),f.push(m),D([...f]),N([...g]);return}D([...f,i])};u.useEffect(()=>{T()},[f]);const o=async()=>{const t=document.getElementsByClassName("input-attachment"),i=[];for(const x of t)for(const m of x.files){const{name:d}=m,R=new FormData;R.append("file",m,d),i.push(l.systemEmailUpload(R))}return Promise.all(i)};return u.useEffect(()=>{document.title=ee,j(),r(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},[]),{emailTemplateDetail:h,setEditorRef:y,addParams:S,backToList:b,confirmData:C,edited:I,setEdited:r,setEditedTrue:w,onAttachFile:M,updateAttachment:T,fileUpload:g,removeAttachment:$,tinyMCEKey:L}},se=v.object({subject:v.string().required("Template subject is required"),categoryId:v.number().required("Template category is required").test("test category id","Template category is required",a=>a>=1),comment:v.string(),body:v.string().required("Template body is required")}),F={"detail-header":"_detail-header_oasq7_1","form-check-disabled":"_form-check-disabled_oasq7_8","active-status":"_active-status_oasq7_14"},ne="create_email_template",ie="edit_email_template",le=()=>{const{id:a}=U.useParams(),{t:s}=z.useTranslation(),{emailTemplateDetail:n,setEditorRef:p,addParams:h,backToList:E,confirmData:I,edited:r,setEdited:w,setEditedTrue:f,onAttachFile:D,fileUpload:g,removeAttachment:N}=ae(parseInt(a||"0")),L=s(a?ie:ne),q=s(a?"update":"create"),_=k.useSelector(j=>j.mailCategory.mailCategoryList);return e.jsx(K.Formik,{initialValues:n,enableReinitialize:!0,validationSchema:se,onSubmit:j=>{I(j),w(!1),localStorage.getItem(window.location.href)&&localStorage.removeItem(window.location.href)},children:j=>{const{values:y,touched:S,errors:b,setFieldValue:C,handleChange:M,handleBlur:T,handleSubmit:$}=j;return e.jsxs("div",{className:"animated fadeIn detail-buttons-padding",id:"email-detail",children:[e.jsx(l.QuitPrompt,{when:r}),e.jsx("h5",{className:"mb-2",style:{textTransform:"capitalize"},children:L}),e.jsxs(c.Row,{className:"my-2",children:[e.jsxs(c.Col,{md:8,children:[e.jsx(l.RequiredLabel,{text:s("mail_subject")}),e.jsxs("div",{className:`${F["detail-header"]}`,children:[e.jsx(c.Input,{placeholder:s("mail_subject_nm"),name:"subject",value:y.subject,onChange:o=>{M(o),f()},onBlur:T("subject"),className:"selector-input"}),e.jsxs(c.FormGroup,{check:!0,className:`${F["form-check-disabled"]}`,children:[e.jsx(c.Input,{type:"checkbox",id:"disable-checkbox",checked:!y.isDisabled,onChange:()=>{C("isDisabled",!y.isDisabled)},className:` ${F["active-status"]}`}),e.jsx(c.Label,{check:!0,for:"di-default-checkbox",children:s("enabled")})]})]}),S.subject&&b.subject&&e.jsx(l.ErrorHandler,{text:b.subject})]}),e.jsxs(c.Col,{md:4,children:[e.jsx(l.RequiredLabel,{text:s("category")}),e.jsx(Z,{onChange:o=>{C("categoryId",o.value),f()},id:y.categoryId}),S.categoryId&&b.categoryId&&e.jsx(l.ErrorHandler,{text:b.categoryId})]})]}),e.jsxs(c.Row,{className:"mb-2",children:[e.jsx(c.Col,{md:8,children:e.jsxs(c.Row,{children:[e.jsxs(c.Col,{md:12,className:"mb-2",children:[e.jsx(l.RequiredLabel,{text:s("mail_body")}),(n.body||!a)&&e.jsx(H.Editor,{tinymceScriptSrc:"/tinymce/tinymce.min.js",ref:o=>p(o),initialValue:n.body,init:l.editorConfig.email,onEditorChange:o=>{C("body",o),f()}}),S.body&&b.body&&e.jsx(l.ErrorHandler,{text:b.body})]}),e.jsx(c.Col,{md:12,children:e.jsxs(c.Row,{children:[e.jsx(c.Col,{md:3,children:e.jsx(c.Button,{color:"link",size:"sm",className:"pl-0",onClick:D,children:s("add_attachment")})}),e.jsx(c.Col,{md:12,children:e.jsxs(c.Row,{children:[y.attachments.map(o=>e.jsx(c.Col,{md:2,children:e.jsx(B,{label:o.name,onRemove:()=>C("attachments",y.attachments.filter(t=>t.name!==o.name))})},o.key)),g.map((o,t)=>e.jsx(c.Col,{md:2,className:"d-flex align-items-center",children:e.jsx(B,{label:o.name,onRemove:()=>N(o.inputId,o.name)})},t))]})})]})})]})}),e.jsxs(c.Col,{md:4,children:[e.jsx(c.Label,{children:s("mail_params")}),e.jsx(X,{onClick:o=>h(o),isResetPasswordTemplate:y.categoryId==(_&&_.length>0&&_.filter(o=>o.name=="Reset password")[0].id)})]})]}),e.jsx(l.DetailActionButtons,{confirmText:q,onConfirm:$,onCancel:E})]})}})};exports.default=le;