// This file is part of Shadcn Admin Kit (https://github.com/marmelab/shadcn-admin-kit) import { useState } from "react"; import { Form, required, useLogin, useNotify } from "ra-core"; import type { SubmitHandler, FieldValues } from "react-hook-form"; import { Button } from "@/components/ui/button"; import { TextInput } from "@/components/admin/text-input"; import { Notification } from "@/components/admin/notification"; export const LoginPage = (props: { redirectTo?: string }) => { const { redirectTo } = props; const [loading, setLoading] = useState(false); const login = useLogin(); const notify = useNotify(); const handleSubmit: SubmitHandler = (values) => { setLoading(true); login(values, redirectTo) .then(() => { setLoading(false); }) .catch((error) => { setLoading(false); notify( typeof error === "string" ? error : typeof error === "undefined" || !error.message ? "ra.auth.sign_in_error" : error.message, { type: "error", messageArgs: { _: typeof error === "string" ? error : error && error.message ? error.message : undefined, }, }, ); }); }; return (
Acme Inc

“Shadcn Admin Kit has allowed us to quickly create and evolve a powerful tool that otherwise would have taken months of time and effort to develop.”

John Doe

Sign in

Try janedoe@acme.com / password

); };