login page

This commit is contained in:
2025-05-19 11:54:30 +03:00
parent 695c29ab62
commit b91bd87555
12 changed files with 457 additions and 14 deletions

View File

@@ -1,7 +1,60 @@
import React from 'react'
'use client'
const page = () => {
return <div>page</div>
import React, { useState, useEffect } from 'react'
import Link from 'next/link'
import { useRouter } from 'next/navigation'
import Loader from '@/components/ui/Loader'
import useUserStore from '@/app/store/userStore'
import ClientView from './ClientView'
const LoginPage = () => {
const router = useRouter()
const { isAuthenticated } = useUserStore()
const [isClient, setIsClient] = useState(true)
const [isLoading, setIsLoading] = useState(true)
useEffect(() => {
// проверяем логин
if (isAuthenticated) {
// распределяем
if (isClient) {
router.replace('/account')
}
return
}
const timer = setTimeout(() => {
setIsLoading(false)
}, 300)
return () => clearTimeout(timer)
}, [isAuthenticated, router, isClient])
if (isLoading) {
return <Loader />
}
return (
<div className="flex items-center justify-center py-8 ">
<div className="flex w-full max-w-xl flex-col gap-4 bg-white rounded-2xl shadow-lg p-6">
<div className="flex flex-col items-center py-4">
<h1 className="text-2xl font-medium pb-1">Рады видеть Вас снова!</h1>
<p className="text-base font-medium text-center">
Пожалуйста, авторизуйтесь, чтобы продолжить
</p>
</div>
<ClientView />
<p className="text-center text-base font-medium">
Впервые у нас?{' '}
<span className="text-orange/70 hover:underline">
<Link href="/register">Зарегистрироваться</Link>
</span>
</p>
</div>
</div>
)
}
export default page
export default LoginPage