1 line
4.5 KiB
JavaScript
1 line
4.5 KiB
JavaScript
(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[676],{7864:(e,s,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/login",function(){return a(5386)}])},4329:(e,s,a)=>{"use strict";a.d(s,{A:()=>l});var t=a(4848);a(6540);var r=a(1710);function l(){return(0,t.jsx)("div",{className:"flex flex-col gap-4 items-center justify-center w-full h-screen p-6 bg-slate-100",children:(0,t.jsxs)("div",{className:"flex flex-col items-center justify-center gap-4 px-6 py-20 bg-white rounded shadow-sm max-w-2xl w-full",children:[(0,t.jsx)("img",{src:"/images/logo-icon-alt-2.webp",alt:"Datasquirel Logo",width:60}),(0,t.jsx)("div",{className:"w-10 h-10 flex flex-col items-center justify-center",children:(0,t.jsx)(r.A,{width:"25px",position:"relative"})})]})})}},5386:(e,s,a)=>{"use strict";a.r(s),a.d(s,{__N_SSP:()=>v,default:()=>w});var t=a(4848),r=a(6540),l=a(3368),n=a.n(l),i=a(9020),o=a(1335),c=a.n(o);async function d(e){let{e:s,setAlert:a,setLoading:t,query:r}=e;s.preventDefault(),t(!0);let l=s.target["email-or-username-input"],n=s.target.password;if((null==l?void 0:l.value)===""&&(null==n?void 0:n.value)===""){l.classList.add("warning"),n.classList.add("warning"),a("No Email or Password Provided"),t(!1);return}if((null==n?void 0:n.value)===""){a(!1),n.classList.add("warning"),a(!0),t(!1);return}l.classList.remove("warning"),n.classList.remove("warning"),a(!1);let o={email:l.value,password:n.value,query:r};(0,i.A)("/api/loginUser",{method:"post",body:o}).then(e=>{var s;e.success&&(null===(s=e.payload)||void 0===s?void 0:s.logged_in_status)?(c().auth.postLogin(e),window.location.reload()):e.msg&&(a(e.msg),t(!1))})}var u=a(1710),m=a(7384);let x=r.createContext({});function h(e){let{user:s,query:a}=e,[l,n]=(0,r.useState)(!1),[i,o]=(0,r.useState)(!1);return(0,t.jsxs)(x.Provider,{value:{loading:i,setLoading:o,alert:l,setAlert:n,user:s},children:[(0,t.jsx)(m.A,{user:s,userType:"admin",setLoading:o}),(0,t.jsxs)("div",{className:"w-full justify-center relative",children:[(0,t.jsx)("span",{className:"bg-white dark:bg-slate-800 px-3 relative z-10",children:"OR"}),(0,t.jsx)("hr",{className:"absolute"})]}),(0,t.jsxs)("div",{className:"w-full flex-col items-stretch gap-4",children:[i&&(0,t.jsx)(u.A,{}),l&&(0,t.jsx)("div",{className:"p-2 justify-center text-sm border border-solid border-orange-400 rounded bg-orange-50",children:l}),(0,t.jsxs)("form",{className:"flex flex-col gap-2 w-full",onSubmit:e=>{d({e,setAlert:n,setLoading:o,query:a})},children:[(0,t.jsx)("input",{type:"text",name:"email-or-username-input",id:"email-or-username-input",placeholder:"Email or username",defaultValue:(null==a?void 0:a.email)?a.email:"",required:!0,onInput:e=>{l&&n(!1)}}),(0,t.jsx)("input",{type:"password",name:"password",id:"password-input",placeholder:"Password",required:!0,onInput:e=>{l&&n(!1)}}),(0,t.jsx)("button",{type:"submit",children:"Login"})]}),(0,t.jsx)("div",{className:"flex flex-col items-center w-full mb-2",children:(0,t.jsx)("a",{href:"/send-password-reset-link",className:"text-secondary font-semibold",children:"Forgot Password?"})}),(0,t.jsxs)("div",{className:"flex items-center gap-2 justify-center w-full mb-2 flex-wrap",children:[(0,t.jsx)("span",{children:"Dont have an account yet?"}),(0,t.jsx)("a",{href:"/create-account",className:"text-secondary font-semibold",children:"Register Now"})]}),(0,t.jsxs)("div",{className:"justify-center text-sm text-secondary",children:[(0,t.jsx)("a",{href:"/terms",className:"text-secondary",children:"Terms and Conditions"}),(0,t.jsx)("a",{href:"/privacy",className:"text-secondary",children:"Privacy Policy"})]})]})]})}var f=a(6232),p=a(4329),v=!0;function w(e){return(r.useEffect(()=>{setTimeout(()=>{e.query.invite&&e.user&&(window.location.pathname="/create-account")},1e3),e.query.invite||localStorage.setItem("user","{}")},[]),e.query.invite&&e.user)?(0,t.jsx)(p.A,{}):(0,t.jsxs)(r.Fragment,{children:[(0,t.jsxs)(n(),{children:[(0,t.jsx)("title",{children:"Login to your account"}),(0,t.jsx)("meta",{name:"description",content:"Login to your account"})]}),(0,t.jsx)("main",{className:"w-screen h-screen flex items-center justify-center p-4 md:p-8",children:(0,t.jsxs)("div",{className:"card col items-center no-hover max-w-md w-full bg-white p-4 sm:p-6 overflow-auto minimal-scrollbars",style:{maxHeight:"calc(100vh - 40px)"},children:[(0,t.jsx)(f.A,{}),(0,t.jsx)("hr",{}),(0,t.jsx)("h3",{className:"m-0 text-lg font-semibold",children:"Login to your account"}),(0,t.jsx)(h,{user:e.user,query:e.query})]})})]})}}},e=>{var s=s=>e(e.s=s);e.O(0,[1335,7384,636,6593,8792],()=>s(7864)),_N_E=e.O()}]); |