import React from 'react'; import './LoginForm.scss'; import Area from '@components/common/Area.js'; import { EmailField } from '@components/common/form/EmailField.js'; import { Form, useFormContext } from '@components/common/form/Form.js'; import { PasswordField } from '@components/common/form/PasswordField.js'; import { Button } from '@components/common/ui/Button.js'; import { _ } from '@evershop/evershop/lib/locale/translate/_'; import { LockKeyhole, Mail } from 'lucide-react'; interface LoginFormProps { authUrl: string; dashboardUrl: string; } const SubmitButton: React.FC = () => { const { formState: { isSubmitting } } = useFormContext(); return (
); }; export default function LoginForm({ authUrl, dashboardUrl }: LoginFormProps) { const [error, setError] = React.useState(null); const onSuccess = (response) => { if (!response.error) { window.location.href = dashboardUrl; } else { setError(response.error.message); } }; return (
{error &&
{error}
}
} label={_('Email')} name="email" placeholder={_('Email')} required validation={{ required: _('Email is required') }} /> ) }, sortOrder: 10 }, { component: { default: ( } label={_('Password')} name="password" placeholder={_('Password')} required validation={{ required: _('Password is required') }} showToggle /> ) }, sortOrder: 20 }, { component: { default: }, sortOrder: 30 } ]} />
); } export const layout = { areaId: 'content', sortOrder: 10 }; export const query = ` query Query { authUrl: url(routeId: "adminLoginJson") dashboardUrl: url(routeId: "dashboard") } `;