mario-core 3.0.42-es-staging → 3.0.46-es-test

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