Files
dsql-admin/dsql-app/.local_dist/static/chunks/pages/login-c85193f251d3e601.js
T
2024-12-05 08:03:33 +01:00

1 line
4.6 KiB
JavaScript

(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[676],{86774:(e,s,r)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/login",function(){return r(74742)}])},87291:(e,s,r)=>{"use strict";r.d(s,{A:()=>l});var t=r(74848);r(96540);var a=r(620);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)(a.A,{width:"25px",position:"relative"})})]})})}},74742:(e,s,r)=>{"use strict";r.r(s),r.d(s,{__N_SSP:()=>p,default:()=>w});var t=r(74848),a=r(96540),l=r(13368),n=r.n(l),i=r(43586),o=r(23698);async function c(e){let{e:s,setAlert:r,setLoading:t,query:a}=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"),r("No Email or Password Provided"),t(!1);return}if((null==n?void 0:n.value)===""){r(!1),n.classList.add("warning"),r(!0),t(!1);return}l.classList.remove("warning"),n.classList.remove("warning"),r(!1);let c={email:l.value,password:n.value,query:a};(0,o.A)("/api/loginUser",{method:"post",body:c}).then(async e=>{console.log(e),e.user&&e.user.auth?(localStorage.setItem("userid",e.user.userid),localStorage.setItem("csrf",e.user.csrf_k),localStorage.setItem("user",JSON.stringify(e.userPayload)),(0,i.A)().then(()=>{window.location.reload()})):(r(e.msg),t(!1))})}var u=r(620),d=r(29907);let m=a.createContext({});function x(e){let{user:s,query:r}=e,[l,n]=(0,a.useState)(null),[i,o]=(0,a.useState)(!1);return(0,t.jsxs)(m.Provider,{value:{loading:i,setLoading:o,alert:l,setAlert:n,user:s},children:[(0,t.jsx)(d.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=>{c({e,setAlert:n,setLoading:o,query:r})},children:[(0,t.jsx)("input",{type:"text",name:"email-or-username-input",id:"email-or-username-input",placeholder:"Email or username",defaultValue:(null==r?void 0:r.email)?r.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=r(61638),h=r(87291),p=!0;function w(e){return(a.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)(h.A,{}):(0,t.jsxs)(a.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)(x,{user:e.user,query:e.query})]})})]})}}},e=>{var s=s=>e(e.s=s);e.O(0,[9907,636,6593,8792],()=>s(86774)),_N_E=e.O()}]);