diff --git a/front/src/api/signup/index.ts b/front/src/api/signup/index.ts
index b1d12e7..003518d 100644
--- a/front/src/api/signup/index.ts
+++ b/front/src/api/signup/index.ts
@@ -5,6 +5,12 @@ const composeSignUpURL = () => (
API_URL + '/signup?'
)
+const composeSignUpBody = (formData: FormData) => {
+ formData.append('nickname', formData.get('username') ?? '')
+
+ return formData
+}
+
const processSignUp = (data: SignUpResponse): SignUp => {
if (!data.Success) {
throw new Error(data.Message)
@@ -13,4 +19,4 @@ const processSignUp = (data: SignUpResponse): SignUp => {
return true
}
-export { composeSignUpURL, processSignUp }
+export { composeSignUpURL, composeSignUpBody, processSignUp }
diff --git a/front/src/components/AuthForm.tsx b/front/src/components/AuthForm.tsx
index 0b33953..3f1dd89 100644
--- a/front/src/components/AuthForm.tsx
+++ b/front/src/components/AuthForm.tsx
@@ -1,14 +1,14 @@
import { FormEventHandler, useCallback } from 'react'
-import { Button, Form } from 'react-bootstrap'
+import { Button, ButtonGroup, Form } from 'react-bootstrap'
import { useSignIn, useSignUp } from '../hooks/api'
+import { composeSignUpBody } from '../api/signup'
type AuthFormProps = {
- register: boolean,
goBack: () => void,
}
-function AuthForm({ goBack, register }: AuthFormProps) {
+const AuthForm = ({ goBack }: AuthFormProps) => {
const { handleSignUp, signUpButton } = useSignUp()
const { handleSignIn, signInButton } = useSignIn()
@@ -19,9 +19,11 @@ function AuthForm({ goBack, register }: AuthFormProps) {
const formData = new FormData(e.currentTarget)
+ const register = (e.nativeEvent as SubmitEvent).submitter?.id === 'register'
+
void (async () => {
const accountCreated = register ? (
- await handleSignUp(formData)
+ await handleSignUp(composeSignUpBody(formData))
) : true
if (accountCreated) {
@@ -31,34 +33,45 @@ function AuthForm({ goBack, register }: AuthFormProps) {
}
})()
- }, [register, goBack, handleSignUp, handleSignIn])
+ }, [goBack, handleSignUp, handleSignIn])
return (
- Как вас называть?
-
+ Как меня называть
+
- Пароль
-
+ И я могу доказать, что это я
+
- {register &&
-
-
-
-
- Я согласен с условиями обработки персональных данных
-
-
-
- }
+
+
+
+
+ Я согласен с условиями обработки персональных данных
+
+
+
-
+
+
+
+
)
}
diff --git a/front/src/hooks/api/useSignIn.ts b/front/src/hooks/api/useSignIn.ts
index 9c94fd9..7cf7e32 100644
--- a/front/src/hooks/api/useSignIn.ts
+++ b/front/src/hooks/api/useSignIn.ts
@@ -5,7 +5,7 @@ import { setToken } from '../../utils/auth'
function useSignIn() {
const { doSend, button } = useSendWithButton(
- 'Войти',
+ 'Мы уже знакомы',
'Войдено',
false,
composeTokenURL(),
diff --git a/front/src/hooks/api/useSignUp.ts b/front/src/hooks/api/useSignUp.ts
index 81bf3ab..2bb95b7 100644
--- a/front/src/hooks/api/useSignUp.ts
+++ b/front/src/hooks/api/useSignUp.ts
@@ -4,7 +4,7 @@ import { isSignUpResponse } from '../../api/signup/types'
function useSignUp() {
const { doSend, button } = useSendWithButton(
- 'Зарегистрироваться',
+ 'Я здесь впервые',
'Зарегистрирован',
false,
composeSignUpURL(),
diff --git a/front/src/hooks/useSend.ts b/front/src/hooks/useSend.ts
index 4e925cf..1742ac5 100644
--- a/front/src/hooks/useSend.ts
+++ b/front/src/hooks/useSend.ts
@@ -48,7 +48,7 @@ function useSend>(
return undefined
}
- headers.append('Auth', `Bearer ${token}`)
+ headers.append('Authorization', `Bearer ${token}`)
}
try {
diff --git a/front/src/pages/LoginPage.tsx b/front/src/pages/LoginPage.tsx
index 68b348c..d569b81 100644
--- a/front/src/pages/LoginPage.tsx
+++ b/front/src/pages/LoginPage.tsx
@@ -1,42 +1,18 @@
-import { useCallback, useState } from 'react'
-import { Tabs, Tab } from 'react-bootstrap'
import { useNavigate } from 'react-router-dom'
import { AuthForm } from '../components'
-import { isLiteralUnion } from '../utils/types'
import CardLayout from '../components/CardLayout'
-const tabKeys = ['register', 'login'] as const
-type TabKeys = typeof tabKeys[number]
-
-const isTabKeys = (s: string | null): s is TabKeys => (
- isLiteralUnion(s, tabKeys)
-)
-
function LoginPage() {
const navigate = useNavigate()
- const [tab, setTab] = useState('register')
-
- const goBack = useCallback(() => (
+ function goBack() {
navigate(-1 - Number(import.meta.env.DEV))
- ), [navigate])
+ }
return (
- isTabKeys(k) && setTab(k)}
- fill justify
- className='mb-3'
- >
-
-
-
-
-
-
-
+
)
}