import { useSearch } from '@tanstack/react-router'
import {
  Card,
  CardContent,
  CardDescription,
  CardHeader,
  CardTitle,
} from '@/components/ui/card'
import { AuthLayout } from '../auth-layout'
import { UserAuthForm } from './components/user-auth-form'

export function SignIn() {
  const { redirect } = useSearch({ from: '/(auth)/sign-in' })

  return (
    <AuthLayout>
      <Card className='max-w-sm gap-4'>
        <CardHeader>
          <CardTitle className='text-lg tracking-tight'>后台登录</CardTitle>
          <CardDescription>
            请输入管理员账号和密码。前端不会直接请求第三方接口，所有业务调用都会经过后台服务。
          </CardDescription>
        </CardHeader>
        <CardContent>
          <UserAuthForm redirectTo={redirect} />
          <p className='mt-4 text-center text-xs text-muted-foreground'>
            本地开发账号：root / 123456
          </p>
        </CardContent>
      </Card>
    </AuthLayout>
  )
}
