UNPKG

@accounter/client

Version:
1 lines 2.23 kB
import{s as e}from"./dist-C51EwTaa.js";import{i as t,o as n}from"./utils-DdVdMk8X.js";import{_ as r,h as i,t as a}from"./routes-DUvpW9-n.js";import{n as o}from"./auth0-react.esm-BrucYGp4.js";import{t as s}from"./button-Dzp2INW0.js";import{i as c,t as l}from"./index-CL8-JoMZ.js";var u=e(n(),1),d=t();function f(){let{loginWithRedirect:e,isAuthenticated:t,isLoading:n}=o(),f=r(),p=i(),m=new URLSearchParams(p.search),h=m.get(`reauth`)===`1`,g=p.state?.returnTo??(h?sessionStorage.getItem(`auth:invitationReturnTo`):null)??a.HOME,_=m.get(`error`),v=_?_===`auth_failed`?`Authentication failed. Please try again.`:l[_]??_:h?`Your session expired. Please sign in again.`:null;return(0,u.useEffect)(()=>{!n&&t&&!h&&f(g,{replace:!0})},[t,n,h,f,g]),(0,u.useEffect)(()=>{localStorage.removeItem(`user`),h&&c()},[h]),(0,d.jsxs)(`div`,{className:`w-full flex flex-col justify-center items-center h-screen lg:grid lg:min-h-[200px] lg:grid-cols-2 xl:min-h-screen`,children:[(0,d.jsx)(`div`,{className:`flex items-center justify-center`,children:(0,d.jsxs)(`div`,{className:`space-y-8 w-[320px]`,children:[(0,d.jsxs)(`div`,{className:`grid gap-2 text-center`,children:[(0,d.jsx)(`h1`,{className:`text-3xl font-bold`,children:`Accounter`}),(0,d.jsx)(`h2`,{className:`text-3xl font-bold`,children:`Sign In`}),(0,d.jsx)(`p`,{className:`text-balance text-muted-foreground`,children:`Use your Auth0 account to continue`}),v?(0,d.jsx)(`p`,{className:`text-sm text-destructive`,children:v}):null]}),(0,d.jsx)(s,{onClick:()=>((!h||!sessionStorage.getItem(`auth:returnTo`))&&sessionStorage.setItem(`auth:returnTo`,g),e({authorizationParams:{audience:void 0,scope:`openid profile email offline_access`,...h?{prompt:`login`}:{},redirect_uri:`${window.location.origin}${a.AUTH_CALLBACK}`},appState:{returnTo:g}})),className:`w-full font-semibold`,disabled:n,children:n?`Preparing sign in...`:`Continue with Auth0`})]})}),(0,d.jsx)(`div`,{className:`hidden bg-muted lg:block bg-black rounded-tl-3xl rounded-bl-3xl`,children:(0,d.jsx)(`div`,{className:`flex flex-row justify-center items-center h-screen`,children:(0,d.jsx)(`img`,{src:`../../icons/guild-logo.svg`,alt:`Guild logo`,className:`w-[100px] h-[100px] object-cover`})})})]})}export{f as LoginPage};