diff --git a/client/src/pages/registration/api/action.ts b/client/src/pages/registration/api/action.ts index e57cf72a..c35dbea6 100644 --- a/client/src/pages/registration/api/action.ts +++ b/client/src/pages/registration/api/action.ts @@ -5,8 +5,7 @@ import { SERVER_URL } from "shared/config"; import { API_REGISTRATION } from "shared/config/backend"; interface RegistrationRequestBody { - name: string; - surname: string; + fullName: string; login: string; password: string; } @@ -18,7 +17,7 @@ export interface RegistrationAction { export const action: ActionFunction = async ({ request, }): Promise => { - const { name, surname, login, password, errors } = parseForm( + const { fullName, login, password, errors } = parseForm( await request.formData(), ); @@ -29,8 +28,7 @@ export const action: ActionFunction = async ({ } const registrationRequestBody: RegistrationRequestBody = { - name: name, - surname: surname, + fullName: fullName, login: login, password: password, }; @@ -48,6 +46,6 @@ export const action: ActionFunction = async ({ } return { - errors: [`Failed to authenticate: '${status}' code`], + errors: [`User already exists`], }; }; diff --git a/client/src/pages/registration/model/parseForm.ts b/client/src/pages/registration/model/parseForm.ts index 2da918e0..5f33535d 100644 --- a/client/src/pages/registration/model/parseForm.ts +++ b/client/src/pages/registration/model/parseForm.ts @@ -3,27 +3,22 @@ import { MINIMAL_PASSWORD_LENGTH } from "shared/config/frontend"; export function parseForm(data: FormData) { const errors = []; - const name = data.get("name"); - if (typeof name !== "string" || name === "") { + const fullName = data.get("fullName"); + if (typeof fullName !== "string" || fullName.trim() === "") { errors.push("Type name at form"); } - const surname = data.get("surname"); - if (typeof surname !== "string" || surname === "") { - errors.push("Type surname at form"); - } - const login = data.get("login"); - if (typeof login !== "string" || login === "") { + if (typeof login !== "string" || login.trim() === "") { errors.push("Type login at form"); } - if (typeof login === "string" && login.length < 4) { - errors.push("Login must greater than 3 symbols"); + if (typeof login === "string" && login.trim() === "") { + errors.push("Type login at form"); } const password = data.get("password"); - if (typeof password !== "string" || password === "") { + if (typeof password !== "string" || password.trim() === "") { errors.push("Type password at form"); } @@ -31,12 +26,11 @@ export function parseForm(data: FormData) { typeof password === "string" && password.length < MINIMAL_PASSWORD_LENGTH ) { - errors.push(`Password must greater ${MINIMAL_PASSWORD_LENGTH} symbols`); + errors.push(`Password length less than ${MINIMAL_PASSWORD_LENGTH}`); } - return { name, surname, login, password, errors } as { - name: string; - surname: string; + return { fullName, login, password, errors } as { + fullName: string; login: string; password: string; errors: string[]; diff --git a/client/src/pages/registration/ui/RegistrationPage.tsx b/client/src/pages/registration/ui/RegistrationPage.tsx index d4aecc9d..a2153d95 100644 --- a/client/src/pages/registration/ui/RegistrationPage.tsx +++ b/client/src/pages/registration/ui/RegistrationPage.tsx @@ -19,8 +19,7 @@ export const RegistrationPage = () => { )}
- - +