apps/web: fix replace location after login
This commit is contained in:
parent
490fdef2ce
commit
993126cfa5
@ -5,13 +5,11 @@ import Error from 'elements/Error';
|
||||
import { H3 } from 'elements/H';
|
||||
import Input from 'elements/Input';
|
||||
import getConfig from 'next/config';
|
||||
import { useRouter } from 'next/router';
|
||||
import { useState } from 'react';
|
||||
|
||||
const { publicRuntimeConfig: config } = getConfig();
|
||||
|
||||
export default function Form() {
|
||||
const router = useRouter();
|
||||
const [hasError, setHasError] = useState(false);
|
||||
const error = hasError ? <Error>Неверный логин или пароль</Error> : null;
|
||||
|
||||
@ -28,7 +26,11 @@ export default function Form() {
|
||||
axios
|
||||
.post('/signin', data)
|
||||
.then(() => {
|
||||
router.reload();
|
||||
const url =
|
||||
(window.location.pathname.replace(config.basePath, '') || '/') +
|
||||
(window.location.search || '');
|
||||
|
||||
window.location.replace(url);
|
||||
})
|
||||
.catch(() => {
|
||||
setHasError(true);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user