import styles from './Form.module.scss'; import axios from 'axios'; import Button from 'elements/Button'; import Error from 'elements/Error'; import { H3 } from 'elements/H'; import Input from 'elements/Input'; import getConfig from 'next/config'; import { useState } from 'react'; const { publicRuntimeConfig: config } = getConfig(); export default function Form() { const [hasError, setHasError] = useState(false); const error = hasError ? Неверный логин или пароль : null; return (
{ e.preventDefault(); const login = e.target[0].value; const password = e.target[1].value; const data = { login, password }; axios .post('/signin', data) .then(() => { const url = (window.location.pathname.replace(config.basePath, '') || '/') + (window.location.search || ''); window.location.replace(url); }) .catch(() => { setHasError(true); }); }} >

{config.appTitle}

{error}
); }