Skip to content

Commit

Permalink
Update admin-login UI
Browse files Browse the repository at this point in the history
  • Loading branch information
mauriciabad committed Jan 23, 2024
1 parent fb4145f commit 55b4b56
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 25 deletions.
20 changes: 13 additions & 7 deletions src/app/[locale]/(app)/profile/login/_components/profile-login.tsx
Original file line number Diff line number Diff line change
@@ -1,25 +1,32 @@
import { Icon } from '@tabler/icons-react'
import { useTranslations } from 'next-intl'
import { FC } from 'react'
import { LinkButton } from '~/components/links/link-button'
import { ContinueWithEmail } from './continue-with-email'
import { ContinueWithProvider } from './continue-with-provider'
import { RegisterBanner } from './register-banner'

export const ProfileLogin: FC<{ registerDisabled?: boolean }> = ({
registerDisabled,
}) => {
export const ProfileLogin: FC<{
registerDisabled?: boolean
title?: string
icon?: Icon
}> = ({ registerDisabled, title, icon }) => {
const t = useTranslations('auth')

const Icon = icon

return (
<>
{!registerDisabled && <RegisterBanner />}

<div className="mx-auto mt-10 max-w-sm">
<div className="mx-auto mt-10 max-w-sm">
{Icon && (
<Icon className="mx-auto mb-4 text-brand-600" stroke={1} size={72} />
)}
<h2 className="mb-2 text-center font-title text-2xl font-semibold uppercase text-stone-800">
{t('login')}
{title ? title : t('login')}
</h2>
<ContinueWithEmail />

<div className="mb-2 mt-4 flex items-center gap-2">
<div className="flex-1 border-t border-stone-300" aria-hidden />
<h3 className=" inline-block font-title text-sm font-medium uppercase text-stone-600">
Expand All @@ -28,7 +35,6 @@ export const ProfileLogin: FC<{ registerDisabled?: boolean }> = ({
<div className="flex-1 border-t border-stone-300" aria-hidden />
</div>
<ContinueWithProvider />

{!registerDisabled && (
<>
<h2 className="mb-2 mt-10 text-center font-title text-2xl font-semibold uppercase text-stone-800">
Expand Down
34 changes: 21 additions & 13 deletions src/app/[locale]/admin-login/page.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { IconBarrierBlockOff } from '@tabler/icons-react'
import { IconBarrierBlock, IconBolt } from '@tabler/icons-react'
import type { Metadata } from 'next'
import { useTranslations } from 'next-intl'
import { getTranslator, redirect } from 'next-intl/server'
Expand Down Expand Up @@ -39,21 +39,29 @@ const NestedAdminLoginPage: FC<{ isLoggedInAsNotAdmin: boolean }> = ({
return (
<>
<main className="mx-auto flex min-h-screen max-w-2xl flex-col items-center justify-center p-4 text-center text-stone-800">
<IconBarrierBlockOff
className="mx-auto mb-4 text-brand-600"
stroke={1.25}
size={96}
/>
{isLoggedInAsNotAdmin ? (
<>
<IconBarrierBlock
className="mx-auto mb-4 text-brand-600"
stroke={1.25}
size={96}
/>

<h1 className="font-title text-4xl font-bold uppercase text-stone-800">
{t('heading')}
</h1>
<h1 className="font-title text-4xl font-bold uppercase text-stone-800">
{t('heading')}
</h1>

<p className="mt-4 text-xl">{t('subtitle')}</p>
{isLoggedInAsNotAdmin ? (
<LogoutButton />
<p className="mt-4 text-xl">{t('subtitle')}</p>
<LogoutButton />
</>
) : (
<ProfileLogin registerDisabled={true} />
<div className="mb-24">
<ProfileLogin
registerDisabled={true}
title={t('login-title')}
icon={IconBolt}
/>
</div>
)}
</main>
</>
Expand Down
2 changes: 1 addition & 1 deletion src/app/[locale]/admin/_components/more-options.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const MoreOptions: FC = () => {
return (
<MoreOptionsModal title={t('title')}>
<MoreOptionsModalButton
onClick={() => signOut({ callbackUrl: '/' })}
onClick={() => signOut({ callbackUrl: '/admin-login' })}
text={t('logout')}
icon={<IconLogout />}
/>
Expand Down
5 changes: 3 additions & 2 deletions src/messages/ca.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
}
},
"admin-login": {
"heading": "Admin",
"subtitle": "Has d'iniciar sessió, i tenir permisos d'administrador, per accedir a aquesta pàgina."
"heading": "Accés denegat",
"subtitle": "No tens permisos per continuar",
"login-title": "Iniciar sessió com administrador"
},
"signIn": {
"meta": {
Expand Down
5 changes: 3 additions & 2 deletions src/messages/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,9 @@
}
},
"admin-login": {
"heading": "Admin",
"subtitle": "You need to be logged in, and have admin permissions, to access this page."
"heading": "Access denied",
"subtitle": "You don't have permission to continue",
"login-title": "Admin login"
},
"signIn": {
"meta": {
Expand Down

0 comments on commit 55b4b56

Please sign in to comment.