mario-core 2.0.190-staging → 2.0.192-staging

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 (42) hide show
  1. package/dist/{Dashboard-CEhcxysO.mjs → Dashboard-D4lIJRL7.mjs} +1 -1
  2. package/dist/{Dashboard-CwzDtmwr.js → Dashboard-DnTRSYdx.js} +1 -1
  3. package/dist/{EmailTemplateDetail-hFh4YZcK.mjs → EmailTemplateDetail-C1L-5b3l.mjs} +2 -2
  4. package/dist/{EmailTemplateDetail-B_owQ4SI.js → EmailTemplateDetail-aHeCJrLN.js} +1 -1
  5. package/dist/{EmailTemplateList-CGxlfXmA.mjs → EmailTemplateList-C0PA2nMM.mjs} +2 -2
  6. package/dist/{EmailTemplateList-CBnAetB3.js → EmailTemplateList-D6Lmaag4.js} +1 -1
  7. package/dist/{GalleryList-UTNv1JlK.mjs → GalleryList-CxyCbSTv.mjs} +1 -1
  8. package/dist/{GalleryList-Bm8OdUWF.js → GalleryList-DpWoVW1V.js} +1 -1
  9. package/dist/{Login-D-qL3j4E.mjs → Login-Bx1Um5mh.mjs} +2 -2
  10. package/dist/{Login-8UPwZA7C.js → Login-DHou8E1x.js} +1 -1
  11. package/dist/{NotificationList-By7e_jcw.js → NotificationList-BlLCrjC-.js} +1 -1
  12. package/dist/{NotificationList-CsOOY8PN.mjs → NotificationList-FnIYSMpg.mjs} +1 -1
  13. package/dist/{SkillList-BpkSmPFN.js → SkillList-Dk2BXwXF.js} +1 -1
  14. package/dist/{SkillList-B2EoiCXH.mjs → SkillList-sqLixnOl.mjs} +1 -1
  15. package/dist/{TeacherSelector-H8u_rtvY.js → TeacherSelector-B26CRTOE.js} +1 -1
  16. package/dist/{TeacherSelector-CaGhBWmg.mjs → TeacherSelector-CocE_8At.mjs} +1 -1
  17. package/dist/{TheContent-BgExd1bY.js → TheContent-8wblzMeE.js} +1 -1
  18. package/dist/{TheContent-DMnayhAB.mjs → TheContent-D6SR5DVj.mjs} +1 -1
  19. package/dist/{UserContainer-IWKbs6Bn.mjs → UserContainer-BKClkDlb.mjs} +5 -5
  20. package/dist/{UserContainer-Boh0p45-.js → UserContainer-DF0SP8Nh.js} +1 -1
  21. package/dist/{UserDetail-C1oMlmdw.js → UserDetail-DEU6GvpM.js} +1 -1
  22. package/dist/{UserDetail-DeCrhKqc.mjs → UserDetail-DX_ltw__.mjs} +4 -4
  23. package/dist/UserList-0ToQqUnX.mjs +1311 -0
  24. package/dist/UserList-B3AZ74EL.js +7 -0
  25. package/dist/{constants-DwMmTVmo.mjs → constants-O8Ssqwfe.mjs} +1 -1
  26. package/dist/{constants-DstAxi4a.js → constants-jaChcnkB.js} +1 -1
  27. package/dist/containers/User/components/HeaderCell.d.ts +1 -1
  28. package/dist/containers/User/constants/types.d.ts +1 -0
  29. package/dist/containers/User/hooks/useFilterPopover.d.ts +3 -1
  30. package/dist/containers/User/hooks/useTableHeader.d.ts +1 -1
  31. package/dist/index-C8ahRx_e.js +15 -0
  32. package/dist/{index-HowoLCcR.mjs → index-Og-CEwCy.mjs} +11406 -11401
  33. package/dist/index.js +1 -1
  34. package/dist/index.modern.js +1 -1
  35. package/dist/{mailCategoryService-DeQpfSVU.mjs → mailCategoryService-C4-hwkzd.mjs} +1 -1
  36. package/dist/{mailCategoryService-Ba9DVl2j.js → mailCategoryService-C4ZpEYPw.js} +1 -1
  37. package/dist/{userService-DEONamk5.js → userService-BzDg17SK.js} +1 -1
  38. package/dist/{userService-DvzTT-hO.mjs → userService-CWYkD32h.mjs} +1 -1
  39. package/package.json +1 -1
  40. package/dist/UserList-DDbXEhGW.js +0 -7
  41. package/dist/UserList-DrYQKIOv.mjs +0 -1269
  42. package/dist/index-DsvKRC4y.js +0 -15
@@ -2,7 +2,7 @@ import { jsxs as a, jsx as e } from "react/jsx-runtime";
2
2
  import { useState as N, useRef as I, useCallback as h, useEffect as f } from "react";
3
3
  import { useSelector as k } from "react-redux";
4
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, H } from "./index-HowoLCcR.mjs";
5
+ import { s as n, h as m, H } from "./index-Og-CEwCy.mjs";
6
6
  import { Link as v } from "react-router-dom";
7
7
  const M = () => /* @__PURE__ */ a("div", { className: `${n["content-quote"]}`, children: [
8
8
  /* @__PURE__ */ a("div", { className: `${n["title-quote"]} d-block`, children: [
@@ -1 +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-DsvKRC4y.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;
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-C8ahRx_e.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;
@@ -3,12 +3,12 @@ import { Table as Y, Row as D, Col as h, Input as V, FormGroup as J, Label as G,
3
3
  import { useNavigate as te, useParams as ae } from "react-router-dom";
4
4
  import { Editor as se } from "@tinymce/tinymce-react";
5
5
  import { Formik as ne } from "formik";
6
- import { W as ie, O as le, b as C, c as k, X as oe, Y as ce, Z as P, E as U, _ as re, $ as me } from "./index-HowoLCcR.mjs";
6
+ import { W as ie, O as le, b as C, c as k, X as oe, Y as ce, Z as P, E as U, _ as re, $ as me } from "./index-Og-CEwCy.mjs";
7
7
  import { useTranslation as W } from "react-i18next";
8
8
  import { useEffect as L, Fragment as de, useState as w, useCallback as z } from "react";
9
9
  import ue from "react-select";
10
10
  import { useDispatch as X, useSelector as Z } from "react-redux";
11
- import { a as he, b as pe, u as fe, c as ge, d as ye } from "./mailCategoryService-DeQpfSVU.mjs";
11
+ import { a as he, b as pe, u as fe, c as ge, d as ye } from "./mailCategoryService-C4-hwkzd.mjs";
12
12
  import * as R from "yup";
13
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, {}) }), H = [
14
14
  { label: "$USER_FIRST_NAME$", meaning: "user_first_name" },
@@ -1 +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-DsvKRC4y.js"),z=require("react-i18next"),u=require("react"),V=require("react-select"),k=require("react-redux"),A=require("./mailCategoryService-Ba9DVl2j.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;
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-C8ahRx_e.js"),z=require("react-i18next"),u=require("react"),V=require("react-select"),k=require("react-redux"),A=require("./mailCategoryService-C4ZpEYPw.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;
@@ -1,11 +1,11 @@
1
1
  import { jsxs as l, jsx as e } from "react/jsx-runtime";
2
2
  import { Row as f, Col as c, Table as _ } from "reactstrap";
3
- import { K as D, b as g, L as I, O as A, c as y, P as R, Q as w, R as x, S as P, T as k, U as M, V as j } from "./index-HowoLCcR.mjs";
3
+ import { K as D, b as g, L as I, O as A, c as y, P as R, Q as w, R as x, S as P, T as k, U as M, V as j } from "./index-Og-CEwCy.mjs";
4
4
  import { format as S } from "date-fns";
5
5
  import { useCallback as T, useEffect as N } from "react";
6
6
  import { useSelector as L, useDispatch as U } from "react-redux";
7
7
  import { useNavigate as z } from "react-router-dom";
8
- import { g as B, a as F, r as $ } from "./mailCategoryService-DeQpfSVU.mjs";
8
+ import { g as B, a as F, r as $ } from "./mailCategoryService-C4-hwkzd.mjs";
9
9
  import { useTranslation as E } from "react-i18next";
10
10
  const O = "/admin/email-template", K = "/admin/create-email-template", Q = "Email template list", V = () => {
11
11
  const n = z(), { t: o } = E(), u = L(
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("reactstrap"),a=require("./index-DsvKRC4y.js"),_=require("date-fns"),m=require("react"),x=require("react-redux"),b=require("react-router-dom"),j=require("./mailCategoryService-Ba9DVl2j.js"),y=require("react-i18next"),N="/admin/email-template",f="/admin/create-email-template",E="Email template list",v=()=>{const c=b.useNavigate(),{t:d}=y.useTranslation(),p=x.useSelector(l=>l.emailTemplate.emailTemplateList),u=x.useSelector(l=>l.emailTemplate.totalItems),o=x.useSelector(l=>l.mailCategory.mailCategoryList),{filters:n,changeFilters:h}=a.useFilters(),t=x.useDispatch(),g=m.useCallback(async()=>{t(a.setLoading(!0));try{const l=await j.get(n),{items:r,totalItems:L}=l.data;if(t(a.setEmailTemplateList({emailTemplateList:r,totalItems:L})),o&&o.length==0){const C=await j.get$1();t(a.setMailCategory(C.data.items))}}catch(l){t(a.setAlert({type:"danger",message:l.response?.data?.title||l.message}))}t(a.setLoading(!1))},[t,n]),s=m.useCallback(l=>{t(a.setLoading(!0));try{t(a.setModal({isOpen:!0,type:"warning",message:d("do_you_want_to_remove_this_email_template"),onConfirm:async()=>{await j.remove(l),t(a.setAlert({type:"success",message:"Remove template successfully"})),h({currentPage:1})}}))}catch(r){t(a.setAlert({type:"danger",message:r.response?.data?.title||r.message}))}t(a.setLoading(!1))},[n]),T=m.useCallback(l=>{const r=l?`${N}/${l}`:f;c(r)},[]);return m.useEffect(()=>{document.title=E},[]),m.useEffect(()=>{g()},[n]),{emailTemplateList:p,totalItems:u,filters:n,changeFilters:h,getData:g,removeData:s,goToDetail:T,mailCategoryList:o}},R="email_template",D=()=>{const{emailTemplateList:c,totalItems:d,filters:p,changeFilters:u,removeData:o,goToDetail:n,mailCategoryList:h}=v(),{t}=y.useTranslation(),g=s=>{o(s)};return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx("h5",{className:"mb-2",children:t(R)}),e.jsxs(i.Row,{className:"my-2",children:[e.jsx(i.Col,{md:4,children:e.jsx(a.AddButton,{text:t("create_template"),onClick:()=>n()})}),e.jsxs(i.Col,{md:4,className:"d-flex align-items-center justify-content-end",children:[t("total_of_templates"),": ",d]})]}),e.jsxs(i.Row,{className:"mb-2",children:[e.jsxs(i.Col,{md:8,children:[c&&c.length>0?e.jsxs(i.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:t("template_name")}),e.jsx("th",{className:"align-top",children:t("category_name")}),e.jsx("th",{className:"align-top",children:t("created_date")}),e.jsx("th",{className:"align-top",children:t("status")}),e.jsx("th",{className:"text-center",children:t("action")})]})}),e.jsx("tbody",{children:c.map(s=>e.jsxs("tr",{children:[e.jsx("td",{className:"align-middle",children:e.jsx(a.LinkEditButton,{label:s.subject,onClick:()=>n(s.id)})}),e.jsx("td",{className:"align-middle",children:s.category.name}),e.jsx("td",{className:"align-middle",children:_.format(new Date(s.createdAt),a.DATE_RESULT)}),e.jsx("td",{className:"align-middle",children:s.isDisabled?t("disabled"):t("enabled")}),e.jsx("td",{className:"text-center align-middle",children:e.jsx(a.DeleteButtonIcon,{onClick:()=>g(s.id)})})]},s.id))})]}):e.jsx(a.EmptyDataAlert,{label:t("template")}),e.jsx(i.Row,{className:"mt-2",children:e.jsx(i.Col,{md:12,children:e.jsx(a.CustomPagination,{filters:p,totalRecordCount:d,changePageSize:s=>u({pageSize:s}),changePage:s=>u({currentPage:s})})})})]}),e.jsx(i.Col,{md:4,children:e.jsxs(i.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{className:"align-top",children:t("category_name")})})}),e.jsx("tbody",{children:h.map(s=>e.jsx("tr",{children:e.jsx("td",{className:"align-middle",children:s.name})},s.id))})]})})]})]})};exports.default=D;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),i=require("reactstrap"),a=require("./index-C8ahRx_e.js"),_=require("date-fns"),m=require("react"),x=require("react-redux"),b=require("react-router-dom"),j=require("./mailCategoryService-C4ZpEYPw.js"),y=require("react-i18next"),N="/admin/email-template",f="/admin/create-email-template",E="Email template list",v=()=>{const c=b.useNavigate(),{t:d}=y.useTranslation(),p=x.useSelector(l=>l.emailTemplate.emailTemplateList),u=x.useSelector(l=>l.emailTemplate.totalItems),o=x.useSelector(l=>l.mailCategory.mailCategoryList),{filters:n,changeFilters:h}=a.useFilters(),t=x.useDispatch(),g=m.useCallback(async()=>{t(a.setLoading(!0));try{const l=await j.get(n),{items:r,totalItems:L}=l.data;if(t(a.setEmailTemplateList({emailTemplateList:r,totalItems:L})),o&&o.length==0){const C=await j.get$1();t(a.setMailCategory(C.data.items))}}catch(l){t(a.setAlert({type:"danger",message:l.response?.data?.title||l.message}))}t(a.setLoading(!1))},[t,n]),s=m.useCallback(l=>{t(a.setLoading(!0));try{t(a.setModal({isOpen:!0,type:"warning",message:d("do_you_want_to_remove_this_email_template"),onConfirm:async()=>{await j.remove(l),t(a.setAlert({type:"success",message:"Remove template successfully"})),h({currentPage:1})}}))}catch(r){t(a.setAlert({type:"danger",message:r.response?.data?.title||r.message}))}t(a.setLoading(!1))},[n]),T=m.useCallback(l=>{const r=l?`${N}/${l}`:f;c(r)},[]);return m.useEffect(()=>{document.title=E},[]),m.useEffect(()=>{g()},[n]),{emailTemplateList:p,totalItems:u,filters:n,changeFilters:h,getData:g,removeData:s,goToDetail:T,mailCategoryList:o}},R="email_template",D=()=>{const{emailTemplateList:c,totalItems:d,filters:p,changeFilters:u,removeData:o,goToDetail:n,mailCategoryList:h}=v(),{t}=y.useTranslation(),g=s=>{o(s)};return e.jsxs("div",{className:"fadeIn animated",children:[e.jsx("h5",{className:"mb-2",children:t(R)}),e.jsxs(i.Row,{className:"my-2",children:[e.jsx(i.Col,{md:4,children:e.jsx(a.AddButton,{text:t("create_template"),onClick:()=>n()})}),e.jsxs(i.Col,{md:4,className:"d-flex align-items-center justify-content-end",children:[t("total_of_templates"),": ",d]})]}),e.jsxs(i.Row,{className:"mb-2",children:[e.jsxs(i.Col,{md:8,children:[c&&c.length>0?e.jsxs(i.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:t("template_name")}),e.jsx("th",{className:"align-top",children:t("category_name")}),e.jsx("th",{className:"align-top",children:t("created_date")}),e.jsx("th",{className:"align-top",children:t("status")}),e.jsx("th",{className:"text-center",children:t("action")})]})}),e.jsx("tbody",{children:c.map(s=>e.jsxs("tr",{children:[e.jsx("td",{className:"align-middle",children:e.jsx(a.LinkEditButton,{label:s.subject,onClick:()=>n(s.id)})}),e.jsx("td",{className:"align-middle",children:s.category.name}),e.jsx("td",{className:"align-middle",children:_.format(new Date(s.createdAt),a.DATE_RESULT)}),e.jsx("td",{className:"align-middle",children:s.isDisabled?t("disabled"):t("enabled")}),e.jsx("td",{className:"text-center align-middle",children:e.jsx(a.DeleteButtonIcon,{onClick:()=>g(s.id)})})]},s.id))})]}):e.jsx(a.EmptyDataAlert,{label:t("template")}),e.jsx(i.Row,{className:"mt-2",children:e.jsx(i.Col,{md:12,children:e.jsx(a.CustomPagination,{filters:p,totalRecordCount:d,changePageSize:s=>u({pageSize:s}),changePage:s=>u({currentPage:s})})})})]}),e.jsx(i.Col,{md:4,children:e.jsxs(i.Table,{bordered:!0,hover:!0,striped:!0,responsive:!0,size:"sm",children:[e.jsx("thead",{children:e.jsx("tr",{children:e.jsx("th",{className:"align-top",children:t("category_name")})})}),e.jsx("tbody",{children:h.map(s=>e.jsx("tr",{children:e.jsx("td",{className:"align-middle",children:s.name})},s.id))})]})})]})]})};exports.default=D;
@@ -2,7 +2,7 @@ import { jsx as e, jsxs as s } from "react/jsx-runtime";
2
2
  import { Row as k, Col as u, Input as $, Button as y, Label as g, Card as E, CardImg as S, CardBody as w, CardTitle as M, CardHeader as B, CardText as j } from "reactstrap";
3
3
  import { useSelector as q } from "react-redux";
4
4
  import { forwardRef as H, memo as v, useRef as U, useState as K } from "react";
5
- import { a1 as W, E as z, at as L, au as P, av as T, aw as Q, ax as J, ay as X, az as C, h as Y, a3 as Z, a0 as ee, aA as le, m as ae } from "./index-HowoLCcR.mjs";
5
+ import { a1 as W, E as z, at as L, au as P, av as T, aw as Q, ax as J, ay as X, az as C, h as Y, a3 as Z, a0 as ee, aA as le, m as ae } from "./index-Og-CEwCy.mjs";
6
6
  import { Formik as ne } from "formik";
7
7
  import * as b from "yup";
8
8
  import { useTranslation as A } from "react-i18next";
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("reactstrap"),F=require("react-redux"),x=require("react"),t=require("./index-DsvKRC4y.js"),v=require("formik"),E=require("yup"),D=require("react-i18next");function A(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>s[a]})}}return n.default=s,Object.freeze(n)}const b=A(E),G=b.object({name:b.string().required("Name is required")}),U=(s,n)=>{const{targetMedia:a,onConfirm:i}=s,r=a?.key?"Update":"Create",m=a?.key?"Rename":"Folder";return e.jsx(v.Formik,{initialValues:{name:a?.name},enableReinitialize:!0,validationSchema:G,onSubmit:(c,u)=>{i&&i(c),u.resetForm()},children:c=>{const{values:u,touched:g,errors:p,handleChange:y,handleBlur:C,handleSubmit:j}=c;return e.jsx(t.CommonModal,{header:m,confirmText:r,onConfirm:j,ref:n,children:e.jsx(l.Row,{children:e.jsxs(l.Col,{md:12,children:[e.jsx(l.Input,{name:"name",placeholder:`Enter your ${a?.key?"file":"folder"} name`,value:u.name,onChange:y,onBlur:C("question")}),g.name&&p.name&&e.jsx(t.ErrorHandler,{text:p.name})]})})})}})},R=x.forwardRef(U),S=({isLibrary:s,step:n,breadcumb:a,currentPrefix:i,targetMedia:r,handleSelectFile:m,handleCreateFolder:c,handleRenameFile:u,handleGoBack:g,handleDownloadMedia:p,handleDeleteMediaOrFolder:y,showErrorAlert:C})=>{const j=x.useRef(null),I=x.useRef(null),{t:O}=D.useTranslation(),f=()=>j?.current?.toggle(),_=()=>e.jsxs(l.Row,{className:"p-2 pl-3",style:{gap:"8px"},children:[!!n&&e.jsxs(l.Button,{className:"mr-2",color:"secondary",onClick:g,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaArrowLeft,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Go up"})]}),r&&!r.isFolder&&e.jsxs(l.Button,{className:"mr-2",color:"success",onClick:p,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaDownload,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Download"})]}),r&&!s&&e.jsxs(l.Button,{className:"mr-2",color:"danger",onClick:y,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaTrash,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Delete"})]}),r&&!s&&!r.isFolder&&e.jsxs(l.Button,{className:"mr-2",color:"primary",onClick:f,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaEdit,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Rename"})]}),!r&&!s&&e.jsxs(l.Button,{className:"mr-2",color:"success",onClick:f,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaFolderPlus,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:O("new_folder")})]}),!r&&!s&&e.jsxs(l.Button,{className:"mr-2",color:"info",onClick:()=>I?.current?.click(),style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaFileUpload,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:O("upload")})]}),a&&e.jsx(l.Col,{className:"h-100 d-flex align-items-center",children:a})]});return e.jsxs("div",{children:[_(),e.jsx(R,{ref:j,targetMedia:r,onConfirm:async h=>{h.name!=""?r&&!r.isFolder?(f(),await u(h.name)):(f(),await c(i,h.name)):C("Name can't be empty")}}),e.jsx("input",{type:"file",id:"customMediaUpload",ref:I,style:{display:"none"},onChange:async h=>{const d=h?.target?.files[0];d&&await m({key:i,file:d})}})]})},B=x.memo(S),N={"media-wrapper":"_media-wrapper_1nc2k_6","media-image":"_media-image_1nc2k_11","media-image-selected":"_media-image-selected_1nc2k_17","media-title":"_media-title_1nc2k_21","filter-media-file":"_filter-media-file_1nc2k_30"};var o=(s=>(s[s.IMAGE=0]="IMAGE",s[s.VIDEO=1]="VIDEO",s[s.AUDIO=2]="AUDIO",s[s.DOC=3]="DOC",s[s.UNKNOW=4]="UNKNOW",s))(o||{});const q=["png","jpg","jpeg","gif"],M=["mp4","mp4v"],V=["txt","pdf","doc","docx","xls","csv"],L=["wav","mp3"],k=s=>{if(s){if(q.includes(s))return o.IMAGE;if(M.includes(s))return o.VIDEO;if(V.includes(s))return o.DOC;if(L.includes(s))return o.AUDIO}return o.UNKNOW},$=s=>{if(s.isFolder)return t.Images.FOLDER_IMAGE;const n=k(s.extension);return n===o.IMAGE?t.Images.PHOTO_IMAGE:n===o.VIDEO?t.Images.VIDEO_IMAGE:n===o.AUDIO?t.Images.AUDIO_IMAGE:n===o.DOC?t.Images.DOCS_IMAGE:t.Images.UNKNOW_IMAGE},T=({media:s,isTarget:n})=>{const a=$(s);return e.jsxs(l.Card,{className:`${n?N["media-image-selected"]:""} border-0 `,children:[e.jsx(l.CardImg,{className:`${N["media-image"]} p-1`,top:!0,width:"90%",src:t.getStaticFileUrl(a),alt:s.name}),e.jsx(l.CardBody,{className:"p-1",style:{height:45},children:e.jsx(l.CardTitle,{tag:"h6",className:N["media-title"],children:s.name})})]})},H=x.memo(T),P=[{value:o.IMAGE,label:"images"},{value:o.AUDIO,label:"audios"},{value:o.DOC,label:"docs"},{value:o.VIDEO,label:"videos"}],K=({changeFilters:s})=>{const[n,a]=x.useState(),{t:i}=D.useTranslation();return e.jsxs(l.Row,{className:`${N["filter-media-file"]}`,children:[e.jsx(l.Col,{sm:8,children:e.jsx(t.SearchBox,{initValue:"",onSearch:r=>s({searchString:r}),placeholder:i("type_something_to_search_by_file_name")})}),e.jsx(l.Col,{sm:4,children:e.jsx(t.CustomSelector,{value:n,isMulti:!0,options:P.map(r=>({...r,label:i(r.label)})),onChange:r=>{a(r);const m=r.map(c=>c.value);s({types:m})}})})]})},W=({height:s,isLibrary:n})=>{const{filters:a,mediaList:i,targetMedia:r,router:m,breadcrumb:c,changeFilters:u,handleOpenFolder:g,handleSelectMedia:p,handleSelectFile:y,handleCreateFolder:C,handleRenameFile:j,handleDownloadMedia:I,handleDeleteMediaOrFolder:O,handleGoBack:f,showErrorAlert:_}=t.useGalleryList(n),h=()=>i.map(d=>{const w=r?.key===d.key;return e.jsx(l.Col,{className:"p-2",xs:"auto",children:e.jsx("div",{onDoubleClick:()=>g(d),onClick:()=>p(d),className:N["media-wrapper"],children:e.jsx(H,{media:d,isTarget:w})})},d.key)});return e.jsxs(l.Card,{children:[e.jsxs(l.CardHeader,{children:[e.jsx(K,{changeFilters:u,filters:a}),e.jsx(B,{isLibrary:n,step:m.step,breadcumb:c,currentPrefix:a.prefix||"",targetMedia:r,handleSelectFile:y,handleCreateFolder:C,handleRenameFile:j,handleDownloadMedia:I,handleDeleteMediaOrFolder:O,handleGoBack:f,showErrorAlert:_})]}),e.jsx(l.CardBody,{style:{minHeight:s},children:e.jsx(l.Row,{className:"p-1",children:h()})})]})},z=({targetMedia:s})=>{if(!s||s?.isFolder)return e.jsx("div",{});const n=k(s.extension),a=t.getFileUrl(s.key||"");return e.jsxs(l.Card,{className:"position-sticky",children:[e.jsx(l.CardHeader,{children:s?.name||"Media name"}),n===o.IMAGE&&e.jsx(l.CardImg,{className:"p-2",src:a,loading:"lazy"}),n===o.VIDEO&&e.jsx("div",{className:"p-2",children:e.jsx("video",{id:s.key,width:"100%",height:"100%",controls:!0,children:e.jsx("source",{src:a})})}),n===o.AUDIO&&e.jsx("div",{className:"p-2",children:e.jsx("audio",{controls:!0,className:"w-100",children:e.jsx("source",{src:a})})}),e.jsxs(l.CardBody,{children:[e.jsx(l.CardTitle,{tag:"h6",children:"General Info"}),e.jsxs(l.CardText,{children:["File extension: ",s.extension?.toUpperCase()]})]})]})},Q=x.memo(z),J="media_gallery",X=({isLibrary:s})=>{const n=F.useSelector(i=>i.gallery.targetMedia),{t:a}=D.useTranslation();return e.jsxs("div",{className:"fadeIn animated",children:[!s&&e.jsx("h5",{className:"mb-2",children:a(J)}),e.jsxs(l.Row,{className:"mb-2",children:[e.jsx(l.Col,{md:8,children:e.jsx(W,{height:"100vh",isLibrary:s})}),e.jsx(l.Col,{md:4,children:e.jsx(Q,{targetMedia:n},n?.key)})]})]})};exports.default=X;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("react/jsx-runtime"),l=require("reactstrap"),F=require("react-redux"),x=require("react"),t=require("./index-C8ahRx_e.js"),v=require("formik"),E=require("yup"),D=require("react-i18next");function A(s){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(s){for(const a in s)if(a!=="default"){const i=Object.getOwnPropertyDescriptor(s,a);Object.defineProperty(n,a,i.get?i:{enumerable:!0,get:()=>s[a]})}}return n.default=s,Object.freeze(n)}const b=A(E),G=b.object({name:b.string().required("Name is required")}),U=(s,n)=>{const{targetMedia:a,onConfirm:i}=s,r=a?.key?"Update":"Create",m=a?.key?"Rename":"Folder";return e.jsx(v.Formik,{initialValues:{name:a?.name},enableReinitialize:!0,validationSchema:G,onSubmit:(c,u)=>{i&&i(c),u.resetForm()},children:c=>{const{values:u,touched:g,errors:p,handleChange:y,handleBlur:C,handleSubmit:j}=c;return e.jsx(t.CommonModal,{header:m,confirmText:r,onConfirm:j,ref:n,children:e.jsx(l.Row,{children:e.jsxs(l.Col,{md:12,children:[e.jsx(l.Input,{name:"name",placeholder:`Enter your ${a?.key?"file":"folder"} name`,value:u.name,onChange:y,onBlur:C("question")}),g.name&&p.name&&e.jsx(t.ErrorHandler,{text:p.name})]})})})}})},R=x.forwardRef(U),S=({isLibrary:s,step:n,breadcumb:a,currentPrefix:i,targetMedia:r,handleSelectFile:m,handleCreateFolder:c,handleRenameFile:u,handleGoBack:g,handleDownloadMedia:p,handleDeleteMediaOrFolder:y,showErrorAlert:C})=>{const j=x.useRef(null),I=x.useRef(null),{t:O}=D.useTranslation(),f=()=>j?.current?.toggle(),_=()=>e.jsxs(l.Row,{className:"p-2 pl-3",style:{gap:"8px"},children:[!!n&&e.jsxs(l.Button,{className:"mr-2",color:"secondary",onClick:g,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaArrowLeft,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Go up"})]}),r&&!r.isFolder&&e.jsxs(l.Button,{className:"mr-2",color:"success",onClick:p,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaDownload,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Download"})]}),r&&!s&&e.jsxs(l.Button,{className:"mr-2",color:"danger",onClick:y,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaTrash,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Delete"})]}),r&&!s&&!r.isFolder&&e.jsxs(l.Button,{className:"mr-2",color:"primary",onClick:f,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaEdit,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:"Rename"})]}),!r&&!s&&e.jsxs(l.Button,{className:"mr-2",color:"success",onClick:f,style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaFolderPlus,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:O("new_folder")})]}),!r&&!s&&e.jsxs(l.Button,{className:"mr-2",color:"info",onClick:()=>I?.current?.click(),style:{width:"auto",display:"flex",gap:"4px"},children:[e.jsx(t.FaFileUpload,{}),e.jsx(l.Label,{className:"ml-1 h6 m-0",children:O("upload")})]}),a&&e.jsx(l.Col,{className:"h-100 d-flex align-items-center",children:a})]});return e.jsxs("div",{children:[_(),e.jsx(R,{ref:j,targetMedia:r,onConfirm:async h=>{h.name!=""?r&&!r.isFolder?(f(),await u(h.name)):(f(),await c(i,h.name)):C("Name can't be empty")}}),e.jsx("input",{type:"file",id:"customMediaUpload",ref:I,style:{display:"none"},onChange:async h=>{const d=h?.target?.files[0];d&&await m({key:i,file:d})}})]})},B=x.memo(S),N={"media-wrapper":"_media-wrapper_1nc2k_6","media-image":"_media-image_1nc2k_11","media-image-selected":"_media-image-selected_1nc2k_17","media-title":"_media-title_1nc2k_21","filter-media-file":"_filter-media-file_1nc2k_30"};var o=(s=>(s[s.IMAGE=0]="IMAGE",s[s.VIDEO=1]="VIDEO",s[s.AUDIO=2]="AUDIO",s[s.DOC=3]="DOC",s[s.UNKNOW=4]="UNKNOW",s))(o||{});const q=["png","jpg","jpeg","gif"],M=["mp4","mp4v"],V=["txt","pdf","doc","docx","xls","csv"],L=["wav","mp3"],k=s=>{if(s){if(q.includes(s))return o.IMAGE;if(M.includes(s))return o.VIDEO;if(V.includes(s))return o.DOC;if(L.includes(s))return o.AUDIO}return o.UNKNOW},$=s=>{if(s.isFolder)return t.Images.FOLDER_IMAGE;const n=k(s.extension);return n===o.IMAGE?t.Images.PHOTO_IMAGE:n===o.VIDEO?t.Images.VIDEO_IMAGE:n===o.AUDIO?t.Images.AUDIO_IMAGE:n===o.DOC?t.Images.DOCS_IMAGE:t.Images.UNKNOW_IMAGE},T=({media:s,isTarget:n})=>{const a=$(s);return e.jsxs(l.Card,{className:`${n?N["media-image-selected"]:""} border-0 `,children:[e.jsx(l.CardImg,{className:`${N["media-image"]} p-1`,top:!0,width:"90%",src:t.getStaticFileUrl(a),alt:s.name}),e.jsx(l.CardBody,{className:"p-1",style:{height:45},children:e.jsx(l.CardTitle,{tag:"h6",className:N["media-title"],children:s.name})})]})},H=x.memo(T),P=[{value:o.IMAGE,label:"images"},{value:o.AUDIO,label:"audios"},{value:o.DOC,label:"docs"},{value:o.VIDEO,label:"videos"}],K=({changeFilters:s})=>{const[n,a]=x.useState(),{t:i}=D.useTranslation();return e.jsxs(l.Row,{className:`${N["filter-media-file"]}`,children:[e.jsx(l.Col,{sm:8,children:e.jsx(t.SearchBox,{initValue:"",onSearch:r=>s({searchString:r}),placeholder:i("type_something_to_search_by_file_name")})}),e.jsx(l.Col,{sm:4,children:e.jsx(t.CustomSelector,{value:n,isMulti:!0,options:P.map(r=>({...r,label:i(r.label)})),onChange:r=>{a(r);const m=r.map(c=>c.value);s({types:m})}})})]})},W=({height:s,isLibrary:n})=>{const{filters:a,mediaList:i,targetMedia:r,router:m,breadcrumb:c,changeFilters:u,handleOpenFolder:g,handleSelectMedia:p,handleSelectFile:y,handleCreateFolder:C,handleRenameFile:j,handleDownloadMedia:I,handleDeleteMediaOrFolder:O,handleGoBack:f,showErrorAlert:_}=t.useGalleryList(n),h=()=>i.map(d=>{const w=r?.key===d.key;return e.jsx(l.Col,{className:"p-2",xs:"auto",children:e.jsx("div",{onDoubleClick:()=>g(d),onClick:()=>p(d),className:N["media-wrapper"],children:e.jsx(H,{media:d,isTarget:w})})},d.key)});return e.jsxs(l.Card,{children:[e.jsxs(l.CardHeader,{children:[e.jsx(K,{changeFilters:u,filters:a}),e.jsx(B,{isLibrary:n,step:m.step,breadcumb:c,currentPrefix:a.prefix||"",targetMedia:r,handleSelectFile:y,handleCreateFolder:C,handleRenameFile:j,handleDownloadMedia:I,handleDeleteMediaOrFolder:O,handleGoBack:f,showErrorAlert:_})]}),e.jsx(l.CardBody,{style:{minHeight:s},children:e.jsx(l.Row,{className:"p-1",children:h()})})]})},z=({targetMedia:s})=>{if(!s||s?.isFolder)return e.jsx("div",{});const n=k(s.extension),a=t.getFileUrl(s.key||"");return e.jsxs(l.Card,{className:"position-sticky",children:[e.jsx(l.CardHeader,{children:s?.name||"Media name"}),n===o.IMAGE&&e.jsx(l.CardImg,{className:"p-2",src:a,loading:"lazy"}),n===o.VIDEO&&e.jsx("div",{className:"p-2",children:e.jsx("video",{id:s.key,width:"100%",height:"100%",controls:!0,children:e.jsx("source",{src:a})})}),n===o.AUDIO&&e.jsx("div",{className:"p-2",children:e.jsx("audio",{controls:!0,className:"w-100",children:e.jsx("source",{src:a})})}),e.jsxs(l.CardBody,{children:[e.jsx(l.CardTitle,{tag:"h6",children:"General Info"}),e.jsxs(l.CardText,{children:["File extension: ",s.extension?.toUpperCase()]})]})]})},Q=x.memo(z),J="media_gallery",X=({isLibrary:s})=>{const n=F.useSelector(i=>i.gallery.targetMedia),{t:a}=D.useTranslation();return e.jsxs("div",{className:"fadeIn animated",children:[!s&&e.jsx("h5",{className:"mb-2",children:a(J)}),e.jsxs(l.Row,{className:"mb-2",children:[e.jsx(l.Col,{md:8,children:e.jsx(W,{height:"100vh",isLibrary:s})}),e.jsx(l.Col,{md:4,children:e.jsx(Q,{targetMedia:n},n?.key)})]})]})};exports.default=X;
@@ -2,14 +2,14 @@ import { jsxs as n, jsx as e } from "react/jsx-runtime";
2
2
  import { memo as je, useState as N, useCallback as k, Fragment as ve, useEffect as Z } from "react";
3
3
  import { Input as ie, Modal as Ye, ModalBody as Ke, ModalFooter as us, Button as ps, Form as fs, FormGroup as me, Row as be, Col as ee } from "reactstrap";
4
4
  import { Link as Je, useLocation as ws, useNavigate as xe } from "react-router-dom";
5
- import { u as Ss, s as o, M as Ze, E as te, a as Qe, A as ys, g as Ie, b as g, f as Ns, c as P, d as G, e as vs, r as Is, h as ge, i as Xe, B as bs, j as ye, k as ks, l as Ts, m as Ls, I as Pe, N as Es, n as Cs, o as Ps, p as xs, q as Rs, t as _s, v as Be, w as $s, x as As, y as Ee, z as Fe, C as Gs, D as Ms, F as Os, G as Us } from "./index-HowoLCcR.mjs";
5
+ import { u as Ss, s as o, M as Ze, E as te, a as Qe, A as ys, g as Ie, b as g, f as Ns, c as P, d as G, e as vs, r as Is, h as ge, i as Xe, B as bs, j as ye, k as ks, l as Ts, m as Ls, I as Pe, N as Es, n as Cs, o as Ps, p as xs, q as Rs, t as _s, v as Be, w as $s, x as As, y as Ee, z as Fe, C as Gs, D as Ms, F as Os, G as Us } from "./index-Og-CEwCy.mjs";
6
6
  import { useDispatch as ke, useSelector as Ce } from "react-redux";
7
7
  import { Formik as Te } from "formik";
8
8
  import * as V from "yup";
9
9
  import { useGoogleReCaptcha as Re, GoogleReCaptcha as zs, GoogleReCaptchaProvider as Bs } from "react-google-recaptcha-v3";
10
10
  import { GoogleOAuthProvider as Fs, useGoogleLogin as Vs } from "@react-oauth/google";
11
11
  import { L as Ne, T as es } from "./types-BvnbDeJF.mjs";
12
- import { G as Ve } from "./constants-DwMmTVmo.mjs";
12
+ import { G as Ve } from "./constants-O8Ssqwfe.mjs";
13
13
  import { LogLevel as Se, PublicClientApplication as Ds } from "@azure/msal-browser";
14
14
  import * as de from "@amplitude/analytics-browser";
15
15
  const Hs = {
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("react"),g=require("reactstrap"),te=require("react-router-dom"),e=require("./index-DsvKRC4y.js"),Q=require("react-redux"),ue=require("formik"),De=require("yup"),le=require("react-google-recaptcha-v3"),ke=require("@react-oauth/google"),se=require("./types-CTFcZUFS.js"),Ce=require("./constants-DstAxi4a.js"),re=require("@azure/msal-browser"),qe=require("@amplitude/analytics-browser");function Ie(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,l.get?l:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const M=Ie(De),ne=Ie(qe),Ve={backgroundColor:"#f7f9fc",borderRadius:"4px",marginBottom:"5px",position:"relative"},He={backgroundColor:"#ffffff",paddingRight:"50px",color:"#333333",caretColor:"#333333"},We={fontSize:"20px",position:"absolute",right:"10px",color:"#316CD9"},Ke=t=>t.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,r)=>r.toUpperCase()),ie=({isShowPassword:t,togglePasswordVisible:n,onChange:r,placeholder:l})=>s.jsxs("div",{className:"d-flex align-items-center w-100",style:Ve,children:[s.jsx(g.Input,{className:"border password-input",style:He,type:t?"text":"password",name:"password",onChange:r,placeholder:l||"Password",autocomplete:l?Ke(l):"password",required:!0}),s.jsx("i",{className:`far ${t?"fa-eye-slash":"fa-eye"} mx-2 cursor-pointer`,style:We,onClick:()=>n(),title:t?"Hide":"Show"})]}),Ye=({open:t,onConfirm:n,onClose:r,clickHandler:l})=>{const{getLabel:m,system:h}=e.useGradeLabel(),[p,y]=o.useState(Ce.GRADE_DEFAULT[0].value);return s.jsxs(g.Modal,{isOpen:t,className:`${e.styles["teacher-code"]}`,style:{zIndex:1201},centered:!0,autoFocus:!1,returnFocusAfterClose:!1,children:[s.jsxs("div",{className:`${e.styles["header-teacher-code"]}`,children:[s.jsx("div",{style:{padding:"16px 24px",margin:0,fontWeight:500,fontSize:"1.25rem"},children:h==="UK"?"Select Year":"Select Grade"}),s.jsx("div",{hidden:!r,children:s.jsx(e.MdClose,{onClick:()=>r?.(),className:`${e.styles["close-icon"]}`,size:24,style:{color:"rgba(0, 0, 0, 0.54)"}})})]}),s.jsxs(g.ModalBody,{style:{padding:"20px 24px"},children:[s.jsx("p",{className:`${e.styles["teacher-code-label"]}`,style:{margin:0,marginBottom:"16px",color:"rgba(0, 0, 0, 0.6)"},children:h==="UK"?"You are logging in as a student, please select your year":"You are logging in as a student, please select your grade"}),s.jsxs("div",{className:"form-floating",style:{marginTop:"16px",marginBottom:"8px"},children:[s.jsx(g.Input,{type:"select",id:"floatingSelectGrade",value:p,onChange:x=>y(x.target.value),children:Ce.GRADE_DEFAULT.map(x=>s.jsx("option",{value:x.value,children:m(x.value)||x.label},x.value))}),s.jsx("label",{htmlFor:"floatingSelectGrade",children:h==="UK"?"Select year":"Select grade"})]})]}),s.jsx(g.ModalFooter,{style:{borderTop:"none",padding:"8px 24px"},children:s.jsx(g.Button,{disabled:!p,style:{borderRadius:20,background:"#316cd9",border:"none",opacity:p?1:.65},color:"primary",onClick:()=>n(p,l),children:"Confirm"})})]})};function Je(t,n){return JSON.stringify(t)===JSON.stringify(n)}const Ze=o.memo(Ye,Je),Qe=M.object({email:M.string().email("Email is invalid").required("Email is required"),password:M.string().required("Password is required"),rememberMe:M.boolean()}),Xe=({onSuccess:t,onError:n})=>{const r=ke.useGoogleLogin({onSuccess:async l=>{try{const m=await fetch("https://www.googleapis.com/oauth2/v3/userinfo",{headers:{Authorization:`Bearer ${l.access_token}`}}).then(p=>p.json()),h={accessToken:l.access_token,googleId:m.sub,profileObj:{email:m.email,familyName:m.family_name,givenName:m.given_name,imageUrl:m.picture,name:m.name}};t(h)}catch(m){n(m)}},onError:l=>n(l)});return s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>r(),children:[s.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"24px",height:"24px",style:{marginRight:"8px"},children:[s.jsx("path",{fill:"#EA4335",d:"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"}),s.jsx("path",{fill:"#4285F4",d:"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"}),s.jsx("path",{fill:"#FBBC05",d:"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"}),s.jsx("path",{fill:"#34A853",d:"M24 48c6.48 0 12.38-2.12 16.66-5.73l-7.73-6c-2.15 1.45-4.92 2.3-8.93 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"}),s.jsx("path",{fill:"none",d:"M0 0h48v48H0z"})]}),s.jsx("p",{children:"GOOGLE"})]})},es=({defaultInfo:t,userLogin:n,school:r,isShowPassword:l,setIsShowPassword:m,fnIsCheckLogin:h,googleClientId:p,fnLoginSSO:y,extensionEmail:x,onLoginWidthClever:C,openModalSelectGrade:b,handleRegisterUser:S,onToggleModelGrade:k})=>{const N=()=>m(!l),D=Q.useDispatch(),{executeRecaptcha:P}=le.useGoogleReCaptcha(),v=o.useCallback(async()=>{if(!P){console.log("execute recaptcha undefined");return}return await P("login")},[P]),T=async E=>{try{await e.AccountSSOLogApi(E)}catch(L){console.error(L)}},q=async E=>{if(E?.accessToken){let{email:L,familyName:V,givenName:j,imageUrl:I,name:_}=E.profileObj,F=E.accessToken,Y=E.googleId;const J=window.location.hostname.split(".marioforme.com")?.[0],W=L.split("@")?.[1],he=x?.split(",")?.map(U=>U.trim())?.filter(U=>U).some(U=>W.includes(U));if(!W.includes(J)&&!he){alert("The email address you used does not match the login information in the database. Please check that you are using your school assigned email address to log into MARIO for Me. If you have further trouble please notify your school site administrator"),await T([`${W} is incorrect`]);return}const ce={firstName:j,lastName:V,imageUrl:I,fullName:_,email:L,accessToken:F,googleId:Y};D(e.setInforUserGoogle(ce)),h(se.TypeLogin.Google,ce,F,v)}};return s.jsxs(o.Fragment,{children:[s.jsx(ue.Formik,{initialValues:t,validationSchema:Qe,onSubmit:async E=>{try{const L=await v();if(!L)return;E.captcha=L,E.loginType=se.LoginType.Default,n(E)}catch(L){console.error(L)}},children:E=>{const{handleBlur:L,handleSubmit:V,values:j,touched:I,errors:_,setFieldValue:F}=E,Y=I.email&&_.email,ae=I.password&&_.password;return s.jsx("div",{className:`${e.styles["box-login"]} w-100`,children:s.jsx(g.Form,{className:`${e.styles["block-login"]}`,onSubmit:V,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsxs("div",{className:"d-flex align-items-center mb-4",children:[s.jsx("img",{hidden:!r?.schoolLogo,src:r?.schoolLogo,className:`${e.styles["school-icon"]} mr-3`}),s.jsx("p",{className:`${e.styles["school-name"]} mb-0`,children:r.schoolName})]}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"Welcome Back!"}),s.jsx("p",{className:`${e.styles["login-description"]} mb-5`,children:"Please enter your MARIO Education account details"}),s.jsxs(g.FormGroup,{className:`${e.styles["form-user-name"]}`,children:[s.jsx(g.Input,{type:"text",name:"email",placeholder:"Email",value:j.email,onChange:J=>F("email",J.target?.value?.trim()||""),autocomplete:"email",onBlur:L("email"),required:!0}),Y&&s.jsx(e.ErrorHandler,{text:_.email})]}),s.jsxs(g.FormGroup,{children:[s.jsx(ie,{isShowPassword:l,togglePasswordVisible:N,onChange:J=>F("password",J.target?.value?.trim()||"")}),ae&&s.jsx(e.ErrorHandler,{text:_.password})]}),s.jsx(g.FormGroup,{}),s.jsxs("div",{className:"d-flex justify-content-between",children:[s.jsxs("div",{className:"d-flex align-items-center",style:{gap:"8px"},children:[s.jsx("input",{type:"checkbox",checked:!j.isSessionUserBrowser,className:`${e.styles["checkbox-keep-login"]}`,onChange:()=>F("isSessionUserBrowser",!j.isSessionUserBrowser)}),s.jsx("p",{className:`${e.styles["label-keep-login"]} mb-0 ml-2`,children:"Keep me logged in"})]}),s.jsx(te.Link,{to:"/forgot-password",className:`${e.styles["link-to-login"]}`,children:"Forgot password?"})]}),s.jsx("button",{className:`${e.styles["btn-login"]} mt-5`,type:"submit",children:"LOG IN"}),s.jsx("p",{className:`${e.styles["option-text"]} my-3 text-center`,children:"OR"}),s.jsxs(g.Row,{className:"mb-4",children:[s.jsx(g.Col,{lg:6,md:6,xs:12,className:"pr-md-3",children:!!p&&s.jsx(ke.GoogleOAuthProvider,{clientId:p,children:s.jsx(Xe,{onSuccess:q,onError:()=>console.log("Google login failed")})})}),r.schoolId&&s.jsx(g.Col,{lg:6,md:6,xs:12,className:`${e.styles["btn-login-sso"]} pl-md-2`,hidden:!r?.schoolId,children:s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>y(v),children:[s.jsx("img",{src:"images/microsoft-logo.png"}),s.jsx("p",{children:"MICROSOFT"})]})})]}),s.jsx("div",{className:`${e.styles["btn-login-sso"]}`,children:s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>window.open("https://launchpad.classlink.com/login"),children:[s.jsx("img",{src:"images/class-link-icon.png"}),s.jsx("p",{children:"SIGN IN WITH CLASSLINK"})]})}),s.jsx("div",{className:`${e.styles["btn-login-sso"]} mt-4`,children:s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>C(),children:[s.jsx("img",{src:"images/clever-icon.png"}),s.jsx("p",{children:"SIGN IN WITH CLEVER"})]})})]})})})}}),s.jsx(Ze,{open:b,onConfirm:S,clickHandler:v,onClose:k})]})},ss={email:"",captcha:""},ts="/",ve="/login",as="Log in",Te=()=>{const t=new URLSearchParams(te.useLocation().search),n=t.get("token"),r=t.get("key")??"",l=Q.useDispatch(),m=te.useNavigate(),[h,p]=o.useState(!1),y=o.useCallback(()=>{p(!h)},[h]),[x,C]=o.useState(!1),[b,S]=o.useState(!1),[k,N]=o.useState({token:"",password:"",reEnterPassword:"",email:"",userId:""}),[D,P]=o.useState(!0),{executeRecaptcha:v}=le.useGoogleReCaptcha();o.useEffect(()=>{document.title=as,e.getAccessToken()&&m(ts)},[]);const T=o.useCallback(async j=>{l(e.setLoading(!0));try{await e.forgotPassword(j),m(ve),l(e.setAlert({type:"success",message:"A mail to reset password was sent"}))}catch(I){l(e.setAlert({type:"danger",message:I.response?.data?.title||I.message||"Error occured"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN)}l(e.setLoading(!1))},[]),q=o.useCallback(async(j,I)=>{l(e.setLoading(!0));try{const _=await e.checkResetToken(j,I);_.data?N({...k,token:j,email:_.data}):P(!1)}catch{P(!1)}l(e.setLoading(!1))},[]),E=o.useCallback(async j=>{l(e.setLoading(!0));try{await e.resetPassword({...j,key:r}),m(ve),l(e.setAlert({type:"success",message:"Reset password sucessfully"}))}catch(I){l(e.setAlert({type:"danger",message:I.response?.data?.title||I.message||"Error occured"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN)}l(e.setLoading(!1))},[]),L=o.useCallback(async()=>{if(!v){console.log("execute recaptcha undefined");return}return await v("forgetPass")},[v]),V=o.useCallback(()=>{},[]);return o.useEffect(()=>{n&&r&&q(n,r)},[n,r]),{defaultInfo:ss,forgotPasswordRequest:T,checkResetTokenRequest:q,validLink:D,resetPasswordRequest:E,openLogin:h,toggle:y,isShowNewPassword:x,setIsShowNewPassword:C,isShowReTypePassword:b,setIsShowReTypePassword:S,clickHandler:L,handleVerify:V,initialValues:k}},os={email:"",captcha:""},ns=M.object({email:M.string().email("Email is invalid").required("Email is required")}),rs=({school:t})=>{const{forgotPasswordRequest:n,clickHandler:r,handleVerify:l}=Te();return s.jsx(ue.Formik,{initialValues:os,enableReinitialize:!0,validationSchema:ns,onSubmit:async m=>{const h=await r();h&&(m.captcha=h,n(m))},children:m=>{const{handleChange:h,handleSubmit:p,values:y,touched:x,errors:C}=m;return s.jsx("div",{className:`${e.styles["box-login"]}`,children:s.jsx("div",{className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsxs("div",{className:"d-flex align-items-center mb-4",children:[s.jsx("img",{src:t.schoolLogo,className:`${e.styles["school-icon"]} mr-3`}),s.jsx("p",{className:`${e.styles["school-name"]} mb-0`,children:t.schoolName})]}),s.jsx("p",{className:`${e.styles["title-login"]} `,children:"Forgot password"}),s.jsx("p",{className:`${e.styles["recover-account"]} mb-5`,children:"Enter email to recover your account"}),s.jsxs("div",{className:"w-100",children:[s.jsx(g.Input,{type:"text",name:"email",id:"email",placeholder:"Input email",onChange:h,value:y.email}),x.email&&C.email&&s.jsx(e.ErrorHandler,{text:C.email})]}),s.jsx(te.Link,{to:"/login",className:`${e.styles["link-to-login"]} mt-2`,children:"Return to login"}),s.jsx(le.GoogleReCaptcha,{action:"forgetPass",onVerify:l}),s.jsx(g.Col,{className:"p-0",children:s.jsx("button",{className:`${e.styles["btn-login"]} mt-5`,onClick:()=>p(),children:"Continue"})})]})})})}})},is=M.object({password:M.string().required("New password is required"),reEnterPassword:M.string().required("Please re-enter new password").test("matching","Passwords do not match",function(){return this.parent.password===this.parent.reEnterPassword})}),ls=()=>{const{validLink:t,resetPasswordRequest:n,isShowNewPassword:r,setIsShowNewPassword:l,isShowReTypePassword:m,setIsShowReTypePassword:h,initialValues:p}=Te();return s.jsx(ue.Formik,{initialValues:p,enableReinitialize:!0,validationSchema:is,onSubmit:y=>{n(y)},children:y=>{const{setFieldValue:x,handleSubmit:C,touched:b,errors:S,values:k}=y;return s.jsx(g.Row,{className:`${e.styles["box-login"]}`,children:s.jsx(g.Col,{className:"p-0",children:s.jsx("div",{className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsx("img",{src:`${e.getStaticFileUrl("/images/horizontal-logo-blue.svg")}`,className:`${e.styles["img-login-rectangle"]}`}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"Reset Password"}),s.jsx("div",{className:"w-100",children:t?s.jsxs(o.Fragment,{children:[s.jsx(g.FormGroup,{className:`${e.styles["form-user-name"]}`,children:s.jsx(g.Input,{disabled:!0,type:"text",name:"email",placeholder:"Email",value:k.email,autocomplete:"email",required:!0,className:`${e.styles.input}`})}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{isShowPassword:r,togglePasswordVisible:()=>l(!r),onChange:N=>x("password",N.target.value)}),b.password&&S.password&&s.jsx(e.ErrorHandler,{text:S.password})]}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{placeholder:"Confirm Password",isShowPassword:m,togglePasswordVisible:()=>h(!m),onChange:N=>x("reEnterPassword",N.target.value)}),b.reEnterPassword&&S.reEnterPassword&&s.jsx(e.ErrorHandler,{text:S.reEnterPassword})]})]}):s.jsxs(o.Fragment,{children:[s.jsx("p",{className:`${e.styles["recover-account"]} mb-5`,children:"Invalid reset password link"}),s.jsx("p",{className:"w-100",children:"It may have been accessed before or expired or you have just tried to reset another account's password"})]})}),t&&s.jsx(g.Col,{className:"p-0",children:s.jsx("button",{className:`${e.styles["btn-login"]} ${e.styles["btn-rounder"]} mt-4`,onClick:()=>C(),children:"SET A NEW PASSWORD"})})]})})})})}})},Ae=`${e.BASE_URL}/api/school`,cs=()=>e.api.get(`${Ae}/settings`),ds=()=>e.api.get(`${Ae}/info`),ms={auth:{clientId:e.isLocalhost?"a27f8ac9-e039-4bbd-a9e1-3096e52a77bb":"90c6897c-f17b-475e-a7a8-9a19651e0060",authority:"https://login.microsoftonline.com/common",redirectUri:"https://sso.marioforme.com/microsoft-login.html"},cache:{cacheLocation:"sessionStorage",storeAuthStateInCookie:!1},system:{loggerOptions:{loggerCallback:(t,n,r)=>{if(!r)switch(t){case re.LogLevel.Error:console.error(n);return;case re.LogLevel.Info:console.info(n);return;case re.LogLevel.Verbose:console.debug(n);return;case re.LogLevel.Warning:console.warn(n);return;default:return}}}}},gs={email:"",password:"",captcha:"",rememberMe:!1,isSessionUserBrowser:!!sessionStorage.getItem(e.IS_USER_SESSION_BROWSER)},us="/home",Ee="/home",hs="/admin/home",ps="/parent",fs="/admin/schools",xs="/list-student",Ss="Log in",ws=()=>{const t=Q.useDispatch(),n=te.useNavigate(),[r,l]=o.useState(!1),m=Q.useSelector(a=>a.common.isLoginGoogle),[h,p]=o.useState(""),[y,x]=o.useState(""),[C,b]=o.useState(""),[S,k]=o.useState(!1),N=Q.useSelector(a=>a.common.inforUserGoogle),D=Q.useSelector(a=>a.common.environment),P=new URLSearchParams(location.search),v=P.get("type")==="classlink",T=P.get("token"),q=P.get("isAdminUser"),[E]=o.useState(!1),[L,V]=o.useState({schoolName:"",schoolLogo:"",schoolId:0}),[j,I]=o.useState(null),_=o.useCallback(()=>{l(!r)},[r]),[F,Y]=o.useState(!1),[ae,J]=o.useState(!1),[W,he]=o.useState({firstName:"",lastName:"",fullName:"",imageUrl:"",email:"",accessToken:"",googleId:""});o.useEffect(()=>{document.title=Ss;const a=e.getCookieValue("auth-token");if(a){const d=window.location.hostname;if(localStorage.setItem(e.ACCESS_TOKEN,a),document.cookie=`auth-token=;domain=${d.includes("localhost")?d:".marioforme.com"}; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`,document.cookie="redirect-uri=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/",q)return n("/admin/home");Se(a);return}e.getAccessToken()&&n("/"),Ge()},[q,Se,n]);const ce=()=>{localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN),localStorage.removeItem("USER_EMAIL")};o.useEffect(()=>{v&&T!=""&&_e()},[]);const U=()=>{J(!ae)},Pe=()=>{if(e.isLocalhost){const a="https://clever.com/oauth/instant-login?client_id=44f4bbf55cd873d3f7e5&district_id=6620cba31f1ddde7bd689dc5";window.location.href=a}else{const a=`https://clever.com/oauth/authorize?response_type=code&redirect_uri=${encodeURIComponent("https://classlink.marioforme.com/api/clever/clever-login")}&client_id=c3da6c669d239c70d48e`;window.location.href=a}},_e=async()=>{t(e.setLoading(!0));try{const a={tokenClassLink:T},i=await e.apiInforUserClassLink(a),{email:d,token:f}=i.data;await Z({email:d,rememberMe:!1,password:"default",accessToken:f})}catch(a){t(e.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}t(e.setLoading(!1))},pe=window.location.host.includes("-district"),Re=o.useCallback(async()=>{t(e.setLoading(!0));try{const a=await ds(),i=a.data.schoolLogo??"";a.data&&V({schoolName:a.data.schoolName,schoolLogo:i?e.getFileUrl(i):e.getStaticFileUrl("/images/logo_header_blue.png"),schoolId:a.data.schoolId})}catch(a){t(e.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}t(e.setLoading(!1))},[]),[$e,de]=o.useState(!1),[X,fe]=o.useState(null),oe=o.useCallback((a,i,d,f,c,B,$,z,H,A)=>{const O=A?.isSessionUserBrowser??!1;O?(sessionStorage.setItem(e.ACCESS_TOKEN,a),sessionStorage.setItem(e.IS_USER_SESSION_BROWSER,String(O))):(sessionStorage.removeItem(e.IS_USER_SESSION_BROWSER),localStorage.setItem(e.ACCESS_TOKEN,a)),localStorage.removeItem(e.NOTIFICATION_ALERT_KEY),sessionStorage.removeItem("ACTIVE_ROLE"),t(e.setUser({id:i,firstName:d,lastName:f,roles:c,email:B,profileImageFileName:$}));let w=localStorage.getItem("ROLES")||"";if(!w){if(c.includes("Admin"))w="Admin";else{const R=((i?localStorage.getItem(`PREFERRED_ROLE_${i}`):null)||"").split(",").map(ge=>ge.trim()).filter(Boolean);R.length>0&&R.every(ge=>c.includes(ge))?R.length>1?w=R.every(je=>je==="Teacher"||je==="Assistant")?"Teacher,Assistant":R[0]:w=R[0]:c.includes("Teacher")?w=c.includes("Assistant")?"Teacher,Assistant":"Teacher":c.includes("Assistant")?w="Assistant":c.includes("Counselor")?w="Counselor":c.includes("SecondaryTeacher")?w="SecondaryTeacher":c.includes("EduTeacher")?w="EduTeacher":c.includes("Student")?w="Student":c.includes("Parent")?w="Parent":c.length>0&&(w=c[0])}w&&(localStorage.setItem("ROLES",w),sessionStorage.setItem("ACTIVE_ROLE",w))}if(A?.email&&!c.includes("Admin")){ne.init(e.isLocalhost?e.INIT_AMPLITUDE_KEY_STAGE:e.INIT_AMPLITUDE_KEY_PROD,A.email,{defaultTracking:!1});const ee=window.location.hostname,R=new ne.Identify;R.set("domain",ee),ne.identify(R),ne.track("general: session start",{user_id:A.email,domain:ee,roles:c?.toString()}),localStorage.setItem("USER_EMAIL",A.email),z&&ne.track("general: first login",{user_id:A.email,domain:ee,roles:c?.toString()})}const K=ee=>{const R=e.navigateBySchoolLevel(ee,H);window.location.pathname.startsWith("/es")?H==="es"?n(R):window.location.href=R:H==="es"?window.location.href=R:n(R)},G=w.split(",")[0]||"";pe?K(fs):c.includes("Admin")||G==="Admin"?K(hs):G==="Teacher"||G==="Assistant"||G==="Counselor"||G==="SecondaryTeacher"||!G&&(c.includes("Teacher")||c.includes("Assistant")||c.includes("Counselor")||c.includes("SecondaryTeacher"))?K(us):G==="Student"||!G&&c.includes("Student")?K(Ee):G==="Parent"||!G&&c.includes("Parent")?K(ps):(G==="EduTeacher"||!G&&c.includes("EduTeacher"))&&K(xs),t(e.setLoading(!1))},[t,n,pe]),me=o.useCallback((a,i,d)=>S&&a?.includes("Student")&&(i==="es"||d==="ES")?(t(e.setAlert({type:"danger",message:"Unable to sign in with SSO. Please contact your admin or teacher."})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN),t(e.setLoading(!1)),!0):!1,[S,t]),xe=o.useCallback(a=>S&&a&&e.ES_GRADES.includes(a.trim())?(t(e.setAlert({type:"danger",message:"Unable to sign in with SSO. Please contact your admin or teacher."})),t(e.setLoading(!1)),!0):!1,[S,t]);async function Se(a){t(e.setLoading(!0));try{const i=await e.getInfo();let{id:d,firstName:f,lastName:c,roles:B,email:$,profileImageFileName:z,isLoginFirst:H,schoolLevel:A,appType:O,preferredAppType:w,needsAppTypeChoice:K}=i.data;if(K){fe({email:$}),de(!0),t(e.setLoading(!1));return}A||(O==="ES"||O==="ES, MS"&&w==="ES")&&(A="es"),oe(a,d,f,c,B,$,z,H,A,{email:$})}catch(i){t(e.setAlert({type:"danger",message:i.response?.data?.title||i.message||"Login failed"})),t(e.setLoading(!1))}}const Oe=o.useCallback(async a=>{if(de(!1),!X)return;t(e.setLoading(!0));const i=a==="es"?"ES":a==="ms"?"MS":"ES, MS";try{const d=await e.logIn({...X,email:X?.email?.trim(),password:X?.password?.trim(),preferredAppType:i});let{token:f,id:c,firstName:B,lastName:$,roles:z,email:H,profileImageFileName:A,isLoginFirst:O,schoolLevel:w}=d.data;if(!w&&a==="es"&&(w="es"),me(z,w,d.data.appType))return;oe(f,c,B,$,z,H,A,O,w,X)}catch(d){t(e.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Login failed"})),t(e.setLoading(!1))}},[X,oe,me,t]),Z=o.useCallback(async a=>{t(e.setLoading(!0));try{const i=await e.logIn({...a,email:a?.email?.trim(),password:a?.password?.trim()});let{token:d,id:f,firstName:c,lastName:B,roles:$,email:z,profileImageFileName:H,isLoginFirst:A,schoolLevel:O}=i.data;if(i.data.needsAppTypeChoice){fe(a),de(!0),t(e.setLoading(!1));return}if(O||(i.data.appType==="ES"||i.data.appType==="ES, MS"&&i.data.preferredAppType==="ES")&&(O="es"),me($,O,i.data.appType))return;oe(d,f,c,B,$,z,H,A,O,a)}catch(i){t(e.setAlert({type:"danger",message:i.response?.data?.title||i.message||"Login failed"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN),t(e.setLoading(!1))}},[oe,me,t]),Ge=async()=>{try{const a=await e.getGoogleClientId();p(a.data.googleClientId),x(a.data.googleCaptchaId),b(a.data.extensionEmail),k(a.data.isRestrictedLogin)}catch(a){t(e.setAlert({type:"danger",message:a.response?.data?.title||a.message||"Login failed"}))}},we=o.useCallback(async(a,i,d,f)=>{t(e.setLoading(!0));try{if((await e.checkUserGoogle(a,i)).data){const $={email:i.email,isLoginGoogle:!0,rememberMe:!1,password:"default",accessToken:d,captcha:"",loginType:se.LoginType.Google};if(f!=null){const z=await f();$.captcha=z}await Z($),t(e.setIsLoginGoogle(!1))}else he({...i,token:d}),U()}catch(c){t(e.setAlert({type:"danger",message:c.response?.data?.title||c.message||"Login failed"}))}t(e.setLoading(!1))},[Z,t,U]),Me=o.useCallback(async(a,i)=>{t(e.setLoading(!0));try{if(xe(a))return;if((await e.registerUserStudent({...W,gradeLevel:a}))?.data){const f={email:W.email,isLoginGoogle:!0,rememberMe:!1,password:"default",accessToken:W.accessToken,captcha:"",loginType:se.LoginType.Google};if(i!=null){const c=await i();f.captcha=c}await Z(f),U()}}catch(d){t(e.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Login failed"}))}t(e.setLoading(!1))},[xe,W,Z,U,t]),Ue=async(a,i)=>{t(e.setLoading(!0));try{const d={firstName:N.firstName,lastName:N.lastName,imageUrl:N.imageUrl,fullName:N.fullName,email:N.email,accessToken:N.accessToken,teacherId:a};if((await e.registerUserStudent(d)).data){const c=await i(),B={email:N.email,captcha:c,isLoginGoogle:!0,rememberMe:!1,password:"default",accessToken:N.accessToken,loginType:se.LoginType.Google};t(e.setIsLoginGoogle(!1)),await Z(B),n(Ee)}}catch(d){t(e.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Login failed"}))}t(e.setIsLoginGoogle(!1)),t(e.setLoading(!1))},Fe=async()=>{try{const a=await cs();t(e.setSandboxMode(a.data.isSandboxMode))}catch(a){console.error(a)}},ye=async a=>{j.handleRedirectPromise().then(async i=>{if(L?.schoolId)if(i){let d=i.account;await Ne(d,a)}else{const d=j.getAllAccounts();if(d.length===0){const f=D==="PreProduction"?"https://mario1.marioforme.com":e.isLocalhost?"https://brightsoft.marioforme.com":"https://sso.marioforme.com";window.location.href=(window.location.hostname==="localhost"?window.location.origin:f)+`/microsoft-login.html?redirect-uri=${window.location.origin}&schoolId=${L.schoolId}`}else{let f=d[0];await Ne(f,a)}}}).catch(i=>{console.error(i)})},Ne=async(a,i)=>{let d=a.name,f={firstName:d.split(" ").slice(0,-1).join(" "),lastName:d.split(" ").slice(-1).join(" "),fullName:d,imageUrl:"",email:a.username,accessToken:a.idTokenClaims.aio,googleId:a.tenantId};t(e.setInforUserGoogle(f)),await we(se.TypeLogin.MicrosoftSSO,f,a.idTokenClaims.aio,i)},Be=async()=>{const a=new re.PublicClientApplication(ms);await a.initialize(),I(a)};return o.useEffect(()=>{let a=window.location.href;j&&a.includes("code")&&a.includes("client_info")&&ye()},[JSON.stringify(j)]),o.useEffect(()=>{Fe(),Be(),Re()},[]),{defaultInfo:gs,userLogin:Z,openLogin:r,toggle:_,isShowPassword:F,setIsShowPassword:Y,fnIsCheckLogin:we,isLoginGoogle:m,infoUser:N,submitLogin:Ue,googleClientId:h,googleRecaptchaId:y,handleCancelModelAssign:ce,openModelAssign:E,fnLoginSSO:ye,school:L,extensionEmail:C,handleLoginWidthClever:Pe,openModalSelectGrade:ae,handleRegisterUser:Me,handleToggleModelGrade:U,openModalSelectTier:$e,handleSelectTier:Oe,setOpenModalSelectTier:de}},Le="/",ys="/login",be="Log in",Ns=()=>{const t=Q.useDispatch(),n=te.useNavigate(),r=location.search,m=new URLSearchParams(r).get("userId"),[h,p]=o.useState(!1),[y,x]=o.useState(!1),[C,b]=o.useState({password:"",reEnterPassword:"",email:"",userId:m??"",token:""}),{executeRecaptcha:S}=le.useGoogleReCaptcha(),k=o.useCallback(async v=>{t(e.setLoading(!0));try{const T=await e.getUserNewPassword(v);b({...C,email:T.data})}catch(T){t(e.setAlert({type:"danger",message:T.message}))}t(e.setLoading(!1))},[]),N=o.useCallback(async v=>{t(e.setLoading(!0));try{await e.createPassword(v),n(ys),t(e.setAlert({type:"success",message:"Create password sucessfully"}))}catch(T){t(e.setAlert({type:"danger",message:T.response?.data?.title||T.message||"Error occured"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN)}t(e.setLoading(!1))},[]),D=o.useCallback(async()=>{if(!S){console.log("execute recaptcha undefined");return}return await S("forgetPass")},[S]),P=o.useCallback(()=>{},[]);return o.useEffect(()=>{document.title=be,e.getAccessToken()&&n(Le),m&&k(m)},[m]),o.useEffect(()=>{document.title=be,e.getAccessToken()&&n(Le)},[]),{createPasswordRequest:N,isShowNewPassword:h,setIsShowNewPassword:p,isShowReTypePassword:y,setIsShowReTypePassword:x,clickHandler:D,handleVerify:P,initialValues:C}},js=M.object({password:M.string().required("Password is required"),reEnterPassword:M.string().required("Please re-enter Password").test("matching","Passwords do not match",function(){return this.parent.password===this.parent.reEnterPassword})}),Cs=()=>{const{createPasswordRequest:t,isShowNewPassword:n,setIsShowNewPassword:r,isShowReTypePassword:l,setIsShowReTypePassword:m,initialValues:h}=Ns();return s.jsx(ue.Formik,{initialValues:h,enableReinitialize:!0,validationSchema:js,onSubmit:p=>{t(p)},children:p=>{const{setFieldValue:y,handleSubmit:x,touched:C,errors:b,values:S}=p;return s.jsx(g.Row,{className:`${e.styles["box-login"]}`,children:s.jsxs(g.Col,{className:"p-0",children:[s.jsx("div",{hidden:!S.email,className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsx("img",{src:`${e.getStaticFileUrl("/images/horizontal-logo-blue.svg")}`,className:`${e.styles["img-login-rectangle"]}`}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"Create Your Password"}),s.jsx("div",{className:"w-100",children:s.jsxs(o.Fragment,{children:[s.jsx(g.FormGroup,{className:`${e.styles["form-user-name"]}`,children:s.jsx(g.Input,{disabled:!0,type:"text",name:"email",placeholder:"Email",value:S.email,autocomplete:"email",required:!0,className:`${e.styles.input}`})}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{isShowPassword:n,togglePasswordVisible:()=>r(!n),onChange:k=>y("password",k.target.value)}),C.password&&b.password&&s.jsx(e.ErrorHandler,{text:b.password})]}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{placeholder:"Confirm Password",isShowPassword:l,togglePasswordVisible:()=>m(!l),onChange:k=>y("reEnterPassword",k.target.value)}),C.reEnterPassword&&b.reEnterPassword&&s.jsx(e.ErrorHandler,{text:b.reEnterPassword})]})]})}),s.jsx("button",{className:`${e.styles["btn-login"]} ${e.styles["btn-rounder"]} mt-4`,onClick:()=>x(),children:"CREATE YOUR PASSWORD"})]})}),s.jsx("div",{hidden:!!S.email,className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsx("img",{src:`${e.getStaticFileUrl("/images/horizontal-logo-blue.svg")}`,className:`${e.styles["img-login-rectangle"]}`}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"You cannot regenerate the password"})]})})]})})}})},vs="_modalContent_1pxxz_1",Es="_closeButton_1pxxz_6",Ls="_modalBody_1pxxz_17",bs="_iconWrapper_1pxxz_22",ks="_title_1pxxz_38",Is="_subtitle_1pxxz_45",Ts="_tierCard_1pxxz_51",As="_es_1pxxz_60",Ps="_tierTitle_1pxxz_71",_s="_tierDesc_1pxxz_76",Rs="_arrow_1pxxz_81",$s="_ms_1pxxz_85",Os="_both_1pxxz_110",Gs="_cardLeft_1pxxz_134",Ms="_cardText_1pxxz_138",u={modalContent:vs,closeButton:Es,modalBody:Ls,iconWrapper:bs,title:ks,subtitle:Is,tierCard:Ts,es:As,tierTitle:Ps,tierDesc:_s,arrow:Rs,ms:$s,both:Os,cardLeft:Gs,cardText:Ms},Us=({open:t,onSelectTier:n,onClose:r})=>s.jsxs(g.Modal,{isOpen:t,style:{zIndex:1201,maxWidth:450},centered:!0,autoFocus:!1,returnFocusAfterClose:!1,contentClassName:u.modalContent,children:[s.jsx("div",{className:u.closeButton,children:r&&s.jsx(e.MdClose,{onClick:()=>r(),size:24})}),s.jsxs(g.ModalBody,{className:u.modalBody,children:[s.jsx("div",{className:u.iconWrapper,children:s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),s.jsx("h4",{className:u.title,children:"Select Grade Level"}),s.jsx("p",{className:u.subtitle,children:"Select the grade levels you support"}),s.jsxs("div",{onClick:()=>n("es"),className:`${u.tierCard} ${u.es}`,children:[s.jsxs("div",{className:u.cardLeft,children:[s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),s.jsxs("div",{className:u.cardText,children:[s.jsx("div",{className:u.tierTitle,children:"Elementary / Primary"}),s.jsx("div",{className:u.tierDesc,children:"Grades 2-5 / Years 3-6"})]})]}),s.jsx("div",{className:u.arrow,children:">"})]}),s.jsxs("div",{onClick:()=>n("ms"),className:`${u.tierCard} ${u.ms}`,children:[s.jsxs("div",{className:u.cardLeft,children:[s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"})}),s.jsxs("div",{className:u.cardText,children:[s.jsx("div",{className:u.tierTitle,children:"Middle & High / Secondary"}),s.jsx("div",{className:u.tierDesc,children:"Grades 6-12 / Years 7-13"})]})]}),s.jsx("div",{className:u.arrow,children:">"})]}),s.jsxs("div",{onClick:()=>n("both"),className:`${u.tierCard} ${u.both}`,children:[s.jsxs("div",{className:u.cardLeft,children:[s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M17 14v6m-3-3h6M6 10h2a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2zm10 0h2a2 2 0 002-2V6a2 2 0 00-2-2h-2a2 2 0 00-2 2v2a2 2 0 002 2zM6 20h2a2 2 0 002-2v-2a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2z"})}),s.jsxs("div",{className:u.cardText,children:[s.jsx("div",{className:u.tierTitle,children:"Both Tiers"}),s.jsx("div",{className:u.tierDesc,children:"Access all grade levels"})]})]}),s.jsx("div",{className:u.arrow,children:">"})]})]})]}),Fs=o.memo(Us),Bs="Log in",zs="Forgot password",Ds="Reset password",qs=t=>{const{isLogin:n,isForgotPassword:r,isResetPassword:l,isCreatePassword:m}=t,{defaultInfo:h,userLogin:p,googleRecaptchaId:y,handleCancelModelAssign:x,school:C,openModelAssign:b,setIsShowPassword:S,fnIsCheckLogin:k,isLoginGoogle:N,submitLogin:D,infoUser:P,googleClientId:v,isShowPassword:T,fnLoginSSO:q,extensionEmail:E,handleLoginWidthClever:L,openModalSelectGrade:V,handleRegisterUser:j,handleToggleModelGrade:I,openModalSelectTier:_,handleSelectTier:F,setOpenModalSelectTier:Y}=ws();return o.useEffect(()=>{n&&(document.title=Bs),r&&(document.title=zs),l&&(document.title=Ds)},[n,r,l]),s.jsxs("div",{className:`${e.styles.login} container-fluid font-family-lato`,children:[s.jsxs(g.Row,{className:"h-100",children:[s.jsxs(g.Col,{lg:8,md:12,xs:12,className:"d-flex justify-content-center h-100 align-items-center p-3 flex-column",children:[!!y&&s.jsxs(le.GoogleReCaptchaProvider,{useRecaptchaNet:!0,reCaptchaKey:y,scriptProps:{async:!0,defer:!0,appendTo:"body"},children:[n&&s.jsx(es,{userLogin:p,defaultInfo:h,onCancelModelAssign:x,openModelAssign:b,school:C,fnIsCheckLogin:k,googleClientId:v,infoUser:P,isLoginGoogle:N,isShowPassword:T,setIsShowPassword:S,submitLogin:D,fnLoginSSO:q,extensionEmail:E,onLoginWidthClever:L,openModalSelectGrade:V,handleRegisterUser:j,onToggleModelGrade:I}),r&&s.jsx(rs,{school:C})]}),l&&s.jsx(ls,{}),m&&s.jsx(Cs,{}),s.jsx("a",{href:"/privacy-policy/",target:"blank",className:`${e.styles["privacy-policy"]}`,children:"Privacy Policy"})]}),s.jsx(g.Col,{className:"p-3 mh-100 d-flex justify-content-end",lg:4,md:12,xs:12,children:s.jsx("img",{src:`${e.getStaticFileUrl(window.innerWidth>992?"/images/img-login.png":"/images/img-login-tablet.png")}`,className:`${e.styles["img-login"]}`})})]}),s.jsx(Fs,{open:_,onSelectTier:F,onClose:()=>Y(!1)})]})};exports.default=qs;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("react/jsx-runtime"),o=require("react"),g=require("reactstrap"),te=require("react-router-dom"),e=require("./index-C8ahRx_e.js"),Q=require("react-redux"),ue=require("formik"),De=require("yup"),le=require("react-google-recaptcha-v3"),ke=require("@react-oauth/google"),se=require("./types-CTFcZUFS.js"),Ce=require("./constants-jaChcnkB.js"),re=require("@azure/msal-browser"),qe=require("@amplitude/analytics-browser");function Ie(t){const n=Object.create(null,{[Symbol.toStringTag]:{value:"Module"}});if(t){for(const r in t)if(r!=="default"){const l=Object.getOwnPropertyDescriptor(t,r);Object.defineProperty(n,r,l.get?l:{enumerable:!0,get:()=>t[r]})}}return n.default=t,Object.freeze(n)}const M=Ie(De),ne=Ie(qe),Ve={backgroundColor:"#f7f9fc",borderRadius:"4px",marginBottom:"5px",position:"relative"},He={backgroundColor:"#ffffff",paddingRight:"50px",color:"#333333",caretColor:"#333333"},We={fontSize:"20px",position:"absolute",right:"10px",color:"#316CD9"},Ke=t=>t.toLowerCase().replace(/[^a-zA-Z0-9]+(.)/g,(n,r)=>r.toUpperCase()),ie=({isShowPassword:t,togglePasswordVisible:n,onChange:r,placeholder:l})=>s.jsxs("div",{className:"d-flex align-items-center w-100",style:Ve,children:[s.jsx(g.Input,{className:"border password-input",style:He,type:t?"text":"password",name:"password",onChange:r,placeholder:l||"Password",autocomplete:l?Ke(l):"password",required:!0}),s.jsx("i",{className:`far ${t?"fa-eye-slash":"fa-eye"} mx-2 cursor-pointer`,style:We,onClick:()=>n(),title:t?"Hide":"Show"})]}),Ye=({open:t,onConfirm:n,onClose:r,clickHandler:l})=>{const{getLabel:m,system:h}=e.useGradeLabel(),[p,y]=o.useState(Ce.GRADE_DEFAULT[0].value);return s.jsxs(g.Modal,{isOpen:t,className:`${e.styles["teacher-code"]}`,style:{zIndex:1201},centered:!0,autoFocus:!1,returnFocusAfterClose:!1,children:[s.jsxs("div",{className:`${e.styles["header-teacher-code"]}`,children:[s.jsx("div",{style:{padding:"16px 24px",margin:0,fontWeight:500,fontSize:"1.25rem"},children:h==="UK"?"Select Year":"Select Grade"}),s.jsx("div",{hidden:!r,children:s.jsx(e.MdClose,{onClick:()=>r?.(),className:`${e.styles["close-icon"]}`,size:24,style:{color:"rgba(0, 0, 0, 0.54)"}})})]}),s.jsxs(g.ModalBody,{style:{padding:"20px 24px"},children:[s.jsx("p",{className:`${e.styles["teacher-code-label"]}`,style:{margin:0,marginBottom:"16px",color:"rgba(0, 0, 0, 0.6)"},children:h==="UK"?"You are logging in as a student, please select your year":"You are logging in as a student, please select your grade"}),s.jsxs("div",{className:"form-floating",style:{marginTop:"16px",marginBottom:"8px"},children:[s.jsx(g.Input,{type:"select",id:"floatingSelectGrade",value:p,onChange:x=>y(x.target.value),children:Ce.GRADE_DEFAULT.map(x=>s.jsx("option",{value:x.value,children:m(x.value)||x.label},x.value))}),s.jsx("label",{htmlFor:"floatingSelectGrade",children:h==="UK"?"Select year":"Select grade"})]})]}),s.jsx(g.ModalFooter,{style:{borderTop:"none",padding:"8px 24px"},children:s.jsx(g.Button,{disabled:!p,style:{borderRadius:20,background:"#316cd9",border:"none",opacity:p?1:.65},color:"primary",onClick:()=>n(p,l),children:"Confirm"})})]})};function Je(t,n){return JSON.stringify(t)===JSON.stringify(n)}const Ze=o.memo(Ye,Je),Qe=M.object({email:M.string().email("Email is invalid").required("Email is required"),password:M.string().required("Password is required"),rememberMe:M.boolean()}),Xe=({onSuccess:t,onError:n})=>{const r=ke.useGoogleLogin({onSuccess:async l=>{try{const m=await fetch("https://www.googleapis.com/oauth2/v3/userinfo",{headers:{Authorization:`Bearer ${l.access_token}`}}).then(p=>p.json()),h={accessToken:l.access_token,googleId:m.sub,profileObj:{email:m.email,familyName:m.family_name,givenName:m.given_name,imageUrl:m.picture,name:m.name}};t(h)}catch(m){n(m)}},onError:l=>n(l)});return s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>r(),children:[s.jsxs("svg",{version:"1.1",xmlns:"http://www.w3.org/2000/svg",viewBox:"0 0 48 48",width:"24px",height:"24px",style:{marginRight:"8px"},children:[s.jsx("path",{fill:"#EA4335",d:"M24 9.5c3.54 0 6.71 1.22 9.21 3.6l6.85-6.85C35.9 2.38 30.47 0 24 0 14.62 0 6.51 5.38 2.56 13.22l7.98 6.19C12.43 13.72 17.74 9.5 24 9.5z"}),s.jsx("path",{fill:"#4285F4",d:"M46.98 24.55c0-1.57-.15-3.09-.38-4.55H24v9.02h12.94c-.58 2.96-2.26 5.48-4.78 7.18l7.73 6c4.51-4.18 7.09-10.36 7.09-17.65z"}),s.jsx("path",{fill:"#FBBC05",d:"M10.53 28.59c-.48-1.45-.76-2.99-.76-4.59s.27-3.14.76-4.59l-7.98-6.19C.92 16.46 0 20.12 0 24c0 3.88.92 7.54 2.56 10.78l7.97-6.19z"}),s.jsx("path",{fill:"#34A853",d:"M24 48c6.48 0 12.38-2.12 16.66-5.73l-7.73-6c-2.15 1.45-4.92 2.3-8.93 2.3-6.26 0-11.57-4.22-13.47-9.91l-7.98 6.19C6.51 42.62 14.62 48 24 48z"}),s.jsx("path",{fill:"none",d:"M0 0h48v48H0z"})]}),s.jsx("p",{children:"GOOGLE"})]})},es=({defaultInfo:t,userLogin:n,school:r,isShowPassword:l,setIsShowPassword:m,fnIsCheckLogin:h,googleClientId:p,fnLoginSSO:y,extensionEmail:x,onLoginWidthClever:C,openModalSelectGrade:b,handleRegisterUser:S,onToggleModelGrade:k})=>{const N=()=>m(!l),D=Q.useDispatch(),{executeRecaptcha:P}=le.useGoogleReCaptcha(),v=o.useCallback(async()=>{if(!P){console.log("execute recaptcha undefined");return}return await P("login")},[P]),T=async E=>{try{await e.AccountSSOLogApi(E)}catch(L){console.error(L)}},q=async E=>{if(E?.accessToken){let{email:L,familyName:V,givenName:j,imageUrl:I,name:_}=E.profileObj,F=E.accessToken,Y=E.googleId;const J=window.location.hostname.split(".marioforme.com")?.[0],W=L.split("@")?.[1],he=x?.split(",")?.map(U=>U.trim())?.filter(U=>U).some(U=>W.includes(U));if(!W.includes(J)&&!he){alert("The email address you used does not match the login information in the database. Please check that you are using your school assigned email address to log into MARIO for Me. If you have further trouble please notify your school site administrator"),await T([`${W} is incorrect`]);return}const ce={firstName:j,lastName:V,imageUrl:I,fullName:_,email:L,accessToken:F,googleId:Y};D(e.setInforUserGoogle(ce)),h(se.TypeLogin.Google,ce,F,v)}};return s.jsxs(o.Fragment,{children:[s.jsx(ue.Formik,{initialValues:t,validationSchema:Qe,onSubmit:async E=>{try{const L=await v();if(!L)return;E.captcha=L,E.loginType=se.LoginType.Default,n(E)}catch(L){console.error(L)}},children:E=>{const{handleBlur:L,handleSubmit:V,values:j,touched:I,errors:_,setFieldValue:F}=E,Y=I.email&&_.email,ae=I.password&&_.password;return s.jsx("div",{className:`${e.styles["box-login"]} w-100`,children:s.jsx(g.Form,{className:`${e.styles["block-login"]}`,onSubmit:V,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsxs("div",{className:"d-flex align-items-center mb-4",children:[s.jsx("img",{hidden:!r?.schoolLogo,src:r?.schoolLogo,className:`${e.styles["school-icon"]} mr-3`}),s.jsx("p",{className:`${e.styles["school-name"]} mb-0`,children:r.schoolName})]}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"Welcome Back!"}),s.jsx("p",{className:`${e.styles["login-description"]} mb-5`,children:"Please enter your MARIO Education account details"}),s.jsxs(g.FormGroup,{className:`${e.styles["form-user-name"]}`,children:[s.jsx(g.Input,{type:"text",name:"email",placeholder:"Email",value:j.email,onChange:J=>F("email",J.target?.value?.trim()||""),autocomplete:"email",onBlur:L("email"),required:!0}),Y&&s.jsx(e.ErrorHandler,{text:_.email})]}),s.jsxs(g.FormGroup,{children:[s.jsx(ie,{isShowPassword:l,togglePasswordVisible:N,onChange:J=>F("password",J.target?.value?.trim()||"")}),ae&&s.jsx(e.ErrorHandler,{text:_.password})]}),s.jsx(g.FormGroup,{}),s.jsxs("div",{className:"d-flex justify-content-between",children:[s.jsxs("div",{className:"d-flex align-items-center",style:{gap:"8px"},children:[s.jsx("input",{type:"checkbox",checked:!j.isSessionUserBrowser,className:`${e.styles["checkbox-keep-login"]}`,onChange:()=>F("isSessionUserBrowser",!j.isSessionUserBrowser)}),s.jsx("p",{className:`${e.styles["label-keep-login"]} mb-0 ml-2`,children:"Keep me logged in"})]}),s.jsx(te.Link,{to:"/forgot-password",className:`${e.styles["link-to-login"]}`,children:"Forgot password?"})]}),s.jsx("button",{className:`${e.styles["btn-login"]} mt-5`,type:"submit",children:"LOG IN"}),s.jsx("p",{className:`${e.styles["option-text"]} my-3 text-center`,children:"OR"}),s.jsxs(g.Row,{className:"mb-4",children:[s.jsx(g.Col,{lg:6,md:6,xs:12,className:"pr-md-3",children:!!p&&s.jsx(ke.GoogleOAuthProvider,{clientId:p,children:s.jsx(Xe,{onSuccess:q,onError:()=>console.log("Google login failed")})})}),r.schoolId&&s.jsx(g.Col,{lg:6,md:6,xs:12,className:`${e.styles["btn-login-sso"]} pl-md-2`,hidden:!r?.schoolId,children:s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>y(v),children:[s.jsx("img",{src:"images/microsoft-logo.png"}),s.jsx("p",{children:"MICROSOFT"})]})})]}),s.jsx("div",{className:`${e.styles["btn-login-sso"]}`,children:s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>window.open("https://launchpad.classlink.com/login"),children:[s.jsx("img",{src:"images/class-link-icon.png"}),s.jsx("p",{children:"SIGN IN WITH CLASSLINK"})]})}),s.jsx("div",{className:`${e.styles["btn-login-sso"]} mt-4`,children:s.jsxs("div",{className:e.styles["btn-login-with-sso"],onClick:()=>C(),children:[s.jsx("img",{src:"images/clever-icon.png"}),s.jsx("p",{children:"SIGN IN WITH CLEVER"})]})})]})})})}}),s.jsx(Ze,{open:b,onConfirm:S,clickHandler:v,onClose:k})]})},ss={email:"",captcha:""},ts="/",ve="/login",as="Log in",Te=()=>{const t=new URLSearchParams(te.useLocation().search),n=t.get("token"),r=t.get("key")??"",l=Q.useDispatch(),m=te.useNavigate(),[h,p]=o.useState(!1),y=o.useCallback(()=>{p(!h)},[h]),[x,C]=o.useState(!1),[b,S]=o.useState(!1),[k,N]=o.useState({token:"",password:"",reEnterPassword:"",email:"",userId:""}),[D,P]=o.useState(!0),{executeRecaptcha:v}=le.useGoogleReCaptcha();o.useEffect(()=>{document.title=as,e.getAccessToken()&&m(ts)},[]);const T=o.useCallback(async j=>{l(e.setLoading(!0));try{await e.forgotPassword(j),m(ve),l(e.setAlert({type:"success",message:"A mail to reset password was sent"}))}catch(I){l(e.setAlert({type:"danger",message:I.response?.data?.title||I.message||"Error occured"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN)}l(e.setLoading(!1))},[]),q=o.useCallback(async(j,I)=>{l(e.setLoading(!0));try{const _=await e.checkResetToken(j,I);_.data?N({...k,token:j,email:_.data}):P(!1)}catch{P(!1)}l(e.setLoading(!1))},[]),E=o.useCallback(async j=>{l(e.setLoading(!0));try{await e.resetPassword({...j,key:r}),m(ve),l(e.setAlert({type:"success",message:"Reset password sucessfully"}))}catch(I){l(e.setAlert({type:"danger",message:I.response?.data?.title||I.message||"Error occured"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN)}l(e.setLoading(!1))},[]),L=o.useCallback(async()=>{if(!v){console.log("execute recaptcha undefined");return}return await v("forgetPass")},[v]),V=o.useCallback(()=>{},[]);return o.useEffect(()=>{n&&r&&q(n,r)},[n,r]),{defaultInfo:ss,forgotPasswordRequest:T,checkResetTokenRequest:q,validLink:D,resetPasswordRequest:E,openLogin:h,toggle:y,isShowNewPassword:x,setIsShowNewPassword:C,isShowReTypePassword:b,setIsShowReTypePassword:S,clickHandler:L,handleVerify:V,initialValues:k}},os={email:"",captcha:""},ns=M.object({email:M.string().email("Email is invalid").required("Email is required")}),rs=({school:t})=>{const{forgotPasswordRequest:n,clickHandler:r,handleVerify:l}=Te();return s.jsx(ue.Formik,{initialValues:os,enableReinitialize:!0,validationSchema:ns,onSubmit:async m=>{const h=await r();h&&(m.captcha=h,n(m))},children:m=>{const{handleChange:h,handleSubmit:p,values:y,touched:x,errors:C}=m;return s.jsx("div",{className:`${e.styles["box-login"]}`,children:s.jsx("div",{className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsxs("div",{className:"d-flex align-items-center mb-4",children:[s.jsx("img",{src:t.schoolLogo,className:`${e.styles["school-icon"]} mr-3`}),s.jsx("p",{className:`${e.styles["school-name"]} mb-0`,children:t.schoolName})]}),s.jsx("p",{className:`${e.styles["title-login"]} `,children:"Forgot password"}),s.jsx("p",{className:`${e.styles["recover-account"]} mb-5`,children:"Enter email to recover your account"}),s.jsxs("div",{className:"w-100",children:[s.jsx(g.Input,{type:"text",name:"email",id:"email",placeholder:"Input email",onChange:h,value:y.email}),x.email&&C.email&&s.jsx(e.ErrorHandler,{text:C.email})]}),s.jsx(te.Link,{to:"/login",className:`${e.styles["link-to-login"]} mt-2`,children:"Return to login"}),s.jsx(le.GoogleReCaptcha,{action:"forgetPass",onVerify:l}),s.jsx(g.Col,{className:"p-0",children:s.jsx("button",{className:`${e.styles["btn-login"]} mt-5`,onClick:()=>p(),children:"Continue"})})]})})})}})},is=M.object({password:M.string().required("New password is required"),reEnterPassword:M.string().required("Please re-enter new password").test("matching","Passwords do not match",function(){return this.parent.password===this.parent.reEnterPassword})}),ls=()=>{const{validLink:t,resetPasswordRequest:n,isShowNewPassword:r,setIsShowNewPassword:l,isShowReTypePassword:m,setIsShowReTypePassword:h,initialValues:p}=Te();return s.jsx(ue.Formik,{initialValues:p,enableReinitialize:!0,validationSchema:is,onSubmit:y=>{n(y)},children:y=>{const{setFieldValue:x,handleSubmit:C,touched:b,errors:S,values:k}=y;return s.jsx(g.Row,{className:`${e.styles["box-login"]}`,children:s.jsx(g.Col,{className:"p-0",children:s.jsx("div",{className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsx("img",{src:`${e.getStaticFileUrl("/images/horizontal-logo-blue.svg")}`,className:`${e.styles["img-login-rectangle"]}`}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"Reset Password"}),s.jsx("div",{className:"w-100",children:t?s.jsxs(o.Fragment,{children:[s.jsx(g.FormGroup,{className:`${e.styles["form-user-name"]}`,children:s.jsx(g.Input,{disabled:!0,type:"text",name:"email",placeholder:"Email",value:k.email,autocomplete:"email",required:!0,className:`${e.styles.input}`})}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{isShowPassword:r,togglePasswordVisible:()=>l(!r),onChange:N=>x("password",N.target.value)}),b.password&&S.password&&s.jsx(e.ErrorHandler,{text:S.password})]}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{placeholder:"Confirm Password",isShowPassword:m,togglePasswordVisible:()=>h(!m),onChange:N=>x("reEnterPassword",N.target.value)}),b.reEnterPassword&&S.reEnterPassword&&s.jsx(e.ErrorHandler,{text:S.reEnterPassword})]})]}):s.jsxs(o.Fragment,{children:[s.jsx("p",{className:`${e.styles["recover-account"]} mb-5`,children:"Invalid reset password link"}),s.jsx("p",{className:"w-100",children:"It may have been accessed before or expired or you have just tried to reset another account's password"})]})}),t&&s.jsx(g.Col,{className:"p-0",children:s.jsx("button",{className:`${e.styles["btn-login"]} ${e.styles["btn-rounder"]} mt-4`,onClick:()=>C(),children:"SET A NEW PASSWORD"})})]})})})})}})},Ae=`${e.BASE_URL}/api/school`,cs=()=>e.api.get(`${Ae}/settings`),ds=()=>e.api.get(`${Ae}/info`),ms={auth:{clientId:e.isLocalhost?"a27f8ac9-e039-4bbd-a9e1-3096e52a77bb":"90c6897c-f17b-475e-a7a8-9a19651e0060",authority:"https://login.microsoftonline.com/common",redirectUri:"https://sso.marioforme.com/microsoft-login.html"},cache:{cacheLocation:"sessionStorage",storeAuthStateInCookie:!1},system:{loggerOptions:{loggerCallback:(t,n,r)=>{if(!r)switch(t){case re.LogLevel.Error:console.error(n);return;case re.LogLevel.Info:console.info(n);return;case re.LogLevel.Verbose:console.debug(n);return;case re.LogLevel.Warning:console.warn(n);return;default:return}}}}},gs={email:"",password:"",captcha:"",rememberMe:!1,isSessionUserBrowser:!!sessionStorage.getItem(e.IS_USER_SESSION_BROWSER)},us="/home",Ee="/home",hs="/admin/home",ps="/parent",fs="/admin/schools",xs="/list-student",Ss="Log in",ws=()=>{const t=Q.useDispatch(),n=te.useNavigate(),[r,l]=o.useState(!1),m=Q.useSelector(a=>a.common.isLoginGoogle),[h,p]=o.useState(""),[y,x]=o.useState(""),[C,b]=o.useState(""),[S,k]=o.useState(!1),N=Q.useSelector(a=>a.common.inforUserGoogle),D=Q.useSelector(a=>a.common.environment),P=new URLSearchParams(location.search),v=P.get("type")==="classlink",T=P.get("token"),q=P.get("isAdminUser"),[E]=o.useState(!1),[L,V]=o.useState({schoolName:"",schoolLogo:"",schoolId:0}),[j,I]=o.useState(null),_=o.useCallback(()=>{l(!r)},[r]),[F,Y]=o.useState(!1),[ae,J]=o.useState(!1),[W,he]=o.useState({firstName:"",lastName:"",fullName:"",imageUrl:"",email:"",accessToken:"",googleId:""});o.useEffect(()=>{document.title=Ss;const a=e.getCookieValue("auth-token");if(a){const d=window.location.hostname;if(localStorage.setItem(e.ACCESS_TOKEN,a),document.cookie=`auth-token=;domain=${d.includes("localhost")?d:".marioforme.com"}; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/`,document.cookie="redirect-uri=; expires=Thu, 01 Jan 1970 00:00:00 GMT; path=/",q)return n("/admin/home");Se(a);return}e.getAccessToken()&&n("/"),Ge()},[q,Se,n]);const ce=()=>{localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN),localStorage.removeItem("USER_EMAIL")};o.useEffect(()=>{v&&T!=""&&_e()},[]);const U=()=>{J(!ae)},Pe=()=>{if(e.isLocalhost){const a="https://clever.com/oauth/instant-login?client_id=44f4bbf55cd873d3f7e5&district_id=6620cba31f1ddde7bd689dc5";window.location.href=a}else{const a=`https://clever.com/oauth/authorize?response_type=code&redirect_uri=${encodeURIComponent("https://classlink.marioforme.com/api/clever/clever-login")}&client_id=c3da6c669d239c70d48e`;window.location.href=a}},_e=async()=>{t(e.setLoading(!0));try{const a={tokenClassLink:T},i=await e.apiInforUserClassLink(a),{email:d,token:f}=i.data;await Z({email:d,rememberMe:!1,password:"default",accessToken:f})}catch(a){t(e.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}t(e.setLoading(!1))},pe=window.location.host.includes("-district"),Re=o.useCallback(async()=>{t(e.setLoading(!0));try{const a=await ds(),i=a.data.schoolLogo??"";a.data&&V({schoolName:a.data.schoolName,schoolLogo:i?e.getFileUrl(i):e.getStaticFileUrl("/images/logo_header_blue.png"),schoolId:a.data.schoolId})}catch(a){t(e.setAlert({type:"danger",message:a.response?.data?.title||a.message}))}t(e.setLoading(!1))},[]),[$e,de]=o.useState(!1),[X,fe]=o.useState(null),oe=o.useCallback((a,i,d,f,c,B,$,z,H,A)=>{const O=A?.isSessionUserBrowser??!1;O?(sessionStorage.setItem(e.ACCESS_TOKEN,a),sessionStorage.setItem(e.IS_USER_SESSION_BROWSER,String(O))):(sessionStorage.removeItem(e.IS_USER_SESSION_BROWSER),localStorage.setItem(e.ACCESS_TOKEN,a)),localStorage.removeItem(e.NOTIFICATION_ALERT_KEY),sessionStorage.removeItem("ACTIVE_ROLE"),t(e.setUser({id:i,firstName:d,lastName:f,roles:c,email:B,profileImageFileName:$}));let w=localStorage.getItem("ROLES")||"";if(!w){if(c.includes("Admin"))w="Admin";else{const R=((i?localStorage.getItem(`PREFERRED_ROLE_${i}`):null)||"").split(",").map(ge=>ge.trim()).filter(Boolean);R.length>0&&R.every(ge=>c.includes(ge))?R.length>1?w=R.every(je=>je==="Teacher"||je==="Assistant")?"Teacher,Assistant":R[0]:w=R[0]:c.includes("Teacher")?w=c.includes("Assistant")?"Teacher,Assistant":"Teacher":c.includes("Assistant")?w="Assistant":c.includes("Counselor")?w="Counselor":c.includes("SecondaryTeacher")?w="SecondaryTeacher":c.includes("EduTeacher")?w="EduTeacher":c.includes("Student")?w="Student":c.includes("Parent")?w="Parent":c.length>0&&(w=c[0])}w&&(localStorage.setItem("ROLES",w),sessionStorage.setItem("ACTIVE_ROLE",w))}if(A?.email&&!c.includes("Admin")){ne.init(e.isLocalhost?e.INIT_AMPLITUDE_KEY_STAGE:e.INIT_AMPLITUDE_KEY_PROD,A.email,{defaultTracking:!1});const ee=window.location.hostname,R=new ne.Identify;R.set("domain",ee),ne.identify(R),ne.track("general: session start",{user_id:A.email,domain:ee,roles:c?.toString()}),localStorage.setItem("USER_EMAIL",A.email),z&&ne.track("general: first login",{user_id:A.email,domain:ee,roles:c?.toString()})}const K=ee=>{const R=e.navigateBySchoolLevel(ee,H);window.location.pathname.startsWith("/es")?H==="es"?n(R):window.location.href=R:H==="es"?window.location.href=R:n(R)},G=w.split(",")[0]||"";pe?K(fs):c.includes("Admin")||G==="Admin"?K(hs):G==="Teacher"||G==="Assistant"||G==="Counselor"||G==="SecondaryTeacher"||!G&&(c.includes("Teacher")||c.includes("Assistant")||c.includes("Counselor")||c.includes("SecondaryTeacher"))?K(us):G==="Student"||!G&&c.includes("Student")?K(Ee):G==="Parent"||!G&&c.includes("Parent")?K(ps):(G==="EduTeacher"||!G&&c.includes("EduTeacher"))&&K(xs),t(e.setLoading(!1))},[t,n,pe]),me=o.useCallback((a,i,d)=>S&&a?.includes("Student")&&(i==="es"||d==="ES")?(t(e.setAlert({type:"danger",message:"Unable to sign in with SSO. Please contact your admin or teacher."})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN),t(e.setLoading(!1)),!0):!1,[S,t]),xe=o.useCallback(a=>S&&a&&e.ES_GRADES.includes(a.trim())?(t(e.setAlert({type:"danger",message:"Unable to sign in with SSO. Please contact your admin or teacher."})),t(e.setLoading(!1)),!0):!1,[S,t]);async function Se(a){t(e.setLoading(!0));try{const i=await e.getInfo();let{id:d,firstName:f,lastName:c,roles:B,email:$,profileImageFileName:z,isLoginFirst:H,schoolLevel:A,appType:O,preferredAppType:w,needsAppTypeChoice:K}=i.data;if(K){fe({email:$}),de(!0),t(e.setLoading(!1));return}A||(O==="ES"||O==="ES, MS"&&w==="ES")&&(A="es"),oe(a,d,f,c,B,$,z,H,A,{email:$})}catch(i){t(e.setAlert({type:"danger",message:i.response?.data?.title||i.message||"Login failed"})),t(e.setLoading(!1))}}const Oe=o.useCallback(async a=>{if(de(!1),!X)return;t(e.setLoading(!0));const i=a==="es"?"ES":a==="ms"?"MS":"ES, MS";try{const d=await e.logIn({...X,email:X?.email?.trim(),password:X?.password?.trim(),preferredAppType:i});let{token:f,id:c,firstName:B,lastName:$,roles:z,email:H,profileImageFileName:A,isLoginFirst:O,schoolLevel:w}=d.data;if(!w&&a==="es"&&(w="es"),me(z,w,d.data.appType))return;oe(f,c,B,$,z,H,A,O,w,X)}catch(d){t(e.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Login failed"})),t(e.setLoading(!1))}},[X,oe,me,t]),Z=o.useCallback(async a=>{t(e.setLoading(!0));try{const i=await e.logIn({...a,email:a?.email?.trim(),password:a?.password?.trim()});let{token:d,id:f,firstName:c,lastName:B,roles:$,email:z,profileImageFileName:H,isLoginFirst:A,schoolLevel:O}=i.data;if(i.data.needsAppTypeChoice){fe(a),de(!0),t(e.setLoading(!1));return}if(O||(i.data.appType==="ES"||i.data.appType==="ES, MS"&&i.data.preferredAppType==="ES")&&(O="es"),me($,O,i.data.appType))return;oe(d,f,c,B,$,z,H,A,O,a)}catch(i){t(e.setAlert({type:"danger",message:i.response?.data?.title||i.message||"Login failed"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN),t(e.setLoading(!1))}},[oe,me,t]),Ge=async()=>{try{const a=await e.getGoogleClientId();p(a.data.googleClientId),x(a.data.googleCaptchaId),b(a.data.extensionEmail),k(a.data.isRestrictedLogin)}catch(a){t(e.setAlert({type:"danger",message:a.response?.data?.title||a.message||"Login failed"}))}},we=o.useCallback(async(a,i,d,f)=>{t(e.setLoading(!0));try{if((await e.checkUserGoogle(a,i)).data){const $={email:i.email,isLoginGoogle:!0,rememberMe:!1,password:"default",accessToken:d,captcha:"",loginType:se.LoginType.Google};if(f!=null){const z=await f();$.captcha=z}await Z($),t(e.setIsLoginGoogle(!1))}else he({...i,token:d}),U()}catch(c){t(e.setAlert({type:"danger",message:c.response?.data?.title||c.message||"Login failed"}))}t(e.setLoading(!1))},[Z,t,U]),Me=o.useCallback(async(a,i)=>{t(e.setLoading(!0));try{if(xe(a))return;if((await e.registerUserStudent({...W,gradeLevel:a}))?.data){const f={email:W.email,isLoginGoogle:!0,rememberMe:!1,password:"default",accessToken:W.accessToken,captcha:"",loginType:se.LoginType.Google};if(i!=null){const c=await i();f.captcha=c}await Z(f),U()}}catch(d){t(e.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Login failed"}))}t(e.setLoading(!1))},[xe,W,Z,U,t]),Ue=async(a,i)=>{t(e.setLoading(!0));try{const d={firstName:N.firstName,lastName:N.lastName,imageUrl:N.imageUrl,fullName:N.fullName,email:N.email,accessToken:N.accessToken,teacherId:a};if((await e.registerUserStudent(d)).data){const c=await i(),B={email:N.email,captcha:c,isLoginGoogle:!0,rememberMe:!1,password:"default",accessToken:N.accessToken,loginType:se.LoginType.Google};t(e.setIsLoginGoogle(!1)),await Z(B),n(Ee)}}catch(d){t(e.setAlert({type:"danger",message:d.response?.data?.title||d.message||"Login failed"}))}t(e.setIsLoginGoogle(!1)),t(e.setLoading(!1))},Fe=async()=>{try{const a=await cs();t(e.setSandboxMode(a.data.isSandboxMode))}catch(a){console.error(a)}},ye=async a=>{j.handleRedirectPromise().then(async i=>{if(L?.schoolId)if(i){let d=i.account;await Ne(d,a)}else{const d=j.getAllAccounts();if(d.length===0){const f=D==="PreProduction"?"https://mario1.marioforme.com":e.isLocalhost?"https://brightsoft.marioforme.com":"https://sso.marioforme.com";window.location.href=(window.location.hostname==="localhost"?window.location.origin:f)+`/microsoft-login.html?redirect-uri=${window.location.origin}&schoolId=${L.schoolId}`}else{let f=d[0];await Ne(f,a)}}}).catch(i=>{console.error(i)})},Ne=async(a,i)=>{let d=a.name,f={firstName:d.split(" ").slice(0,-1).join(" "),lastName:d.split(" ").slice(-1).join(" "),fullName:d,imageUrl:"",email:a.username,accessToken:a.idTokenClaims.aio,googleId:a.tenantId};t(e.setInforUserGoogle(f)),await we(se.TypeLogin.MicrosoftSSO,f,a.idTokenClaims.aio,i)},Be=async()=>{const a=new re.PublicClientApplication(ms);await a.initialize(),I(a)};return o.useEffect(()=>{let a=window.location.href;j&&a.includes("code")&&a.includes("client_info")&&ye()},[JSON.stringify(j)]),o.useEffect(()=>{Fe(),Be(),Re()},[]),{defaultInfo:gs,userLogin:Z,openLogin:r,toggle:_,isShowPassword:F,setIsShowPassword:Y,fnIsCheckLogin:we,isLoginGoogle:m,infoUser:N,submitLogin:Ue,googleClientId:h,googleRecaptchaId:y,handleCancelModelAssign:ce,openModelAssign:E,fnLoginSSO:ye,school:L,extensionEmail:C,handleLoginWidthClever:Pe,openModalSelectGrade:ae,handleRegisterUser:Me,handleToggleModelGrade:U,openModalSelectTier:$e,handleSelectTier:Oe,setOpenModalSelectTier:de}},Le="/",ys="/login",be="Log in",Ns=()=>{const t=Q.useDispatch(),n=te.useNavigate(),r=location.search,m=new URLSearchParams(r).get("userId"),[h,p]=o.useState(!1),[y,x]=o.useState(!1),[C,b]=o.useState({password:"",reEnterPassword:"",email:"",userId:m??"",token:""}),{executeRecaptcha:S}=le.useGoogleReCaptcha(),k=o.useCallback(async v=>{t(e.setLoading(!0));try{const T=await e.getUserNewPassword(v);b({...C,email:T.data})}catch(T){t(e.setAlert({type:"danger",message:T.message}))}t(e.setLoading(!1))},[]),N=o.useCallback(async v=>{t(e.setLoading(!0));try{await e.createPassword(v),n(ys),t(e.setAlert({type:"success",message:"Create password sucessfully"}))}catch(T){t(e.setAlert({type:"danger",message:T.response?.data?.title||T.message||"Error occured"})),localStorage.removeItem(e.ACCESS_TOKEN),sessionStorage.removeItem(e.ACCESS_TOKEN)}t(e.setLoading(!1))},[]),D=o.useCallback(async()=>{if(!S){console.log("execute recaptcha undefined");return}return await S("forgetPass")},[S]),P=o.useCallback(()=>{},[]);return o.useEffect(()=>{document.title=be,e.getAccessToken()&&n(Le),m&&k(m)},[m]),o.useEffect(()=>{document.title=be,e.getAccessToken()&&n(Le)},[]),{createPasswordRequest:N,isShowNewPassword:h,setIsShowNewPassword:p,isShowReTypePassword:y,setIsShowReTypePassword:x,clickHandler:D,handleVerify:P,initialValues:C}},js=M.object({password:M.string().required("Password is required"),reEnterPassword:M.string().required("Please re-enter Password").test("matching","Passwords do not match",function(){return this.parent.password===this.parent.reEnterPassword})}),Cs=()=>{const{createPasswordRequest:t,isShowNewPassword:n,setIsShowNewPassword:r,isShowReTypePassword:l,setIsShowReTypePassword:m,initialValues:h}=Ns();return s.jsx(ue.Formik,{initialValues:h,enableReinitialize:!0,validationSchema:js,onSubmit:p=>{t(p)},children:p=>{const{setFieldValue:y,handleSubmit:x,touched:C,errors:b,values:S}=p;return s.jsx(g.Row,{className:`${e.styles["box-login"]}`,children:s.jsxs(g.Col,{className:"p-0",children:[s.jsx("div",{hidden:!S.email,className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsx("img",{src:`${e.getStaticFileUrl("/images/horizontal-logo-blue.svg")}`,className:`${e.styles["img-login-rectangle"]}`}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"Create Your Password"}),s.jsx("div",{className:"w-100",children:s.jsxs(o.Fragment,{children:[s.jsx(g.FormGroup,{className:`${e.styles["form-user-name"]}`,children:s.jsx(g.Input,{disabled:!0,type:"text",name:"email",placeholder:"Email",value:S.email,autocomplete:"email",required:!0,className:`${e.styles.input}`})}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{isShowPassword:n,togglePasswordVisible:()=>r(!n),onChange:k=>y("password",k.target.value)}),C.password&&b.password&&s.jsx(e.ErrorHandler,{text:b.password})]}),s.jsxs("div",{className:`${e.styles["form-user-name"]}`,children:[s.jsx(ie,{placeholder:"Confirm Password",isShowPassword:l,togglePasswordVisible:()=>m(!l),onChange:k=>y("reEnterPassword",k.target.value)}),C.reEnterPassword&&b.reEnterPassword&&s.jsx(e.ErrorHandler,{text:b.reEnterPassword})]})]})}),s.jsx("button",{className:`${e.styles["btn-login"]} ${e.styles["btn-rounder"]} mt-4`,onClick:()=>x(),children:"CREATE YOUR PASSWORD"})]})}),s.jsx("div",{hidden:!!S.email,className:`${e.styles["block-login"]}`,children:s.jsxs("div",{className:`${e.styles["block-form"]}`,children:[s.jsx("img",{src:`${e.getStaticFileUrl("/images/horizontal-logo-blue.svg")}`,className:`${e.styles["img-login-rectangle"]}`}),s.jsx("p",{className:`${e.styles["title-login"]}`,children:"You cannot regenerate the password"})]})})]})})}})},vs="_modalContent_1pxxz_1",Es="_closeButton_1pxxz_6",Ls="_modalBody_1pxxz_17",bs="_iconWrapper_1pxxz_22",ks="_title_1pxxz_38",Is="_subtitle_1pxxz_45",Ts="_tierCard_1pxxz_51",As="_es_1pxxz_60",Ps="_tierTitle_1pxxz_71",_s="_tierDesc_1pxxz_76",Rs="_arrow_1pxxz_81",$s="_ms_1pxxz_85",Os="_both_1pxxz_110",Gs="_cardLeft_1pxxz_134",Ms="_cardText_1pxxz_138",u={modalContent:vs,closeButton:Es,modalBody:Ls,iconWrapper:bs,title:ks,subtitle:Is,tierCard:Ts,es:As,tierTitle:Ps,tierDesc:_s,arrow:Rs,ms:$s,both:Os,cardLeft:Gs,cardText:Ms},Us=({open:t,onSelectTier:n,onClose:r})=>s.jsxs(g.Modal,{isOpen:t,style:{zIndex:1201,maxWidth:450},centered:!0,autoFocus:!1,returnFocusAfterClose:!1,contentClassName:u.modalContent,children:[s.jsx("div",{className:u.closeButton,children:r&&s.jsx(e.MdClose,{onClick:()=>r(),size:24})}),s.jsxs(g.ModalBody,{className:u.modalBody,children:[s.jsx("div",{className:u.iconWrapper,children:s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"})})}),s.jsx("h4",{className:u.title,children:"Select Grade Level"}),s.jsx("p",{className:u.subtitle,children:"Select the grade levels you support"}),s.jsxs("div",{onClick:()=>n("es"),className:`${u.tierCard} ${u.es}`,children:[s.jsxs("div",{className:u.cardLeft,children:[s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"})}),s.jsxs("div",{className:u.cardText,children:[s.jsx("div",{className:u.tierTitle,children:"Elementary / Primary"}),s.jsx("div",{className:u.tierDesc,children:"Grades 2-5 / Years 3-6"})]})]}),s.jsx("div",{className:u.arrow,children:">"})]}),s.jsxs("div",{onClick:()=>n("ms"),className:`${u.tierCard} ${u.ms}`,children:[s.jsxs("div",{className:u.cardLeft,children:[s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M19 20H5a2 2 0 01-2-2V6a2 2 0 012-2h10a2 2 0 012 2v1m2 13a2 2 0 01-2-2V7m2 13a2 2 0 002-2V9a2 2 0 00-2-2h-2m-4-3H9M7 16h6M7 8h6v4H7V8z"})}),s.jsxs("div",{className:u.cardText,children:[s.jsx("div",{className:u.tierTitle,children:"Middle & High / Secondary"}),s.jsx("div",{className:u.tierDesc,children:"Grades 6-12 / Years 7-13"})]})]}),s.jsx("div",{className:u.arrow,children:">"})]}),s.jsxs("div",{onClick:()=>n("both"),className:`${u.tierCard} ${u.both}`,children:[s.jsxs("div",{className:u.cardLeft,children:[s.jsx("svg",{fill:"none",viewBox:"0 0 24 24",stroke:"currentColor",children:s.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:"2",d:"M17 14v6m-3-3h6M6 10h2a2 2 0 002-2V6a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2zm10 0h2a2 2 0 002-2V6a2 2 0 00-2-2h-2a2 2 0 00-2 2v2a2 2 0 002 2zM6 20h2a2 2 0 002-2v-2a2 2 0 00-2-2H6a2 2 0 00-2 2v2a2 2 0 002 2z"})}),s.jsxs("div",{className:u.cardText,children:[s.jsx("div",{className:u.tierTitle,children:"Both Tiers"}),s.jsx("div",{className:u.tierDesc,children:"Access all grade levels"})]})]}),s.jsx("div",{className:u.arrow,children:">"})]})]})]}),Fs=o.memo(Us),Bs="Log in",zs="Forgot password",Ds="Reset password",qs=t=>{const{isLogin:n,isForgotPassword:r,isResetPassword:l,isCreatePassword:m}=t,{defaultInfo:h,userLogin:p,googleRecaptchaId:y,handleCancelModelAssign:x,school:C,openModelAssign:b,setIsShowPassword:S,fnIsCheckLogin:k,isLoginGoogle:N,submitLogin:D,infoUser:P,googleClientId:v,isShowPassword:T,fnLoginSSO:q,extensionEmail:E,handleLoginWidthClever:L,openModalSelectGrade:V,handleRegisterUser:j,handleToggleModelGrade:I,openModalSelectTier:_,handleSelectTier:F,setOpenModalSelectTier:Y}=ws();return o.useEffect(()=>{n&&(document.title=Bs),r&&(document.title=zs),l&&(document.title=Ds)},[n,r,l]),s.jsxs("div",{className:`${e.styles.login} container-fluid font-family-lato`,children:[s.jsxs(g.Row,{className:"h-100",children:[s.jsxs(g.Col,{lg:8,md:12,xs:12,className:"d-flex justify-content-center h-100 align-items-center p-3 flex-column",children:[!!y&&s.jsxs(le.GoogleReCaptchaProvider,{useRecaptchaNet:!0,reCaptchaKey:y,scriptProps:{async:!0,defer:!0,appendTo:"body"},children:[n&&s.jsx(es,{userLogin:p,defaultInfo:h,onCancelModelAssign:x,openModelAssign:b,school:C,fnIsCheckLogin:k,googleClientId:v,infoUser:P,isLoginGoogle:N,isShowPassword:T,setIsShowPassword:S,submitLogin:D,fnLoginSSO:q,extensionEmail:E,onLoginWidthClever:L,openModalSelectGrade:V,handleRegisterUser:j,onToggleModelGrade:I}),r&&s.jsx(rs,{school:C})]}),l&&s.jsx(ls,{}),m&&s.jsx(Cs,{}),s.jsx("a",{href:"/privacy-policy/",target:"blank",className:`${e.styles["privacy-policy"]}`,children:"Privacy Policy"})]}),s.jsx(g.Col,{className:"p-3 mh-100 d-flex justify-content-end",lg:4,md:12,xs:12,children:s.jsx("img",{src:`${e.getStaticFileUrl(window.innerWidth>992?"/images/img-login.png":"/images/img-login-tablet.png")}`,className:`${e.styles["img-login"]}`})})]}),s.jsx(Fs,{open:_,onSelectTier:F,onClose:()=>Y(!1)})]})};exports.default=qs;