import { BaseAuthProps } from './types'; import { AuthWrapper } from '@/components/AuthWrapper'; import { TextInput } from '@/components/ra-inputs'; import { Button, CircularProgress, Grid, Stack, Typography } from '@mui/material'; import { email, required, useAuthProvider, useNotify, useRedirect, useTranslate } from 'ra-core'; import { useState } from 'react'; import { Form } from 'react-admin'; import { Link } from 'react-router-dom'; function RegisterPage({ name, copy, version, logo, background }: BaseAuthProps) { const [loading, setLoading] = useState(false); const translate = useTranslate(); const redirect = useRedirect(); const notify = useNotify(); const authProvider = useAuthProvider(); function handleSubmit(values: any) { setLoading(true); authProvider .register(values) .then((response: any) => { const message = `ra.auth.register_${response.responseCode}`; const type = response.responseCode === 'ok' ? 'info' : 'error'; // @ts-ignore notify(message, { type }); redirect('/login'); }) .catch((error: any) => { notify(error.message || error, { type: 'error' }); }) .finally(() => setLoading(false)); } return ( {translate('ra.auth.register.title')} {translate('ra.auth.already_have_account')}
); } export { RegisterPage };