Skip to content

Conversation

@anutaguzova
Copy link
Owner

Copy link
Collaborator

@KseniyaYatskevich KseniyaYatskevich left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. При попытке выбрать Gender: male, отоброжается сообщение "gender should be fill", при этом флажок на Male установлен. Установить Male можно только после того, как выбрал Female,а потом Male. Не очищается после сабмита формы
  2. Хотелось бы увидеть валидацию не только на обязательность заполнения, но и валидацию введенных данных. Например запретить вводить цыфры и специальные символы в поле Name.
  3. Если ввести в поле Name или Surname слишком длинную строку - ломается верстка карточки.
  4. Необходимо добалять node_module в gitignore. Добавить коментарии к коду в данной ситуации не представляется возможным.

<div className="card">
<div>
<span>Name: </span>
<span className="field">{Item.firstName}</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше использовать деструктуризацию const { firstName, lastName, country ...} = Item Названия props обычно называются с маленькой буквы

import { useState, useEffect } from 'react';

export interface State {
firstName: string;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

State не лучшее название для интерфейса

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Переименовала


useEffect(() => {
const validate = () => {
setErrors({}); // сбрасываем ошибки
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Комментарии на русском - плохая практика

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

исправила

}
if (
birthDate === '' ||
birthDate >
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Можно заменить birthDate === '' -> !birthDate

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

setErrors((state) => ({ ...state, birthDate }));
}
if (gender === '') {
setErrors((state) => ({ ...state, gender }));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

можно заменить gender === '' -> !gender

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено


const handleSubmit = (event) => {
event.preventDefault();
if (Object.keys(errors).length === 0) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Не обязателельно сравнивать с 0: !Object.keys(errors).length

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Исправлено

gender,
},
]);
alert('data saved succesfully');
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше не использовать allert, предупреждение eslint

<option value="poland">Poland</option>
<option value="turkey">Turkey</option>
<option value="germany">Germany</option>
</select>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Лучше спользовать массив для генерации options

<p>
I agree...
{errors?.agree !== undefined && (
<span className="errors"> * agree should be check</span>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Сравнивать что либо с undefined - плохая идея

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants