@acuteinfo/common-screens 1.0.43 → 1.0.44

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.
package/dist/index.js CHANGED
@@ -1,2 +1,3206 @@
1
- import"regenerator-runtime/runtime";import{jsx as e,jsxs as r,Fragment as o}from"react/jsx-runtime";import{TextField as a,GradientButton as t,utilFunction as n,ClearCacheProvider as i,queryClient as s,Alert as l,GridWrapper as d,SearchBar as c}from"@acuteinfo/common-base";import{useState as p,useRef as m,useEffect as g,Fragment as u,useMemo as h,useReducer as f,useCallback as w}from"react";import{makeStyles as y}from"@mui/styles";import x from"@mui/icons-material/Visibility";import b from"@mui/icons-material/VisibilityOff";import{Container as v,Grid as C,InputAdornment as P,IconButton as S,CircularProgress as T,FormHelperText as N,Typography as k,Tooltip as E,tooltipClasses as D,Stack as B,Box as _,Avatar as M,Button as I,alpha as O,AppBar as A,Toolbar as R,List as L,ListItemIcon as U,ListItem as F,ListItemText as W,Collapse as V,Drawer as z}from"@mui/material";import{useTranslation as q}from"react-i18next";import H,{ResendOTP as j}from"otp-input-react";import G from"@mui/material/IconButton";import $ from"clsx";import{useSnackbar as K}from"notistack";import X from"@mui/icons-material/FingerprintSharp";import Y from"crypto-js";import{useQuery as J,useMutation as Z}from"react-query";import{styled as Q}from"@mui/material/styles";import ee from"@mui/icons-material/Logout";import re from"@mui/icons-material/MenuOutlined";import{format as oe}from"date-fns";import{FontAwesomeIcon as ae}from"@fortawesome/react-fontawesome";import te from"react-perfect-scrollbar";import{ExpandLess as ne,ExpandMore as ie}from"@mui/icons-material";import se from"@mui/icons-material/ArrowBackIosNew";import{library as le}from"@fortawesome/fontawesome-svg-core";import{faHandsHelping as de,faUsers as ce,faBars as pe,faBalanceScale as me,faHandHoldingHeart as ge,faTasks as ue,faCog as he,faHome as fe,faTh as we,faUsersCog as ye,faCircle as xe,faUserCircle as be,faHashtag as ve,faThumbtack as Ce,faSquare as Pe,faLink as Se,faQuestion as Te,faPlus as Ne,faTable as ke,faLocationArrow as Ee,faHeadset as De,faGears as Be,faArrowDown as _e,faArrowUp as Me,faSpinner as Ie,faCircleExclamation as Oe,faRotateRight as Ae,faUserLock as Re,faUserClock as Le,faGripHorizontal as Ue,faFileLines as Fe,faGear as We,faHeadphones as Ve,faUsersGear as ze,faMessage as qe,faUnlock as He,faUserPlus as je,faUserCheck as Ge,faKey as $e,faIdCard as Ke,faIdBadge as Xe,faCheck as Ye,faCheckDouble as Je,faCircleCheck as Ze,faCircleXmark as Qe,faUserTag as er,faAddressCard as rr,faChartColumn as or,faUserPen as ar,faHandHolding as tr,faHandHoldingMedical as nr,faObjectGroup as ir,faTowerCell as sr,faTowerObservation as lr,faBuilding as dr,faMailBulk as cr,faLandmarkFlag as pr,faCreditCard as mr,faHospitalSymbol as gr,faPlugCircleBolt as ur,faCodeBranch as hr,faPersonCircleCheck as fr,faBank as wr,faServer as yr,faNotesMedical as xr,faA as br,faB as vr,faC as Cr,faD as Pr,faE as Sr,faF as Tr,faG as Nr,faH as kr,faI as Er,faJ as Dr,faK as Br,faL as _r,faM as Mr,faN as Ir,faO as Or,faP as Ar,faQ as Rr,faR as Lr,faS as Ur,faT as Fr,faU as Wr,faV as Vr,faW as zr,faX as qr,faY as Hr,faZ as jr}from"@fortawesome/free-solid-svg-icons";import"lodash";function Gr(e,r){void 0===r&&(r={});var o=r.insertAt;if(e&&"undefined"!=typeof document){var a=document.head||document.getElementsByTagName("head")[0],t=document.createElement("style");t.type="text/css","top"===o&&a.firstChild?a.insertBefore(t,a.firstChild):a.appendChild(t),t.styleSheet?t.styleSheet.cssText=e:t.appendChild(document.createTextNode(e))}}Gr(":root{--theme-color1:#07288e;--theme-color2:#fff;--theme-color3:#4263c7;--theme-color4:#eceff9;--theme-color5:linear-gradient(71.66deg,#4285f4 -2.97%,#885df5 111.3%);--theme-color6:#949597}");const $r=y((e=>({wrapper:{minHeight:"100vh",boxShadow:"0 3px 6px rgba(0,0,0,0.03)",background:"var(--theme-color2)"},loginEmp:{background:"#fff",padding:e.spacing(2,4),display:"flex",maxWidth:"400px",margin:"auto",boxShadow:"0 0 20px rgba(0,0,0,0.06)",borderRadius:"8px",[e.breakpoints.down("sm")]:{width:"100%"}},formWrap:{marginTop:e.spacing(2)},loginBtn:{minWidth:"100% !important",margin:e.spacing(2,0),fontSize:"1rem",padding:"10px .75rem",background:"rgb(128,0,0)",border:0,color:"#fff !important",fontWeight:600,letterSpacing:"0.02857em",boxShadow:"none",textTransform:"capitalize",alignSelf:"flex-end","&:hover":{background:"#fedad8",boxShadow:"none"}},OTPTimer:{marginTop:"10px",color:e.palette.primary.main,fontWeight:600},resendLink:{marginTop:"10px",cursor:"pointer",color:e.palette.secondary.main,fontWeight:600,fontSize:"0.875 rem"},logo:{marginBottom:e.spacing(1)},loginLeft:{[e.breakpoints.down("sm")]:{display:"none"}},loginRight:{background:"#fff",padding:e.spacing(2,4),display:"flex",maxWidth:"400px",margin:"auto",boxShadow:"0 0 20px rgba(0,0,0,0.06)",borderRadius:"8px",[e.breakpoints.down("sm")]:{width:"100%"},"& img":{alignSelf:"center"}},loginImg:{},verifybutton:{alignSelf:"center",padding:"5px"},otpButtons:{},divflex:{display:"flex"},otpinputpadding:{"& input":{marginRight:"25px !important",border:"1.42444px solid var(--theme-color3)",borderRadius:"10px",width:"45px !important",height:"45px !important",marginBottom:"15px",boxShadow:"0px 5.69775px 11.3955px rgba(66, 99, 199, 0.16)"}},ibtnvisible:{marginBottom:"15px"},btnvisibleoff:{display:"none"},OTPalignName:{display:"flex",alignItems:"center",marginBottom:"12px",color:"#1C1C1C",fonWeight:"400",fontSize:"17px",lineHeight:"33px"},resendOTPalign:{color:"var(--theme-color3)",fonWeight:"400",fontSize:"17px",lineHeight:"33px",margin:"0 auto"},resendbtnLink:{textDecoration:"underline",color:"var(--theme-color3)",cursor:"pointer","&:hover":{textDecoration:"underline",color:"var(--theme-color3)"}},dialogTitleClass:{background:"var(--theme-color5)",padding:"6px 15px !important",margin:"10px",color:"var(--theme-color2)",borderRadius:"4px","& h2":{fontWeight:"500 !important"}},lang_svg:{marginRight:"10px",width:"22px",height:"22px"},dialogContent:{padding:"0px 15px","& p":{whiteSpace:"pre-wrap",color:"black",marginTop:"8px",marginBottom:"6px"}},button:{display:"flex",alignItems:"center",justifyContent:"center",flexDirection:"column",margin:"6px",background:"var(--theme-color1)","&:hover":{background:"var(--theme-color1) !important"}}}))),Kr=({classes:o,loginState:n,verifyUsernamePassword:i,forgotPasswordEndpoint:s})=>{const[l,d]=p({userName:"",password:""}),[c,h]=p(0),f=Date.now()<c,[,w]=p(),y=m(null),{t:N}=q();g((()=>()=>clearTimeout(y.current)),[]);const k=e=>{const r=e.target.name,o=e.target.value;"userName"===r&&o&&(n.isUsernameError=!1),"password"===r&&o&&(n.isPasswordError=!1),d((e=>({...e,[r]:o})))},E=m(null),D=m(null),B=m(null);return g((()=>{let e;return n.isUsernameError?e=setTimeout((()=>{E?.current?.focus?.()}),1e3):n.isPasswordError&&(e=setTimeout((()=>{D?.current?.focus?.()}),1e3)),()=>{e&&clearTimeout(e)}}),[n.isUsernameError,n.isPasswordError]),g((()=>{let e;return n?.otpmodelClose&&(d((e=>({...e,password:""}))),e=setTimeout((()=>{D?.current?.focus?.()}),1500)),()=>{e&&clearTimeout(e)}}),[n.otpmodelClose]),e(u,{children:e(v,{maxWidth:"xs",children:r(C,{alignItems:"center",style:{paddingTop:"20px"},children:[e("div",{style:{color:"#000000 !important",fontSize:"30px",fontWeight:"600",alignItems:"center",fontStyle:"normal",lineHeight:"150%"},children:e("h3",{children:N("SignIn")})}),e("div",{className:"",style:{color:"#949597",fontSize:"16px",fontWeight:"400",alignItems:"center",fontStyle:"normal",width:"360px"},children:N("SignInWithUserIDandPassword")}),r("div",{className:o.formWrap,children:[e(a,{autoFocus:!0,label:N("UserID"),placeholder:String(N("UserID")),style:{marginTop:"10px",marginBottom:"17px"},fullWidth:!0,type:"text",name:"userName",value:l.userName.trimStart()||"",onChange:k,error:n.isUsernameError,helperText:n.isUsernameError?N(n.userMessageforusername):"",InputLabelProps:{shrink:!0},disabled:n.loading,autoComplete:"off",ref:E,onKeyDown:e=>{"Enter"===e.key&&B?.current?.click?.()},inputProps:{maxLength:"16"}}),e("div",{style:{display:"flex",flexDirection:"row-reverse",marginTop:"8px"},children:e(a,{label:N("Password"),placeholder:String(N("EnterPassword")),InputLabelProps:{shrink:!0},fullWidth:!0,type:f?"text":"password",name:"password",value:l.password,onChange:k,error:n.isPasswordError,helperText:n.isPasswordError?N(n.userMessageforpassword):"",disabled:n.loading,ref:D,onKeyDown:e=>{"Enter"===e.key&&B?.current?.click?.()},InputProps:{endAdornment:e(P,{position:"end",children:e(S,{"aria-label":"toggle password visibility",onClick:()=>{f?f&&h(0):(h(Date.now()+5e3),y.current=setTimeout((()=>w(Date.now())),5e3))},onMouseDown:e=>e.preventDefault(),disabled:n.loading,children:e(f?x:b,{})})})},inputProps:{maxLength:"16"}},"employee")}),e("div",{style:{marginTop:"20px",display:"flex"},children:e("div",{style:{flex:"auto",textAlign:"end"},children:e("a",{href:s??"",style:{color:"var(--theme-color3)"},children:N("ForgotPassword")})})}),e("div",{style:{marginTop:"20px",display:"flex"},children:e("div",{style:{flex:"auto",textAlign:"center",marginTop:"5px",marginBottom:"17px"},children:e(t,{style:{borderRadius:n.loading?"50%":"10px",height:n.loading?"40px":"100%",width:n.loading?"0px":"100%",minWidth:n.loading?"40px":"80px"},fullWidth:!0,disabled:n.loading,onClick:()=>i((l.userName||"").toLowerCase(),l.password),ref:B,endicon:n.loading?void 0:"East",rotateIcon:"scale(1.4) rotateX(360deg)",children:n.loading?e(T,{size:25,thickness:4.6}):N("Next")})})})]})]})})})},Xr=({classes:o,OTPResendRequest:a,open:n,handleClose:i,loginState:s,VerifyOTP:l,OTPError:d,setOTPError:c,previousStep:h,setNewRequestID:f=(e=>{}),otpresendCount:w=0,resendFlag:y})=>{const[P,S]=p(""),[k,E]=p(0),D=Date.now()<k,[,B]=p(),_=m(null);g((()=>()=>clearTimeout(_.current)),[]);const[M,I]=p(!1),O=m(null),[A,R]=p(!1),{enqueueSnackbar:L}=K(),{t:U}=q();return g((()=>{s?.otpmodelClose&&(c(""),S(""),i(""))}),[s.otpmodelClose]),e(u,{children:e(v,{maxWidth:"sm",children:e(C,{alignItems:"center",marginTop:"4em",children:r("div",{style:{},children:[e("div",{style:{color:"#000000",fontSize:"30px",fontWeight:"600",alignItems:"center",fontStyle:"normal",lineHeight:"150%",marginBottom:"10px"},children:U("otp.OTPAuthentication")}),e("div",{style:{color:"#949597",fontSize:"16px",fontWeight:"400",alignItems:"center",fontStyle:"normal",lineHeight:"33px"},children:U("otp.EnterOTP")}),r("div",{className:o.OTPalignName,children:[U("otp.Hello")," ",s?.username?s.username.charAt(0).toUpperCase()+s.username.slice(1):null,e(j,{onResendClick:async()=>{R(!0);const{status:e,data:r,message:o}=await a("FORGET_PW"===y||"FORGT_TOTP"===y?s?.requestCd:s?.transactionID,s?.username,y,s.auth_data?.[0]?.company_ID,s.auth_data?.[0]?.branch_cd);R(!1),"0"===e?(f(r?.TRAN_CD),I(!1),L(o,{variant:"success"})):L(o,{variant:"error"})},renderButton:a=>{let{remainingTime:t,...n}=a;return A?r("a",{className:$(o.resendbtnLink,!M&&o.btnvisibleoff),style:{cursor:"wait"},children:[U("otp.GetNewOTP")," ",e(T,{size:20,color:"secondary"})]}):e("a",{remainingtime:t,...n,className:$(o.resendbtnLink,!M&&o.btnvisibleoff),children:U("otp.GetNewOTP")})},renderTime:e=>(0===parseInt(e)&&setTimeout((()=>{I(!0)}),700),r("span",{className:$(M&&o.btnvisibleoff),children:[U("otp.OtpExpired")," ",e," ",U("otp.second")]})),maxTime:s?.otpValidFor??60,className:o.resendOTPalign})]}),r("div",{className:o.divflex,onKeyDown:e=>{"Enter"===e.key&&O?.current?.click?.()},children:[e(H,{value:P,onChange:S,autoFocus:!0,OTPLength:6,otpType:"number",disabled:!1,secure:!D,className:o.otpinputpadding}),e(G,{"aria-label":"toggle password visibility",onClick:()=>{D?D&&E(0):(E(Date.now()+5e3),_.current=setTimeout((()=>B(Date.now())),5e3))},onMouseDown:e=>e.preventDefault(),disabled:s.otploading,className:o.ibtnvisible,children:e(D?x:b,{})})]}),Boolean(d)?e(N,{style:{color:"red"},children:d}):null,r("div",{style:{display:"flex",gap:"10px",margin:"42px 0 0 42px",width:"60%"},children:[e(t,{disabled:s.otploading,onClick:()=>{h(!1,"")},className:o.otpButtons,textColor:"var(--theme-color3)",sx:{border:"var(--theme-color3)1px solid",minWidth:"50%",background:"var(--theme-color2)",borderRadius:"10px","&:hover":{background:"var(--theme-color2) !important"}},starticon:"West",rotateIcon:"scale(1.4) rotateX(360deg)",children:U("otp.Back")}),e(t,{style:{borderRadius:s.loading?"50%":"10px",height:s.loading?"40px":"100%",width:s.loading?"0px":"100%",minWidth:s.loading?"40px":"80px"},fullWidth:!0,disabled:s.loading,onClick:()=>{!Boolean(P)||P.length<6?c("otp.EnterOTPDigit"):(c(""),l(P))},ref:O,className:o.otpButtons,endicon:s.loading?void 0:"TaskAlt",rotateIcon:"scale(1.4)",children:s.loading?e(T,{size:25,thickness:4.6}):U("otp.VerifyOTP")})]})]})})})})},Yr=({classes:a,OTPResendRequest:n,handleClose:i,loginState:s,VerifyOTP:l,OTPError:d,setOTPError:c,resendFlag:h,setNewRequestID:f=(e=>{}),otpresendCount:w=0})=>{const[y,v]=p(""),[P,S]=p(0),k=Date.now()<P,[,E]=p(),D=m(null);g((()=>()=>clearTimeout(D.current)),[]);const[B,_]=p(!1),[M,I]=p(!1),O=m(null),{enqueueSnackbar:A}=K(),{t:R}=q(),L=()=>{c(""),v(""),i()};return g((()=>{s?.otpmodelClose&&L()}),[s.otpmodelClose]),e(u,{children:e(C,{alignItems:"center",children:r("div",{children:[e("div",{style:{color:"#000000",fontSize:"30px",fontWeight:"600",alignItems:"center",fontStyle:"normal",lineHeight:"150%",marginBottom:"10px"},children:R("otp.OTPAuthentication")}),r("div",{className:a.OTPalignName,children:[R("otp.Hello")," ",s?.username?s.username.charAt(0).toUpperCase()+s.username.slice(1):null,s.otploading||w>=3||"TOTP"===s?.auth_type?null:e(j,{onResendClick:async()=>{I(!0);const{status:e,data:r,message:o}=await n("FORGET_PW"===h?s?.requestCd:s?.transactionID,s?.username,h,s?.company_ID,s?.branch_cd);I(!1),"0"===e?(f(r?.TRAN_CD),_(!1),A(o,{variant:"success"})):A(o,{variant:"error"})},renderButton:o=>{let{remainingTime:t,...n}=o;return M?r("a",{className:$(a.resendbtnLink,!B&&a.btnvisibleoff),style:{cursor:"wait"},children:[R("otp.GetNewOTP")," ",e(T,{size:20,color:"secondary"})]}):e("a",{remainingtime:t,...n,className:$(a.resendbtnLink,!B&&a.btnvisibleoff),children:R("otp.GetNewOTP")})},renderTime:e=>(0===parseInt(e)&&setTimeout((()=>{_(!0)}),700),r("span",{className:$(B&&a.btnvisibleoff),children:[R("otp.OtpExpired")," ",e]})),maxTime:s?.otpValidFor??60,className:a.resendOTPalign})]}),r("div",{className:a.divflex,onKeyDown:e=>{"Enter"===e.key&&O?.current?.click?.()},children:[e(H,{value:y,onChange:v,autoFocus:!0,OTPLength:6,otpType:"number",disabled:!1,secure:!k,className:a.otpinputpadding}),e(G,{"aria-label":"toggle password visibility",onClick:()=>{k?k&&S(0):(S(Date.now()+5e3),D.current=setTimeout((()=>E(Date.now())),5e3))},onMouseDown:e=>e.preventDefault(),disabled:s.otploading,className:a.ibtnvisible,children:e(k?x:b,{})})]}),Boolean(d)?e(N,{style:{color:"red"},children:d}):null,"TOTP"===s?.auth_type?e("div",{style:{flex:"auto"},children:e("a",{href:"forgot-totp",style:{color:"var(--theme-color3)"},children:"Forgot TOTP"})}):e(o,{}),r("div",{style:{display:"flex",gap:"10px",margin:"42px 0 0 42px",width:"60%"},children:[e(t,{fullWidth:!0,disabled:s.otploading,onClick:L,className:a.otpButtons,starticon:"West",textColor:"var(--theme-color3) !important",sx:{"&:disabled":{color:"var(-theme-color3) !important"}},rotateIcon:"scale(1.4) rotateX(360deg)",style:{border:"var(--theme-color3)1px solid",borderRadius:"10px",minWidth:"48%"},children:R("otp.Back")}),e(t,{style:{borderRadius:s.otploading?"50%":"10px",height:s.otploading?"40px":"100%",width:s.otploading?"0px":"100%",minWidth:s.otploading?"40px":"80px"},disabled:s.loading,onClick:()=>{!Boolean(y)||y.length<6?c("otp.EnterOTPDigit"):(c(""),l(y))},ref:O,className:a.otpButtons,children:s.otploading?e(T,{size:25,thickness:4.6}):R("otp.VerifyOTP")})]})]})})})};Gr(".spinner-wrap{position:relative}.spinner-item{animation:zoom 2s linear .75s infinite;border:1px solid #949597;border-radius:50%;height:250px;left:50%;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);width:250px}.spinner-item--2{animation-delay:1.25s}.spinner-item--3{animation-delay:1.75s}@keyframes zoom{0%{opacity:0;transform:translate(-50%,-50%) scale(.1)}50%{opacity:1}to{opacity:0;transform:translate(-50%,-50%) scale(.6)}}.image{height:50px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.progress{backdrop-filter:blur(2px) brightness(101%);border:1px solid #b0b0b0;border-radius:4px;box-shadow:0 0 3px #b0b0;margin:0 auto;width:20em}.bar{background:#4263c7;height:4px;width:65%}");const Jr=({classes:a,loginState:n,verifyFinger:i,previousStep:s})=>{const{t:l}=q();return e(u,{children:e(v,{maxWidth:"xs",children:r(C,{alignItems:"center",children:[r("div",{style:{marginRight:"25px",width:"102%"},children:[e("br",{}),e("div",{style:{color:"#000000",fontSize:"34px",fontWeight:"600",alignItems:"center",fontStyle:"normal",lineHeight:"150%",marginBottom:"10px"},children:l("Biometric.BiometrixAuthentication")}),e("div",{style:{color:"#949597",fontSize:"18px",fontWeight:"400",alignItems:"center",fontStyle:"normal",lineHeight:"33px"},children:l("Biometric.Kindlyplaceyoufinger")}),e("br",{}),r(k,{variant:"h5",style:{color:"#000000"},children:[l("otp.Hello")," ","",` ${n?.username?n.username.charAt(0).toUpperCase()+n.username.slice(1):null}`]}),e("br",{}),e("div",{className:n?.isBiometricError?a.eFingerUi:a.fingerUi,children:r("div",{className:"spinner-wrap",children:[e(X,{sx:{fontSize:"80px",opacity:"0.4",borderRadius:"50%",display:"flex",margin:"0 auto","&:after":{borderBottom:"2px solid #26A456"}},className:n?.isBiometricError?a.FingerIcon:null,color:n?.isBiometricError?"error":"inherit"}),n?.isScanning?r(o,{children:[e("div",{className:"spinner-item",style:{border:n?.isScanning?"1px solid #949597":" 1px solid red"}}),e("div",{className:"spinner-item spinner-item--2",style:{border:n?.isScanning?"1px solid #949597":"1px solid red"}}),e("div",{className:"spinner-item spinner-item--3",style:{border:n?.isScanning?"1px solid #949597":"1px solid red"}})]}):null]})}),e("div",{className:a.biometric,children:r("div",{style:{marginTop:"50px"},children:[e("div",{className:n.isScanning?"progress":"hide",children:e("div",{className:"bar",style:{width:n.isScanning?"30%":"0%"}})}),e("h3",{style:{display:"flex",marginTop:"20px",justifyContent:"space-around",color:n?.isBiometricError?"rgb(255 0 0 / 65%)":"inherit"},children:n?.isBiometricError?n?.userMessage:n?.loading?l("Biometric.Loading"):n?.isScanning?l("Biometric.Scanning"):null})]})})]}),r("div",{style:{display:"flex",justifyContent:"center",margin:"42px 0 0 42px",gap:"10px"},children:[e(t,{fullWidth:!0,disabled:n.loading,onClick:()=>{s(!1,"")},className:a.otpButtons,starticon:"West",rotateIcon:"scale(1.4) rotateX(360deg)",textColor:"var(--theme-color3) !important",style:{border:"var(--theme-color3)1px solid",color:"var(--theme-color3)",background:"var(--theme-color2)",borderRadius:"10px",minWidth:"48%"},children:l("otp.Back")}),e(t,{style:{borderRadius:n.loading?"50%":"10px",height:n.loading?"40px":"100%",width:n.loading?"0px":"100%",minWidth:n.loading?"40px":"80px"},disabled:n.loading,onKeyDown:e=>13===e.keyCode&&i,onClick:i,className:a.otpButtons,children:n.loading?e(T,{size:25,thickness:4.6,style:{color:"#fff"}}):l("Biometric.Verify")})]})]})})})},Zr=async(e,r)=>new Promise(((o,a)=>{"string"==typeof e&&(e=JSON.parse(e)),e.forEach((async(a,t)=>{try{var n={GalleryTemplate:(e=>{var r=Y.PBKDF2("SUPERACUTE@MKS","Ivan Medvedev",{keySize:12,iterations:1e3});console.log(r.toString());var o=new Y.lib.WordArray.init(r.words,32),a=new Y.lib.WordArray.init(r.words.splice(8),16),t=Y.AES.decrypt({ciphertext:Y.enc.Base64.parse(Y.enc.Base64.parse(e).toString(Y.enc.Utf8))},o,{iv:a});return console.log("CryptoJS.AES.decrypt",t),t.toString(Y.enc.Utf8).split(String.fromCharCode(0)).join("")})(a.IMG_DATA),ProbTemplate:r,BioType:"Iso"},i=JSON.stringify(n);await fetch("http://localhost:8004/mfs100/verify",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:i}).then((e=>e.json())).then((r=>{"0"===r?.ErrorCode&&r.Status?o({status:!0,errorCode:"0",errorMessage:"",isError:!1,sr_cd:a.SR_CD}):e.length!==t+1||o({status:!1,errorCode:r.ErrorCode,errorMessage:r.ErrorMessage,isError:!1})})).catch((e=>{o({status:!1,errorCode:"999",errorMessage:e,isError:!0})}))}catch(e){console.log(e),o({status:!1,errorCode:"999",errorMessage:"Something went wrong!",isError:!0})}}))})),Qr=(e="")=>{if("string"!=typeof e)return!1;return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)},eo=({bannerDetails:a})=>{const[t,i]=p(null),s=m(null),l=$r(),d=h((()=>a),[]);return g((()=>{if(Boolean(d?.bannerImg))if(Qr(d?.bannerImg)){let e=n.base64toBlob(d?.bannerImg);s.current="object"==typeof e&&Boolean(e)?URL.createObjectURL(e):"",i(s.current)}else i(d?.bannerImg)}),[d]),e(o,{children:r(C,{item:!0,xs:6,md:6,lg:6,className:l.loginLeft,children:[e(C,{item:!0,xs:12,md:12,lg:12,style:{height:"70vh"},children:e("img",{alt:"",style:{width:"100%",height:"100%",objectFit:"cover",objectPosition:"center"},src:Boolean(t)?t:""})}),e(C,{item:!0,xs:12,md:12,lg:12,style:{height:"30vh",background:"var(--theme-color5)"},children:r(v,{maxWidth:"sm",children:[r("div",{className:"text",style:{color:"white",fontStyle:"normal",fontSize:"35px",paddingTop:"30px"},children:[d?.bannerTitle??"",e("span",{style:{marginLeft:"8px",fontWeight:"900"}})]}),e("div",{style:{lineHeight:"27px",fontSize:"15px",fontWeight:"500px",letterSpacing:"0.02em",color:"#ebedee",maxWidth:"464px"},children:d?.bannerNote??""})]})})]})})},ro=({classes:o,ResetPassword:i,open:s,username:l,accessToken:d,tokenType:c,handleClose:g})=>{const h=m(null),{enqueueSnackbar:f}=K(),{t:w}=q(),[y,x]=p({userName:l,oldpassword:"",password:"",confirmpassword:""}),[b,P]=p({isError:!1,errorMessage:"",isLoading:!1,isoldPwdError:!1,oldpassworderror:"",isnewpwdError:!1,newpassworderror:"",isconfirmnewpwdError:!1,confirmnewpassworderror:""}),S=e=>{const r=e.target.name;let o=e.target.value;"oldpassword"===r&&Boolean(o)?P((e=>({...e,isoldPwdError:!1}))):"password"===r&&Boolean(o)?P((e=>({...e,isnewpwdError:!1}))):"confirmpassword"===r&&Boolean(o)&&P((e=>({...e,isconfirmnewpwdError:!1}))),x((e=>({...e,[r]:o})))};return e(u,{children:e(v,{maxWidth:"xs",children:r(C,{alignItems:"center",children:[e("div",{style:{color:"#000000 !important",fontSize:"30px",fontWeight:"600",alignItems:"center",fontStyle:"normal"},children:e("h3",{children:"Password Rotation"})}),e("div",{className:"",style:{color:"#949597",fontSize:"18px",fontWeight:"400",alignItems:"center",fontStyle:"normal",width:"360px"},children:"Please Verify OTP"}),r("div",{className:o.formWrap,children:[e(a,{label:"User ID",placeholder:"Enter User ID",fullWidth:!0,type:"text",name:"userName",value:y.userName||"",onChange:S,InputLabelProps:{shrink:!0},disabled:!0,autoComplete:"off",inputProps:{maxLength:16},style:{paddingBottom:"8px"}}),e(a,{autoFocus:!0,label:"Current Password",placeholder:"Enter Current Password",fullWidth:!0,type:"password",name:"oldpassword",value:y.oldpassword||"",onChange:S,error:b.isoldPwdError,helperText:b.isoldPwdError?w(b.oldpassworderror):"",InputLabelProps:{shrink:!0},disabled:b.isLoading,autoComplete:"off",onKeyDown:e=>{"Enter"===e.key&&h?.current?.click?.()},inputProps:{maxLength:16},style:{paddingBottom:"8px"}}),e(a,{label:"New Password",placeholder:"Enter New Password",fullWidth:!0,type:"password",name:"password",value:y.password||"",onChange:S,error:b.isnewpwdError,helperText:b.isnewpwdError?w(b.newpassworderror):"",InputLabelProps:{shrink:!0},disabled:b.isLoading,autoComplete:"off",onKeyDown:e=>{"Enter"===e.key&&h?.current?.click?.()},inputProps:{maxLength:16},style:{paddingBottom:"8px"}}),e(a,{label:"Confirm New Password",placeholder:"Enter confirm new password",fullWidth:!0,type:"password",name:"confirmpassword",value:y.confirmpassword||"",onChange:S,error:b.isconfirmnewpwdError,helperText:b.isconfirmnewpwdError?w(b.confirmnewpassworderror):"",InputLabelProps:{shrink:!0},disabled:b.isLoading,autoComplete:"off",onKeyDown:e=>{"Enter"===e.key&&h?.current?.click?.()},inputProps:{maxLength:16},style:{paddingBottom:"8px"}}),b.isError?e(N,{style:{color:"red"},children:b.errorMessage}):null]}),r("div",{style:{display:"flex",gap:"10px",margin:"20px 0 0 10px",width:"94%"},children:[e(t,{fullWidth:!0,disabled:b.isLoading,onClick:()=>{g("")},className:o.otpButtons,style:{border:"var(--theme-color3)1px solid",color:"var(--theme-color3)",borderRadius:"10px"},children:"Back"}),e(t,{style:{borderRadius:b.isLoading?"50%":"10px",height:b.isLoading?"40px":"100%",width:b.isLoading?"0px":"100%",minWidth:b.isLoading?"40px":"80px"},fullWidth:!0,disabled:b.isLoading,onClick:async()=>{let e=!1,r={isError:!1,errorMessage:"",isLoading:!1,isoldPwdError:!1,oldpassworderror:"",isnewpwdError:!1,newpassworderror:"",isconfirmnewpwdError:!1,confirmnewpassworderror:""};Boolean(y.oldpassword)||(r.isoldPwdError=!0,r.oldpassworderror="Current Password is required.",e=!0);let o=n.ValidatePassword(y.password);if(Boolean(o)&&(r.isnewpwdError=!0,r.newpassworderror=o,e=!0),Boolean(y.oldpassword)&&Boolean(y.password)&&y.oldpassword===y.password&&(r.isnewpwdError=!0,r.newpassworderror="The new password cannot be the same as the old password",e=!0),Boolean(y.confirmpassword)?Boolean(y.password)&&y.password!==y.confirmpassword&&(r.isconfirmnewpwdError=!0,r.confirmnewpassworderror="New Password and Confirm Password did not matched",e=!0):(r.isconfirmnewpwdError=!0,r.confirmnewpassworderror="Confirm new password is required.",e=!0),e)P(r);else{P((e=>({...e,isLoading:!0})));let e=await i(y.userName,y.oldpassword,y.password,d,c);P((e=>({...e,isLoading:!1}))),"0"===e.status?(f("Password successfully changed.",{variant:"success"}),g("0")):P((r=>({...r,isError:!0,errorMessage:e.message})))}},ref:h,className:o.otpButtons,children:b.isLoading?e(T,{size:25,thickness:4.6}):"Update"})]})]})})})},oo={username:"",firstName:"",lastName:"",loading:!1,otploading:!1,isError:!1,isUsernameError:!1,isPasswordError:!1,userMessage:"",OtpuserMessage:"",userMessageforpassword:"",userMessageforusername:"",currentFlow:"username",transactionID:"",access_token:"",token_type:"",otpmodelClose:!1,authType:"",isScanning:!1,auth_data:[],company_ID:"",Branch_CD:"",auth_type:"O",otpValidFor:60},ao=(e,r)=>{switch(r.type){case"inititateUserFingerVerification":case"inititateOTPVerification":return{...e,loading:!0,isError:!1,isUsernameError:!1,isPasswordError:!1,isOTPError:!1,isBiometricError:!1,userMessage:""};case"inititateUserFingerScanner":return{...e,isScanning:!0,isBiometricError:!1};case"usernameandpasswordrequired":return{...e,loading:!1,isError:!0,isUsernameError:!0,isPasswordError:!0,otploading:!1,userMessage:r?.payload?.error,userMessageforpassword:r?.payload?.errorPassword,userMessageforusername:r?.payload?.errorUsername,username:"",transactionID:""};case"passwordVerificationFailure":return{...e,loading:!1,isError:!0,isUsernameError:!1,isPasswordError:!0,otploading:!1,userMessage:r?.payload?.error,userMessageforpassword:r?.payload?.errorPassword,username:"",transactionID:""};case"usernameVerificationFailure":return{...e,loading:!1,isError:!0,isUsernameError:!0,isPasswordError:!1,otploading:!1,userMessage:r?.payload?.error,userMessageforusername:r?.payload?.errorUsername,username:"",transactionID:""};case"inititatePasswordVerification":return{...e,loading:!0,isError:!1,isUsernameError:!1,isPasswordError:!1,otploading:!1,userMessage:"",userMessageforusername:"",userMessageforpassword:"",username:"",transactionID:"",access_token:""};case"passwordRotation":return{...e,loading:!1,username:r?.payload?.username,access_token:r?.payload?.access_token,token_type:r?.payload?.token_type};case"passwordRotationsuccess":return{...e,loading:!1,otpmodelClose:Boolean(r?.payload?.otpmodelclose)};case"passwordVerificationSuccessful":return{...e,loading:!1,otploading:!1,transactionID:r?.payload?.transactionID,username:r?.payload?.username,auth_type:r?.payload?.auth_type,OtpuserMessage:"",access_token:r?.payload?.access_token,token_type:r?.payload?.token_type,otpmodelClose:!1,currentFlow:"OTP",authType:r?.payload?.authType,auth_data:r?.payload?.auth_data,otpValidFor:r?.payload?.otpValidFor,company_ID:r?.paylod?.company_ID};case"inititatebiometricVerification":return{...e,loading:!0,otploading:!0,OtpuserMessage:"",otpmodelClose:!1};case"biometricVerificationFailure":return{...e,loading:!1,isError:!0,isBiometricError:!0,userMessage:r?.payload?.error,isScanning:!1};case"biometricVerificationSuccessful":return{...e,loading:!1,isError:!1,isBiometricError:!1,state:r.payload,isScanning:!1};case"OTPVerificationComplate":return{...e,loading:!1,otploading:!1,OtpuserMessage:""};case"OTPVerificationFailed":return{...e,loading:!1,otploading:!1,OtpuserMessage:r?.payload?.error,otpmodelClose:Boolean(r?.payload?.otpmodelclose)};case"OTPResendSuccess":return{...e,transactionID:r?.payload?.transactionID};case"backToUsernameVerification":return{...oo,isPasswordError:r?.payload?.isError,userMessageforpassword:r?.payload?.errorMessage};default:return e}},to=({bannerDetails:a,logoUrl:t,logoTitle:i,loginFn:s,veirfyUsernameandPassword:l,verifyOTP:d,OTPResendRequest:c,ResetPassword:u,LanguageComponent:h,forgotPasswordEndpoint:w})=>{const y=$r(),[x,b]=f(ao,oo),[v,P]=p(!1),S=m(0),[T,N]=p(null),k=m(null),{t:D}=q(),B=m(1);g((()=>{if(Boolean(t))if(Qr(t)){let e=n.base64toBlob(t);k.current="object"==typeof e&&Boolean(e)?URL.createObjectURL(e):"",N(k.current)}else N(t)}),[t]);const _=async e=>{if(Boolean(e)&&6===e.toString().length){b({type:"inititateOTPVerification"});const{status:r,data:o,message:a}=await d(x.transactionID,x.username,e,x.access_token,x.token_type,x.authType);"0"===r?(b({type:"OTPVerificationComplate"}),s(o)):b("999"===r?{type:"OTPVerificationFailed",payload:{error:a,otpmodelclose:!0}}:{type:"OTPVerificationFailed",payload:{error:a,otpmodelclose:!1}})}else b({type:"OTPVerificationFailed",payload:{error:"Please enter a 6 digit OTP number"}})},M=(e=!1,r="")=>{b({type:"backToUsernameVerification",payload:{isError:e,errorMessage:r}})};return e(o,{children:r(C,{container:!0,style:{height:"100vh",overflow:"hidden"},children:[e(eo,{bannerDetails:a}),r(C,{item:!0,xs:11,md:6,lg:6,sm:6,children:[t?e(C,{container:!0,direction:"row",justifyContent:"flex-end",alignItems:"center",padding:"25px",maxWidth:"210px",ml:"auto",children:e(E,{describeChild:!0,title:i??"",children:e("img",{src:Boolean(T)?T:"",alt:"Logo",width:"100%"})})}):null,h?e(C,{container:!0,direction:"row",justifyContent:"flex-end",alignItems:"center",padding:"0 35px 0 0",maxWidth:"180px",ml:"auto",children:e(h,{})}):null,v?e(ro,{classes:y,ResetPassword:u,open:v,username:x.username,accessToken:x.access_token,tokenType:x.token_type,handleClose:e=>{"0"===e&&b({type:"passwordRotationsuccess",payload:{otpmodelclose:!0}}),P(!1)}}):e(o,{children:"username"===x.currentFlow?e(Kr,{classes:y,loginState:x,verifyUsernamePassword:async(e,r)=>{if(Boolean(e)&&Boolean(r)){b({type:"inititatePasswordVerification"});try{const{status:o="",data:a=null,message:t="",responseType:n="",access_token:i=null}=await l(e,r);"0"===o&&"S"===n?(b({type:"passwordRotation",payload:{username:e,access_token:i?.access_token||"",token_type:i?.token_type||""}}),P(!0)):b("0"===o?{type:"passwordVerificationSuccessful",payload:{transactionID:a?.REQUEST_CD,username:e,access_token:i?.access_token,token_type:i?.token_type,authType:a?.AUTH_TYPE,auth_data:[{company_ID:a?.BASE_COMP_CD??"",branch_cd:a?.BASE_BRANCH_CD}],otpValidFor:a?.OTP_VALID}}:{type:"passwordVerificationFailure",payload:{error:t,errorPassword:t}})}catch(e){throw new Error("Error occurred while verifying username and password: "+e)}}else Boolean(e)||Boolean(r)?Boolean(e)?b({type:"passwordVerificationFailure",payload:{error:"PasswordisRequired",errorPassword:"PasswordisRequired"}}):b({type:"usernameVerificationFailure",payload:{error:"UsernameisRequired",errorUsername:"UsernameisRequired"}}):b({type:"usernameandpasswordrequired",payload:{error:"UsernamenandPasswordisRequired",errorUsername:"UsernameisRequired",errorPassword:"PasswordisRequired"}})},forgotPasswordEndpoint:w},"username"):e(o,{children:"OTP"===x.authType?e(Xr,{OTPResendRequest:c,classes:y,loginState:x,VerifyOTP:_,previousStep:M,OTPError:D(x?.OtpuserMessage??""),setOTPError:e=>{b({type:"OTPVerificationFailed",payload:{error:e}})},open:!0,handleClose:M,resendFlag:"LOGIN",setNewRequestID:e=>{b({type:"OTPResendSuccess",payload:{transactionID:e}}),B.current=B.current+1},otpresendCount:B.current},"otp"):"TOTP"===x.authType?r(o,{children:[" ",e(Yr,{OTPResendRequest:c,classes:y,handleClose:M,loginState:x,VerifyOTP:_,OTPError:x?.OtpuserMessage??"",setOTPError:e=>{b({type:"OTPVerificationFailed",payload:{error:e}})},resendFlag:"LOGIN",setNewRequestID:e=>{b({type:"OTPResendSuccess",payload:{transactionID:e}}),B.current=B.current+1},otpresendCount:B.current},"OTPForm")]}):e(Jr,{classes:y,loginState:x,verifyFinger:async()=>{try{b({type:"inititateUserFingerScanner"});const e=await(async()=>{var e=JSON.stringify({Quality:60,TimeOut:10});const r=await fetch("http://localhost:8004/mfs100/capture",{method:"POST",headers:{Accept:"application/json","Content-Type":"application/json"},body:e});return await r.json()})();if("0"===e?.ErrorCode){b({type:"inititateUserFingerVerification"});const r=await Zr(x.auth_data,e.IsoTemplate);if(r.isError)b({type:"biometricVerificationFailure",payload:{error:r?.errorMessage??"Something went wrong."}});else{const{status:e,data:o,message:a}=await d(x.transactionID,x.username,String(r?.sr_cd??"0"),x.access_token,x.token_type,x.authType,r.status?"Y":"N");"0"===e&&r.status?(b({type:"biometricVerificationSuccessful"}),s(o)):"0"!==e||r.status?"99"===e?b({type:"biometricVerificationFailure",payload:{error:a??"Finger Not Match.Please Try Again"}}):"999"===e?(b({type:"biometricVerificationFailure",payload:{error:a??"Finger Not Match.Please Try Again"}}),M(!0,a??"Finger Not Match.Please Try Again")):b({type:"biometricVerificationFailure",payload:{error:a??"Finger Not Match.Please Try Again"}}):(S.current=S.current+1,b({type:"biometricVerificationFailure",payload:{error:"Finger Not Match.Please Try Again"}}),S.current>=3&&M(!0,"Finger Not Match.Please Try Again"))}}else b({type:"biometricVerificationFailure",payload:{error:e?.ErrorMessage??D("Biometric.MFS100NotFound")}})}catch(e){b({type:"biometricVerificationFailure",payload:{error:e?.message??D("Biometric.Unknownerroroccured")}})}},previousStep:M},"biometric")})})]})]})})},no=({classes:n,loginState:i,onSubmit:s,navigate:l,loginPageEndpoint:d})=>{const[c,h]=p({userName:1===i.workingState?i?.username:"",mobileno:"",password:"",confirmpassword:""}),f=m(null),w=m(null),y=m(null),[v,C]=p(0),[k,E]=p(0),D=Date.now()<v,B=Date.now()<k,[,_]=p(),M=m(null);g((()=>()=>clearTimeout(M.current)),[]);const{t:I}=q(),O=e=>{const r=e.target.name;let o=e.target.value;"userName"===r&&o&&(i.isUsernameError=!1),"mobileno"===r&&o&&(o=o.replace(/\D/g,""),Boolean(o)&&(i.isMobileError=!1)),h((e=>({...e,[r]:o})))};return g((()=>{1===i.workingState&&setTimeout((()=>{w?.current?.focus?.()}),2e3)}),[i.workingState]),e(u,{children:r("div",{className:n.formWrap,children:[e(a,{autoFocus:!0,label:I("UserID"),placeholder:String(I("UserID")),fullWidth:!0,type:"text",name:"userName",value:c.userName||"",onChange:O,error:i.isUsernameError,helperText:i.isUsernameError?I(i.userMessageforusername):"",InputLabelProps:{shrink:!0},disabled:!!i.loading||0!==i.workingState,autoComplete:"off",ref:f,inputProps:{maxLength:16},onKeyDown:e=>{"Enter"===e.key&&y?.current?.click?.()},style:{paddingBottom:"8px"}}),0===i.workingState?e(a,{label:I("MobileNo"),placeholder:"Enter Mobile No.",fullWidth:!0,type:"text",name:"mobileno",value:c.mobileno||"",onChange:O,error:i.isMobileError,helperText:i.isMobileError?I(i.userMessageforMobileno):"",InputLabelProps:{shrink:!0},disabled:!!i.loading||0!==i.workingState,autoComplete:"off",onKeyDown:e=>{"Enter"===e.key&&y?.current?.click?.()},inputProps:{maxLength:13},style:{paddingBottom:"8px"}}):null,1===i.workingState?r(o,{children:[e(a,{autoFocus:!0,label:I("Password"),placeholder:"Enter Password",fullWidth:!0,type:D?"text":"password",name:"password",value:c.password||"",onChange:O,error:i.isPasswordError,helperText:i.isPasswordError?I(i.userMessageforPassword):"",InputLabelProps:{shrink:!0},disabled:i.loading,autoComplete:"off",ref:w,onKeyDown:e=>{"Enter"===e.key&&y?.current?.click?.()},InputProps:{endAdornment:e(P,{position:"end",children:e(S,{"aria-label":"toggle password visibility",onClick:()=>{D?D&&C(0):(C(Date.now()+5e3),M.current=setTimeout((()=>_(Date.now())),5e3))},onMouseDown:e=>e.preventDefault(),disabled:i.loading,children:e(D?x:b,{})})})},inputProps:{maxLength:16},style:{paddingBottom:"8px"}}),e(a,{label:I("ConfirmPassword"),placeholder:String(I("EnterConfirmPassword")),fullWidth:!0,type:B?"text":"password",name:"confirmpassword",value:c.confirmpassword||"",onChange:O,error:i.isConfirmPasswordError,helperText:i.isConfirmPasswordError?I(i.userMessageforconfirmPassword):"",InputLabelProps:{shrink:!0},disabled:i.loading,autoComplete:"off",onKeyDown:e=>{"Enter"===e.key&&y?.current?.click?.()},InputProps:{endAdornment:e(P,{position:"end",children:e(S,{"aria-label":"toggle password visibility",onClick:()=>{B?B&&E(0):(E(Date.now()+5e3),M.current=setTimeout((()=>_(Date.now())),5e3))},onMouseDown:e=>e.preventDefault(),disabled:i.loading,children:e(B?x:b,{})})})},inputProps:{maxLength:16},style:{paddingBottom:"8px"}})]}):null,i.isApiError?e(N,{style:{color:"red"},children:i.apierrorMessage}):null,e("div",{style:{marginTop:"20px",display:"flex",flexDirection:"row-reverse"},children:e("div",{style:{flex:"auto",textAlign:"center",marginTop:"5px",marginBottom:"17px"},children:r("div",{children:[e(t,{style:{borderRadius:"10px",marginRight:"5px"},disabled:i.loading,onClick:()=>{l(d)},starticon:"West",rotateIcon:"scale(1.4) rotateX(360deg)",children:I("backtologin")}),e(t,{style:{borderRadius:"10px"},disabled:i.loading,onClick:()=>{s(c,i.workingState)},ref:y,endicon:i.loading?void 0:"East",rotateIcon:"scale(1.4) rotateX(360deg)",children:i.loading?e(T,{size:25,thickness:4.6}):I("Next")})]})})})]})})},io=e=>Boolean(e)?/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)(?!.*\s)/.test(e)?e.length<8||e.length>16?"Password must be between 8 and 16 characters long.":"":"Password must be 8-16 characters long, containing at least one uppercase letter, one lowercase letter, one number, and one special character, with no spaces allowed.":"Password is Required",so={isUsernameError:!1,userMessageforusername:"",loading:!1,isMobileError:!1,userMessageforMobileno:"",isPasswordError:!1,userMessageforPassword:"",isConfirmPasswordError:!1,userMessageforconfirmPassword:"",workingState:0,isApiError:!1,apierrorMessage:"",otploading:!1,OtpuserMessage:"",otpmodelClose:!1,requestCd:"",username:"",auth_type:"O",transactionID:""},lo=(e,r)=>{switch(r.type){case"verifyUserNameandMobileNoFailed":return{...e,loading:!1,isUsernameError:r?.payload?.isUsernameError??!1,isMobileError:r?.payload?.isMobileError??!1,userMessageforusername:r?.payload?.userMessageforusername??"",userMessageforMobileno:r?.payload?.userMessageforMobileno??"",isApiError:r?.payload?.isApiError??!1,apierrorMessage:r?.payload?.apierrorMessage??"",requestCd:"",username:""};case"initverifyUserNameandMobileNo":return{...e,loading:!0,isUsernameError:!1,isMobileError:!1,requestCd:"",username:""};case"verifyUserNameandMobileNoSuccess":return{...e,loading:!1,isUsernameError:!1,isMobileError:!1,workingState:0,isApiError:!1,apierrorMessage:"",requestCd:r?.payload?.requestCd??"",username:r?.payload?.username??"",auth_type:r?.payload?.auth_type,company_ID:r?.payload?.company_ID,branch_cd:r?.payload?.branch_cd,otpValidFor:r?.payload?.otpValidFor};case"inititateOTPVerification":return{...e,loading:!1,otploading:!0,OtpuserMessage:"",otpmodelClose:!1};case"OTPVerificationComplate":return{...e,loading:!1,otploading:!1,OtpuserMessage:"",workingState:1,otpmodelClose:Boolean(r?.payload?.otpmodelclose)};case"OTPVerificationFailed":return{...e,otploading:!1,OtpuserMessage:r?.payload?.error,otpmodelClose:Boolean(r?.payload?.otpmodelclose)};case"verifyPasswordFailed":return{...e,loading:!1,isPasswordError:r?.payload?.isPasswordError??!1,isConfirmPasswordError:r?.payload?.isConfirmPasswordError??!1,userMessageforPassword:r?.payload?.userMessageforPassword??"",userMessageforconfirmPassword:r?.payload?.userMessageforconfirmPassword??"",isApiError:!1,apierrorMessage:""};case"initverifyPasswordSetReq":return{...e,loading:!0,isPasswordError:!1,isConfirmPasswordError:!1};case"passwordRegistaredSuccess":return{...e,loading:!1,isPasswordError:!1,isConfirmPasswordError:!1};case"OTPResendSuccess":return{...e,requestCd:r?.payload?.requestCd};default:return e}},co=({screenFlag:a,updatenewPassword:t,veirfyUsernameandMobileNo:i,verifyOTPForPWDReset:s,logoUrl:l,logoTitle:d,LanguageComponent:c,bannerDetails:u,navigate:h,loginPageEndpoint:w})=>{const y=$r(),[x,b]=f(lo,so),[P,S]=p(!1),{enqueueSnackbar:T}=K(),N=m(1),{t:k}=q(),[E,D]=p(null),B=m(null);g((()=>{if(Boolean(l))if(Qr(l)){let e=n.base64toBlob(l);B.current="object"==typeof e&&Boolean(e)?URL.createObjectURL(e):"",D(B.current)}else D(l)}),[l]);const _=(e,r)=>{if(0===r){let r={isUsernameError:!1,isMobileError:!1,userMessageforusername:"",userMessageforMobileno:""};return Boolean(e.userName)||(r.isUsernameError=!0,r.userMessageforusername="UsernameisRequired"),Boolean(e.mobileno)?(isNaN(e.mobileno)||10!==e.mobileno.length&&13!==e.mobileno.length)&&(r.isMobileError=!0,r.userMessageforMobileno="Please enter valid Mobile No."):(r.isMobileError=!0,r.userMessageforMobileno="MobileNoisRequired"),b({type:"verifyUserNameandMobileNoFailed",payload:r}),!(r.isMobileError||r.isUsernameError)}if(1===r){let r={isPasswordError:!1,userMessageforPassword:"",isConfirmPasswordError:!1,userMessageforconfirmPassword:""},o=io(e.password);return Boolean(o)&&(r.isPasswordError=!0,r.userMessageforPassword=o),Boolean(e.confirmpassword)?Boolean(e.password)&&e.password!==e.confirmpassword&&(r.isConfirmPasswordError=!0,r.userMessageforconfirmPassword="New Password and Confirm Password did not matched"):(r.isConfirmPasswordError=!0,r.userMessageforconfirmPassword="Confirmpasswordisrequired"),b({type:"verifyPasswordFailed",payload:r}),!(r.isConfirmPasswordError||r.isPasswordError)}return!0};return e(o,{children:r(C,{container:!0,style:{height:"100vh",overflow:"hidden"},children:[e(eo,{bannerDetails:u}),r(C,{item:!0,xs:6,md:6,lg:6,sm:6,children:[l?e(C,{container:!0,direction:"row",justifyContent:"flex-end",alignItems:"center",padding:"31px",maxWidth:"210px",ml:"auto",children:e("img",{src:Boolean(E)?E:"",alt:"Logo",width:"100%"})}):null,c?e(C,{container:!0,direction:"row",justifyContent:"flex-end",alignItems:"center",padding:"0 35px 0 0",maxWidth:"180px",ml:"auto",children:e(c,{})}):null,e(v,{maxWidth:"xs",children:r(C,{alignItems:"center",style:{paddingTop:"20px"},children:[e("h2",{style:{margin:"10px 0"},children:1===x.workingState?k("Setnewpassword"):"totp"===a?"Forgot TOTP":k("ForgotPassword")}),P?e(Yr,{classes:y,handleClose:()=>{S(!1)},loginState:x,VerifyOTP:async e=>{if(Boolean(e)&&6===e.toString().length){b({type:"inititateOTPVerification"});const{status:r,data:o,message:t}=await s(x?.requestCd,x?.username,e,x?.auth_type,a);"0"===r?"totp"===a?(T(t,{variant:"success"}),h(w)):b({type:"OTPVerificationComplate",payload:{otpmodelclose:!0}}):"99"===r?b({type:"OTPVerificationFailed",payload:{error:t}}):(T(t,{variant:"error"}),h(w))}else b({type:"OTPVerificationFailed",payload:{error:"Please enter a 6 digit OTP number"}})},OTPError:k(x?.OtpuserMessage??""),setOTPError:e=>{b({type:"OTPVerificationFailed",payload:{error:e}})},resendFlag:"FORGET_PW",setNewRequestID:e=>{b({type:"OTPResendSuccess",payload:{requestCd:e}}),N.current=N.current+1},otpresendCount:N.current,OTPResendRequest:void 0}):e(no,{classes:y,loginState:x,onSubmit:async(e,r)=>{if(_(e,r))if(0===r){b({type:"initverifyUserNameandMobileNo"});const{status:r,data:o,message:t}=await i(e?.userName.toLowerCase(),e?.mobileno,a);"0"===r?(b({type:"verifyUserNameandMobileNoSuccess",payload:{requestCd:String(o?.TRAN_CD??""),username:e?.userName,auth_type:o?.AUTH_TYPE,company_ID:o?.COMP_CD,branch_cd:o?.BRANCH_CD,otpValidFor:o?.OTP_VALID}}),S(!0)):b({type:"verifyUserNameandMobileNoFailed",payload:{isApiError:!0,apierrorMessage:t}})}else if(1===r){b({type:"initverifyPasswordSetReq"});const{status:r,data:o,message:a}=await t(x?.requestCd,x?.username,e?.password);"0"===r?(b({type:"passwordRegistaredSuccess"}),T("Password successfully reset",{variant:"success"}),h(w)):"99"===r?b({type:"verifyPasswordFailed",payload:{isApiError:!0,apierrorMessage:a}}):(T(a,{variant:"error"}),h(w))}},navigate:h,loginPageEndpoint:w})]})})]})]})})},po={gridConfig:{dense:!0,gridLabel:"Access Branch List",rowIdColumn:"BRANCH_CD",defaultColumnConfig:{width:400,maxWidth:450,minWidth:300},allowColumnReordering:!1,disableSorting:!1,hideHeader:!1,disableGroupBy:!0,enablePagination:!1,containerHeight:{min:"68vh",max:"68vh "},allowFilter:!1,allowColumnHiding:!1,allowRowSelection:!1,isCusrsorFocused:!0,hideFooter:!0},columns:[{accessor:"BRANCH_CD",columnName:"Branch Code",sequence:1,alignment:"left",componentType:"default",width:200,minWidth:140,maxWidth:220},{accessor:"BRANCH_NM",columnName:"Branch Name",sequence:2,alignment:"left",componentType:"default",width:280,minWidth:280,maxWidth:420},{accessor:"DISP_STATUS",columnName:"Status",sequence:3,alignment:"left",componentType:"default",width:200,minWidth:140,maxWidth:220},{accessor:"BEGIN_DATETIME",columnName:"Begin Time",sequence:4,alignment:"left",componentType:"dateTime",width:222,minWidth:140,maxWidth:240},{accessor:"END_DATETIME",columnName:"End Time",sequence:5,alignment:"left",componentType:"dateTime",width:222,minWidth:140,maxWidth:240},{accessor:"DAYEND_STATUS",columnName:"Dayend Status",sequence:6,componentType:"default",isVisible:!1},{accessor:"EOD_RUNNING_STATUS",columnName:"EOD Running Status",sequence:6,componentType:"default",isVisible:!1},{accessor:"BASE_COMP_CD",columnName:"Base Comp Cd",sequence:6,componentType:"default",isVisible:!1},{accessor:"BASE_BRANCH_CD",columnName:"Base Branch Cd",sequence:6,componentType:"default",isVisible:!1},{accessor:"COMP_CD",columnName:"Comp Cd",sequence:6,componentType:"default",isVisible:!1},{accessor:"COMP_NM",columnName:"Comp Name",sequence:6,componentType:"default",isVisible:!1}]};Gr("*{box-sizing:border-box}*,.sideImage{margin:0;padding:0}.sideImage{display:flex;height:100%;position:relative;z-index:1}.bank-name,.emp-id{font-size:18px;font-weight:600;line-height:1em;margin:8px 0}.bank-name{word-wrap:break-word}.name-heading{color:var(--theme-color1);font-weight:400;position:relative;z-index:1}.name-heading span{color:var(--theme-color1);font-weight:700}");var mo="waving-hand.png";const go=y((e=>({heading_user_img:{width:"40px",height:"40px"},heading_user_img_border:{border:"2px dashed var(--theme-color3)",borderRadius:"50%",padding:"4px"},logo:{height:"38px"}})));var uo="profile-default.png";const ho=[{actionName:"back",actionLabel:"Back",multiple:void 0,rowDoubleClick:!1,alwaysAvailable:!0},{actionName:"proceed",actionLabel:"Proceed",multiple:!1,rowDoubleClick:!0}],fo=({selectionMode:a,authState:t,isBranchSelectedFn:n,isLoggedInFn:i,logoutFn:c,logos:p,logo:m,navigate:h,BranchSelectionGridDataApiFn:f,GetMenuDataApiFn:y,sideImage:x,branchSelectFn:b,dashboardUrl:v,loginUrl:P,appTranCd:S})=>{const T=go(),{enqueueSnackbar:N}=K(),{data:k,isLoading:O,isFetching:A,refetch:R,error:L,isError:U}=J(["BranchSelectionGridData"],(()=>f()));g((()=>()=>{s.removeQueries(["BranchSelectionGridData",{}])}),[]),g((()=>{i()?n()&&"C"!==a&&h(v):h(P)}),[n,i]);const F=Z(y,{onSuccess:(e,r)=>{b({menulistdata:e,branchCode:r?.BRANCH_CD,branch:r?.BRANCH_NM,baseBranchCode:r?.BASE_BRANCH_CD})}}),W=F.error,V=w((e=>{"proceed"===e.name?0===e.rows?.length?N("Please Select Branch",{variant:"error"}):"C"===e.rows?.[0]?.data?.STATUS?N("Branch is in Day End Status.~rPlease contact system Vendor.",{variant:"error"}):F.mutate({BASE_COMP_CD:e.rows?.[0]?.data?.BASE_COMP_CD??"",BASE_BRANCH_CD:e.rows?.[0]?.data?.BASE_BRANCH_CD??"",COMP_CD:e.rows?.[0]?.data?.COMP_CD??"",BRANCH_CD:e.rows?.[0]?.data?.BRANCH_CD??"",GROUP_NAME:t?.groupName??"",APP_TRAN_CD:S,COMP_NM:e.rows?.[0]?.data?.COMP_NM??"",BRANCH_NM:e.rows?.[0]?.data?.BRANCH_NM??"",DAYEND_STATUS:e.rows?.[0]?.data?.DAYEND_STATUS??"",EOD_RUNNING_STATUS:e.rows?.[0]?.data?.EOD_RUNNING_STATUS??"",IS_UPD_DEF_BRANCH:t?.user?.isUpdDefBranch??"",COMP_BASE_BRANCH_CD:e.rows?.[0]?.data?.COMP_BASE_BRANCH_CD??"",selectionMode:a}):"back"===e.name&&("C"===a?h(v,{replace:!0}):c())}),[h,k,F]);g((()=>{var e=k?.some((e=>"O"===e.STATUS));!1===e&&(N("Branch is in Day End Status.~rPlease contact system Vendor.",{variant:"error"}),c()),1===k?.length&&"O"===k?.[0]?.STATUS&&V({name:"proceed",rows:[{data:{...k[0]}}]})}),[JSON.stringify(k)]);const z=Q((({className:r,...o})=>e(E,{...o,classes:{popper:r}})))((({theme:e})=>({[`& .${D.tooltip}`]:{backgroundColor:e.palette.common.white,color:"rgba(0, 0, 0, 0.87)",boxShadow:e.shadows[1],fontSize:13}})));return e(o,{children:r(C,{container:!0,style:{margin:"0",padding:"0",height:"100vh"},children:[x?e(C,{item:!0,lg:1,md:1,xl:1,xs:1,sm:1,children:e("img",{className:"sideImage",src:x,alt:"side-Image"})}):null,e(C,{item:!0,lg:11,md:11,xl:11,xs:11,style:{display:"flex",justifyContent:"center"},children:r(C,{container:!0,style:{minHeight:"100vh",padding:"10px 0px 0px 0px"},lg:11,md:11,xl:11,xs:11,children:[r(C,{container:!0,style:{margin:"0",padding:"0"},lg:12,md:12,xl:12,xs:12,children:[e(C,{xs:12,sm:1,md:1,lg:1,xl:1,sx:{display:"flex",alignItems:"center"},children:e(B,{direction:"row",spacing:4,ml:1,children:e(_,{className:T.heading_user_img_border,sx:{cursor:"pointer"},children:e(z,{title:r(o,{children:[r("div",{children:["User ID : ",t?.user?.id??""]}),r("div",{children:["Role : ",t?.roleName??""]}),e("div",{children:'Last Unsuccessful Login : ""'})]}),placement:"bottom-start",children:e(M,{className:T.heading_user_img,alt:"Remy Sharp",src:Boolean(p?.profile)?p?.profile:uo})})})})}),r(C,{xs:12,sm:5,md:5,lg:5,xl:5,sx:{justifyContent:"center",display:"flex",flexDirection:"column"},children:[r("h1",{className:"name-heading",style:{fontSize:"24px",margin:"4px 0px"},children:["Welcome ",e("span",{children:`${t?.user?.name??""},`})]}),r("div",{style:{display:"flex",alignItems:"center",gap:10},children:[e("h3",{style:{margin:"4px 0px"},children:(()=>{let e,o=(new Date).getHours();return o<12?e="morning":o>=12&&o<=16?e="afternoon":o>=16&&o<=24&&(e="evening"),r("span",{children:["Good ",e,","]})})()}),e("img",{src:mo,alt:"",style:{height:"18px"}})]})]}),e(C,{xs:12,sm:1,md:1,lg:1,xl:1,sx:{display:"flex",justifyContent:"center",alignItems:"center"},children:e(B,{direction:"row",justifyContent:"flex-start",spacing:2,children:e(_,{className:T.heading_user_img_border,children:e(M,{className:T.heading_user_img,alt:"Remy Sharp",src:Boolean(p?.bank)?p?.bank:"BecomePartnerImg.svg"})})})}),r(C,{xs:12,sm:3,md:3,lg:3,xl:3,sx:{display:"flex",flexDirection:"column",justifyContent:"center"},children:[e("div",{className:"bank-name-container",style:{fontSize:"14px"},children:e("p",{className:"bank-name",children:`Bank Name: ${t?.companyName??""}`})}),e("p",{className:"emp-id",children:`Emp. Id: ${t?.user?.employeeID??""}`})]}),r(C,{xs:12,sm:3,md:3,lg:2,xl:2,sx:{display:"flex",alignItems:"center",justifyContent:"right"},children:[" ",e("div",{children:e("img",{src:Boolean(p?.logo)?p?.logo:m,alt:"CbsEnfinity",className:T.logo})})]})]}),U?e(u,{children:e("div",{style:{width:"100%",paddingTop:"10px"},children:e(l,{severity:L?.severity??"error",errorMsg:L?.error_msg??"Error",errorDetail:L?.error_detail??""})})}):F.isError&&F.error?e(u,{children:e("div",{style:{width:"100%",paddingTop:"10px"},children:e(l,{severity:W.severity??"error",errorMsg:W.error_msg??"Error",errorDetail:W.error_detail??""})})}):null,e(d,{finalMetaData:po,data:k??[],setData:()=>null,actions:ho,setAction:V,loading:O||A||F.isLoading},"branchSelection"),U||0===k?.length?e(I,{sx:{backgroundColor:"var(--theme-color3)",position:"absolute",right:"113px",bottom:"20px",width:"7rem","&:hover":{backgroundColor:"var(--theme-color3)"}},onClick:()=>{"C"===a?h(v,{replace:!0}):c()},children:"Back"}):null]})})]})})},wo=r=>e(i,{children:e(fo,{...r})}),yo=y((e=>({appBar:{transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),color:"#0063A3",height:"80px",background:"var(--theme-color2)",boxShadow:"0px 1px 0px -0.5px #DEE0E2"},searchBar:{width:290,border:"none",color:"rgba(0, 0, 0, 0.87) !important",backgroundColor:"rgb(235 237 238 / 26%)!important","& input":{width:"100% !important"}},searchList:{position:"absolute",background:"#fff",width:"100%",borderRadius:"6px",boxShadow:"0 12px 25px rgba(0,0,0,.3)",top:"120%",height:"auto",maxHeight:"325px",overflowY:"auto","& .list-links":{background:"none",border:"none",outline:"none",cursor:"pointer",textDecoration:"none",padding:"0.7rem 1rem",fontSize:"0.90rem",textAlign:"left",borderBottom:"1px solid #ddd",color:"#222 !important",fontWeight:500,"&:hover, &.active":{backgroundColor:"#f4f4f4"}}},appBarShift:{paddingLeft:"0px",transition:e.transitions.create(["width","margin"],{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen,background:"rgba(250, 251, 255, 0.9)"})},heading_user_dtl:{width:"458px",height:"73px",left:"37px",top:"calc(50% - 73px/2)"},heading_user_img:{width:"40px",height:"40px"},heading_user_img_border:{border:"2px dashed var(--theme-color3)",borderRadius:"50%",padding:"4px"},toolbar:{minHeight:"80px",paddingLeft:"0px",height:"80px"},title:{flexGrow:1,padding:e.spacing(.5,0),color:"var(--theme-color1)"},searchRoot:{fontFamily:e.typography.fontFamily,position:"relative",boxShadow:"0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)",marginRight:e.spacing(2),marginLeft:e.spacing(1),marginBottom:e.spacing(.25),marginTop:e.spacing(.25),borderRadius:40,backgroundColor:O(e.palette.common.white,.15),"&:hover":{backgroundColor:O(e.palette.common.white,.25)},"& $inputInput":{transition:e.transitions.create("width"),width:120,"&:focus":{width:170}}},search:{width:e.spacing(6),height:"100%",position:"absolute",pointerEvents:"none",display:"flex",alignItems:"center",justifyContent:"center"},inputRoot:{color:"inherit",marginTop:0,borderRadius:"40px"},inputInput:{padding:e.spacing(1,1,1,6)},loggedInUser:{marginLeft:e.spacing(2)},nameClass:{color:"#0063A3",fontWeight:600,textTransform:"capitalize",lineHeight:"1.4",textAlign:"left"},dropDown:{fontSize:"2rem"},vTop:{verticalAlign:"top",paddingLeft:"4px",color:"var(--theme-color1)"},userDesignation:{margin:"0px",fontWeight:500,fontSize:"0.875rem",lineHeight:1.57,color:"var(--theme-color1)"},userName:{margin:"0px",fontWeight:500,fontSize:"0.875rem",lineHeight:1.57,color:"var(--theme-color3)"},userprofilehover:{"&:hover":{backgroundColor:"var(--theme-color2)"}},lang_svg:{marginRight:"10px",width:"22px",height:"22px"},logo:{height:"38px"},version01:{margin:"0",textAlign:"center",color:"var(--theme-color3)",fontSize:"9px"},DrawerClose_icon:{color:"var(--theme-color3)",position:"static",background:"transperant","&:hover":{background:"var(--theme-color4)"},width:"46px",height:"46px"},marquee:{animation:"$marquee 10s linear infinite",animationDelay:"3s"},"@keyframes marquee":{"0%":{transform:"translateX(100%)"},"100%":{transform:"translateX(-100%)"}},popover:{popover:{maxWidth:"100%",width:"fit-content","& .MuiPopover-paper":{maxWidth:"100%"}}}}))),xo=({handleDrawerOpen:a,handleDrawerClose:t,open:n,authState:i,LanguageComponent:s,SearchComponent:l,dashboardUrl:d,logos:c,bankLogo:p,profilePic:m,handleLogout:g,handleProfile:u,navigate:h,hideGreetings:f,menuIconPosition:w="left"})=>{console.log(uo);const y=yo(),{t:x}=q(),b=Q((({className:r,...o})=>e(E,{...o,classes:{popper:r}})))((({theme:e})=>({[`& .${D.tooltip}`]:{backgroundColor:e.palette.common.white,color:"rgba(0, 0, 0, 0.87)",boxShadow:e.shadows[1],fontSize:13}})));return e(A,{position:"fixed",elevation:0,className:$(y.appBar,n&&y.appBarShift),children:r(R,{className:y.toolbar,children:[r(_,{sx:{display:"flex",justifyContent:"space-evenly",alignItems:"center",height:"80px",width:"227px",flexDirection:"right"===w?"row-reverse":"row"},children:[e(G,n?{disableRipple:!0,onClick:()=>t(),className:y.DrawerClose_icon,children:e(re,{fontSize:"large"})}:{disableRipple:!0,"aria-label":"open drawer",onClick:()=>a(),className:y.DrawerClose_icon,children:e(re,{fontSize:"large"})}),r("div",{children:[e("img",{src:Boolean(c?.logo)?c?.logo:p,alt:"CbsEnfinity",className:y.logo,onClick:e=>{e.preventDefault(),h(d??"./dashboard")}}),e("p",{className:y.version01,children:c?.version})]})]}),e(B,{direction:"row",spacing:4,mx:2,children:e(_,{className:y.heading_user_img_border,children:e(M,{className:y.heading_user_img,alt:"Remy Sharp",src:Boolean(c?.bank)?c?.bank:uo})})}),r(k,{component:"h1",variant:"h6",color:"inherit",noWrap:!0,className:y.title,children:[e(_,{style:{marginBottom:"8px",fontSize:"17px",color:"var(--theme-color1)",width:"555px"},className:$({[y.marquee]:i?.companyName.length>55}),children:i?.companyName||""}),e("div",{style:{display:"flex",gap:"8px"},children:r("div",{style:{color:"var(--theme-color6)"},children:[r(k,{variant:"caption",display:"block",lineHeight:0,fontSize:"11px",children:[x("appBar.Branch"),":",i?.user?.branchCode??"001 ","-",i?.user?.branch??""]}),r(k,{variant:"caption",display:"inline",fontSize:"11px",children:[x("appBar.WorkingDate"),":"," ",Boolean(i?.workingDate)?bo(oe(new Date(i?.workingDate),"dd/MM/yyyy")):"not found"]}),r(k,{marginLeft:1,variant:"caption",display:"inline",fontSize:"11px",children:[x("appBar.LastLoginDate")," :"," ",bo(i?.user?.lastLogin??"Vastrapur")]})]})})]}),r(_,{children:[f?null:e(_,{sx:{marginBottom:"3px",paddingRight:"15px"},children:r(B,{direction:"row",spacing:2,justifyContent:"flex-end",alignItems:"center",children:[r(k,{fontSize:"17px",color:"#1C1C1C",children:[(()=>{let e,o=(new Date).getHours();return o<12?e="morning":o>=12&&o<=16?e="afternoon":o>=16&&o<=24&&(e="evening"),r("span",{children:["Good ",e,","]})})()," ",i?.user?.id??""]}),e("img",{src:mo,alt:"",style:{height:"18px"}})]})}),r(_,{display:"flex",justifyContent:"space-evenly",alignItems:"center",children:[l?e(l,{}):null,s?e(s,{}):null,e(_,{maxWidth:170,display:"flex",justifyContent:"end",children:e(E,{title:"Logout",placement:"bottom",arrow:!0,children:e(G,{onClick:()=>"function"==typeof g?g():null,color:"error",sx:{backgroundColor:"rgba(235, 237, 238, 0.45)",borderRadius:"10px",height:"30px",width:"30px","&:hover":{background:"var(--theme-color2)",borderRadius:"10px",transition:"all 0.2s ease 0s",boxShadow:"rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px","& .MuiSvgIcon-root":{height:"32px",width:"32px",transition:"all 0.2s ease 0s",padding:"4px"}}},"aria-label":"show 4 new mails",children:e(ee,{})})})})]})]}),e(B,{direction:"row",spacing:4,ml:1,children:e(_,{className:y.heading_user_img_border,sx:{cursor:"pointer"},children:e(b,{title:r(o,{children:[r("div",{children:[" ",x("appBar.UserID"),": ",i?.user?.id]}),r("div",{children:[x("appBar.Role")," : ",i?.roleName]}),r("div",{children:[x("appBar.LastUnsuccessfulLogin"),' : ""']})]}),placement:"bottom-start",children:e(M,{className:y.heading_user_img,onClick:()=>"function"==typeof u?u():null,alt:"Remy Sharp",src:m??""})})})})]})})},bo=e=>Boolean(e)?e:"N/A",vo=y((e=>({drawerPaper:{position:"relative",whiteSpace:"nowrap",width:227,transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.enteringScreen}),border:"none",overflow:"hidden",zIndex:120},drawerPaperClose:{overflowX:"hidden",transition:e.transitions.create("width",{easing:e.transitions.easing.sharp,duration:e.transitions.duration.leavingScreen}),width:e.spacing(8),[e.breakpoints.up("sm")]:{width:e.spacing(8)}},toolbarIcon:{display:"flex",alignItems:"center",zIndex:9999,...e.mixins.toolbar,background:"var(--theme-color2)",justifyContent:"center",height:"80px"},hrCSS:{zIndex:9999},buttonLink:{backgroundColor:"transparent",border:"none",cursor:"pointer",textDecoration:"underline",display:"inline",margin:0,padding:0,"&:focus":{textDecoration:"none"},"$:hover":{textDecoration:"none"}}}))),Co=[];y((e=>({navBarCSS:{padding:"4px 1rem ",backgroundColor:"#fff !important",minHeight:"64px",boxShadow:"0 3px 6px rgba(0,0,0,0.03)",margin:"10px"},headerDropdown:{backgroundColor:"#fff",minWidth:"205px",boxShadow:"0 3px 6px rgba(0,0,0,0.16)",textDecoration:"none",borderBottom:"3px solid #26A456"},navLinkHeader:{color:"#555",fontSize:"14px",lineHeight:"1.2",paddingTop:"4px",paddingBottom:"4px",paddingRight:".5rem",paddingLeft:".5rem",fontWeight:600,textTransform:"capitalize",display:"flex",alignItems:"center",cursor:"pointer","& hover":{color:"#0b6fb8"}},productLink:{color:"#555",padding:"0 1rem 8px 1rem",display:"inline-block",verticalAlign:"middle",cursor:"pointer",textTransform:"capitalize"},font13:{fontSize:"13px"},loginDropdown:{width:"160px"}})));const Po=y((e=>({root:{justifyContent:"center"},drawer:{margin:"5px"},item:{display:"flex",borderRadius:"8px",marginLeft:"7px",marginTop:"6.5px",width:"90%",height:"50px",paddingLeft:e.spacing(2),paddingRight:e.spacing(2),background:"var(--theme-color2)",boxShadow:"3px 6px 9px rgba(93, 95, 121, 0.26)","& svg":{color:"var(--theme-color1)"},"&:hover":{boxShadow:"6px 6px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 0px 0px rgba(0,0,5,0.12)",background:"var(--theme-color4)",transition:"0.6s ease"}},drawerIconSize:{width:"50px",height:"50px",padding:"18px",justifyItems:"cenetr"},button:{color:"#0063A3",padding:"10px 8px",textTransform:"none",letterSpacing:0,width:"100%",textAlign:"left","&:hover":{backgroundColor:"var(--theme-color1)"}},btnRoot:{paddingLeft:"24px",justifyContent:"left "},navLinks:{overflowY:"auto",overflowX:"hidden",backgroundColor:"rgba(250, 251, 255, 0.9);",borderRadius:"10px",paddingTop:"5px"},navLinksforseparateView:{overflowY:"auto",overflowX:"hidden",height:"calc(100vh - 180px)",paddingTop:"10px"},nestedMenuLevel1:{paddingLeft:"20px",marginTop:"11px",paddingRight:e.spacing(3),height:"auto",fontSize:"13px","& div > svg":{fontSize:"14px"}},nestedMenuLevel2:{paddingLeft:"20px",marginTop:"11px",fontSize:"12px","& div > svg":{fontSize:"9px"}},listIcon:{minWidth:"30px !important",justifyItems:"center",color:"var(--theme-color6)",fontWeight:700,fontSize:"18px"},link:{fontSize:"1rem ",marginTop:"2px",marginBottom:"2px",textOverflow:"ellipsis",color:"var(--theme-color1)",marginLeft:"15px",whiteSpace:"break-spaces","& span":{fontWeight:400,whiteSpace:"break-spaces"},"& p":{color:"var(--theme-color3)",fontweight:400}},linktext:{backgroundColor:"var(--theme-color2)","&:hover":{background:"var(--theme-color1)","& div":{color:"var(--theme-color2) !important"},"& div > svg":{color:"var(--theme-color2) !important"}}},faSmall:{fontSize:"13px "},openList:{":not(activeMenuItem)":{"& > div":{backgroundColor:"rgba(0, 0, 0, 0.04)"},"& *":{color:"var(--theme-color2)"}}},openCurrent:{backgroundColor:"var(--theme-color1)","& *":{color:"var(--theme-color2)"},"&:hover":{backgroundColor:"var(--theme-color1)"}},slimList:{paddingTop:"15px",paddingBottom:"13px",height:"auto",paddingLeft:"15px",justifyItems:"center"},activeMenuItem:{backgroundColor:"var(--theme-color1)!important ","& > div":{color:"var(--theme-color2)!important"},"& svg":{color:"var(--theme-color4)"},"& hover":{"& > div":{color:"var(--theme-color3)"}},"& p":{color:"var(--theme-color6)"}}})));let So=!0;const To=({metaData:r,handleDrawerOpen:o,drawerOpen:a,setView:t,slimSize:n,setNewFilterData:i,setNewFilterView:s,isFromSeparetView:l=!1,rootUrl:d,dashboardUrl:c,navigate:p})=>{const m=Po();let g=null;return So=a,Array.isArray(r.navItems)&&(g=r.navItems.map((r=>!0===r?.seperateView?e(No,{item:r,setView:t,classes:m,level:0,slimSize:n,setNewFilterData:i,setNewFilterView:s},r.label):Array.isArray(r.children)?e(Eo,{item:r,classes:m,level:0,handleDrawerOpen:o,drawerOpen:a,slimSize:n,rootUrl:d,dashboardUrl:c,navigate:p},r.label):e(ko,{item:r,classes:m,level:0,slimSize:n,drawerOpen:a,rootUrl:d,dashboardUrl:c,navigate:p},r.label)))),e(L,{component:"nav",disablePadding:!0,className:l?m.navLinksforseparateView:m.navLinks,children:e(te,{children:g})})},No=({item:o,setView:a,level:t,classes:n,slimSize:i,setNewFilterData:s,setNewFilterView:l})=>{let d=(o.label||"").toLowerCase().substring(0,1)||"circle";const c=o.icon?e(U,{className:n.listIcon,children:e(ae,{icon:["fas",d]})}):null,p=1===t?n.nestedMenuLevel1:2===t?n.nestedMenuLevel2:"";return r(F,{button:!0,disableGutters:!0,className:$({[n.item]:!0,[p]:Boolean(p),[n.slimList]:Boolean(i),[n.drawerIconSize]:!So}),onClick:()=>{if("newfilterview"===o.viewName&&Array.isArray(o.children)){l({label:o.label,placeholder:"Search "+o.label+" Screen..."});let e=o.children.map((e=>({...e,secondaryLabel:e.user_code})));s(e)}a(o.viewName)},children:[e(E,{title:o.label,arrow:!0,placement:So?"bottom-start":"right",children:e("span",{children:c})}),So&&o.label.length>27||!Boolean(c)?e(E,{title:o.label,arrow:!0,placement:So?"bottom-start":"right",children:e(W,{primary:o.label,className:n.link,secondary:o.secondaryLabel??null})}):So?e(W,{primary:o.label,className:n.link,secondary:o.secondaryLabel??null}):null]})},ko=({item:o,classes:a,level:t,slimSize:n,drawerOpen:i,rootUrl:s,dashboardUrl:l,navigate:d})=>{const c=Do(window.location?.pathname??"",o?.href??"",o?.navigationProps,s,l);if(c){let e=document.title;document.title=e.split(" - ")[0]+" - "+o.label}let p=(o.label||"").toLowerCase().substring(0,1)||"circle";const m="process.gif"===o.icon.toLowerCase()?e(U,{className:a.listIcon,children:e(ae,{icon:["fas",p]})}):e(U,{className:a.listIcon,children:e(ae,{icon:["fas",o.icon]})}),g=1===t?a.nestedMenuLevel1:2===t?a.nestedMenuLevel2:"";return r(F,{button:!0,disableGutters:!0,className:$({[a.item]:!0,[g]:Boolean(g),[a.slimList]:Boolean(n),[a.activeMenuItem]:c,[a.drawerIconSize]:!So}),onClick:e=>{if(e.preventDefault(),o.isRouterLink){let e=o.href;if(e="/"===o.href?.substring(0,1)?o.href.substring(1):o.href,o.passNavigationPropsAsURLParmas){let r=new URLSearchParams(o?.navigationProps);d(`${e}?${r.toString()}`)}else d(`${e}`,{state:{...o?.navigationProps}})}else Boolean(o.href)&&window.open(o.href,o.rel??"_newtab")},children:[e(E,{title:o.label,arrow:!0,placement:So?"bottom-start":"right",children:e("span",{children:m})}),So&&o.label.length>27||!Boolean(m)?e(E,{title:o.label,arrow:!0,placement:So?"bottom-start":"right",children:e(W,{primary:o.label,className:a.link,secondary:o.secondaryLabel??null})}):So?e(W,{primary:o.label,className:a.link,secondary:o.secondaryLabel??null}):null]})},Eo=({item:a,classes:t,level:n,handleDrawerOpen:i,drawerOpen:s,slimSize:l,rootUrl:d,navigate:c})=>{const[m,g]=p(!1),u=a.children?.map((r=>Array.isArray(r.children)?e(Eo,{item:r,classes:t,level:n+1,handleDrawerOpen:i,drawerOpen:s,slimSize:l,rootUrl:d,navigate:c},r.label):e(ko,{item:r,classes:t,level:n+1,slimSize:l,rootUrl:d,navigate:c},r.label)));let h=(a.label||"").toLowerCase().substring(0,1)||"circle";const f="Process.gif"===a.icon?e(U,{className:t.listIcon,children:e(ae,{icon:["fas",h]})}):e(U,{className:t.listIcon,children:e(ae,{icon:["fas",a.icon]})}),w=1===n?t.nestedMenuLevel1:2===n?t.nestedMenuLevel2:"";return r(o,{children:[r(F,{button:!0,onClick:()=>{g(!m)},disableGutters:!0,className:$(m?{[t.item]:!0,[w]:Boolean(w),[t.slimList]:Boolean(l),[t.openCurrent]:!0,[t.drawerIconSize]:!So}:{[t.item]:!0,[w]:Boolean(w),[t.slimList]:Boolean(l),[t.drawerIconSize]:!So}),children:[e(E,{title:a.label,arrow:!0,placement:So?"bottom-start":"right",children:e("span",{children:f})}),s||!Boolean(f)?r(o,{children:[e(W,{primary:a.label,secondary:a.secondaryLabel??null,color:"primary",className:t.link}),e(m?ne:ie,{})]}):null]}),e(V,{in:m,timeout:"auto",unmountOnExit:!0,children:e(L,{component:"div",disablePadding:!0,className:m?t.openList:"",children:u})})]})},Do=(e,r,o,a,t)=>{if((e===`/${a}`||e===`/${a}/`)&&r===t)return!0;if("report"===r){try{if("?"+new URLSearchParams(o).toString()===window.location.search)return!0}catch(e){console.log(e)}return!1}return!(e===`/${a}`||"/"===e||!Boolean(r)||!e.includes(r))},Bo=(e,r,o)=>(Array.isArray(r)||(r=[r]),r.some((r=>o[r]?.toLocaleLowerCase?.()?.includes(e?.toLocaleLowerCase?.())))),_o=(e,r,o)=>{let a=[];for(let t=0;t<r.length;t++)if(Bo(e,o,r[t])){let{children:n,...i}=r[t];if(Array.isArray(n)&&n.length>0){let r=_o(e,n,o);r.length>0&&a.push({...i,children:r})}else a.push({...i})}return a},Mo=({metaData:o,handleDrawerOpen:a,drawerOpen:t,setView:n,label:i,icon:s,placeholder:l="Search Reports...",rootUrl:d,dashboardUrl:m,navigate:g})=>{const[u,f]=p(""),w=h((()=>_o(u,o.navItems,["label","secondaryLabel"])),[u,o.navItems]),y=Po(),x=s?e(U,{className:y.listIcon,children:e(se,{})}):null;return r("div",{style:{display:"flex",flexDirection:"column"},children:[r(F,{button:!0,className:$({[y.item]:!0,[y.nestedMenuLevel1]:!0,[y.linktext]:!0}),onClick:()=>n("/"),children:[x,e(W,{primary:i,className:y.link})]}),e(c,{sx:{overflow:"hidden"},value:u,onChange:e=>f(e.target.value),onClick:()=>{t||a()},placeholder:Boolean(l)?l:"Search Reports...",autoFocus:t}),e(To,{handleDrawerOpen:a,drawerOpen:t,setView:n,metaData:{navItems:w,config:{rel:"",target:"_blank"}},slimSize:!0,isFromSeparetView:!0,rootUrl:d,dashboardUrl:m,navigate:g})]})};le.add(de,ce,pe,me,ge,ue,he,fe,we,ye,xe,be,ve,Ce,Pe,Se,Te,Ne,ke,Ee,De,Be,_e,Me,Ie,Oe,Ae,Re,Le,Ue,Fe,We,Ve,ze,qe,He,je,Ge,$e,Ke,Xe,Ye,Je,Ze,Qe,er,rr,or,ar,tr,nr,ir,sr,lr,dr,cr,pr,mr,gr,ur,hr,fr,wr,yr,xr,br,vr,Cr,Pr,Sr,Tr,Nr,kr,Er,Dr,Br,_r,Mr,Ir,Or,Ar,Rr,Lr,Ur,Fr,Wr,Vr,zr,qr,Hr,jr);const Io=(e,r,o,a,t,n)=>{let i=Lo(e.navItems,r,o,a,t,n).map((e=>{let{children:r,...o}=e;return Array.isArray(r)&&r.length>5&&(Boolean(o.seperateView)||(o.seperateView=!0,o.viewName="newfilterview")),{...o,children:r}}));return{config:e.config,navItems:i}},Oo=(e,r)=>{if(!Array.isArray(r)||!Array.isArray(e))return!0;if(r.length<=0||e.length<=0)return!0;for(const o of r)if(e.indexOf(o)>=0)return!0;return!1},Ao=(e,r)=>!Array.isArray(r)||"number"!=typeof e||(r.length<=0||!(r.indexOf(e)>=0)),Ro=(e,r)=>{if(!Array.isArray(r)||!Array.isArray(e))return!0;if(r.length<=0||e.length<=0)return!0;for(const o of r)if(e.indexOf(o)>=0)return!0;return!1},Lo=(e,r,o,a,t,n)=>{let i=[];for(let m=0;m<e.length;m++)if(c=Number(r),p=e[m].visibleToRoles,(!Array.isArray(p)||"number"!=typeof c||p.length<=0||p.indexOf(c)>=0)&&(l=a,d=e[m].visibleToCompanies,!Array.isArray(d)||!Boolean(l)||d.length<=0||d.indexOf(l)>=0)&&Oo(o,e[m].visibleToBranches)&&Ao(Number(r),e[m].invisibleToRoles)&&Ro(n,e[m].visibleToProducts)&&(s=e[m],Array.isArray(s.children)&&s.children.length>0||Boolean(s.href))){let{children:s,...l}=e[m];if(Array.isArray(s)&&s.length>0){let e=Lo(s,r,o,a,t,n);e.length>0&&i.push({...l,children:e})}else i.push({...l,secondaryLabel:l.system_code})}var s,l,d,c,p;return i},Uo=({authState:r,handleDrawerOpen:a,open:t,rootUrl:n,dashboardUrl:i="dashboard",navigate:s})=>{const[l,d]=p("/"),[c,m]=p({}),[g,u]=p([]),f=h((()=>{let e=r?.access?.entities?.Branch??[];return Array.isArray(e)&&e.length>=0?e.map((e=>e.branchCode)):[]}),[]),w=h((()=>{let e=r?.access?.products??[];return Array.isArray(e)&&e.length>=0?e.map((e=>e.categoryCode)):[]}),[]);let y={navItems:r.menulistdata},x=Io(y,Number(r.role),f,r.companyID,r.access,w),b=Io({config:{rel:"",target:"_blank"},navItems:Co},Number(r.role),f,r.companyID,r.access,w);return"report"===l?e(Mo,{metaData:b,handleDrawerOpen:a,drawerOpen:t,setView:d,label:"Reports",icon:"table",rootUrl:n,dashboardUrl:i,navigate:s}):"newfilterview"===l?e(Mo,{metaData:{config:{rel:"",target:"_blank"},navItems:g},handleDrawerOpen:a,drawerOpen:t,setView:d,label:c?.label??"Reports",icon:"table",placeholder:c?.placeholder,rootUrl:n,dashboardUrl:i,navigate:s}):e(o,{children:e(To,{metaData:x,handleDrawerOpen:a,drawerOpen:t,setView:d,slimSize:!0,setNewFilterData:u,setNewFilterView:m,rootUrl:n,dashboardUrl:i,navigate:s})})},Fo=o=>{const a=vo();return r(z,{variant:"permanent",classes:{paper:$(a.drawerPaper,!o.open&&a.drawerPaperClose)},open:o.open,children:[e("div",{className:a.toolbarIcon}),e(Uo,{...o})]})};export{xo as AppbarWrapper,to as AuthControllerWrapper,wo as BranchSelectionGridWrapper,co as ForgotPasswordControllerWrapper,Fo as SidebarWrapper,io as ValidatePassword};
1
+ import 'regenerator-runtime/runtime';
2
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
3
+ import { TextField, GradientButton, utilFunction, ClearCacheProvider, queryClient, Alert, GridWrapper, SearchBar } from '@acuteinfo/common-base';
4
+ import { useState, useRef, useEffect, Fragment, useMemo, useReducer, useCallback } from 'react';
5
+ import { makeStyles } from '@mui/styles';
6
+ import Visibility from '@mui/icons-material/Visibility';
7
+ import VisibilityOff from '@mui/icons-material/VisibilityOff';
8
+ import { Container, Grid, InputAdornment, IconButton, CircularProgress, FormHelperText, Typography, Tooltip, tooltipClasses, Stack, Box, Avatar, Button, alpha, AppBar, Toolbar, List, ListItemIcon, ListItem, ListItemText, Collapse, Drawer } from '@mui/material';
9
+ import { useTranslation } from 'react-i18next';
10
+ import OTPInput, { ResendOTP } from 'otp-input-react';
11
+ import IconButton$1 from '@mui/material/IconButton';
12
+ import clsx from 'clsx';
13
+ import { useSnackbar } from 'notistack';
14
+ import FingerprintSharpIcon from '@mui/icons-material/FingerprintSharp';
15
+ import CryptoJS from 'crypto-js';
16
+ import { useQuery, useMutation } from 'react-query';
17
+ import { styled } from '@mui/material/styles';
18
+ import LogoutIcon from '@mui/icons-material/Logout';
19
+ import MenuOutlinedIcon from '@mui/icons-material/MenuOutlined';
20
+ import { format } from 'date-fns';
21
+ import { FontAwesomeIcon } from '@fortawesome/react-fontawesome';
22
+ import ScrollBar from 'react-perfect-scrollbar';
23
+ import { ExpandLess, ExpandMore } from '@mui/icons-material';
24
+ import ArrowBackIosNewIcon from '@mui/icons-material/ArrowBackIosNew';
25
+ import { library } from '@fortawesome/fontawesome-svg-core';
26
+ import { faHandsHelping, faUsers, faBars, faBalanceScale, faHandHoldingHeart, faTasks, faCog, faHome, faTh, faUsersCog, faCircle, faUserCircle, faHashtag, faThumbtack, faSquare, faLink, faQuestion, faPlus, faTable, faLocationArrow, faHeadset, faGears, faArrowDown, faArrowUp, faSpinner, faCircleExclamation, faRotateRight, faUserLock, faUserClock, faGripHorizontal, faFileLines, faGear, faHeadphones, faUsersGear, faMessage, faUnlock, faUserPlus, faUserCheck, faKey, faIdCard, faIdBadge, faCheck, faCheckDouble, faCircleCheck, faCircleXmark, faUserTag, faAddressCard, faChartColumn, faUserPen, faHandHolding, faHandHoldingMedical, faObjectGroup, faTowerCell, faTowerObservation, faBuilding, faMailBulk, faLandmarkFlag, faCreditCard, faHospitalSymbol, faPlugCircleBolt, faCodeBranch, faPersonCircleCheck, faBank, faServer, faNotesMedical, faA, faB, faC, faD, faE, faF, faG, faH, faI, faJ, faK, faL, faM, faN, faO, faP, faQ, faR, faS, faT, faU, faV, faW, faX, faY, faZ } from '@fortawesome/free-solid-svg-icons';
27
+ import 'lodash';
28
+
29
+ function styleInject(css, ref) {
30
+ if ( ref === void 0 ) ref = {};
31
+ var insertAt = ref.insertAt;
32
+
33
+ if (!css || typeof document === 'undefined') { return; }
34
+
35
+ var head = document.head || document.getElementsByTagName('head')[0];
36
+ var style = document.createElement('style');
37
+ style.type = 'text/css';
38
+
39
+ if (insertAt === 'top') {
40
+ if (head.firstChild) {
41
+ head.insertBefore(style, head.firstChild);
42
+ } else {
43
+ head.appendChild(style);
44
+ }
45
+ } else {
46
+ head.appendChild(style);
47
+ }
48
+
49
+ if (style.styleSheet) {
50
+ style.styleSheet.cssText = css;
51
+ } else {
52
+ style.appendChild(document.createTextNode(css));
53
+ }
54
+ }
55
+
56
+ var css_248z$2 = ":root{--theme-color1:#07288e;--theme-color2:#fff;--theme-color3:#4263c7;--theme-color4:#eceff9;--theme-color5:linear-gradient(71.66deg,#4285f4 -2.97%,#885df5 111.3%);--theme-color6:#949597}";
57
+ styleInject(css_248z$2);
58
+
59
+ const useStyles$3 = makeStyles((theme) => ({
60
+ wrapper: {
61
+ minHeight: "100vh",
62
+ boxShadow: "0 3px 6px rgba(0,0,0,0.03)",
63
+ // background: "#fff",
64
+ background: "var(--theme-color2)",
65
+ },
66
+ loginEmp: {
67
+ background: "#fff",
68
+ padding: theme.spacing(2, 4),
69
+ display: "flex",
70
+ maxWidth: "400px",
71
+ margin: "auto",
72
+ boxShadow: "0 0 20px rgba(0,0,0,0.06)",
73
+ borderRadius: "8px",
74
+ [theme.breakpoints.down("sm")]: {
75
+ width: "100%",
76
+ },
77
+ },
78
+ formWrap: {
79
+ marginTop: theme.spacing(2),
80
+ },
81
+ loginBtn: {
82
+ minWidth: "100% !important",
83
+ margin: theme.spacing(2, 0),
84
+ fontSize: "1rem",
85
+ padding: "10px .75rem",
86
+ background: "rgb(128,0,0)",
87
+ border: 0,
88
+ color: "#fff !important",
89
+ fontWeight: 600,
90
+ letterSpacing: "0.02857em",
91
+ boxShadow: "none",
92
+ textTransform: "capitalize",
93
+ alignSelf: "flex-end",
94
+ "&:hover": {
95
+ background: "#fedad8",
96
+ boxShadow: "none",
97
+ },
98
+ },
99
+ OTPTimer: {
100
+ marginTop: "10px",
101
+ color: theme.palette.primary.main,
102
+ fontWeight: 600,
103
+ },
104
+ resendLink: {
105
+ marginTop: "10px",
106
+ cursor: "pointer",
107
+ color: theme.palette.secondary.main,
108
+ fontWeight: 600,
109
+ fontSize: "0.875 rem",
110
+ },
111
+ logo: {
112
+ marginBottom: theme.spacing(1),
113
+ },
114
+ loginLeft: {
115
+ [theme.breakpoints.down("sm")]: {
116
+ display: "none",
117
+ },
118
+ },
119
+ loginRight: {
120
+ background: "#fff",
121
+ padding: theme.spacing(2, 4),
122
+ display: "flex",
123
+ maxWidth: "400px",
124
+ margin: "auto",
125
+ boxShadow: "0 0 20px rgba(0,0,0,0.06)",
126
+ borderRadius: "8px",
127
+ [theme.breakpoints.down("sm")]: {
128
+ width: "100%",
129
+ },
130
+ "& img": {
131
+ alignSelf: "center",
132
+ },
133
+ },
134
+ loginImg: {},
135
+ verifybutton: {
136
+ alignSelf: "center",
137
+ // marginBottom: "10px",
138
+ // marginTop: "10px",
139
+ padding: "5px",
140
+ },
141
+ otpButtons: {
142
+ // padding: "10px",
143
+ },
144
+ divflex: {
145
+ display: "flex",
146
+ },
147
+ otpinputpadding: {
148
+ "& input": {
149
+ marginRight: "25px !important",
150
+ border: "1.42444px solid var(--theme-color3)",
151
+ borderRadius: "10px",
152
+ width: "45px !important",
153
+ height: "45px !important",
154
+ marginBottom: "15px",
155
+ boxShadow: "0px 5.69775px 11.3955px rgba(66, 99, 199, 0.16)",
156
+ },
157
+ },
158
+ ibtnvisible: {
159
+ // padding: "7px !important",
160
+ // alignItems: "baseline",
161
+ marginBottom: "15px",
162
+ },
163
+ btnvisibleoff: {
164
+ display: "none",
165
+ },
166
+ OTPalignName: {
167
+ display: "flex",
168
+ alignItems: "center",
169
+ // justifyContent: "space-between",
170
+ marginBottom: "12px",
171
+ color: "#1C1C1C",
172
+ fonWeight: "400",
173
+ fontSize: "17px",
174
+ lineHeight: "33px",
175
+ },
176
+ resendOTPalign: {
177
+ color: "var(--theme-color3)",
178
+ fonWeight: "400",
179
+ fontSize: "17px",
180
+ lineHeight: "33px",
181
+ margin: "0 auto",
182
+ // marginTop: "15px",
183
+ // display: "block !important",
184
+ },
185
+ resendbtnLink: {
186
+ textDecoration: "underline",
187
+ color: "var(--theme-color3)",
188
+ cursor: "pointer",
189
+ "&:hover": {
190
+ textDecoration: "underline",
191
+ color: "var(--theme-color3)",
192
+ },
193
+ },
194
+ dialogTitleClass: {
195
+ background: "var(--theme-color5)",
196
+ padding: "6px 15px !important",
197
+ margin: "10px",
198
+ color: "var(--theme-color2)",
199
+ borderRadius: "4px",
200
+ "& h2": {
201
+ fontWeight: "500 !important",
202
+ },
203
+ },
204
+ lang_svg: {
205
+ marginRight: "10px",
206
+ width: "22px",
207
+ height: "22px",
208
+ },
209
+ dialogContent: {
210
+ padding: "0px 15px",
211
+ "& p": {
212
+ whiteSpace: "pre-wrap",
213
+ color: "black",
214
+ marginTop: "8px",
215
+ marginBottom: "6px",
216
+ },
217
+ },
218
+ button: {
219
+ display: "flex",
220
+ alignItems: "center",
221
+ justifyContent: "center",
222
+ flexDirection: "column",
223
+ margin: "6px",
224
+ background: "var(--theme-color1)",
225
+ "&:hover": {
226
+ background: "var(--theme-color1) !important",
227
+ },
228
+ },
229
+ }));
230
+
231
+ const UsernamePasswordField = ({ classes, loginState, verifyUsernamePassword, forgotPasswordEndpoint, }) => {
232
+ const [input, setInput] = useState({ userName: "", password: "" });
233
+ const [showPasswordTime, setShowPasswordTime] = useState(0);
234
+ const showPassword = Date.now() < showPasswordTime;
235
+ const [, forceUpdate] = useState();
236
+ const timerRef = useRef(null);
237
+ const { t } = useTranslation();
238
+ useEffect(() => {
239
+ return () => clearTimeout(timerRef.current);
240
+ }, []);
241
+ const handleChange = (event) => {
242
+ const name = event.target.name;
243
+ const value = event.target.value;
244
+ if (name === "userName" && value) {
245
+ loginState.isUsernameError = false;
246
+ }
247
+ if (name === "password" && value) {
248
+ loginState.isPasswordError = false;
249
+ }
250
+ setInput((values) => ({ ...values, [name]: value }));
251
+ };
252
+ const inputRef = useRef(null);
253
+ const inputPassRef = useRef(null);
254
+ const inputButtonRef = useRef(null);
255
+ useEffect(() => {
256
+ let timeoutCd;
257
+ if (loginState.isUsernameError) {
258
+ timeoutCd = setTimeout(() => {
259
+ inputRef?.current?.focus?.();
260
+ }, 1000);
261
+ }
262
+ else if (loginState.isPasswordError) {
263
+ timeoutCd = setTimeout(() => {
264
+ inputPassRef?.current?.focus?.();
265
+ }, 1000);
266
+ }
267
+ return () => {
268
+ if (timeoutCd) {
269
+ clearTimeout(timeoutCd);
270
+ }
271
+ };
272
+ }, [loginState.isUsernameError, loginState.isPasswordError]);
273
+ useEffect(() => {
274
+ let timeoutCd;
275
+ if (loginState?.otpmodelClose ?? false) {
276
+ setInput((values) => ({ ...values, password: "" }));
277
+ timeoutCd = setTimeout(() => {
278
+ inputPassRef?.current?.focus?.();
279
+ }, 1500);
280
+ }
281
+ return () => {
282
+ if (timeoutCd) {
283
+ clearTimeout(timeoutCd);
284
+ }
285
+ };
286
+ }, [loginState.otpmodelClose]);
287
+ return (jsx(Fragment, { children: jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", style: { paddingTop: "20px" }, children: [jsx("div", { style: {
288
+ color: "#000000 !important",
289
+ fontSize: "30px",
290
+ fontWeight: "600",
291
+ // fontFamily: "Poppins",
292
+ alignItems: "center",
293
+ fontStyle: "normal",
294
+ lineHeight: "150%",
295
+ }, children: jsx("h3", { children: t("SignIn") }) }), jsx("div", { className: "", style: {
296
+ color: "#949597",
297
+ fontSize: "16px",
298
+ fontWeight: "400",
299
+ // fontFamily: "Poppins",
300
+ alignItems: "center",
301
+ fontStyle: "normal",
302
+ width: "360px",
303
+ }, children: t("SignInWithUserIDandPassword") }), jsxs("div", { className: classes.formWrap, children: [jsx(TextField
304
+ // variant="filled"
305
+ // color="secondary"
306
+ , {
307
+ // variant="filled"
308
+ // color="secondary"
309
+ autoFocus: true, label: t("UserID"),
310
+ // placeholder="User ID"
311
+ placeholder: String(t("UserID")), style: {
312
+ marginTop: "10px",
313
+ marginBottom: "17px",
314
+ }, fullWidth: true, type: "text", name: "userName", value: input.userName.trimStart() || "", onChange: handleChange, error: loginState.isUsernameError, helperText: loginState.isUsernameError
315
+ ? t(loginState.userMessageforusername)
316
+ : "", InputLabelProps: { shrink: true }, disabled: loginState.loading, autoComplete: "off", ref: inputRef, onKeyDown: (e) => {
317
+ if (e.key === "Enter") {
318
+ inputButtonRef?.current?.click?.();
319
+ }
320
+ }, inputProps: {
321
+ maxLength: "16",
322
+ } }), jsx("div", { style: {
323
+ display: "flex",
324
+ flexDirection: "row-reverse",
325
+ marginTop: "8px",
326
+ }, children: jsx(TextField, { label: t("Password"),
327
+ // variant="filled"
328
+ // color="secondary"
329
+ placeholder: String(t("EnterPassword")), InputLabelProps: {
330
+ shrink: true,
331
+ }, fullWidth: true, type: showPassword ? "text" : "password", name: "password", value: input.password, onChange: handleChange, error: loginState.isPasswordError, helperText: loginState.isPasswordError
332
+ ? t(loginState.userMessageforpassword)
333
+ : "", disabled: loginState.loading, ref: inputPassRef, onKeyDown: (e) => {
334
+ if (e.key === "Enter") {
335
+ inputButtonRef?.current?.click?.();
336
+ }
337
+ }, InputProps: {
338
+ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(IconButton, { "aria-label": "toggle password visibility", onClick: () => {
339
+ if (!showPassword) {
340
+ setShowPasswordTime(Date.now() + 5000);
341
+ timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
342
+ }
343
+ else if (showPassword)
344
+ setShowPasswordTime(0);
345
+ }, onMouseDown: (e) => e.preventDefault(), disabled: loginState.loading, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) }) })),
346
+ }, inputProps: { maxLength: "16" } }, "employee") }), jsx("div", { style: { marginTop: "20px", display: "flex" }, children: jsx("div", { style: { flex: "auto", textAlign: "end" }, children: jsx("a", { href: forgotPasswordEndpoint ?? "", style: { color: "var(--theme-color3)" }, children: t("ForgotPassword") }) }) }), jsx("div", { style: { marginTop: "20px", display: "flex" }, children: jsx("div", { style: {
347
+ flex: "auto",
348
+ textAlign: "center",
349
+ marginTop: "5px",
350
+ marginBottom: "17px",
351
+ }, children: jsx(GradientButton, { style: {
352
+ borderRadius: loginState.loading ? "50%" : "10px",
353
+ height: loginState.loading ? "40px" : "100%",
354
+ width: loginState.loading ? "0px" : "100%",
355
+ minWidth: loginState.loading ? "40px" : "80px",
356
+ }, fullWidth: true, disabled: loginState.loading, onClick: () => verifyUsernamePassword((input.userName || "").toLowerCase(), input.password), ref: inputButtonRef, endicon: loginState.loading ? undefined : "East", rotateIcon: "scale(1.4) rotateX(360deg)", children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("Next")) }) }) })] })] }) }) }));
357
+ };
358
+
359
+ const OTPModel = ({ classes, OTPResendRequest, open, handleClose, loginState, VerifyOTP, OTPError, setOTPError, previousStep, setNewRequestID = (id) => { }, otpresendCount = 0, resendFlag, }) => {
360
+ const [OTP, setOTP] = useState("");
361
+ const [showPasswordTime, setShowPasswordTime] = useState(0);
362
+ const showPassword = Date.now() < showPasswordTime;
363
+ const [, forceUpdate] = useState();
364
+ const timerRef = useRef(null);
365
+ useEffect(() => {
366
+ return () => clearTimeout(timerRef.current);
367
+ }, []);
368
+ const [btnshow, setbtnshow] = useState(false);
369
+ const inputButtonRef = useRef(null);
370
+ const [resendotpLoading, setResendotpLoading] = useState(false);
371
+ const { enqueueSnackbar } = useSnackbar();
372
+ const { t } = useTranslation();
373
+ // const renderButton = (buttonProps) => {
374
+ // let { remainingTime, ...other } = buttonProps;
375
+ // return resendotpLoading ? (
376
+ // <a
377
+ // remainingtime={remainingTime}
378
+ // {...other}
379
+ // className={clsx(
380
+ // classes.resendbtnLink,
381
+ // !btnshow && classes.btnvisibleoff
382
+ // )}
383
+ // >
384
+ // {t("otp.ResendOTP")}
385
+ // </a>
386
+ // ) : null;
387
+ // };
388
+ const renderButton = (buttonProps) => {
389
+ let { remainingTime, ...other } = buttonProps;
390
+ return resendotpLoading ? (jsxs("a", { className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), style: { cursor: "wait" }, children: [t("otp.GetNewOTP"), " ", jsx(CircularProgress, { size: 20, color: "secondary" })] })) : (jsx("a", { remainingtime: remainingTime, ...other, className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), children: t("otp.GetNewOTP") }));
391
+ };
392
+ const ClickEventHandler = () => {
393
+ if (!Boolean(OTP) || OTP.length < 6) {
394
+ setOTPError("otp.EnterOTPDigit");
395
+ }
396
+ else {
397
+ setOTPError("");
398
+ VerifyOTP(OTP);
399
+ }
400
+ };
401
+ const handleResendClick = async () => {
402
+ setResendotpLoading(true);
403
+ const { status, data, message } = await OTPResendRequest(resendFlag === "FORGET_PW" || resendFlag === "FORGT_TOTP"
404
+ ? loginState?.requestCd
405
+ : loginState?.transactionID, loginState?.username, resendFlag, loginState.auth_data?.[0]?.company_ID, loginState.auth_data?.[0]?.branch_cd);
406
+ setResendotpLoading(false);
407
+ if (status === "0") {
408
+ setNewRequestID(data?.TRAN_CD);
409
+ setbtnshow(false);
410
+ enqueueSnackbar(message, { variant: "success" });
411
+ }
412
+ else {
413
+ enqueueSnackbar(message, { variant: "error" });
414
+ }
415
+ };
416
+ const handleCloseEvent = () => {
417
+ setOTPError("");
418
+ setOTP("");
419
+ handleClose("");
420
+ };
421
+ const renderTime = (remainingtime) => {
422
+ if (parseInt(remainingtime) === 0) {
423
+ setTimeout(() => {
424
+ setbtnshow(true);
425
+ }, 700);
426
+ }
427
+ return (jsxs("span", { className: clsx(btnshow && classes.btnvisibleoff), children: [t("otp.OtpExpired"), " ", remainingtime, " ", t("otp.second")] }));
428
+ };
429
+ useEffect(() => {
430
+ if (loginState?.otpmodelClose ?? false) {
431
+ handleCloseEvent();
432
+ }
433
+ }, [loginState.otpmodelClose]);
434
+ return (jsx(Fragment, { children: jsx(Container, { maxWidth: "sm", children: jsx(Grid, { alignItems: "center", marginTop: "4em", children: jsxs("div", {
435
+ // className={classes.formWrap}
436
+ style: {
437
+ // marginRight: "25px",
438
+ // width: "100%",
439
+ // position: "relative",
440
+ // right: "42px",
441
+ // bottom: "13px",
442
+ }, children: [jsx("div", { style: {
443
+ color: "#000000",
444
+ fontSize: "30px",
445
+ fontWeight: "600",
446
+ // fontFamily: "Poppins",
447
+ alignItems: "center",
448
+ fontStyle: "normal",
449
+ lineHeight: "150%",
450
+ marginBottom: "10px",
451
+ }, children: t("otp.OTPAuthentication") }), jsx("div", { style: {
452
+ color: "#949597",
453
+ fontSize: "16px",
454
+ fontWeight: "400",
455
+ alignItems: "center",
456
+ fontStyle: "normal",
457
+ lineHeight: "33px",
458
+ }, children: t("otp.EnterOTP") }), jsxs("div", { className: classes.OTPalignName, children: [t("otp.Hello"), " ", loginState?.username
459
+ ? loginState.username.charAt(0).toUpperCase() +
460
+ loginState.username.slice(1)
461
+ : null, jsx(ResendOTP
462
+ // onResendClick={() => setbtnshow(false)}
463
+ , {
464
+ // onResendClick={() => setbtnshow(false)}
465
+ onResendClick: handleResendClick,
466
+ // onTimerComplete={() => setbtnshow(true)}
467
+ renderButton: renderButton, renderTime: renderTime, maxTime: loginState?.otpValidFor ?? 60, className: classes.resendOTPalign })] }), jsxs("div", { className: classes.divflex, onKeyDown: (e) => {
468
+ if (e.key === "Enter") {
469
+ inputButtonRef?.current?.click?.();
470
+ }
471
+ }, children: [jsx(OTPInput, { value: OTP, onChange: setOTP, autoFocus: true, OTPLength: 6, otpType: "number", disabled: false, secure: !showPassword, className: classes.otpinputpadding }), jsx(IconButton$1, { "aria-label": "toggle password visibility", onClick: () => {
472
+ if (!showPassword) {
473
+ setShowPasswordTime(Date.now() + 5000);
474
+ timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
475
+ }
476
+ else if (showPassword)
477
+ setShowPasswordTime(0);
478
+ }, onMouseDown: (e) => e.preventDefault(), disabled: loginState.otploading, className: classes.ibtnvisible, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) })] }), Boolean(OTPError) ? (jsx(FormHelperText, { style: { color: "red" }, children: OTPError })) : null, jsxs("div", { style: {
479
+ display: "flex",
480
+ gap: "10px",
481
+ margin: "42px 0 0 42px",
482
+ width: "60%",
483
+ }, children: [jsx(GradientButton
484
+ // fullWidth
485
+ , {
486
+ // fullWidth
487
+ disabled: loginState.otploading, onClick: () => {
488
+ previousStep(false, "");
489
+ }, className: classes.otpButtons, textColor: "var(--theme-color3)", sx: {
490
+ border: "var(--theme-color3)1px solid",
491
+ minWidth: "50%",
492
+ background: "var(--theme-color2)",
493
+ borderRadius: "10px",
494
+ "&:hover": {
495
+ background: "var(--theme-color2) !important",
496
+ },
497
+ },
498
+ // customstyle = {{color : "var(--theme-color3) !important"}}
499
+ starticon: "West", rotateIcon: "scale(1.4) rotateX(360deg)", children: t("otp.Back") }), jsx(GradientButton, { style: {
500
+ borderRadius: loginState.loading ? "50%" : "10px",
501
+ height: loginState.loading ? "40px" : "100%",
502
+ width: loginState.loading ? "0px" : "100%",
503
+ minWidth: loginState.loading ? "40px" : "80px",
504
+ }, fullWidth: true, disabled: loginState.loading, onClick: ClickEventHandler, ref: inputButtonRef, className: classes.otpButtons, endicon: loginState.loading ? undefined : "TaskAlt", rotateIcon: "scale(1.4)", children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("otp.VerifyOTP")) })] })] }) }) }) }));
505
+ };
506
+ const OTPModelForm = ({ classes, OTPResendRequest, handleClose, loginState, VerifyOTP, OTPError, setOTPError, resendFlag, setNewRequestID = (id) => { }, otpresendCount = 0, }) => {
507
+ const [OTP, setOTP] = useState("");
508
+ const [showPasswordTime, setShowPasswordTime] = useState(0);
509
+ const showPassword = Date.now() < showPasswordTime;
510
+ const [, forceUpdate] = useState();
511
+ const timerRef = useRef(null);
512
+ useEffect(() => {
513
+ return () => clearTimeout(timerRef.current);
514
+ }, []);
515
+ const [btnshow, setbtnshow] = useState(false);
516
+ const [resendotpLoading, setResendotpLoading] = useState(false);
517
+ const inputButtonRef = useRef(null);
518
+ const { enqueueSnackbar } = useSnackbar();
519
+ const { t } = useTranslation();
520
+ const renderButton = (buttonProps) => {
521
+ let { remainingTime, ...other } = buttonProps;
522
+ return resendotpLoading ? (jsxs("a", { className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), style: { cursor: "wait" }, children: [t("otp.GetNewOTP"), " ", jsx(CircularProgress, { size: 20, color: "secondary" })] })) : (jsx("a", { remainingtime: remainingTime, ...other, className: clsx(classes.resendbtnLink, !btnshow && classes.btnvisibleoff), children: t("otp.GetNewOTP") }));
523
+ };
524
+ const ClickEventHandler = () => {
525
+ if (!Boolean(OTP) || OTP.length < 6) {
526
+ setOTPError("otp.EnterOTPDigit");
527
+ }
528
+ else {
529
+ setOTPError("");
530
+ VerifyOTP(OTP);
531
+ }
532
+ };
533
+ const handleResendClick = async () => {
534
+ setResendotpLoading(true);
535
+ const { status, data, message } = await OTPResendRequest(resendFlag === "FORGET_PW"
536
+ ? loginState?.requestCd
537
+ : loginState?.transactionID, loginState?.username, resendFlag, loginState?.company_ID, loginState?.branch_cd);
538
+ setResendotpLoading(false);
539
+ if (status === "0") {
540
+ setNewRequestID(data?.TRAN_CD);
541
+ setbtnshow(false);
542
+ enqueueSnackbar(message, { variant: "success" });
543
+ }
544
+ else {
545
+ enqueueSnackbar(message, { variant: "error" });
546
+ }
547
+ };
548
+ const handleCloseEvent = () => {
549
+ setOTPError("");
550
+ setOTP("");
551
+ handleClose();
552
+ };
553
+ const renderTime = (remainingtime) => {
554
+ if (parseInt(remainingtime) === 0) {
555
+ setTimeout(() => {
556
+ setbtnshow(true);
557
+ }, 700);
558
+ }
559
+ return (jsxs("span", { className: clsx(btnshow && classes.btnvisibleoff), children: [t("otp.OtpExpired"), " ", remainingtime] }));
560
+ };
561
+ useEffect(() => {
562
+ if (loginState?.otpmodelClose ?? false) {
563
+ handleCloseEvent();
564
+ }
565
+ }, [loginState.otpmodelClose]);
566
+ return (jsx(Fragment, { children: jsx(Grid, { alignItems: "center", children: jsxs("div", { children: [jsx("div", { style: {
567
+ color: "#000000",
568
+ fontSize: "30px",
569
+ fontWeight: "600",
570
+ // fontFamily: "Poppins",
571
+ alignItems: "center",
572
+ fontStyle: "normal",
573
+ lineHeight: "150%",
574
+ marginBottom: "10px",
575
+ }, children: t("otp.OTPAuthentication") }), jsxs("div", { className: classes.OTPalignName, children: [t("otp.Hello"), " ", loginState?.username
576
+ ? loginState.username.charAt(0).toUpperCase() +
577
+ loginState.username.slice(1)
578
+ : null, loginState.otploading ||
579
+ otpresendCount >= 3 ||
580
+ loginState?.auth_type === "TOTP" ? null : (jsx(ResendOTP, { onResendClick: handleResendClick,
581
+ // onTimerComplete={() => setbtnshow(true)}
582
+ renderButton: renderButton, renderTime: renderTime, maxTime: loginState?.otpValidFor ?? 60, className: classes.resendOTPalign }))] }), jsxs("div", { className: classes.divflex, onKeyDown: (e) => {
583
+ if (e.key === "Enter") {
584
+ inputButtonRef?.current?.click?.();
585
+ }
586
+ }, children: [jsx(OTPInput, { value: OTP, onChange: setOTP, autoFocus: true, OTPLength: 6, otpType: "number", disabled: false, secure: !showPassword, className: classes.otpinputpadding }), jsx(IconButton$1, { "aria-label": "toggle password visibility", onClick: () => {
587
+ if (!showPassword) {
588
+ setShowPasswordTime(Date.now() + 5000);
589
+ timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
590
+ }
591
+ else if (showPassword)
592
+ setShowPasswordTime(0);
593
+ }, onMouseDown: (e) => e.preventDefault(), disabled: loginState.otploading, className: classes.ibtnvisible, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) })] }), Boolean(OTPError) ? (jsx(FormHelperText, { style: { color: "red" }, children: OTPError })) : null, loginState?.auth_type === "TOTP" ? (jsx("div", { style: { flex: "auto" }, children: jsx("a", { href: "forgot-totp", style: { color: "var(--theme-color3)" }, children: "Forgot TOTP" }) })) : (jsx(Fragment$1, {})), jsxs("div", { style: {
594
+ display: "flex",
595
+ gap: "10px",
596
+ margin: "42px 0 0 42px",
597
+ width: "60%",
598
+ }, children: [jsx(GradientButton, { fullWidth: true, disabled: loginState.otploading, onClick: handleCloseEvent, className: classes.otpButtons, starticon: "West", textColor: "var(--theme-color3) !important", sx: {
599
+ "&:disabled": {
600
+ color: "var(-theme-color3) !important",
601
+ },
602
+ }, rotateIcon: "scale(1.4) rotateX(360deg)", style: {
603
+ border: "var(--theme-color3)1px solid",
604
+ // color: "var(--theme-color2)",
605
+ // background: "var(--theme-color2)",
606
+ borderRadius: "10px",
607
+ minWidth: "48%",
608
+ }, children: t("otp.Back") }), jsx(GradientButton, { style: {
609
+ borderRadius: loginState.otploading ? "50%" : "10px",
610
+ height: loginState.otploading ? "40px" : "100%",
611
+ width: loginState.otploading ? "0px" : "100%",
612
+ minWidth: loginState.otploading ? "40px" : "80px",
613
+ },
614
+ // fullWidth
615
+ disabled: loginState.loading, onClick: ClickEventHandler, ref: inputButtonRef, className: classes.otpButtons, children: loginState.otploading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("otp.VerifyOTP")) })] })] }) }) }));
616
+ };
617
+
618
+ var css_248z$1 = ".spinner-wrap{position:relative}.spinner-item{animation:zoom 2s linear .75s infinite;border:1px solid #949597;border-radius:50%;height:250px;left:50%;opacity:0;position:absolute;top:50%;transform:translate(-50%,-50%);width:250px}.spinner-item--2{animation-delay:1.25s}.spinner-item--3{animation-delay:1.75s}@keyframes zoom{0%{opacity:0;transform:translate(-50%,-50%) scale(.1)}50%{opacity:1}to{opacity:0;transform:translate(-50%,-50%) scale(.6)}}.image{height:50px;left:50%;position:absolute;top:50%;transform:translate(-50%,-50%)}.progress{backdrop-filter:blur(2px) brightness(101%);border:1px solid #b0b0b0;border-radius:4px;box-shadow:0 0 3px #b0b0;margin:0 auto;width:20em}.bar{background:#4263c7;height:4px;width:65%}";
619
+ styleInject(css_248z$1);
620
+
621
+ const VerifyFinger = ({ classes, loginState, verifyFinger, previousStep, }) => {
622
+ const { t } = useTranslation();
623
+ return (jsx(Fragment, { children: jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", children: [jsxs("div", { style: {
624
+ marginRight: "25px",
625
+ width: "102%",
626
+ // marginBottom: "55px",
627
+ }, children: [jsx("br", {}), jsx("div", { style: {
628
+ color: "#000000",
629
+ fontSize: "34px",
630
+ fontWeight: "600",
631
+ // fontFamily: "Poppins",
632
+ alignItems: "center",
633
+ fontStyle: "normal",
634
+ lineHeight: "150%",
635
+ marginBottom: "10px",
636
+ }, children: t("Biometric.BiometrixAuthentication") }), jsx("div", { style: {
637
+ color: "#949597",
638
+ fontSize: "18px",
639
+ fontWeight: "400",
640
+ // fontFamily: "Poppins",
641
+ alignItems: "center",
642
+ fontStyle: "normal",
643
+ lineHeight: "33px",
644
+ // marginBottom: "10px",
645
+ }, children: t("Biometric.Kindlyplaceyoufinger") }), jsx("br", {}), jsxs(Typography, { variant: "h5", style: { color: "#000000" }, children: [t("otp.Hello"), " ", "", ` ${loginState?.username
646
+ ? loginState.username.charAt(0).toUpperCase() +
647
+ loginState.username.slice(1)
648
+ : null}`] }), jsx("br", {}), jsx("div", { className: loginState?.isBiometricError
649
+ ? classes.eFingerUi
650
+ : classes.fingerUi, children: jsxs("div", { className: "spinner-wrap", children: [jsx(FingerprintSharpIcon, { sx: {
651
+ fontSize: "80px",
652
+ opacity: "0.4",
653
+ borderRadius: "50%",
654
+ display: "flex",
655
+ margin: "0 auto",
656
+ "&:after": {
657
+ borderBottom: "2px solid #26A456",
658
+ },
659
+ }, className: loginState?.isBiometricError ? classes.FingerIcon : null, color: loginState?.isBiometricError ? "error" : "inherit" }), loginState?.isScanning ? (jsxs(Fragment$1, { children: [jsx("div", { className: "spinner-item", style: {
660
+ border: loginState?.isScanning
661
+ ? "1px solid #949597"
662
+ : " 1px solid red",
663
+ } }), jsx("div", { className: "spinner-item spinner-item--2", style: {
664
+ border: loginState?.isScanning
665
+ ? "1px solid #949597"
666
+ : "1px solid red",
667
+ } }), jsx("div", { className: "spinner-item spinner-item--3", style: {
668
+ border: loginState?.isScanning
669
+ ? "1px solid #949597"
670
+ : "1px solid red",
671
+ } })] })) : null] }) }), jsx("div", { className: classes.biometric, children: jsxs("div", { style: { marginTop: "50px" }, children: [jsx("div", { className: loginState.isScanning ? "progress" : "hide", children: jsx("div", { className: "bar", style: { width: loginState.isScanning ? "30%" : "0%" } }) }), jsx("h3", { style: {
672
+ display: "flex",
673
+ marginTop: "20px",
674
+ justifyContent: "space-around",
675
+ color: loginState?.isBiometricError
676
+ ? "rgb(255 0 0 / 65%)"
677
+ : "inherit",
678
+ }, children: loginState?.isBiometricError
679
+ ? loginState?.userMessage
680
+ : loginState?.loading
681
+ ? t("Biometric.Loading")
682
+ : loginState?.isScanning
683
+ ? t("Biometric.Scanning")
684
+ : null })] }) })] }), jsxs("div", { style: {
685
+ display: "flex",
686
+ justifyContent: "center",
687
+ margin: "42px 0 0 42px",
688
+ // margin: "38px 0 0 0",
689
+ gap: "10px",
690
+ }, children: [jsx(GradientButton, { fullWidth: true, disabled: loginState.loading, onClick: () => {
691
+ previousStep(false, "");
692
+ }, className: classes.otpButtons, starticon: "West", rotateIcon: "scale(1.4) rotateX(360deg)", textColor: "var(--theme-color3) !important", style: {
693
+ border: "var(--theme-color3)1px solid",
694
+ color: "var(--theme-color3)",
695
+ background: "var(--theme-color2)",
696
+ borderRadius: "10px",
697
+ minWidth: "48%",
698
+ }, children: t("otp.Back") }), jsx(GradientButton, { style: {
699
+ borderRadius: loginState.loading ? "50%" : "10px",
700
+ height: loginState.loading ? "40px" : "100%",
701
+ width: loginState.loading ? "0px" : "100%",
702
+ minWidth: loginState.loading ? "40px" : "80px",
703
+ // width: loginState.loading ? "0px" : "90%",
704
+ // minWidth: loginState.loading ? "40px" : "80px",
705
+ }, disabled: loginState.loading, onKeyDown: (e) => e.keyCode === 13 && verifyFinger, onClick: verifyFinger, className: classes.otpButtons, children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6, style: { color: "#fff" } })) : (t("Biometric.Verify")) })] })] }) }) }));
706
+ };
707
+
708
+ const capture = async () => {
709
+ var MFS100Request = {
710
+ Quality: 60,
711
+ TimeOut: 10,
712
+ };
713
+ var jsondata = JSON.stringify(MFS100Request);
714
+ const rawResponse = await fetch("http://localhost:8004/mfs100/capture", {
715
+ method: "POST",
716
+ headers: {
717
+ Accept: "application/json",
718
+ "Content-Type": "application/json",
719
+ },
720
+ body: jsondata,
721
+ });
722
+ const content = await rawResponse.json();
723
+ return content;
724
+ };
725
+
726
+ const decryptString = (encryptString) => {
727
+ var secretKey = "SUPERACUTE@MKS";
728
+ var keyBytes = CryptoJS.PBKDF2(secretKey, "Ivan Medvedev", {
729
+ keySize: 48 / 4,
730
+ iterations: 1000,
731
+ });
732
+ console.log(keyBytes.toString());
733
+ // take first 32 bytes as key (like in C# code)
734
+ var key = new CryptoJS.lib.WordArray.init(keyBytes.words, 32);
735
+ // // skip first 32 bytes and take next 16 bytes as IV
736
+ var iv = new CryptoJS.lib.WordArray.init(keyBytes.words.splice(32 / 4), 16);
737
+ // console.log(key.toString());
738
+ //console.log(encryptString, CryptoJS.enc.Base64.parse(encryptString));
739
+ var dec = CryptoJS.AES.decrypt({
740
+ ciphertext: CryptoJS.enc.Base64.parse(CryptoJS.enc.Base64.parse(encryptString).toString(CryptoJS.enc.Utf8)),
741
+ }, key, {
742
+ iv: iv,
743
+ });
744
+ console.log("CryptoJS.AES.decrypt", dec);
745
+ return dec.toString(CryptoJS.enc.Utf8).split(String.fromCharCode(0)).join("");
746
+ };
747
+ const matchFinger = async (rows, captureFinger) => {
748
+ var promise = new Promise((resolve, reject) => {
749
+ //console.log("matchFinger", rows, typeof rows);
750
+ if (typeof rows === "string") {
751
+ rows = JSON.parse(rows);
752
+ }
753
+ rows.forEach(async (element, i) => {
754
+ try {
755
+ var galleryTemplate = decryptString(element.IMG_DATA);
756
+ var MFS100Request = {
757
+ GalleryTemplate: galleryTemplate,
758
+ ProbTemplate: captureFinger,
759
+ BioType: "Iso",
760
+ };
761
+ var jsondata = JSON.stringify(MFS100Request);
762
+ await fetch("http://localhost:8004/mfs100/verify", {
763
+ method: "POST",
764
+ headers: {
765
+ Accept: "application/json",
766
+ "Content-Type": "application/json",
767
+ },
768
+ body: jsondata,
769
+ })
770
+ .then((response) => response.json())
771
+ .then((response) => {
772
+ if (response?.ErrorCode === "0" && response["Status"]) {
773
+ resolve({
774
+ status: true,
775
+ errorCode: "0",
776
+ errorMessage: "",
777
+ isError: false,
778
+ sr_cd: element.SR_CD,
779
+ });
780
+ return;
781
+ }
782
+ if (rows.length === i + 1) {
783
+ resolve({
784
+ status: false,
785
+ errorCode: response.ErrorCode,
786
+ errorMessage: response.ErrorMessage,
787
+ isError: false,
788
+ });
789
+ return;
790
+ }
791
+ })
792
+ .catch((reason) => {
793
+ resolve({
794
+ status: false,
795
+ errorCode: "999",
796
+ errorMessage: reason,
797
+ isError: true,
798
+ });
799
+ });
800
+ }
801
+ catch (err) {
802
+ console.log(err);
803
+ resolve({
804
+ status: false,
805
+ errorCode: "999",
806
+ errorMessage: "Something went wrong!",
807
+ isError: true,
808
+ });
809
+ }
810
+ });
811
+ });
812
+ return promise;
813
+ };
814
+
815
+ const isBase64 = (str = "") => {
816
+ if (typeof str !== "string") {
817
+ return false;
818
+ }
819
+ const base64Regex = /^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/;
820
+ return base64Regex.test(str);
821
+ };
822
+
823
+ const BankDetails = ({ bannerDetails }) => {
824
+ const [loginImageURL, setLoginImageURL] = useState(null);
825
+ const urlObj = useRef(null);
826
+ const classes = useStyles$3();
827
+ const banner = useMemo(() => bannerDetails, []);
828
+ useEffect(() => {
829
+ if (Boolean(banner?.bannerImg)) {
830
+ if (isBase64(banner?.bannerImg)) {
831
+ let blob = utilFunction.base64toBlob(banner?.bannerImg);
832
+ urlObj.current =
833
+ typeof blob === "object" && Boolean(blob)
834
+ ? URL.createObjectURL(blob)
835
+ : "";
836
+ setLoginImageURL(urlObj.current);
837
+ }
838
+ else {
839
+ setLoginImageURL(banner?.bannerImg);
840
+ }
841
+ }
842
+ }, [banner]);
843
+ return (jsx(Fragment$1, { children: jsxs(Grid, { item: true, xs: 6, md: 6, lg: 6, className: classes.loginLeft, children: [jsx(Grid, { item: true, xs: 12, md: 12, lg: 12, style: { height: "70vh" }, children: jsx("img", { alt: "", style: {
844
+ width: "100%",
845
+ height: "100%",
846
+ objectFit: "cover",
847
+ objectPosition: "center",
848
+ }, src: Boolean(loginImageURL) ? loginImageURL : "" }) }), jsx(Grid, { item: true, xs: 12, md: 12, lg: 12, style: {
849
+ height: "30vh",
850
+ background: "var(--theme-color5)",
851
+ }, children: jsxs(Container, { maxWidth: "sm", children: [jsxs("div", { className: "text", style: {
852
+ color: "white",
853
+ fontStyle: "normal",
854
+ fontSize: "35px",
855
+ paddingTop: "30px",
856
+ }, children: [banner?.bannerTitle ?? "", jsx("span", { style: { marginLeft: "8px", fontWeight: "900" } })] }), jsx("div", { style: {
857
+ lineHeight: "27px",
858
+ fontSize: "15px",
859
+ fontWeight: "500px",
860
+ letterSpacing: "0.02em",
861
+ color: "#ebedee",
862
+ maxWidth: "464px",
863
+ }, children: banner?.bannerNote ?? "" })] }) })] }) }));
864
+ };
865
+
866
+ const PasswordRotation = ({ classes, ResetPassword, open, username, accessToken, tokenType, handleClose, }) => {
867
+ const inputButtonRef = useRef(null);
868
+ const { enqueueSnackbar } = useSnackbar();
869
+ const { t } = useTranslation();
870
+ const [input, setInput] = useState({
871
+ userName: username,
872
+ oldpassword: "",
873
+ password: "",
874
+ confirmpassword: "",
875
+ });
876
+ const [pwdReset, setPasswordReset] = useState({
877
+ isError: false,
878
+ errorMessage: "",
879
+ isLoading: false,
880
+ isoldPwdError: false,
881
+ oldpassworderror: "",
882
+ isnewpwdError: false,
883
+ newpassworderror: "",
884
+ isconfirmnewpwdError: false,
885
+ confirmnewpassworderror: "",
886
+ });
887
+ const handleCloseEvent = () => {
888
+ handleClose("");
889
+ };
890
+ const ClickEventHandler = async () => {
891
+ let isError = false;
892
+ let setPwdData = {
893
+ isError: false,
894
+ errorMessage: "",
895
+ isLoading: false,
896
+ isoldPwdError: false,
897
+ oldpassworderror: "",
898
+ isnewpwdError: false,
899
+ newpassworderror: "",
900
+ isconfirmnewpwdError: false,
901
+ confirmnewpassworderror: "",
902
+ };
903
+ if (!Boolean(input.oldpassword)) {
904
+ setPwdData.isoldPwdError = true;
905
+ setPwdData.oldpassworderror = "Current Password is required.";
906
+ isError = true;
907
+ }
908
+ let pwdData = utilFunction.ValidatePassword(input.password);
909
+ if (Boolean(pwdData)) {
910
+ setPwdData.isnewpwdError = true;
911
+ setPwdData.newpassworderror = pwdData;
912
+ isError = true;
913
+ }
914
+ if (Boolean(input.oldpassword) &&
915
+ Boolean(input.password) &&
916
+ input.oldpassword === input.password) {
917
+ setPwdData.isnewpwdError = true;
918
+ setPwdData.newpassworderror =
919
+ "The new password cannot be the same as the old password";
920
+ isError = true;
921
+ }
922
+ if (!Boolean(input.confirmpassword)) {
923
+ setPwdData.isconfirmnewpwdError = true;
924
+ setPwdData.confirmnewpassworderror = "Confirm new password is required.";
925
+ isError = true;
926
+ }
927
+ else if (Boolean(input.password) &&
928
+ input.password !== input.confirmpassword) {
929
+ setPwdData.isconfirmnewpwdError = true;
930
+ setPwdData.confirmnewpassworderror =
931
+ "New Password and Confirm Password did not matched";
932
+ isError = true;
933
+ }
934
+ if (isError) {
935
+ setPasswordReset(setPwdData);
936
+ }
937
+ else {
938
+ setPasswordReset((values) => ({ ...values, isLoading: true }));
939
+ let response = await ResetPassword(input.userName, input.oldpassword, input.password, accessToken, tokenType);
940
+ setPasswordReset((values) => ({ ...values, isLoading: false }));
941
+ if (response.status === "0") {
942
+ enqueueSnackbar("Password successfully changed.", {
943
+ variant: "success",
944
+ });
945
+ handleClose("0");
946
+ }
947
+ else {
948
+ setPasswordReset((values) => ({
949
+ ...values,
950
+ isError: true,
951
+ errorMessage: response.message,
952
+ }));
953
+ }
954
+ }
955
+ };
956
+ const handleChange = (event) => {
957
+ const name = event.target.name;
958
+ let value = event.target.value;
959
+ if (name === "oldpassword" && Boolean(value)) {
960
+ setPasswordReset((values) => ({ ...values, isoldPwdError: false }));
961
+ }
962
+ else if (name === "password" && Boolean(value)) {
963
+ setPasswordReset((values) => ({ ...values, isnewpwdError: false }));
964
+ }
965
+ else if (name === "confirmpassword" && Boolean(value)) {
966
+ setPasswordReset((values) => ({
967
+ ...values,
968
+ isconfirmnewpwdError: false,
969
+ }));
970
+ }
971
+ setInput((values) => ({ ...values, [name]: value }));
972
+ };
973
+ return (jsx(Fragment, { children: jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", children: [jsx("div", { style: {
974
+ color: "#000000 !important",
975
+ fontSize: "30px",
976
+ fontWeight: "600",
977
+ alignItems: "center",
978
+ fontStyle: "normal",
979
+ }, children: jsx("h3", { children: "Password Rotation" }) }), jsx("div", { className: "", style: {
980
+ color: "#949597",
981
+ fontSize: "18px",
982
+ fontWeight: "400",
983
+ alignItems: "center",
984
+ fontStyle: "normal",
985
+ width: "360px",
986
+ }, children: "Please Verify OTP" }), jsxs("div", { className: classes.formWrap, children: [jsx(TextField, { label: "User ID", placeholder: "Enter User ID", fullWidth: true, type: "text", name: "userName", value: input.userName || "", onChange: handleChange, InputLabelProps: { shrink: true }, disabled: true, autoComplete: "off", inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { autoFocus: true, label: "Current Password", placeholder: "Enter Current Password", fullWidth: true, type: "password", name: "oldpassword", value: input.oldpassword || "", onChange: handleChange, error: pwdReset.isoldPwdError, helperText: pwdReset.isoldPwdError ? t(pwdReset.oldpassworderror) : "", InputLabelProps: { shrink: true }, disabled: pwdReset.isLoading, autoComplete: "off", onKeyDown: (e) => {
987
+ if (e.key === "Enter") {
988
+ inputButtonRef?.current?.click?.();
989
+ }
990
+ }, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { label: "New Password", placeholder: "Enter New Password", fullWidth: true, type: "password", name: "password", value: input.password || "", onChange: handleChange, error: pwdReset.isnewpwdError, helperText: pwdReset.isnewpwdError ? t(pwdReset.newpassworderror) : "", InputLabelProps: { shrink: true }, disabled: pwdReset.isLoading, autoComplete: "off", onKeyDown: (e) => {
991
+ if (e.key === "Enter") {
992
+ inputButtonRef?.current?.click?.();
993
+ }
994
+ }, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { label: "Confirm New Password", placeholder: "Enter confirm new password", fullWidth: true, type: "password", name: "confirmpassword", value: input.confirmpassword || "", onChange: handleChange, error: pwdReset.isconfirmnewpwdError, helperText: pwdReset.isconfirmnewpwdError
995
+ ? t(pwdReset.confirmnewpassworderror)
996
+ : "", InputLabelProps: { shrink: true }, disabled: pwdReset.isLoading, autoComplete: "off", onKeyDown: (e) => {
997
+ if (e.key === "Enter") {
998
+ inputButtonRef?.current?.click?.();
999
+ }
1000
+ }, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), pwdReset.isError ? (jsx(FormHelperText, { style: { color: "red" }, children: pwdReset.errorMessage })) : null] }), jsxs("div", { style: {
1001
+ display: "flex",
1002
+ gap: "10px",
1003
+ margin: "20px 0 0 10px",
1004
+ width: "94%",
1005
+ }, children: [jsx(GradientButton, { fullWidth: true, disabled: pwdReset.isLoading, onClick: handleCloseEvent, className: classes.otpButtons, style: {
1006
+ border: "var(--theme-color3)1px solid",
1007
+ color: "var(--theme-color3)",
1008
+ // pebbackground: "var(--theme-color2)",
1009
+ borderRadius: "10px",
1010
+ }, children: "Back" }), jsx(GradientButton, { style: {
1011
+ borderRadius: pwdReset.isLoading ? "50%" : "10px",
1012
+ height: pwdReset.isLoading ? "40px" : "100%",
1013
+ width: pwdReset.isLoading ? "0px" : "100%",
1014
+ minWidth: pwdReset.isLoading ? "40px" : "80px",
1015
+ }, fullWidth: true, disabled: pwdReset.isLoading, onClick: ClickEventHandler, ref: inputButtonRef, className: classes.otpButtons, children: pwdReset.isLoading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : ("Update") })] })] }) }) }));
1016
+ };
1017
+
1018
+ const inititalState$1 = {
1019
+ username: "",
1020
+ firstName: "",
1021
+ lastName: "",
1022
+ loading: false,
1023
+ otploading: false,
1024
+ isError: false,
1025
+ isUsernameError: false,
1026
+ isPasswordError: false,
1027
+ userMessage: "",
1028
+ OtpuserMessage: "",
1029
+ userMessageforpassword: "",
1030
+ userMessageforusername: "",
1031
+ currentFlow: "username",
1032
+ transactionID: "",
1033
+ access_token: "",
1034
+ token_type: "",
1035
+ otpmodelClose: false,
1036
+ authType: "",
1037
+ isScanning: false,
1038
+ auth_data: [],
1039
+ company_ID: "",
1040
+ Branch_CD: "",
1041
+ auth_type: "O",
1042
+ otpValidFor: 60,
1043
+ };
1044
+ const reducer$1 = (state, action) => {
1045
+ switch (action.type) {
1046
+ case "inititateUserFingerVerification":
1047
+ case "inititateOTPVerification": {
1048
+ return {
1049
+ ...state,
1050
+ loading: true,
1051
+ isError: false,
1052
+ isUsernameError: false,
1053
+ isPasswordError: false,
1054
+ isOTPError: false,
1055
+ isBiometricError: false,
1056
+ userMessage: "",
1057
+ };
1058
+ }
1059
+ case "inititateUserFingerScanner": {
1060
+ return { ...state, isScanning: true, isBiometricError: false };
1061
+ }
1062
+ case "usernameandpasswordrequired": {
1063
+ return {
1064
+ ...state,
1065
+ loading: false,
1066
+ isError: true,
1067
+ isUsernameError: true,
1068
+ isPasswordError: true,
1069
+ otploading: false,
1070
+ userMessage: action?.payload?.error,
1071
+ userMessageforpassword: action?.payload?.errorPassword,
1072
+ userMessageforusername: action?.payload?.errorUsername,
1073
+ username: "",
1074
+ transactionID: "",
1075
+ };
1076
+ }
1077
+ case "passwordVerificationFailure":
1078
+ return {
1079
+ ...state,
1080
+ loading: false,
1081
+ isError: true,
1082
+ isUsernameError: false,
1083
+ isPasswordError: true,
1084
+ otploading: false,
1085
+ userMessage: action?.payload?.error,
1086
+ userMessageforpassword: action?.payload?.errorPassword,
1087
+ username: "",
1088
+ transactionID: "",
1089
+ };
1090
+ case "usernameVerificationFailure": {
1091
+ return {
1092
+ ...state,
1093
+ loading: false,
1094
+ isError: true,
1095
+ isUsernameError: true,
1096
+ isPasswordError: false,
1097
+ otploading: false,
1098
+ userMessage: action?.payload?.error,
1099
+ userMessageforusername: action?.payload?.errorUsername,
1100
+ username: "",
1101
+ transactionID: "",
1102
+ };
1103
+ }
1104
+ case "inititatePasswordVerification": {
1105
+ return {
1106
+ ...state,
1107
+ loading: true,
1108
+ isError: false,
1109
+ isUsernameError: false,
1110
+ isPasswordError: false,
1111
+ otploading: false,
1112
+ userMessage: "",
1113
+ userMessageforusername: "",
1114
+ userMessageforpassword: "",
1115
+ username: "",
1116
+ transactionID: "",
1117
+ access_token: "",
1118
+ };
1119
+ }
1120
+ case "passwordRotation": {
1121
+ return {
1122
+ ...state,
1123
+ loading: false,
1124
+ username: action?.payload?.username,
1125
+ access_token: action?.payload?.access_token,
1126
+ token_type: action?.payload?.token_type,
1127
+ };
1128
+ }
1129
+ case "passwordRotationsuccess": {
1130
+ return {
1131
+ ...state,
1132
+ loading: false,
1133
+ otpmodelClose: Boolean(action?.payload?.otpmodelclose),
1134
+ };
1135
+ }
1136
+ case "passwordVerificationSuccessful": {
1137
+ return {
1138
+ ...state,
1139
+ loading: false,
1140
+ otploading: false,
1141
+ transactionID: action?.payload?.transactionID,
1142
+ username: action?.payload?.username,
1143
+ auth_type: action?.payload?.auth_type,
1144
+ OtpuserMessage: "",
1145
+ access_token: action?.payload?.access_token,
1146
+ token_type: action?.payload?.token_type,
1147
+ otpmodelClose: false,
1148
+ currentFlow: "OTP",
1149
+ authType: action?.payload?.authType,
1150
+ auth_data: action?.payload?.auth_data,
1151
+ otpValidFor: action?.payload?.otpValidFor,
1152
+ company_ID: action?.paylod?.company_ID,
1153
+ };
1154
+ }
1155
+ case "inititatebiometricVerification": {
1156
+ return {
1157
+ ...state,
1158
+ loading: true,
1159
+ otploading: true,
1160
+ OtpuserMessage: "",
1161
+ otpmodelClose: false,
1162
+ };
1163
+ }
1164
+ case "biometricVerificationFailure":
1165
+ return {
1166
+ ...state,
1167
+ loading: false,
1168
+ isError: true,
1169
+ isBiometricError: true,
1170
+ userMessage: action?.payload?.error,
1171
+ isScanning: false,
1172
+ };
1173
+ case "biometricVerificationSuccessful":
1174
+ return {
1175
+ ...state,
1176
+ loading: false,
1177
+ isError: false,
1178
+ isBiometricError: false,
1179
+ state: action.payload,
1180
+ isScanning: false,
1181
+ };
1182
+ case "OTPVerificationComplate": {
1183
+ return {
1184
+ ...state,
1185
+ loading: false,
1186
+ otploading: false,
1187
+ OtpuserMessage: "",
1188
+ };
1189
+ }
1190
+ case "OTPVerificationFailed": {
1191
+ return {
1192
+ ...state,
1193
+ loading: false,
1194
+ otploading: false,
1195
+ OtpuserMessage: action?.payload?.error,
1196
+ otpmodelClose: Boolean(action?.payload?.otpmodelclose),
1197
+ };
1198
+ }
1199
+ case "OTPResendSuccess": {
1200
+ return {
1201
+ ...state,
1202
+ transactionID: action?.payload?.transactionID,
1203
+ };
1204
+ }
1205
+ case "backToUsernameVerification": {
1206
+ return {
1207
+ ...inititalState$1,
1208
+ isPasswordError: action?.payload?.isError,
1209
+ userMessageforpassword: action?.payload?.errorMessage,
1210
+ };
1211
+ }
1212
+ default: {
1213
+ return state;
1214
+ }
1215
+ }
1216
+ };
1217
+ const AuthControllerWrapper = ({ bannerDetails, logoUrl, logoTitle, loginFn, veirfyUsernameandPassword, verifyOTP, OTPResendRequest, ResetPassword, LanguageComponent, forgotPasswordEndpoint, }) => {
1218
+ const classes = useStyles$3();
1219
+ const [loginState, dispath] = useReducer(reducer$1, inititalState$1);
1220
+ const [openpwdreset, setOpenPwdReset] = useState(false);
1221
+ const failureCount = useRef(0);
1222
+ const [dashboardLogoURL, setDashboardLogoURL] = useState(null);
1223
+ const urlObj = useRef(null);
1224
+ const { t } = useTranslation();
1225
+ const otpResendRef = useRef(1);
1226
+ useEffect(() => {
1227
+ if (Boolean(logoUrl)) {
1228
+ if (isBase64(logoUrl)) {
1229
+ let blob = utilFunction.base64toBlob(logoUrl);
1230
+ urlObj.current =
1231
+ typeof blob === "object" && Boolean(blob)
1232
+ ? URL.createObjectURL(blob)
1233
+ : "";
1234
+ setDashboardLogoURL(urlObj.current);
1235
+ }
1236
+ else {
1237
+ setDashboardLogoURL(logoUrl);
1238
+ }
1239
+ }
1240
+ }, [logoUrl]);
1241
+ const verifyUsernamePassword = async (username, password) => {
1242
+ if (Boolean(username) && Boolean(password)) {
1243
+ dispath({ type: "inititatePasswordVerification" });
1244
+ try {
1245
+ const { status = "", data = null, message = "", responseType = "", access_token = null, } = await veirfyUsernameandPassword(username, password);
1246
+ if (status === "0" && responseType === "S") {
1247
+ dispath({
1248
+ type: "passwordRotation",
1249
+ payload: {
1250
+ username: username,
1251
+ access_token: access_token?.access_token || "",
1252
+ token_type: access_token?.token_type || "",
1253
+ },
1254
+ });
1255
+ setOpenPwdReset(true);
1256
+ }
1257
+ else if (status === "0") {
1258
+ dispath({
1259
+ type: "passwordVerificationSuccessful",
1260
+ payload: {
1261
+ transactionID: data?.REQUEST_CD,
1262
+ username: username,
1263
+ access_token: access_token?.access_token,
1264
+ token_type: access_token?.token_type,
1265
+ authType: data?.AUTH_TYPE,
1266
+ auth_data: [
1267
+ {
1268
+ company_ID: data?.BASE_COMP_CD ?? "",
1269
+ branch_cd: data?.BASE_BRANCH_CD,
1270
+ },
1271
+ ],
1272
+ otpValidFor: data?.OTP_VALID,
1273
+ },
1274
+ });
1275
+ }
1276
+ else {
1277
+ dispath({
1278
+ type: "passwordVerificationFailure",
1279
+ payload: { error: message, errorPassword: message },
1280
+ });
1281
+ }
1282
+ }
1283
+ catch (err) {
1284
+ throw new Error("Error occurred while verifying username and password: " + err);
1285
+ }
1286
+ }
1287
+ else if (!Boolean(username) && !Boolean(password)) {
1288
+ dispath({
1289
+ type: "usernameandpasswordrequired",
1290
+ payload: {
1291
+ error: "UsernamenandPasswordisRequired",
1292
+ errorUsername: "UsernameisRequired",
1293
+ errorPassword: "PasswordisRequired",
1294
+ },
1295
+ });
1296
+ }
1297
+ else if (!Boolean(username)) {
1298
+ dispath({
1299
+ type: "usernameVerificationFailure",
1300
+ payload: {
1301
+ error: "UsernameisRequired",
1302
+ errorUsername: "UsernameisRequired",
1303
+ },
1304
+ });
1305
+ }
1306
+ else {
1307
+ dispath({
1308
+ type: "passwordVerificationFailure",
1309
+ payload: {
1310
+ error: "PasswordisRequired",
1311
+ errorPassword: "PasswordisRequired",
1312
+ },
1313
+ });
1314
+ }
1315
+ };
1316
+ const VerifyOTP = async (OTPNumber) => {
1317
+ if (Boolean(OTPNumber) && OTPNumber.toString().length === 6) {
1318
+ dispath({ type: "inititateOTPVerification" });
1319
+ const { status, data, message } = await verifyOTP(loginState.transactionID,
1320
+ // loginState.app_transactionId,
1321
+ loginState.username, OTPNumber, loginState.access_token, loginState.token_type, loginState.authType);
1322
+ if (status === "0") {
1323
+ // try {
1324
+ // audio.play();
1325
+ // } catch (error) {
1326
+ // console.log(error);
1327
+ // }
1328
+ dispath({ type: "OTPVerificationComplate" });
1329
+ loginFn(data);
1330
+ }
1331
+ else if (status === "999") {
1332
+ dispath({
1333
+ type: "OTPVerificationFailed",
1334
+ payload: { error: message, otpmodelclose: true },
1335
+ });
1336
+ // enqueueSnackbar(message, { variant: "error" });
1337
+ }
1338
+ else {
1339
+ dispath({
1340
+ type: "OTPVerificationFailed",
1341
+ payload: { error: message, otpmodelclose: false },
1342
+ });
1343
+ }
1344
+ }
1345
+ else {
1346
+ dispath({
1347
+ type: "OTPVerificationFailed",
1348
+ payload: { error: "Please enter a 6 digit OTP number" },
1349
+ });
1350
+ }
1351
+ };
1352
+ const handlePasswordRotationClose = (flag) => {
1353
+ if (flag === "0") {
1354
+ dispath({
1355
+ type: "passwordRotationsuccess",
1356
+ payload: { otpmodelclose: true },
1357
+ });
1358
+ }
1359
+ setOpenPwdReset(false);
1360
+ };
1361
+ const changeUserName = (isError = false, errorMessage = "") => {
1362
+ dispath({
1363
+ type: "backToUsernameVerification",
1364
+ payload: {
1365
+ isError: isError,
1366
+ errorMessage: errorMessage,
1367
+ },
1368
+ });
1369
+ };
1370
+ const verifyFinger = async () => {
1371
+ try {
1372
+ dispath({ type: "inititateUserFingerScanner" });
1373
+ const fingerResponse = await capture();
1374
+ if (fingerResponse?.ErrorCode === "0") {
1375
+ dispath({ type: "inititateUserFingerVerification" });
1376
+ const promise = await matchFinger(loginState.auth_data, fingerResponse.IsoTemplate);
1377
+ if (promise.isError) {
1378
+ dispath({
1379
+ type: "biometricVerificationFailure",
1380
+ payload: {
1381
+ error: promise?.errorMessage ?? "Something went wrong.",
1382
+ },
1383
+ });
1384
+ }
1385
+ else {
1386
+ const { status, data, message } = await verifyOTP(loginState.transactionID, loginState.username, String(promise?.sr_cd ?? "0"), loginState.access_token, loginState.token_type, loginState.authType, promise.status ? "Y" : "N");
1387
+ if (status === "0" && promise.status) {
1388
+ dispath({ type: "biometricVerificationSuccessful" });
1389
+ loginFn(data);
1390
+ }
1391
+ else if (status === "0" && !promise.status) {
1392
+ failureCount.current = failureCount.current + 1;
1393
+ dispath({
1394
+ type: "biometricVerificationFailure",
1395
+ payload: {
1396
+ error: "Finger Not Match.Please Try Again",
1397
+ },
1398
+ });
1399
+ if (failureCount.current >= 3)
1400
+ changeUserName(true, "Finger Not Match.Please Try Again");
1401
+ }
1402
+ else if (status === "99") {
1403
+ dispath({
1404
+ type: "biometricVerificationFailure",
1405
+ payload: {
1406
+ error: message ?? "Finger Not Match.Please Try Again",
1407
+ },
1408
+ });
1409
+ }
1410
+ else if (status === "999") {
1411
+ dispath({
1412
+ type: "biometricVerificationFailure",
1413
+ payload: {
1414
+ error: message ?? "Finger Not Match.Please Try Again",
1415
+ },
1416
+ });
1417
+ changeUserName(true, message ?? "Finger Not Match.Please Try Again");
1418
+ }
1419
+ else {
1420
+ dispath({
1421
+ type: "biometricVerificationFailure",
1422
+ payload: {
1423
+ error: message ?? "Finger Not Match.Please Try Again",
1424
+ },
1425
+ });
1426
+ }
1427
+ }
1428
+ }
1429
+ else {
1430
+ dispath({
1431
+ type: "biometricVerificationFailure",
1432
+ payload: {
1433
+ error: fingerResponse?.ErrorMessage ?? t("Biometric.MFS100NotFound"),
1434
+ },
1435
+ });
1436
+ }
1437
+ }
1438
+ catch (e) {
1439
+ dispath({
1440
+ type: "biometricVerificationFailure",
1441
+ payload: {
1442
+ error: e?.message ?? t("Biometric.Unknownerroroccured"),
1443
+ },
1444
+ });
1445
+ }
1446
+ };
1447
+ return (jsx(Fragment$1, { children: jsxs(Grid, { container: true, style: { height: "100vh", overflow: "hidden" }, children: [jsx(BankDetails, { bannerDetails: bannerDetails }), jsxs(Grid, { item: true, xs: 11, md: 6, lg: 6, sm: 6, children: [logoUrl ? (jsx(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", padding: "25px", maxWidth: "210px", ml: "auto", children: jsx(Tooltip, { describeChild: true, title: logoTitle ?? "", children: jsx("img", { src: Boolean(dashboardLogoURL) ? dashboardLogoURL : "", alt: "Logo", width: "100%" }) }) })) : null, LanguageComponent ? (jsx(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", padding: "0 35px 0 0", maxWidth: "180px", ml: "auto", children: jsx(LanguageComponent, {}) })) : null, openpwdreset ? (jsx(PasswordRotation, { classes: classes, ResetPassword: ResetPassword, open: openpwdreset, username: loginState.username, accessToken: loginState.access_token, tokenType: loginState.token_type, handleClose: handlePasswordRotationClose })) : (jsx(Fragment$1, { children: loginState.currentFlow === "username" ? (jsx(UsernamePasswordField, { classes: classes, loginState: loginState, verifyUsernamePassword: verifyUsernamePassword, forgotPasswordEndpoint: forgotPasswordEndpoint }, "username")) : (jsx(Fragment$1, { children: loginState.authType === "OTP" ? (jsx(OTPModel, { OTPResendRequest: OTPResendRequest, classes: classes, loginState: loginState, VerifyOTP: VerifyOTP, previousStep: changeUserName, OTPError: t(loginState?.OtpuserMessage ?? ""), setOTPError: (error) => {
1448
+ dispath({
1449
+ type: "OTPVerificationFailed",
1450
+ payload: { error: error },
1451
+ });
1452
+ }, open: true, handleClose: changeUserName, resendFlag: "LOGIN", setNewRequestID: (newRequestID) => {
1453
+ dispath({
1454
+ type: "OTPResendSuccess",
1455
+ payload: { transactionID: newRequestID },
1456
+ });
1457
+ otpResendRef.current = otpResendRef.current + 1;
1458
+ }, otpresendCount: otpResendRef.current }, "otp")) : loginState.authType === "TOTP" ? (jsxs(Fragment$1, { children: [" ", jsx(OTPModelForm, { OTPResendRequest: OTPResendRequest, classes: classes,
1459
+ // handleClose={() => {}}
1460
+ handleClose: changeUserName, loginState: loginState, VerifyOTP: VerifyOTP, OTPError: loginState?.OtpuserMessage ?? "", setOTPError: (error) => {
1461
+ dispath({
1462
+ type: "OTPVerificationFailed",
1463
+ payload: { error: error },
1464
+ });
1465
+ }, resendFlag: "LOGIN", setNewRequestID: (newRequestID) => {
1466
+ dispath({
1467
+ type: "OTPResendSuccess",
1468
+ payload: { transactionID: newRequestID },
1469
+ });
1470
+ otpResendRef.current = otpResendRef.current + 1;
1471
+ }, otpresendCount: otpResendRef.current }, "OTPForm")] })) : (jsx(VerifyFinger, { classes: classes, loginState: loginState, verifyFinger: verifyFinger, previousStep: changeUserName }, "biometric")) })) }))] })] }) }));
1472
+ };
1473
+
1474
+ const ForgotPasswordFields = ({ classes, loginState, onSubmit, navigate, loginPageEndpoint, }) => {
1475
+ const [input, setInput] = useState({
1476
+ userName: loginState.workingState === 1 ? loginState?.username : "",
1477
+ mobileno: "",
1478
+ password: "",
1479
+ confirmpassword: "",
1480
+ });
1481
+ const inputRef = useRef(null);
1482
+ const inputPassRef = useRef(null);
1483
+ const inputButtonRef = useRef(null);
1484
+ const [showPasswordTime, setShowPasswordTime] = useState(0);
1485
+ const [showConfirmPasswordTime, setShowConfirmPasswordTime] = useState(0);
1486
+ const showPassword = Date.now() < showPasswordTime;
1487
+ const showConfirmPassword = Date.now() < showConfirmPasswordTime;
1488
+ const [, forceUpdate] = useState();
1489
+ const timerRef = useRef(null);
1490
+ useEffect(() => {
1491
+ return () => clearTimeout(timerRef.current);
1492
+ }, []);
1493
+ // const navigate = useNavigate();
1494
+ const { t } = useTranslation();
1495
+ const handleChange = (event) => {
1496
+ const name = event.target.name;
1497
+ let value = event.target.value;
1498
+ if (name === "userName" && value) {
1499
+ loginState.isUsernameError = false;
1500
+ }
1501
+ if (name === "mobileno" && value) {
1502
+ value = value.replace(/\D/g, "");
1503
+ if (Boolean(value)) {
1504
+ loginState.isMobileError = false;
1505
+ }
1506
+ }
1507
+ setInput((values) => ({ ...values, [name]: value }));
1508
+ };
1509
+ useEffect(() => {
1510
+ if (loginState.workingState === 1) {
1511
+ setTimeout(() => {
1512
+ inputPassRef?.current?.focus?.();
1513
+ }, 2000);
1514
+ }
1515
+ }, [loginState.workingState]);
1516
+ return (jsx(Fragment, { children: jsxs("div", { className: classes.formWrap, children: [jsx(TextField, { autoFocus: true, label: t("UserID"), placeholder: String(t("UserID")), fullWidth: true, type: "text", name: "userName", value: input.userName || "", onChange: handleChange, error: loginState.isUsernameError, helperText: loginState.isUsernameError
1517
+ ? t(loginState.userMessageforusername)
1518
+ : "", InputLabelProps: { shrink: true }, disabled: loginState.loading
1519
+ ? true
1520
+ : loginState.workingState === 0
1521
+ ? false
1522
+ : true, autoComplete: "off", ref: inputRef, inputProps: { maxLength: 16 }, onKeyDown: (e) => {
1523
+ if (e.key === "Enter") {
1524
+ inputButtonRef?.current?.click?.();
1525
+ }
1526
+ }, style: { paddingBottom: "8px" } }), loginState.workingState === 0 ? (jsx(TextField, { label: t("MobileNo"), placeholder: "Enter Mobile No.",
1527
+ // placeholder={String(t("EnterMobileNo"))}
1528
+ fullWidth: true, type: "text", name: "mobileno", value: input.mobileno || "", onChange: handleChange, error: loginState.isMobileError, helperText: loginState.isMobileError
1529
+ ? t(loginState.userMessageforMobileno)
1530
+ : "", InputLabelProps: { shrink: true }, disabled: loginState.loading
1531
+ ? true
1532
+ : loginState.workingState === 0
1533
+ ? false
1534
+ : true, autoComplete: "off", onKeyDown: (e) => {
1535
+ if (e.key === "Enter") {
1536
+ inputButtonRef?.current?.click?.();
1537
+ }
1538
+ }, inputProps: { maxLength: 13 }, style: { paddingBottom: "8px" } })) : null, loginState.workingState === 1 ? (jsxs(Fragment$1, { children: [jsx(TextField, { autoFocus: true, label: t("Password"), placeholder: "Enter Password", fullWidth: true, type: showPassword ? "text" : "password", name: "password", value: input.password || "", onChange: handleChange, error: loginState.isPasswordError, helperText: loginState.isPasswordError
1539
+ ? t(loginState.userMessageforPassword)
1540
+ : "", InputLabelProps: { shrink: true }, disabled: loginState.loading, autoComplete: "off", ref: inputPassRef, onKeyDown: (e) => {
1541
+ if (e.key === "Enter") {
1542
+ inputButtonRef?.current?.click?.();
1543
+ }
1544
+ }, InputProps: {
1545
+ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(IconButton, { "aria-label": "toggle password visibility", onClick: () => {
1546
+ if (!showPassword) {
1547
+ setShowPasswordTime(Date.now() + 5000);
1548
+ timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
1549
+ }
1550
+ else if (showPassword)
1551
+ setShowPasswordTime(0);
1552
+ }, onMouseDown: (e) => e.preventDefault(), disabled: loginState.loading, children: showPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) }) })),
1553
+ }, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } }), jsx(TextField, { label: t("ConfirmPassword"), placeholder: String(t("EnterConfirmPassword")), fullWidth: true, type: showConfirmPassword ? "text" : "password", name: "confirmpassword", value: input.confirmpassword || "", onChange: handleChange, error: loginState.isConfirmPasswordError, helperText: loginState.isConfirmPasswordError
1554
+ ? t(loginState.userMessageforconfirmPassword)
1555
+ : "", InputLabelProps: { shrink: true }, disabled: loginState.loading, autoComplete: "off", onKeyDown: (e) => {
1556
+ if (e.key === "Enter") {
1557
+ inputButtonRef?.current?.click?.();
1558
+ }
1559
+ }, InputProps: {
1560
+ endAdornment: (jsx(InputAdornment, { position: "end", children: jsx(IconButton, { "aria-label": "toggle password visibility", onClick: () => {
1561
+ if (!showConfirmPassword) {
1562
+ setShowConfirmPasswordTime(Date.now() + 5000);
1563
+ timerRef.current = setTimeout(() => forceUpdate(Date.now()), 5000);
1564
+ }
1565
+ else if (showConfirmPassword)
1566
+ setShowConfirmPasswordTime(0);
1567
+ }, onMouseDown: (e) => e.preventDefault(), disabled: loginState.loading, children: showConfirmPassword ? jsx(Visibility, {}) : jsx(VisibilityOff, {}) }) })),
1568
+ }, inputProps: { maxLength: 16 }, style: { paddingBottom: "8px" } })] })) : null, loginState.isApiError ? (jsx(FormHelperText, { style: { color: "red" }, children: loginState.apierrorMessage })) : null, jsx("div", { style: {
1569
+ marginTop: "20px",
1570
+ display: "flex",
1571
+ flexDirection: "row-reverse",
1572
+ }, children: jsx("div", { style: {
1573
+ flex: "auto",
1574
+ textAlign: "center",
1575
+ marginTop: "5px",
1576
+ marginBottom: "17px",
1577
+ }, children: jsxs("div", { children: [jsx(GradientButton, { style: { borderRadius: "10px", marginRight: "5px" },
1578
+ // fullWidth
1579
+ disabled: loginState.loading, onClick: () => {
1580
+ navigate(loginPageEndpoint);
1581
+ }, starticon: "West", rotateIcon: "scale(1.4) rotateX(360deg)", children: t("backtologin") }), jsx(GradientButton, { style: { borderRadius: "10px" }, disabled: loginState.loading, onClick: () => {
1582
+ onSubmit(input, loginState.workingState);
1583
+ }, ref: inputButtonRef, endicon: loginState.loading ? undefined : "East", rotateIcon: "scale(1.4) rotateX(360deg)", children: loginState.loading ? (jsx(CircularProgress, { size: 25, thickness: 4.6 })) : (t("Next")) })] }) }) })] }) }));
1584
+ };
1585
+
1586
+ const ValidatePassword = (pwd) => {
1587
+ // if (!Boolean(pwd)) {
1588
+ // return "Password is Required";
1589
+ // } else if (pwd.length < 8 || pwd.length > 16) {
1590
+ // return "Password must be between 8 and 16 characters long.";
1591
+ // }
1592
+ // return "";
1593
+ if (!Boolean(pwd)) {
1594
+ // return t("PasswordisRequired");
1595
+ return "Password is Required";
1596
+ }
1597
+ else if (!/(?=.*\d)(?=.*[a-z])(?=.*[A-Z])(?=.*\W)(?!.*\s)/.test(pwd)) {
1598
+ // return t("EnterPasswordPolicy");
1599
+ return "Password must be 8-16 characters long, containing at least one uppercase letter, one lowercase letter, one number, and one special character, with no spaces allowed.";
1600
+ }
1601
+ else if (pwd.length < 8 || pwd.length > 16) {
1602
+ // return t("EnterPasswordValid");
1603
+ return "Password must be between 8 and 16 characters long.";
1604
+ // return "Password must be between 8 and 16 characters long.";
1605
+ }
1606
+ return "";
1607
+ };
1608
+ const inititalState = {
1609
+ isUsernameError: false,
1610
+ userMessageforusername: "",
1611
+ loading: false,
1612
+ isMobileError: false,
1613
+ userMessageforMobileno: "",
1614
+ isPasswordError: false,
1615
+ userMessageforPassword: "",
1616
+ isConfirmPasswordError: false,
1617
+ userMessageforconfirmPassword: "",
1618
+ workingState: 0,
1619
+ isApiError: false,
1620
+ apierrorMessage: "",
1621
+ otploading: false,
1622
+ OtpuserMessage: "",
1623
+ otpmodelClose: false,
1624
+ requestCd: "",
1625
+ username: "",
1626
+ auth_type: "O",
1627
+ transactionID: "",
1628
+ };
1629
+ const reducer = (state, action) => {
1630
+ switch (action.type) {
1631
+ case "verifyUserNameandMobileNoFailed": {
1632
+ return {
1633
+ ...state,
1634
+ loading: false,
1635
+ isUsernameError: action?.payload?.isUsernameError ?? false,
1636
+ isMobileError: action?.payload?.isMobileError ?? false,
1637
+ userMessageforusername: action?.payload?.userMessageforusername ?? "",
1638
+ userMessageforMobileno: action?.payload?.userMessageforMobileno ?? "",
1639
+ isApiError: action?.payload?.isApiError ?? false,
1640
+ apierrorMessage: action?.payload?.apierrorMessage ?? "",
1641
+ requestCd: "",
1642
+ username: "",
1643
+ };
1644
+ }
1645
+ case "initverifyUserNameandMobileNo": {
1646
+ return {
1647
+ ...state,
1648
+ loading: true,
1649
+ isUsernameError: false,
1650
+ isMobileError: false,
1651
+ requestCd: "",
1652
+ username: "",
1653
+ };
1654
+ }
1655
+ case "verifyUserNameandMobileNoSuccess": {
1656
+ return {
1657
+ ...state,
1658
+ loading: false,
1659
+ isUsernameError: false,
1660
+ isMobileError: false,
1661
+ workingState: 0,
1662
+ isApiError: false,
1663
+ apierrorMessage: "",
1664
+ requestCd: action?.payload?.requestCd ?? "",
1665
+ username: action?.payload?.username ?? "",
1666
+ auth_type: action?.payload?.auth_type,
1667
+ company_ID: action?.payload?.company_ID,
1668
+ branch_cd: action?.payload?.branch_cd,
1669
+ otpValidFor: action?.payload?.otpValidFor,
1670
+ };
1671
+ }
1672
+ case "inititateOTPVerification": {
1673
+ return {
1674
+ ...state,
1675
+ loading: false,
1676
+ otploading: true,
1677
+ OtpuserMessage: "",
1678
+ otpmodelClose: false,
1679
+ };
1680
+ }
1681
+ case "OTPVerificationComplate": {
1682
+ return {
1683
+ ...state,
1684
+ loading: false,
1685
+ otploading: false,
1686
+ OtpuserMessage: "",
1687
+ workingState: 1,
1688
+ otpmodelClose: Boolean(action?.payload?.otpmodelclose),
1689
+ };
1690
+ }
1691
+ case "OTPVerificationFailed": {
1692
+ return {
1693
+ ...state,
1694
+ otploading: false,
1695
+ OtpuserMessage: action?.payload?.error,
1696
+ otpmodelClose: Boolean(action?.payload?.otpmodelclose),
1697
+ };
1698
+ }
1699
+ case "verifyPasswordFailed": {
1700
+ return {
1701
+ ...state,
1702
+ loading: false,
1703
+ isPasswordError: action?.payload?.isPasswordError ?? false,
1704
+ isConfirmPasswordError: action?.payload?.isConfirmPasswordError ?? false,
1705
+ userMessageforPassword: action?.payload?.userMessageforPassword ?? "",
1706
+ userMessageforconfirmPassword: action?.payload?.userMessageforconfirmPassword ?? "",
1707
+ isApiError: false,
1708
+ apierrorMessage: "",
1709
+ };
1710
+ }
1711
+ case "initverifyPasswordSetReq": {
1712
+ return {
1713
+ ...state,
1714
+ loading: true,
1715
+ isPasswordError: false,
1716
+ isConfirmPasswordError: false,
1717
+ };
1718
+ }
1719
+ case "passwordRegistaredSuccess": {
1720
+ return {
1721
+ ...state,
1722
+ loading: false,
1723
+ isPasswordError: false,
1724
+ isConfirmPasswordError: false,
1725
+ };
1726
+ }
1727
+ case "OTPResendSuccess": {
1728
+ return {
1729
+ ...state,
1730
+ requestCd: action?.payload?.requestCd,
1731
+ };
1732
+ }
1733
+ default: {
1734
+ return state;
1735
+ }
1736
+ }
1737
+ };
1738
+ const ForgotPasswordControllerWrapper = ({ screenFlag, updatenewPassword, veirfyUsernameandMobileNo, verifyOTPForPWDReset, logoUrl, logoTitle, LanguageComponent, bannerDetails, navigate, loginPageEndpoint, }) => {
1739
+ const classes = useStyles$3();
1740
+ const [loginState, dispath] = useReducer(reducer, inititalState);
1741
+ const [open, setOpen] = useState(false);
1742
+ const { enqueueSnackbar } = useSnackbar();
1743
+ const otpResendRef = useRef(1);
1744
+ const { t } = useTranslation();
1745
+ const [dashboardLogoURL, setDashboardLogoURL] = useState(null);
1746
+ const urlObj = useRef(null);
1747
+ useEffect(() => {
1748
+ if (Boolean(logoUrl)) {
1749
+ if (isBase64(logoUrl)) {
1750
+ let blob = utilFunction.base64toBlob(logoUrl);
1751
+ urlObj.current =
1752
+ typeof blob === "object" && Boolean(blob)
1753
+ ? URL.createObjectURL(blob)
1754
+ : "";
1755
+ setDashboardLogoURL(urlObj.current);
1756
+ }
1757
+ else {
1758
+ setDashboardLogoURL(logoUrl);
1759
+ }
1760
+ }
1761
+ }, [logoUrl]);
1762
+ const onSubmitHandel = async (data, flag) => {
1763
+ if (verifyRequestData(data, flag)) {
1764
+ if (flag === 0) {
1765
+ dispath({ type: "initverifyUserNameandMobileNo" });
1766
+ const { status, data: resdata, message, } = await veirfyUsernameandMobileNo(data?.userName.toLowerCase(), data?.mobileno, screenFlag);
1767
+ if (status === "0") {
1768
+ dispath({
1769
+ type: "verifyUserNameandMobileNoSuccess",
1770
+ payload: {
1771
+ requestCd: String(resdata?.TRAN_CD ?? ""),
1772
+ username: data?.userName,
1773
+ auth_type: resdata?.AUTH_TYPE,
1774
+ company_ID: resdata?.COMP_CD,
1775
+ branch_cd: resdata?.BRANCH_CD,
1776
+ otpValidFor: resdata?.OTP_VALID,
1777
+ },
1778
+ });
1779
+ setOpen(true);
1780
+ }
1781
+ else {
1782
+ dispath({
1783
+ type: "verifyUserNameandMobileNoFailed",
1784
+ payload: {
1785
+ isApiError: true,
1786
+ apierrorMessage: message,
1787
+ },
1788
+ });
1789
+ }
1790
+ }
1791
+ else if (flag === 1) {
1792
+ dispath({ type: "initverifyPasswordSetReq" });
1793
+ const { status, data: resdata, message, } = await updatenewPassword(loginState?.requestCd, loginState?.username, data?.password);
1794
+ if (status === "0") {
1795
+ dispath({ type: "passwordRegistaredSuccess" });
1796
+ enqueueSnackbar("Password successfully reset", {
1797
+ variant: "success",
1798
+ });
1799
+ navigate(loginPageEndpoint);
1800
+ }
1801
+ else if (status === "99") {
1802
+ dispath({
1803
+ type: "verifyPasswordFailed",
1804
+ payload: {
1805
+ isApiError: true,
1806
+ apierrorMessage: message,
1807
+ },
1808
+ });
1809
+ }
1810
+ else {
1811
+ enqueueSnackbar(message, {
1812
+ variant: "error",
1813
+ });
1814
+ navigate(loginPageEndpoint);
1815
+ }
1816
+ }
1817
+ }
1818
+ };
1819
+ const verifyRequestData = (data, flag) => {
1820
+ if (flag === 0) {
1821
+ let validationData = {
1822
+ isUsernameError: false,
1823
+ isMobileError: false,
1824
+ userMessageforusername: "",
1825
+ userMessageforMobileno: "",
1826
+ };
1827
+ if (!Boolean(data.userName)) {
1828
+ validationData.isUsernameError = true;
1829
+ validationData.userMessageforusername = "UsernameisRequired";
1830
+ }
1831
+ if (!Boolean(data.mobileno)) {
1832
+ validationData.isMobileError = true;
1833
+ validationData.userMessageforMobileno = "MobileNoisRequired";
1834
+ }
1835
+ else if (isNaN(data.mobileno) ||
1836
+ (data.mobileno.length !== 10 && data.mobileno.length !== 13)) {
1837
+ validationData.isMobileError = true;
1838
+ validationData.userMessageforMobileno = "Please enter valid Mobile No.";
1839
+ }
1840
+ dispath({
1841
+ type: "verifyUserNameandMobileNoFailed",
1842
+ payload: validationData,
1843
+ });
1844
+ return !(validationData.isMobileError || validationData.isUsernameError);
1845
+ }
1846
+ else if (flag === 1) {
1847
+ let validationData = {
1848
+ isPasswordError: false,
1849
+ userMessageforPassword: "",
1850
+ isConfirmPasswordError: false,
1851
+ userMessageforconfirmPassword: "",
1852
+ };
1853
+ let pwdverify = ValidatePassword(data.password);
1854
+ if (Boolean(pwdverify)) {
1855
+ validationData.isPasswordError = true;
1856
+ validationData.userMessageforPassword = pwdverify;
1857
+ }
1858
+ if (!Boolean(data.confirmpassword)) {
1859
+ validationData.isConfirmPasswordError = true;
1860
+ validationData.userMessageforconfirmPassword =
1861
+ "Confirmpasswordisrequired";
1862
+ }
1863
+ else if (Boolean(data.password) &&
1864
+ data.password !== data.confirmpassword) {
1865
+ validationData.isConfirmPasswordError = true;
1866
+ validationData.userMessageforconfirmPassword =
1867
+ "New Password and Confirm Password did not matched";
1868
+ }
1869
+ dispath({
1870
+ type: "verifyPasswordFailed",
1871
+ payload: validationData,
1872
+ });
1873
+ return !(validationData.isConfirmPasswordError || validationData.isPasswordError);
1874
+ }
1875
+ return true;
1876
+ };
1877
+ const handleClose = () => {
1878
+ setOpen(false);
1879
+ };
1880
+ const VerifyOTP = async (OTPNumber) => {
1881
+ if (Boolean(OTPNumber) && OTPNumber.toString().length === 6) {
1882
+ dispath({ type: "inititateOTPVerification" });
1883
+ const { status, data: resdata, message, } = await verifyOTPForPWDReset(loginState?.requestCd, loginState?.username, OTPNumber, loginState?.auth_type, screenFlag);
1884
+ if (status === "0") {
1885
+ if (screenFlag === "totp") {
1886
+ enqueueSnackbar(message, {
1887
+ variant: "success",
1888
+ });
1889
+ navigate(loginPageEndpoint);
1890
+ }
1891
+ else {
1892
+ dispath({
1893
+ type: "OTPVerificationComplate",
1894
+ payload: { otpmodelclose: true },
1895
+ });
1896
+ }
1897
+ }
1898
+ else if (status === "99") {
1899
+ dispath({
1900
+ type: "OTPVerificationFailed",
1901
+ payload: { error: message },
1902
+ });
1903
+ }
1904
+ else {
1905
+ enqueueSnackbar(message, {
1906
+ variant: "error",
1907
+ });
1908
+ navigate(loginPageEndpoint);
1909
+ }
1910
+ }
1911
+ else {
1912
+ dispath({
1913
+ type: "OTPVerificationFailed",
1914
+ payload: { error: "Please enter a 6 digit OTP number" },
1915
+ });
1916
+ }
1917
+ };
1918
+ return (jsx(Fragment$1, { children: jsxs(Grid, { container: true, style: { height: "100vh", overflow: "hidden" }, children: [jsx(BankDetails, { bannerDetails: bannerDetails }), jsxs(Grid, { item: true, xs: 6, md: 6, lg: 6, sm: 6, children: [logoUrl ? (jsx(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", padding: "31px", maxWidth: "210px", ml: "auto", children: jsx("img", { src: Boolean(dashboardLogoURL) ? dashboardLogoURL : "", alt: "Logo", width: "100%" }) })) : null, LanguageComponent ? (jsx(Grid, { container: true, direction: "row", justifyContent: "flex-end", alignItems: "center", padding: "0 35px 0 0", maxWidth: "180px", ml: "auto", children: jsx(LanguageComponent, {}) })) : null, jsx(Container, { maxWidth: "xs", children: jsxs(Grid, { alignItems: "center", style: { paddingTop: "20px" }, children: [jsx("h2", { style: { margin: "10px 0" }, children: loginState.workingState === 1
1919
+ ? t("Setnewpassword")
1920
+ : screenFlag === "totp"
1921
+ ? "Forgot TOTP"
1922
+ : t("ForgotPassword") }), open ? (jsx(OTPModelForm, { classes: classes, handleClose: handleClose, loginState: loginState, VerifyOTP: VerifyOTP, OTPError: t(loginState?.OtpuserMessage ?? ""), setOTPError: (error) => {
1923
+ dispath({
1924
+ type: "OTPVerificationFailed",
1925
+ payload: { error: error },
1926
+ });
1927
+ }, resendFlag: "FORGET_PW", setNewRequestID: (newRequestID) => {
1928
+ dispath({
1929
+ type: "OTPResendSuccess",
1930
+ payload: { requestCd: newRequestID },
1931
+ });
1932
+ otpResendRef.current = otpResendRef.current + 1;
1933
+ }, otpresendCount: otpResendRef.current, OTPResendRequest: undefined })) : (jsx(ForgotPasswordFields, { classes: classes, loginState: loginState, onSubmit: onSubmitHandel, navigate: navigate, loginPageEndpoint: loginPageEndpoint }))] }) })] })] }) }));
1934
+ };
1935
+
1936
+ const BranchSelectionGridMetaData = {
1937
+ gridConfig: {
1938
+ dense: true,
1939
+ gridLabel: "Access Branch List",
1940
+ rowIdColumn: "BRANCH_CD",
1941
+ // searchPlaceholder: "Branches",
1942
+ defaultColumnConfig: {
1943
+ width: 400,
1944
+ maxWidth: 450,
1945
+ minWidth: 300,
1946
+ },
1947
+ allowColumnReordering: false,
1948
+ disableSorting: false,
1949
+ hideHeader: false,
1950
+ disableGroupBy: true,
1951
+ enablePagination: false,
1952
+ containerHeight: {
1953
+ min: "68vh",
1954
+ max: "68vh ",
1955
+ },
1956
+ allowFilter: false,
1957
+ allowColumnHiding: false,
1958
+ allowRowSelection: false,
1959
+ isCusrsorFocused: true,
1960
+ hideFooter: true,
1961
+ },
1962
+ columns: [
1963
+ {
1964
+ accessor: "BRANCH_CD",
1965
+ columnName: "Branch Code",
1966
+ sequence: 1,
1967
+ alignment: "left",
1968
+ componentType: "default",
1969
+ width: 200,
1970
+ minWidth: 140,
1971
+ maxWidth: 220,
1972
+ },
1973
+ {
1974
+ accessor: "BRANCH_NM",
1975
+ columnName: "Branch Name",
1976
+ sequence: 2,
1977
+ alignment: "left",
1978
+ componentType: "default",
1979
+ width: 280,
1980
+ minWidth: 280,
1981
+ maxWidth: 420,
1982
+ },
1983
+ {
1984
+ accessor: "DISP_STATUS",
1985
+ columnName: "Status",
1986
+ sequence: 3,
1987
+ alignment: "left",
1988
+ componentType: "default",
1989
+ width: 200,
1990
+ minWidth: 140,
1991
+ maxWidth: 220,
1992
+ },
1993
+ {
1994
+ accessor: "BEGIN_DATETIME",
1995
+ columnName: "Begin Time",
1996
+ sequence: 4,
1997
+ alignment: "left",
1998
+ componentType: "dateTime",
1999
+ width: 222,
2000
+ minWidth: 140,
2001
+ maxWidth: 240,
2002
+ },
2003
+ {
2004
+ accessor: "END_DATETIME",
2005
+ columnName: "End Time",
2006
+ sequence: 5,
2007
+ alignment: "left",
2008
+ componentType: "dateTime",
2009
+ width: 222,
2010
+ minWidth: 140,
2011
+ maxWidth: 240,
2012
+ },
2013
+ {
2014
+ accessor: "DAYEND_STATUS",
2015
+ columnName: "Dayend Status",
2016
+ sequence: 6,
2017
+ componentType: "default",
2018
+ isVisible: false,
2019
+ },
2020
+ {
2021
+ accessor: "EOD_RUNNING_STATUS",
2022
+ columnName: "EOD Running Status",
2023
+ sequence: 6,
2024
+ componentType: "default",
2025
+ isVisible: false,
2026
+ },
2027
+ {
2028
+ accessor: "BASE_COMP_CD",
2029
+ columnName: "Base Comp Cd",
2030
+ sequence: 6,
2031
+ componentType: "default",
2032
+ isVisible: false,
2033
+ },
2034
+ {
2035
+ accessor: "BASE_BRANCH_CD",
2036
+ columnName: "Base Branch Cd",
2037
+ sequence: 6,
2038
+ componentType: "default",
2039
+ isVisible: false,
2040
+ },
2041
+ {
2042
+ accessor: "COMP_CD",
2043
+ columnName: "Comp Cd",
2044
+ sequence: 6,
2045
+ componentType: "default",
2046
+ isVisible: false,
2047
+ },
2048
+ {
2049
+ accessor: "COMP_NM",
2050
+ columnName: "Comp Name",
2051
+ sequence: 6,
2052
+ componentType: "default",
2053
+ isVisible: false,
2054
+ },
2055
+ ],
2056
+ };
2057
+
2058
+ var css_248z = "*{box-sizing:border-box}*,.sideImage{margin:0;padding:0}.sideImage{display:flex;height:100%;position:relative;z-index:1}.bank-name,.emp-id{font-size:18px;font-weight:600;line-height:1em;margin:8px 0}.bank-name{word-wrap:break-word}.name-heading{color:var(--theme-color1);font-weight:400;position:relative;z-index:1}.name-heading span{color:var(--theme-color1);font-weight:700}";
2059
+ styleInject(css_248z);
2060
+
2061
+ var BecomePartnerImg = "BecomePartnerImg.svg";
2062
+
2063
+ var Waving_hand = "waving-hand.png";
2064
+
2065
+ const useStyles$2 = makeStyles((theme) => ({
2066
+ heading_user_img: {
2067
+ width: "40px",
2068
+ height: "40px",
2069
+ // cursor: "pointer",
2070
+ },
2071
+ heading_user_img_border: {
2072
+ border: "2px dashed var(--theme-color3)",
2073
+ borderRadius: "50%",
2074
+ padding: "4px",
2075
+ },
2076
+ logo: {
2077
+ height: "38px",
2078
+ },
2079
+ }));
2080
+
2081
+ var USER_PROFILE_DEFAULT = "profile-default.png";
2082
+
2083
+ const actions = [
2084
+ {
2085
+ actionName: "back",
2086
+ actionLabel: "Back",
2087
+ multiple: undefined,
2088
+ rowDoubleClick: false,
2089
+ alwaysAvailable: true,
2090
+ // actionTextColor: "var(--theme-color3)",
2091
+ // actionBackground: "var(--theme-color2)",
2092
+ // startsIcon: "West",
2093
+ // rotateIcon: "scale(1.4) rotateX(-360deg)",
2094
+ },
2095
+ {
2096
+ actionName: "proceed",
2097
+ actionLabel: "Proceed",
2098
+ multiple: false,
2099
+ rowDoubleClick: true,
2100
+ // actionTextColor: "var(--theme-color2)",
2101
+ // actionBackground: "var(--theme-color3)",
2102
+ // onEnterSubmit: true,
2103
+ // endsIcon: "East",
2104
+ // rotateIcon: "scale(1.4) rotateX(-360deg)",
2105
+ },
2106
+ ];
2107
+ const BranchSelectionGrid = ({ selectionMode, authState, isBranchSelectedFn, isLoggedInFn, logoutFn, logos, logo, navigate, BranchSelectionGridDataApiFn, GetMenuDataApiFn, sideImage, branchSelectFn, dashboardUrl, loginUrl, appTranCd, }) => {
2108
+ const classes = useStyles$2();
2109
+ const { enqueueSnackbar } = useSnackbar();
2110
+ const { data, isLoading, isFetching, refetch, error, isError } = useQuery(["BranchSelectionGridData"], () => BranchSelectionGridDataApiFn());
2111
+ useEffect(() => {
2112
+ return () => {
2113
+ queryClient.removeQueries(["BranchSelectionGridData", {}]);
2114
+ };
2115
+ }, []);
2116
+ useEffect(() => {
2117
+ if (!isLoggedInFn()) {
2118
+ navigate(loginUrl);
2119
+ }
2120
+ else if (isBranchSelectedFn() && selectionMode !== "C") {
2121
+ navigate(dashboardUrl);
2122
+ }
2123
+ }, [isBranchSelectedFn, isLoggedInFn]);
2124
+ const mutation = useMutation(GetMenuDataApiFn, {
2125
+ onSuccess: (data, extreData) => {
2126
+ branchSelectFn({
2127
+ menulistdata: data,
2128
+ branchCode: extreData?.BRANCH_CD,
2129
+ branch: extreData?.BRANCH_NM,
2130
+ baseBranchCode: extreData?.BASE_BRANCH_CD,
2131
+ });
2132
+ },
2133
+ });
2134
+ const getError = mutation.error;
2135
+ const setCurrentAction = useCallback((data) => {
2136
+ if (data.name === "proceed") {
2137
+ if (data.rows?.length === 0) {
2138
+ enqueueSnackbar("Please Select Branch", {
2139
+ variant: "error",
2140
+ });
2141
+ }
2142
+ else if (data.rows?.[0]?.data?.STATUS === "C") {
2143
+ enqueueSnackbar("Branch is in Day End Status.~rPlease contact system Vendor.", {
2144
+ variant: "error",
2145
+ });
2146
+ }
2147
+ else {
2148
+ mutation.mutate({
2149
+ BASE_COMP_CD: data.rows?.[0]?.data?.BASE_COMP_CD ?? "",
2150
+ BASE_BRANCH_CD: data.rows?.[0]?.data?.BASE_BRANCH_CD ?? "",
2151
+ COMP_CD: data.rows?.[0]?.data?.COMP_CD ?? "",
2152
+ BRANCH_CD: data.rows?.[0]?.data?.BRANCH_CD ?? "",
2153
+ GROUP_NAME: authState?.groupName ?? "",
2154
+ APP_TRAN_CD: appTranCd,
2155
+ COMP_NM: data.rows?.[0]?.data?.COMP_NM ?? "",
2156
+ BRANCH_NM: data.rows?.[0]?.data?.BRANCH_NM ?? "",
2157
+ DAYEND_STATUS: data.rows?.[0]?.data?.DAYEND_STATUS ?? "",
2158
+ EOD_RUNNING_STATUS: data.rows?.[0]?.data?.EOD_RUNNING_STATUS ?? "",
2159
+ IS_UPD_DEF_BRANCH: authState?.user?.isUpdDefBranch ?? "",
2160
+ COMP_BASE_BRANCH_CD: data.rows?.[0]?.data?.COMP_BASE_BRANCH_CD ?? "",
2161
+ selectionMode: selectionMode,
2162
+ });
2163
+ }
2164
+ }
2165
+ else if (data.name === "back") {
2166
+ if (selectionMode === "C") {
2167
+ navigate(dashboardUrl, {
2168
+ replace: true,
2169
+ });
2170
+ }
2171
+ else {
2172
+ logoutFn();
2173
+ }
2174
+ }
2175
+ }, [navigate, data, mutation]);
2176
+ useEffect(() => {
2177
+ var oneBranchOpen = data?.some((branch) => branch.STATUS === "O");
2178
+ if (oneBranchOpen === false) {
2179
+ enqueueSnackbar("Branch is in Day End Status.~rPlease contact system Vendor.", {
2180
+ variant: "error",
2181
+ });
2182
+ logoutFn();
2183
+ }
2184
+ if (data?.length === 1) {
2185
+ if (data?.[0]?.STATUS === "O") {
2186
+ setCurrentAction({ name: "proceed", rows: [{ data: { ...data[0] } }] });
2187
+ }
2188
+ }
2189
+ }, [JSON.stringify(data)]);
2190
+ const Greetings = () => {
2191
+ let hours = new Date().getHours();
2192
+ let greet;
2193
+ if (hours < 12)
2194
+ greet = "morning";
2195
+ else if (hours >= 12 && hours <= 16)
2196
+ greet = "afternoon";
2197
+ else if (hours >= 16 && hours <= 24)
2198
+ greet = "evening";
2199
+ return jsxs("span", { children: ["Good ", greet, ","] });
2200
+ };
2201
+ const LightTooltip = styled(({ className, ...props }) => (jsx(Tooltip, { ...props, classes: { popper: className } })))(({ theme }) => ({
2202
+ [`& .${tooltipClasses.tooltip}`]: {
2203
+ backgroundColor: theme.palette.common.white,
2204
+ color: "rgba(0, 0, 0, 0.87)",
2205
+ boxShadow: theme.shadows[1],
2206
+ fontSize: 13,
2207
+ },
2208
+ }));
2209
+ // const greet = Greetings();
2210
+ return (jsx(Fragment$1, { children: jsxs(Grid, { container: true, style: {
2211
+ margin: "0",
2212
+ padding: "0",
2213
+ height: "100vh",
2214
+ // overflowY: "hidden",
2215
+ }, children: [sideImage ? (jsx(Grid, { item: true, lg: 1, md: 1, xl: 1, xs: 1, sm: 1, children: jsx("img", { className: "sideImage", src: sideImage, alt: "side-Image" }) })) : null, jsx(Grid, { item: true, lg: 11, md: 11, xl: 11, xs: 11, style: {
2216
+ display: "flex",
2217
+ justifyContent: "center",
2218
+ }, children: jsxs(Grid, { container: true, style: {
2219
+ minHeight: "100vh",
2220
+ padding: "10px 0px 0px 0px",
2221
+ }, lg: 11, md: 11, xl: 11, xs: 11, children: [jsxs(Grid, { container: true, style: {
2222
+ margin: "0",
2223
+ padding: "0",
2224
+ // height: "12vh",
2225
+ }, lg: 12, md: 12, xl: 12, xs: 12, children: [jsx(Grid, { xs: 12, sm: 1, md: 1, lg: 1, xl: 1, sx: {
2226
+ display: "flex",
2227
+ alignItems: "center",
2228
+ // justifyContent: "center",
2229
+ }, children: jsx(Stack, { direction: "row", spacing: 4, ml: 1, children: jsx(Box, { className: classes.heading_user_img_border, sx: { cursor: "pointer" }, children: jsx(LightTooltip, { title: jsxs(Fragment$1, { children: [jsxs("div", { children: ["User ID : ", authState?.user?.id ?? ""] }), jsxs("div", { children: ["Role : ", authState?.roleName ?? ""] }), jsx("div", { children: "Last Unsuccessful Login : \"\"" })] }), placement: "bottom-start", children: jsx(Avatar, { className: classes.heading_user_img,
2230
+ // onClick={handleNavigate}
2231
+ alt: "Remy Sharp", src: Boolean(logos?.profile)
2232
+ ? logos?.profile
2233
+ : USER_PROFILE_DEFAULT }) }) }) }) }), jsxs(Grid, { xs: 12, sm: 5, md: 5, lg: 5, xl: 5, sx: {
2234
+ justifyContent: "center",
2235
+ display: "flex",
2236
+ flexDirection: "column",
2237
+ }, children: [jsxs("h1", { className: "name-heading", style: { fontSize: "24px", margin: "4px 0px" }, children: ["Welcome ", jsx("span", { children: `${authState?.user?.name ?? ""},` })] }), jsxs("div", { style: { display: "flex", alignItems: "center", gap: 10 }, children: [jsx("h3", { style: { margin: "4px 0px" }, children: Greetings() }), jsx("img", { src: Waving_hand, alt: "", style: { height: "18px" } })] })] }), jsx(Grid, { xs: 12, sm: 1, md: 1, lg: 1, xl: 1, sx: {
2238
+ display: "flex",
2239
+ // flexDirection: "column",
2240
+ justifyContent: "center",
2241
+ alignItems: "center",
2242
+ }, children: jsx(Stack, { direction: "row", justifyContent: "flex-start", spacing: 2, children: jsx(Box, { className: classes.heading_user_img_border, children: jsx(Avatar, { className: classes.heading_user_img, alt: "Remy Sharp", src: Boolean(logos?.bank) ? logos?.bank : BecomePartnerImg }) }) }) }), jsxs(Grid, { xs: 12, sm: 3, md: 3, lg: 3, xl: 3, sx: {
2243
+ display: "flex",
2244
+ flexDirection: "column",
2245
+ justifyContent: "center",
2246
+ }, children: [jsx("div", { className: "bank-name-container", style: { fontSize: "14px" }, children: jsx("p", { className: "bank-name", children: `Bank Name: ${authState?.companyName ?? ""}` }) }), jsx("p", { className: "emp-id", children: `Emp. Id: ${authState?.user?.employeeID ?? ""}` })] }), jsxs(Grid, { xs: 12, sm: 3, md: 3, lg: 2, xl: 2, sx: {
2247
+ display: "flex",
2248
+ alignItems: "center",
2249
+ justifyContent: "right",
2250
+ }, children: [" ", jsx("div", { children: jsx("img", { src: Boolean(logos?.logo) ? logos?.logo : logo, alt: "CbsEnfinity", className: classes.logo }) })] })] }), isError ? (jsx(Fragment, { children: jsx("div", { style: { width: "100%", paddingTop: "10px" }, children: jsx(Alert, { severity: error?.severity ?? "error", errorMsg: error?.error_msg ?? "Error", errorDetail: error?.error_detail ?? "" }) }) })) : mutation.isError && mutation.error ? (jsx(Fragment, { children: jsx("div", { style: { width: "100%", paddingTop: "10px" }, children: jsx(Alert, { severity: getError.severity ?? "error", errorMsg: getError.error_msg ?? "Error", errorDetail: getError.error_detail ?? "" }) }) })) : null, jsx(GridWrapper, { finalMetaData: BranchSelectionGridMetaData, data: data ?? [], setData: () => null, actions: actions, setAction: setCurrentAction,
2251
+ // controlsAtBottom={true}
2252
+ // headerToolbarStyle={{
2253
+ // background: "var(--theme-color2)",
2254
+ // color: "black",
2255
+ // padding: "0",
2256
+ // }}
2257
+ // onlySingleSelectionAllow={true}
2258
+ // isNewRowStyle={true}
2259
+ loading: isLoading || isFetching || mutation.isLoading }, `branchSelection`), isError || data?.length === 0 ? (jsx(Button, { sx: {
2260
+ backgroundColor: "var(--theme-color3)",
2261
+ position: "absolute",
2262
+ right: "113px",
2263
+ bottom: "20px",
2264
+ width: "7rem",
2265
+ "&:hover": {
2266
+ backgroundColor: "var(--theme-color3)",
2267
+ },
2268
+ }, onClick: () => {
2269
+ if (selectionMode === "C") {
2270
+ navigate(dashboardUrl, {
2271
+ replace: true,
2272
+ });
2273
+ }
2274
+ else {
2275
+ logoutFn();
2276
+ }
2277
+ }, children: "Back" })) : null] }) })] }) }));
2278
+ };
2279
+ const BranchSelectionGridWrapper = (props) => {
2280
+ return (jsx(ClearCacheProvider, { children: jsx(BranchSelectionGrid, { ...props }) }));
2281
+ };
2282
+
2283
+ const useStyles$1 = makeStyles((theme) => ({
2284
+ appBar: {
2285
+ // zIndex: theme.zIndex.drawer + 1,
2286
+ transition: theme.transitions.create(["width", "margin"], {
2287
+ easing: theme.transitions.easing.sharp,
2288
+ duration: theme.transitions.duration.leavingScreen,
2289
+ }),
2290
+ color: "#0063A3",
2291
+ height: "80px",
2292
+ background: "var(--theme-color2)",
2293
+ boxShadow: "0px 1px 0px -0.5px #DEE0E2",
2294
+ },
2295
+ searchBar: {
2296
+ width: 290,
2297
+ border: "none",
2298
+ color: "rgba(0, 0, 0, 0.87) !important",
2299
+ backgroundColor: "rgb(235 237 238 / 26%)!important",
2300
+ "& input": {
2301
+ width: "100% !important",
2302
+ },
2303
+ },
2304
+ searchList: {
2305
+ position: "absolute",
2306
+ background: "#fff",
2307
+ width: "100%",
2308
+ borderRadius: "6px",
2309
+ boxShadow: "0 12px 25px rgba(0,0,0,.3)",
2310
+ top: "120%",
2311
+ height: "auto",
2312
+ maxHeight: "325px",
2313
+ overflowY: "auto",
2314
+ "& .list-links": {
2315
+ background: "none",
2316
+ border: "none",
2317
+ outline: "none",
2318
+ cursor: "pointer",
2319
+ textDecoration: "none",
2320
+ padding: "0.7rem 1rem",
2321
+ fontSize: "0.90rem",
2322
+ textAlign: "left",
2323
+ borderBottom: "1px solid #ddd",
2324
+ color: "#222 !important",
2325
+ fontWeight: 500,
2326
+ "&:hover, &.active": {
2327
+ backgroundColor: "#f4f4f4",
2328
+ },
2329
+ },
2330
+ },
2331
+ appBarShift: {
2332
+ paddingLeft: "0px",
2333
+ // width: `calc(100% - ${drawerWidth}px)`,
2334
+ transition: theme.transitions.create(["width", "margin"], {
2335
+ easing: theme.transitions.easing.sharp,
2336
+ duration: theme.transitions.duration.enteringScreen,
2337
+ background: "rgba(250, 251, 255, 0.9)",
2338
+ }),
2339
+ },
2340
+ heading_user_dtl: {
2341
+ width: "458px",
2342
+ height: "73px",
2343
+ left: "37px",
2344
+ top: "calc(50% - 73px/2)",
2345
+ },
2346
+ heading_user_img: {
2347
+ width: "40px",
2348
+ height: "40px",
2349
+ // cursor: "pointer",
2350
+ },
2351
+ heading_user_img_border: {
2352
+ border: "2px dashed var(--theme-color3)",
2353
+ borderRadius: "50%",
2354
+ padding: "4px",
2355
+ },
2356
+ toolbar: {
2357
+ minHeight: "80px",
2358
+ paddingLeft: "0px",
2359
+ height: "80px",
2360
+ },
2361
+ title: {
2362
+ flexGrow: 1,
2363
+ padding: theme.spacing(0.5, 0),
2364
+ color: "var(--theme-color1)",
2365
+ },
2366
+ searchRoot: {
2367
+ fontFamily: theme.typography.fontFamily,
2368
+ position: "relative",
2369
+ boxShadow: "0px 2px 4px -1px rgba(0,0,0,0.2), 0px 4px 5px 0px rgba(0,0,0,0.14), 0px 1px 10px 0px rgba(0,0,0,0.12)",
2370
+ marginRight: theme.spacing(2),
2371
+ marginLeft: theme.spacing(1),
2372
+ marginBottom: theme.spacing(0.25),
2373
+ marginTop: theme.spacing(0.25),
2374
+ borderRadius: 40,
2375
+ backgroundColor: alpha(theme.palette.common.white, 0.15),
2376
+ "&:hover": {
2377
+ backgroundColor: alpha(theme.palette.common.white, 0.25),
2378
+ },
2379
+ "& $inputInput": {
2380
+ transition: theme.transitions.create("width"),
2381
+ width: 120,
2382
+ "&:focus": {
2383
+ width: 170,
2384
+ },
2385
+ },
2386
+ },
2387
+ search: {
2388
+ width: theme.spacing(6),
2389
+ height: "100%",
2390
+ position: "absolute",
2391
+ pointerEvents: "none",
2392
+ display: "flex",
2393
+ alignItems: "center",
2394
+ justifyContent: "center",
2395
+ },
2396
+ inputRoot: {
2397
+ color: "inherit",
2398
+ marginTop: 0,
2399
+ borderRadius: "40px",
2400
+ },
2401
+ inputInput: {
2402
+ padding: theme.spacing(1, 1, 1, 6),
2403
+ },
2404
+ loggedInUser: {
2405
+ marginLeft: theme.spacing(2),
2406
+ },
2407
+ nameClass: {
2408
+ color: "#0063A3",
2409
+ fontWeight: 600,
2410
+ textTransform: "capitalize",
2411
+ lineHeight: "1.4",
2412
+ textAlign: "left",
2413
+ },
2414
+ dropDown: {
2415
+ fontSize: "2rem",
2416
+ },
2417
+ vTop: {
2418
+ verticalAlign: "top",
2419
+ paddingLeft: "4px",
2420
+ color: "var(--theme-color1)",
2421
+ },
2422
+ userDesignation: {
2423
+ margin: "0px",
2424
+ fontWeight: 500,
2425
+ fontSize: "0.875rem",
2426
+ lineHeight: 1.57,
2427
+ color: "var(--theme-color1)",
2428
+ },
2429
+ userName: {
2430
+ margin: "0px",
2431
+ fontWeight: 500,
2432
+ fontSize: "0.875rem",
2433
+ lineHeight: 1.57,
2434
+ color: "var(--theme-color3)",
2435
+ },
2436
+ userprofilehover: {
2437
+ "&:hover": {
2438
+ backgroundColor: "var(--theme-color2)",
2439
+ },
2440
+ },
2441
+ lang_svg: {
2442
+ marginRight: "10px",
2443
+ width: "22px",
2444
+ height: "22px",
2445
+ },
2446
+ logo: {
2447
+ height: "38px",
2448
+ },
2449
+ version01: {
2450
+ margin: "0",
2451
+ textAlign: "center",
2452
+ color: "var(--theme-color3)",
2453
+ fontSize: "9px",
2454
+ },
2455
+ DrawerClose_icon: {
2456
+ color: "var(--theme-color3)",
2457
+ position: "static",
2458
+ background: "transperant",
2459
+ "&:hover": {
2460
+ background: "var(--theme-color4)",
2461
+ },
2462
+ width: "46px",
2463
+ height: "46px",
2464
+ },
2465
+ marquee: {
2466
+ animation: "$marquee 10s linear infinite",
2467
+ animationDelay: "3s",
2468
+ },
2469
+ "@keyframes marquee": {
2470
+ "0%": { transform: "translateX(100%)" },
2471
+ "100%": { transform: "translateX(-100%)" },
2472
+ },
2473
+ popover: {
2474
+ popover: {
2475
+ maxWidth: "100%",
2476
+ width: "fit-content",
2477
+ "& .MuiPopover-paper": {
2478
+ maxWidth: "100%",
2479
+ },
2480
+ },
2481
+ },
2482
+ }));
2483
+
2484
+ const AppbarWrapper = ({ handleDrawerOpen, handleDrawerClose, open, authState, LanguageComponent, SearchComponent, dashboardUrl, logos, bankLogo, profilePic, handleLogout, handleProfile, navigate, hideGreetings, menuIconPosition = "left", }) => {
2485
+ console.log(BecomePartnerImg);
2486
+ const classes = useStyles$1();
2487
+ const { t } = useTranslation();
2488
+ const LightTooltip = styled(({ className, ...props }) => (jsx(Tooltip, { ...props, classes: { popper: className } })))(({ theme }) => ({
2489
+ [`& .${tooltipClasses.tooltip}`]: {
2490
+ backgroundColor: theme.palette.common.white,
2491
+ color: "rgba(0, 0, 0, 0.87)",
2492
+ boxShadow: theme.shadows[1],
2493
+ fontSize: 13,
2494
+ },
2495
+ }));
2496
+ const Greetings = () => {
2497
+ let hours = new Date().getHours();
2498
+ let greet;
2499
+ if (hours < 12)
2500
+ greet = "morning";
2501
+ else if (hours >= 12 && hours <= 16)
2502
+ greet = "afternoon";
2503
+ else if (hours >= 16 && hours <= 24)
2504
+ greet = "evening";
2505
+ return jsxs("span", { children: ["Good ", greet, ","] });
2506
+ };
2507
+ return (jsx(AppBar, { position: "fixed", elevation: 0, className: clsx(classes.appBar, open && classes.appBarShift), children: jsxs(Toolbar, { className: classes.toolbar, children: [jsxs(Box, { sx: {
2508
+ display: "flex",
2509
+ justifyContent: "space-evenly",
2510
+ alignItems: "center",
2511
+ height: "80px",
2512
+ width: "227px",
2513
+ flexDirection: menuIconPosition === "right" ? "row-reverse" : "row",
2514
+ }, children: [open ? (jsx(IconButton$1, { disableRipple: true, onClick: () => handleDrawerClose(), className: classes.DrawerClose_icon, children: jsx(MenuOutlinedIcon, { fontSize: "large" }) })) : (jsx(IconButton$1, { disableRipple: true, "aria-label": "open drawer", onClick: () => handleDrawerOpen(), className: classes.DrawerClose_icon, children: jsx(MenuOutlinedIcon, { fontSize: "large" }) })), jsxs("div", { children: [jsx("img", { src: Boolean(logos?.logo) ? logos?.logo : bankLogo, alt: "CbsEnfinity", className: classes.logo, onClick: (e) => {
2515
+ e.preventDefault();
2516
+ navigate(dashboardUrl ?? "./dashboard");
2517
+ } }), jsx("p", { className: classes.version01, children: logos?.version })] })] }), jsx(Stack, { direction: "row", spacing: 4, mx: 2, children: jsx(Box, { className: classes.heading_user_img_border, children: jsx(Avatar, { className: classes.heading_user_img, alt: "Remy Sharp", src: Boolean(logos?.bank) ? logos?.bank : BecomePartnerImg }) }) }), jsxs(Typography, { component: "h1", variant: "h6", color: "inherit", noWrap: true, className: classes.title, children: [jsx(Box, { style: {
2518
+ marginBottom: "8px",
2519
+ fontSize: "17px",
2520
+ color: "var(--theme-color1)",
2521
+ width: "555px",
2522
+ }, className: clsx({
2523
+ [classes.marquee]: authState?.companyName.length > 55,
2524
+ }), children: authState?.companyName || "" }), jsx("div", { style: { display: "flex", gap: "8px" }, children: jsxs("div", { style: { color: "var(--theme-color6)" }, children: [jsxs(Typography, { variant: "caption", display: "block", lineHeight: 0, fontSize: "11px", children: [t("appBar.Branch"), ":", authState?.user?.branchCode ?? "001 ", "-", authState?.user?.branch ?? ""] }), jsxs(Typography, { variant: "caption", display: "inline", fontSize: "11px", children: [t("appBar.WorkingDate"), ":", " ", Boolean(authState?.workingDate)
2525
+ ? checkDateAndDisplay(format(new Date(authState?.workingDate), "dd/MM/yyyy"))
2526
+ : "not found"] }), jsxs(Typography, { marginLeft: 1, variant: "caption", display: "inline", fontSize: "11px", children: [t("appBar.LastLoginDate"), " :", " ", checkDateAndDisplay(authState?.user?.lastLogin ?? "Vastrapur")] })] }) })] }), jsxs(Box, { children: [!hideGreetings ? (jsx(Box, { sx: { marginBottom: "3px", paddingRight: "15px" }, children: jsxs(Stack, { direction: "row", spacing: 2, justifyContent: "flex-end", alignItems: "center", children: [jsxs(Typography, { fontSize: "17px", color: "#1C1C1C", children: [Greetings(), " ", authState?.user?.id ?? ""] }), jsx("img", { src: Waving_hand, alt: "", style: { height: "18px" } })] }) })) : null, jsxs(Box, { display: "flex", justifyContent: "space-evenly", alignItems: "center", children: [SearchComponent ? jsx(SearchComponent, {}) : null, LanguageComponent ? jsx(LanguageComponent, {}) : null, jsx(Box, { maxWidth: 170, display: "flex", justifyContent: "end", children: jsx(Tooltip, { title: "Logout", placement: "bottom", arrow: true, children: jsx(IconButton$1, { onClick: () => typeof handleLogout === "function" ? handleLogout() : null, color: "error", sx: {
2527
+ backgroundColor: "rgba(235, 237, 238, 0.45)",
2528
+ borderRadius: "10px",
2529
+ height: "30px",
2530
+ width: "30px",
2531
+ "&:hover": {
2532
+ background: "var(--theme-color2)",
2533
+ borderRadius: "10px",
2534
+ transition: "all 0.2s ease 0s",
2535
+ boxShadow: "rgba(0, 0, 0, 0.16) 0px 3px 6px, rgba(0, 0, 0, 0.23) 0px 3px 6px",
2536
+ "& .MuiSvgIcon-root": {
2537
+ height: "32px",
2538
+ width: "32px",
2539
+ transition: "all 0.2s ease 0s",
2540
+ padding: "4px",
2541
+ },
2542
+ },
2543
+ }, "aria-label": "show 4 new mails", children: jsx(LogoutIcon, {}) }) }) })] })] }), jsx(Stack, { direction: "row", spacing: 4, ml: 1, children: jsx(Box, { className: classes.heading_user_img_border, sx: { cursor: "pointer" }, children: jsx(LightTooltip, { title: jsxs(Fragment$1, { children: [jsxs("div", { children: [" ", t("appBar.UserID"), ": ", authState?.user?.id] }), jsxs("div", { children: [t("appBar.Role"), " : ", authState?.roleName] }), jsxs("div", { children: [t("appBar.LastUnsuccessfulLogin"), " : \"\""] })] }), placement: "bottom-start", children: jsx(Avatar, { className: classes.heading_user_img, onClick: () => typeof handleProfile === "function" ? handleProfile() : null, alt: "Remy Sharp", src: profilePic ?? "" }) }) }) })] }) }));
2544
+ };
2545
+ const checkDateAndDisplay = (dateStr) => {
2546
+ // const dt = new Date(dateStr);
2547
+ // //@ts-ignore
2548
+ // if (dt instanceof Date && !isNaN(dt)) {
2549
+ // return dt.toDateString();
2550
+ // }
2551
+ if (Boolean(dateStr)) {
2552
+ return dateStr;
2553
+ }
2554
+ return "N/A";
2555
+ };
2556
+
2557
+ const drawerWidth = 227;
2558
+ const useStyles = makeStyles((theme) => {
2559
+ return {
2560
+ drawerPaper: {
2561
+ position: "relative",
2562
+ whiteSpace: "nowrap",
2563
+ width: drawerWidth,
2564
+ transition: theme.transitions.create("width", {
2565
+ easing: theme.transitions.easing.sharp,
2566
+ duration: theme.transitions.duration.enteringScreen,
2567
+ }),
2568
+ border: "none",
2569
+ overflow: "hidden",
2570
+ zIndex: 120,
2571
+ },
2572
+ drawerPaperClose: {
2573
+ overflowX: "hidden",
2574
+ transition: theme.transitions.create("width", {
2575
+ easing: theme.transitions.easing.sharp,
2576
+ duration: theme.transitions.duration.leavingScreen,
2577
+ }),
2578
+ width: theme.spacing(8),
2579
+ [theme.breakpoints.up("sm")]: {
2580
+ width: theme.spacing(8),
2581
+ },
2582
+ },
2583
+ toolbarIcon: {
2584
+ display: "flex",
2585
+ alignItems: "center",
2586
+ zIndex: 9999,
2587
+ ...theme.mixins.toolbar,
2588
+ background: "var(--theme-color2)",
2589
+ justifyContent: "center",
2590
+ height: "80px",
2591
+ // borderBottom: "1px dashed #949597",
2592
+ },
2593
+ hrCSS: {
2594
+ zIndex: 9999,
2595
+ },
2596
+ buttonLink: {
2597
+ backgroundColor: "transparent",
2598
+ border: "none",
2599
+ cursor: "pointer",
2600
+ textDecoration: "underline",
2601
+ display: "inline",
2602
+ margin: 0,
2603
+ padding: 0,
2604
+ "&:focus": {
2605
+ textDecoration: "none",
2606
+ },
2607
+ "$:hover": {
2608
+ textDecoration: "none",
2609
+ },
2610
+ },
2611
+ };
2612
+ });
2613
+ /*
2614
+
2615
+ */
2616
+
2617
+ const reportMetaData = [];
2618
+
2619
+ // import { createTheme } from "@mui/material";
2620
+ // const theme = createTheme();
2621
+ makeStyles((theme) => ({
2622
+ navBarCSS: {
2623
+ padding: "4px 1rem ",
2624
+ backgroundColor: "#fff !important",
2625
+ minHeight: "64px",
2626
+ boxShadow: "0 3px 6px rgba(0,0,0,0.03)",
2627
+ margin: "10px",
2628
+ },
2629
+ headerDropdown: {
2630
+ backgroundColor: "#fff",
2631
+ minWidth: "205px",
2632
+ boxShadow: "0 3px 6px rgba(0,0,0,0.16)",
2633
+ textDecoration: "none",
2634
+ borderBottom: "3px solid #26A456",
2635
+ },
2636
+ navLinkHeader: {
2637
+ color: "#555",
2638
+ fontSize: "14px",
2639
+ lineHeight: "1.2",
2640
+ paddingTop: "4px",
2641
+ paddingBottom: "4px",
2642
+ paddingRight: ".5rem",
2643
+ paddingLeft: ".5rem",
2644
+ fontWeight: 600,
2645
+ textTransform: "capitalize",
2646
+ display: "flex",
2647
+ alignItems: "center",
2648
+ cursor: "pointer",
2649
+ "& hover": {
2650
+ color: "#0b6fb8",
2651
+ },
2652
+ },
2653
+ productLink: {
2654
+ color: "#555",
2655
+ padding: "0 1rem 8px 1rem",
2656
+ display: "inline-block",
2657
+ verticalAlign: "middle",
2658
+ cursor: "pointer",
2659
+ textTransform: "capitalize",
2660
+ },
2661
+ font13: {
2662
+ fontSize: "13px",
2663
+ },
2664
+ loginDropdown: {
2665
+ width: "160px",
2666
+ },
2667
+ }));
2668
+ const useStylesSideBar = makeStyles((theme) => ({
2669
+ root: {
2670
+ justifyContent: "center",
2671
+ },
2672
+ drawer: {
2673
+ margin: "5px",
2674
+ },
2675
+ item: {
2676
+ display: "flex",
2677
+ //borderBottom: "2px solid #93242433",
2678
+ borderRadius: "8px",
2679
+ marginLeft: "7px",
2680
+ marginTop: "6.5px",
2681
+ width: "90%",
2682
+ height: "50px",
2683
+ paddingLeft: theme.spacing(2),
2684
+ paddingRight: theme.spacing(2),
2685
+ background: "var(--theme-color2)",
2686
+ boxShadow: "3px 6px 9px rgba(93, 95, 121, 0.26)",
2687
+ "& svg": {
2688
+ // color: theme.palette.primary.main,
2689
+ color: "var(--theme-color1)",
2690
+ },
2691
+ "&:hover": {
2692
+ boxShadow: "6px 6px 1px -1px rgba(0,0,0,0.2), 0px 1px 1px 0px rgba(0,0,0,0.14), 0px 1px 0px 0px rgba(0,0,5,0.12)",
2693
+ background: "var(--theme-color4)",
2694
+ transition: "0.6s ease",
2695
+ },
2696
+ },
2697
+ drawerIconSize: {
2698
+ width: "50px",
2699
+ height: "50px",
2700
+ padding: "18px",
2701
+ justifyItems: "cenetr",
2702
+ },
2703
+ button: {
2704
+ color: "#0063A3",
2705
+ padding: "10px 8px",
2706
+ //justifyContent: "flex-start",
2707
+ textTransform: "none",
2708
+ letterSpacing: 0,
2709
+ width: "100%",
2710
+ textAlign: "left",
2711
+ "&:hover": {
2712
+ backgroundColor: "var(--theme-color1)",
2713
+ // boxShadow: "0px 15px 20px rgb(221 176 176 / 37%)",
2714
+ },
2715
+ },
2716
+ btnRoot: {
2717
+ paddingLeft: "24px",
2718
+ justifyContent: "left ",
2719
+ },
2720
+ navLinks: {
2721
+ // height: "calc(100vh - 78px)",
2722
+ overflowY: "auto",
2723
+ overflowX: "hidden",
2724
+ // height:"100px",
2725
+ backgroundColor: "rgba(250, 251, 255, 0.9);",
2726
+ // height: "calc(100vh - 230px)",
2727
+ //background: "var(--theme-color1)",
2728
+ // marginTop: "25px",
2729
+ // boxShadow: "0 3px 6px rgba(255, 99, 71, 0.3)",
2730
+ borderRadius: "10px",
2731
+ paddingTop: "5px",
2732
+ //margin: "5px",
2733
+ },
2734
+ navLinksforseparateView: {
2735
+ overflowY: "auto",
2736
+ overflowX: "hidden",
2737
+ height: "calc(100vh - 180px)",
2738
+ // height:"auto",
2739
+ paddingTop: "10px",
2740
+ },
2741
+ nestedMenuLevel1: {
2742
+ paddingLeft: "20px",
2743
+ marginTop: "11px",
2744
+ paddingRight: theme.spacing(3),
2745
+ height: "auto",
2746
+ fontSize: "13px",
2747
+ "& div > svg": {
2748
+ fontSize: "14px",
2749
+ },
2750
+ },
2751
+ nestedMenuLevel2: {
2752
+ paddingLeft: "20px",
2753
+ marginTop: "11px",
2754
+ fontSize: "12px",
2755
+ "& div > svg": {
2756
+ fontSize: "9px",
2757
+ },
2758
+ },
2759
+ listIcon: {
2760
+ minWidth: "30px !important",
2761
+ justifyItems: "center",
2762
+ color: "var(--theme-color6)",
2763
+ fontWeight: 700,
2764
+ fontSize: "18px",
2765
+ },
2766
+ link: {
2767
+ fontSize: "1rem ",
2768
+ marginTop: "2px",
2769
+ marginBottom: "2px",
2770
+ textOverflow: "ellipsis",
2771
+ color: "var(--theme-color1)",
2772
+ marginLeft: "15px",
2773
+ whiteSpace: "break-spaces",
2774
+ "& span": {
2775
+ fontWeight: 400,
2776
+ whiteSpace: "break-spaces",
2777
+ },
2778
+ "& p": {
2779
+ color: "var(--theme-color3)",
2780
+ fontweight: 400,
2781
+ },
2782
+ },
2783
+ linktext: {
2784
+ backgroundColor: "var(--theme-color2)",
2785
+ "&:hover": {
2786
+ background: "var(--theme-color1)",
2787
+ "& div": {
2788
+ color: "var(--theme-color2) !important",
2789
+ },
2790
+ "& div > svg": {
2791
+ color: "var(--theme-color2) !important",
2792
+ },
2793
+ },
2794
+ },
2795
+ faSmall: {
2796
+ fontSize: "13px ",
2797
+ },
2798
+ openList: {
2799
+ ":not(activeMenuItem)": {
2800
+ "& > div": {
2801
+ backgroundColor: "rgba(0, 0, 0, 0.04)",
2802
+ },
2803
+ "& *": {
2804
+ color: "var(--theme-color2)",
2805
+ },
2806
+ },
2807
+ },
2808
+ openCurrent: {
2809
+ backgroundColor: "var(--theme-color1)",
2810
+ "& *": {
2811
+ color: "var(--theme-color2)",
2812
+ },
2813
+ "&:hover": {
2814
+ backgroundColor: "var(--theme-color1)",
2815
+ },
2816
+ },
2817
+ slimList: {
2818
+ paddingTop: "15px",
2819
+ paddingBottom: "13px",
2820
+ height: "auto",
2821
+ paddingLeft: "15px",
2822
+ justifyItems: "center",
2823
+ },
2824
+ activeMenuItem: {
2825
+ backgroundColor: "var(--theme-color1)!important ",
2826
+ "& > div": {
2827
+ color: "var(--theme-color2)!important",
2828
+ },
2829
+ "& svg": {
2830
+ color: "var(--theme-color4)",
2831
+ },
2832
+ "& hover": {
2833
+ "& > div": {
2834
+ color: "var(--theme-color3)",
2835
+ },
2836
+ },
2837
+ "& p": {
2838
+ color: "var(--theme-color6)",
2839
+ },
2840
+ },
2841
+ }));
2842
+
2843
+ let localdrawerOpen = true;
2844
+ const SideBarNav = ({ metaData, handleDrawerOpen, drawerOpen, setView, slimSize, setNewFilterData, setNewFilterView, isFromSeparetView = false, rootUrl, dashboardUrl, navigate, }) => {
2845
+ const classes = useStylesSideBar();
2846
+ let result = null;
2847
+ localdrawerOpen = drawerOpen;
2848
+ if (Array.isArray(metaData.navItems)) {
2849
+ result = metaData.navItems.map((one) => {
2850
+ if (one?.seperateView === true) {
2851
+ return (jsx(SeperateListView, { item: one, setView: setView, classes: classes, level: 0, slimSize: slimSize, setNewFilterData: setNewFilterData, setNewFilterView: setNewFilterView }, one.label));
2852
+ }
2853
+ else if (Array.isArray(one.children)) {
2854
+ return (jsx(NestedListItem, { item: one, classes: classes, level: 0, handleDrawerOpen: handleDrawerOpen, drawerOpen: drawerOpen, slimSize: slimSize, rootUrl: rootUrl, dashboardUrl: dashboardUrl, navigate: navigate }, one.label));
2855
+ }
2856
+ else {
2857
+ return (jsx(SingleListItem, { item: one, classes: classes, level: 0, slimSize: slimSize, drawerOpen: drawerOpen, rootUrl: rootUrl, dashboardUrl: dashboardUrl, navigate: navigate }, one.label));
2858
+ }
2859
+ });
2860
+ }
2861
+ return (jsx(List, { component: "nav", disablePadding: true, className: isFromSeparetView ? classes.navLinksforseparateView : classes.navLinks, children: jsx(ScrollBar, { children: result }) }));
2862
+ };
2863
+ const SeperateListView = ({ item, setView, level, classes, slimSize, setNewFilterData, setNewFilterView, }) => {
2864
+ let labelStart = (item.label || "").toLowerCase().substring(0, 1) || "circle";
2865
+ const icon = item.icon ? (jsx(ListItemIcon, { className: classes.listIcon, children: jsx(FontAwesomeIcon, { icon: ["fas", labelStart] }) })) : null;
2866
+ const levelClassName = level === 1
2867
+ ? classes.nestedMenuLevel1
2868
+ : level === 2
2869
+ ? classes.nestedMenuLevel2
2870
+ : "";
2871
+ return (jsxs(ListItem, { button: true, disableGutters: true, className: clsx({
2872
+ [classes.item]: true,
2873
+ [levelClassName]: Boolean(levelClassName),
2874
+ [classes.slimList]: Boolean(slimSize),
2875
+ [classes.drawerIconSize]: !localdrawerOpen,
2876
+ }), onClick: () => {
2877
+ if (item.viewName === "newfilterview" && Array.isArray(item.children)) {
2878
+ setNewFilterView({
2879
+ label: item.label,
2880
+ placeholder: "Search " + item.label + " Screen...",
2881
+ });
2882
+ let newChield = item.children.map((item1) => {
2883
+ return { ...item1, secondaryLabel: item1.user_code };
2884
+ });
2885
+ setNewFilterData(newChield);
2886
+ }
2887
+ setView(item.viewName);
2888
+ }, children: [jsx(Tooltip, { title: item.label, arrow: true, placement: localdrawerOpen ? "bottom-start" : "right", children: jsx("span", { children: icon }) }), (localdrawerOpen && item.label.length > 27) || !Boolean(icon) ? (jsx(Tooltip, { title: item.label, arrow: true, placement: localdrawerOpen ? "bottom-start" : "right", children: jsx(ListItemText, { primary: item.label, className: classes.link, secondary: item.secondaryLabel ?? null }) })) : localdrawerOpen ? (jsx(ListItemText, { primary: item.label, className: classes.link, secondary: item.secondaryLabel ?? null })) : null] }));
2889
+ };
2890
+ const SingleListItem = ({ item, classes, level, slimSize, drawerOpen, rootUrl, dashboardUrl, navigate, }) => {
2891
+ const isActiveMenu = isActiveMenuFromhref(window.location?.pathname ?? "", item?.href ?? "", item?.navigationProps, rootUrl, dashboardUrl);
2892
+ if (isActiveMenu) {
2893
+ // GeneralAPI.setDocumentName(item.label);
2894
+ let titleText = document.title;
2895
+ document.title = titleText.split(" - ")[0] + " - " + item.label;
2896
+ }
2897
+ let labelStart = (item.label || "").toLowerCase().substring(0, 1) || "circle";
2898
+ const icon = item.icon.toLowerCase() === "process.gif" ? (jsx(ListItemIcon, { className: classes.listIcon, children: jsx(FontAwesomeIcon, { icon: ["fas", labelStart] }) })) : (jsx(ListItemIcon, { className: classes.listIcon, children: jsx(FontAwesomeIcon, { icon: ["fas", item.icon] }) }));
2899
+ const levelClassName = level === 1
2900
+ ? classes.nestedMenuLevel1
2901
+ : level === 2
2902
+ ? classes.nestedMenuLevel2
2903
+ : "";
2904
+ return (jsxs(ListItem, { button: true, disableGutters: true, className: clsx({
2905
+ [classes.item]: true,
2906
+ [levelClassName]: Boolean(levelClassName),
2907
+ [classes.slimList]: Boolean(slimSize),
2908
+ [classes.activeMenuItem]: isActiveMenu,
2909
+ [classes.drawerIconSize]: !localdrawerOpen,
2910
+ }), onClick: (e) => {
2911
+ e.preventDefault();
2912
+ if (item.isRouterLink) {
2913
+ let path = item.href;
2914
+ path =
2915
+ item.href?.substring(0, 1) === "/"
2916
+ ? item.href.substring(1)
2917
+ : item.href;
2918
+ if (item.passNavigationPropsAsURLParmas) {
2919
+ let urlParms = new URLSearchParams(item?.navigationProps);
2920
+ navigate(`${path}?${urlParms.toString()}`);
2921
+ }
2922
+ else {
2923
+ navigate(`${path}`, {
2924
+ state: { ...item?.navigationProps },
2925
+ });
2926
+ }
2927
+ }
2928
+ else if (Boolean(item.href)) {
2929
+ window.open(item.href, item.rel ?? "_newtab");
2930
+ }
2931
+ }, children: [jsx(Tooltip, { title: item.label, arrow: true, placement: localdrawerOpen ? "bottom-start" : "right", children: jsx("span", { children: icon }) }), (localdrawerOpen && item.label.length > 27) || !Boolean(icon) ? (jsx(Tooltip, { title: item.label, arrow: true, placement: localdrawerOpen ? "bottom-start" : "right", children: jsx(ListItemText, { primary: item.label, className: classes.link, secondary: item.secondaryLabel ?? null }) })) : localdrawerOpen ? (jsx(ListItemText, { primary: item.label, className: classes.link, secondary: item.secondaryLabel ?? null })) : null] }));
2932
+ };
2933
+ const NestedListItem = ({ item, classes, level, handleDrawerOpen, drawerOpen, slimSize, rootUrl, navigate, }) => {
2934
+ const [open, setOpen] = useState(false);
2935
+ const handleClick = () => {
2936
+ setOpen(!open);
2937
+ };
2938
+ const childrens = item.children?.map((one) => {
2939
+ if (Array.isArray(one.children)) {
2940
+ return (jsx(NestedListItem, { item: one, classes: classes, level: level + 1, handleDrawerOpen: handleDrawerOpen, drawerOpen: drawerOpen, slimSize: slimSize, rootUrl: rootUrl, navigate: navigate }, one.label));
2941
+ }
2942
+ else {
2943
+ return (jsx(SingleListItem, { item: one, classes: classes, level: level + 1, slimSize: slimSize, rootUrl: rootUrl, navigate: navigate }, one.label));
2944
+ }
2945
+ });
2946
+ let labelStart = (item.label || "").toLowerCase().substring(0, 1) || "circle";
2947
+ const icon = item.icon === "Process.gif" ? (jsx(ListItemIcon, { className: classes.listIcon, children: jsx(FontAwesomeIcon, { icon: ["fas", labelStart] }) })) : (jsx(ListItemIcon, { className: classes.listIcon, children: jsx(FontAwesomeIcon, { icon: ["fas", item.icon] }) }));
2948
+ const levelClassName = level === 1
2949
+ ? classes.nestedMenuLevel1
2950
+ : level === 2
2951
+ ? classes.nestedMenuLevel2
2952
+ : "";
2953
+ return (jsxs(Fragment$1, { children: [jsxs(ListItem, { button: true, onClick: handleClick, disableGutters: true, className: open
2954
+ ? clsx({
2955
+ [classes.item]: true,
2956
+ [levelClassName]: Boolean(levelClassName),
2957
+ [classes.slimList]: Boolean(slimSize),
2958
+ [classes.openCurrent]: true,
2959
+ [classes.drawerIconSize]: !localdrawerOpen,
2960
+ })
2961
+ : clsx({
2962
+ [classes.item]: true,
2963
+ [levelClassName]: Boolean(levelClassName),
2964
+ [classes.slimList]: Boolean(slimSize),
2965
+ [classes.drawerIconSize]: !localdrawerOpen,
2966
+ }), children: [jsx(Tooltip, { title: item.label, arrow: true, placement: localdrawerOpen ? "bottom-start" : "right", children: jsx("span", { children: icon }) }), drawerOpen || !Boolean(icon) ? (jsxs(Fragment$1, { children: [jsx(ListItemText, { primary: item.label, secondary: item.secondaryLabel ?? null, color: "primary", className: classes.link }), open ? jsx(ExpandLess, {}) : jsx(ExpandMore, {})] })) : null] }), jsx(Collapse, { in: open, timeout: "auto", unmountOnExit: true, children: jsx(List, { component: "div", disablePadding: true, className: open ? classes.openList : "", children: childrens }) })] }));
2967
+ };
2968
+ const isActiveMenuFromhref = (location, menuhref, navigationProps, rootUrl, dashboardUrl) => {
2969
+ if ((location === `/${rootUrl}` || location === `/${rootUrl}/`) &&
2970
+ menuhref === dashboardUrl) {
2971
+ return true;
2972
+ }
2973
+ else if (menuhref === "report") {
2974
+ try {
2975
+ let urlParms = new URLSearchParams(navigationProps);
2976
+ if ("?" + urlParms.toString() === window.location.search) {
2977
+ return true;
2978
+ }
2979
+ }
2980
+ catch (error) {
2981
+ console.log(error);
2982
+ }
2983
+ return false;
2984
+ }
2985
+ else if (location !== `/${rootUrl}` &&
2986
+ location !== "/" &&
2987
+ Boolean(menuhref) &&
2988
+ location.includes(menuhref)) {
2989
+ return true;
2990
+ }
2991
+ return false;
2992
+ };
2993
+
2994
+ const matchByValue = (search, tags, navItem) => {
2995
+ if (!Array.isArray(tags)) {
2996
+ tags = [tags];
2997
+ }
2998
+ return tags.some((one) => navItem[one]
2999
+ ?.toLocaleLowerCase?.()
3000
+ ?.includes(search?.toLocaleLowerCase?.()));
3001
+ };
3002
+ const filterMetaDataByValue = (searchString, navItems, tagsToSearch) => {
3003
+ let newNavItems = [];
3004
+ for (let i = 0; i < navItems.length; i++) {
3005
+ if (matchByValue(searchString, tagsToSearch, navItems[i])) {
3006
+ let { children, ...newItem } = navItems[i];
3007
+ if (Array.isArray(children) && children.length > 0) {
3008
+ let newChildren = filterMetaDataByValue(searchString, children, tagsToSearch);
3009
+ if (newChildren.length > 0) {
3010
+ newNavItems.push({ ...newItem, children: newChildren });
3011
+ }
3012
+ }
3013
+ else {
3014
+ newNavItems.push({ ...newItem });
3015
+ }
3016
+ }
3017
+ }
3018
+ return newNavItems;
3019
+ };
3020
+
3021
+ const SearchViewNavigation = ({ metaData, handleDrawerOpen, drawerOpen, setView, label, icon, placeholder = "Search Reports...", rootUrl, dashboardUrl, navigate, }) => {
3022
+ const [search, setSearch] = useState("");
3023
+ const filteredMetaData = useMemo(() => {
3024
+ return filterMetaDataByValue(search, metaData.navItems, [
3025
+ "label",
3026
+ "secondaryLabel",
3027
+ ]);
3028
+ }, [search, metaData.navItems]);
3029
+ const classes = useStylesSideBar();
3030
+ const myIcon = icon ? (jsx(ListItemIcon, { className: classes.listIcon, children: jsx(ArrowBackIosNewIcon, {}) })) : null;
3031
+ const handleClick = () => {
3032
+ if (!drawerOpen) {
3033
+ handleDrawerOpen();
3034
+ }
3035
+ };
3036
+ return (jsxs("div", { style: { display: "flex", flexDirection: "column" }, children: [jsxs(ListItem, { button: true, className: clsx({
3037
+ [classes.item]: true,
3038
+ [classes.nestedMenuLevel1]: true,
3039
+ [classes.linktext]: true,
3040
+ }), onClick: () => setView("/"), children: [myIcon, jsx(ListItemText, { primary: label, className: classes.link })] }), jsx(SearchBar, { sx: { overflow: "hidden" }, value: search, onChange: (e) => setSearch(e.target.value), onClick: handleClick, placeholder: Boolean(placeholder) ? placeholder : "Search Reports...", autoFocus: drawerOpen }), jsx(SideBarNav, { handleDrawerOpen: handleDrawerOpen, drawerOpen: drawerOpen, setView: setView, metaData: {
3041
+ navItems: filteredMetaData,
3042
+ config: { rel: "", target: "_blank" },
3043
+ }, slimSize: true, isFromSeparetView: true, rootUrl: rootUrl, dashboardUrl: dashboardUrl, navigate: navigate })] }));
3044
+ };
3045
+
3046
+ library.add(faHandsHelping, faUsers, faBars, faBalanceScale, faHandHoldingHeart, faTasks, faCog, faHome, faTh, faUsersCog, faCircle, faUserCircle, faHashtag, faThumbtack, faSquare, faLink, faQuestion, faPlus, faTable, faLocationArrow, faHeadset, faGears, faArrowDown, faArrowUp, faSpinner, faCircleExclamation, faRotateRight, faUserLock, faUserClock, faGripHorizontal, faFileLines, faGear, faHeadphones, faUsersGear, faMessage, faUnlock, faUserPlus, faUserCheck, faKey, faIdCard, faIdBadge, faCheck, faCheckDouble, faCircleCheck, faCircleXmark, faUserTag, faAddressCard, faChartColumn, faUserPen, faHandHolding, faHandHoldingMedical, faObjectGroup, faTowerCell, faTowerObservation, faBuilding, faMailBulk, faLandmarkFlag, faCreditCard, faHospitalSymbol, faPlugCircleBolt, faCodeBranch, faPersonCircleCheck, faBank, faServer, faNotesMedical, faA, faB, faC, faD, faE, faF, faG, faH, faI, faJ, faK, faL, faM, faN, faO, faP, faQ, faR, faS, faT, faU, faV, faW, faX, faY, faZ);
3047
+
3048
+ const transformMetaDataAsPerRole = (metaData, role, branches, company, access, products) => {
3049
+ let navItems = filterMetaData(metaData.navItems, role, branches, company, access, products);
3050
+ //console.log(navItems);
3051
+ let newnavItem = navItems.map((item) => {
3052
+ let { children, ...newItem } = item;
3053
+ if (Array.isArray(children) && children.length > 5) {
3054
+ if (!Boolean(newItem.seperateView)) {
3055
+ newItem.seperateView = true;
3056
+ newItem.viewName = "newfilterview";
3057
+ //console.log(newItem);
3058
+ }
3059
+ }
3060
+ return { ...newItem, children: children };
3061
+ });
3062
+ return {
3063
+ config: metaData.config,
3064
+ navItems: newnavItem,
3065
+ };
3066
+ };
3067
+ const matchBranches = (userBranches, accessBranches) => {
3068
+ if (!Array.isArray(accessBranches) || !Array.isArray(userBranches)) {
3069
+ return true;
3070
+ }
3071
+ if (accessBranches.length <= 0 || userBranches.length <= 0) {
3072
+ return true;
3073
+ }
3074
+ for (const one of accessBranches) {
3075
+ if (userBranches.indexOf(one) >= 0) {
3076
+ return true;
3077
+ }
3078
+ }
3079
+ return false;
3080
+ };
3081
+ const matchComany = (userCompany, accessCompany) => {
3082
+ if (!Array.isArray(accessCompany) || !Boolean(userCompany)) {
3083
+ return true;
3084
+ }
3085
+ if (accessCompany.length <= 0) {
3086
+ return true;
3087
+ }
3088
+ if (accessCompany.indexOf(userCompany) >= 0) {
3089
+ return true;
3090
+ }
3091
+ return false;
3092
+ };
3093
+ const matchRoles = (userRole, accessRoles) => {
3094
+ if (!Array.isArray(accessRoles) || typeof userRole !== "number") {
3095
+ return true;
3096
+ }
3097
+ if (accessRoles.length <= 0) {
3098
+ return true;
3099
+ }
3100
+ if (accessRoles.indexOf(userRole) >= 0) {
3101
+ return true;
3102
+ }
3103
+ return false;
3104
+ };
3105
+ const matchInvisibleRoles = (userRole, accessRoles) => {
3106
+ if (!Array.isArray(accessRoles) || typeof userRole !== "number") {
3107
+ return true;
3108
+ }
3109
+ if (accessRoles.length <= 0) {
3110
+ return true;
3111
+ }
3112
+ if (accessRoles.indexOf(userRole) >= 0) {
3113
+ return false;
3114
+ }
3115
+ return true;
3116
+ };
3117
+ const matchProducts = (userProducts, accessProducts) => {
3118
+ if (!Array.isArray(accessProducts) || !Array.isArray(userProducts)) {
3119
+ return true;
3120
+ }
3121
+ if (accessProducts.length <= 0 || userProducts.length <= 0) {
3122
+ return true;
3123
+ }
3124
+ for (const one of accessProducts) {
3125
+ if (userProducts.indexOf(one) >= 0) {
3126
+ return true;
3127
+ }
3128
+ }
3129
+ return false;
3130
+ };
3131
+ const ishrefisNotNull = (item) => {
3132
+ if (!(Array.isArray(item.children) && item.children.length > 0) &&
3133
+ !Boolean(item.href)) {
3134
+ //console.log(item);
3135
+ return false;
3136
+ }
3137
+ return true;
3138
+ };
3139
+ const filterMetaData = (navItems, role, branches, company, access, products) => {
3140
+ let newNavItems = [];
3141
+ for (let i = 0; i < navItems.length; i++) {
3142
+ if (matchRoles(Number(role), navItems[i].visibleToRoles) &&
3143
+ matchComany(company, navItems[i].visibleToCompanies) &&
3144
+ matchBranches(branches, navItems[i].visibleToBranches) &&
3145
+ matchInvisibleRoles(Number(role), navItems[i].invisibleToRoles) &&
3146
+ matchProducts(products, navItems[i].visibleToProducts) &&
3147
+ ishrefisNotNull(navItems[i])) {
3148
+ let { children, ...newItem } = navItems[i];
3149
+ if (Array.isArray(children) && children.length > 0) {
3150
+ let newChildren = filterMetaData(children, role, branches, company, access, products);
3151
+ if (newChildren.length > 0) {
3152
+ newNavItems.push({ ...newItem, children: newChildren });
3153
+ }
3154
+ }
3155
+ else {
3156
+ newNavItems.push({ ...newItem, secondaryLabel: newItem.system_code });
3157
+ }
3158
+ }
3159
+ }
3160
+ return newNavItems;
3161
+ };
3162
+
3163
+ /* eslint-disable react-hooks/exhaustive-deps */
3164
+ const SideBar = ({ authState, handleDrawerOpen, open, rootUrl, dashboardUrl = "dashboard", navigate, }) => {
3165
+ const [view, setView] = useState("/");
3166
+ const [NewFilterView, setNewFilterView] = useState({});
3167
+ const [NewFilterData, setNewFilterData] = useState([]);
3168
+ const branches = useMemo(() => {
3169
+ let myBranches = authState?.access?.entities?.Branch ?? [];
3170
+ if (Array.isArray(myBranches) && myBranches.length >= 0) {
3171
+ return myBranches.map((one) => one.branchCode);
3172
+ }
3173
+ else {
3174
+ return [];
3175
+ }
3176
+ }, []);
3177
+ const products = useMemo(() => {
3178
+ let myProducts = authState?.access?.products ?? [];
3179
+ if (Array.isArray(myProducts) && myProducts.length >= 0) {
3180
+ return myProducts.map((one) => one.categoryCode);
3181
+ }
3182
+ else {
3183
+ return [];
3184
+ }
3185
+ }, []);
3186
+ let newMetaData = { navItems: authState.menulistdata };
3187
+ let filteredMetaDataSideBar = transformMetaDataAsPerRole(newMetaData, Number(authState.role), branches, authState.companyID, authState.access, products);
3188
+ let filteredReportsMetaData = transformMetaDataAsPerRole({
3189
+ config: { rel: "", target: "_blank" },
3190
+ navItems: reportMetaData,
3191
+ }, Number(authState.role), branches, authState.companyID, authState.access, products);
3192
+ return view === "report" ? (jsx(SearchViewNavigation, { metaData: filteredReportsMetaData, handleDrawerOpen: handleDrawerOpen, drawerOpen: open, setView: setView, label: "Reports", icon: "table", rootUrl: rootUrl, dashboardUrl: dashboardUrl, navigate: navigate })) : view === "newfilterview" ? (jsx(SearchViewNavigation, { metaData: {
3193
+ config: { rel: "", target: "_blank" },
3194
+ navItems: NewFilterData,
3195
+ }, handleDrawerOpen: handleDrawerOpen, drawerOpen: open, setView: setView, label: NewFilterView?.label ?? "Reports", icon: "table", placeholder: NewFilterView?.placeholder, rootUrl: rootUrl, dashboardUrl: dashboardUrl, navigate: navigate })) : (jsx(Fragment$1, { children: jsx(SideBarNav, { metaData: filteredMetaDataSideBar, handleDrawerOpen: handleDrawerOpen, drawerOpen: open, setView: setView, slimSize: true, setNewFilterData: setNewFilterData, setNewFilterView: setNewFilterView, rootUrl: rootUrl, dashboardUrl: dashboardUrl, navigate: navigate }) }));
3196
+ };
3197
+
3198
+ const SidebarWrapper = (props) => {
3199
+ const classes = useStyles();
3200
+ return (jsxs(Drawer, { variant: "permanent", classes: {
3201
+ paper: clsx(classes.drawerPaper, !props.open && classes.drawerPaperClose),
3202
+ }, open: props.open, children: [jsx("div", { className: classes.toolbarIcon }), jsx(SideBar, { ...props })] }));
3203
+ };
3204
+
3205
+ export { AppbarWrapper, AuthControllerWrapper, BranchSelectionGridWrapper, ForgotPasswordControllerWrapper, SidebarWrapper, ValidatePassword };
2
3206
  //# sourceMappingURL=index.js.map