-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(23UG-19): добавляет раздел со сменой пароля #36
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Проверки - такая форма, либо другая форма, такая кнопка, либо другая кнопка - это нездорово. По сути выглядит, как будто 2 страницы в одну объединены.
Ну и визуально на сайте похоже на смену страницы. По этим причинам предлагаю вынести эту историю в отдельный роут.
Ещё, как вариант, можно вынести в отдельный компонент, сделать в виде модального окна и вызывать его при клике по кнопке. Модальное окно будет просто загораживать контент профиля. В общем, сделать как предложил Алексей, только без роута. |
Но только он не должен возвращаться сразу. Нужно будет дождаться ответа, показать оповещение Ок или не ОК все прошло (т.к. должно быть понятно сменился пароль или нет). Ну и по крестику наверное закрываться... или по таймауту после отображения оповещения. |
Хорошо, я тогда вынесу все в отдельный компонент и модалкой реализую на странице |
import { UpdateUserPassword } from "../../services/api/types"; | ||
import { | ||
ERROR_MESSAGE, | ||
InputNames, | ||
REQUIRED_MESSAGE, | ||
validationTemplate, | ||
} from "../../utils/validation/validation"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { UpdateUserPassword } from "services/api/types";
import {
ERROR_MESSAGE,
InputNames,
REQUIRED_MESSAGE,
validationTemplate,
} from "utils/validation/validation";
.changePassword { | ||
position: absolute; | ||
top: -6rem; | ||
left: 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А зачем верстать свою модалку, когда у нас библиотека компонентов подключена и там полно их?
Ну и если уж на то пошло, то 100% модальное окно должно быть отдельным компонентом, получающим содержимое в качестве чилдренов... А не монолитом с формой. Завтра еще одна форма в модалке понадобится - как ты будешь ее реализовывать?
|
||
export const ChangePassword: React.FC<Props> = (props: Props) => { | ||
const updatedUserPassword = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В качестве названия компонента обычно выбирают существительное.
const { | ||
control, | ||
handleSubmit, | ||
formState: { errors, isValid }, | ||
} = useForm({ | ||
defaultValues: { | ||
...updatedUserPassword, | ||
}, | ||
mode: "onChange", | ||
}); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
А для чего тут переменная updatedUserPassword
, если она используется в одном месте сразу после своего объявления?
Почему не написать так?
const {
control,
handleSubmit,
formState: { errors, isValid },
} = useForm({
defaultValues: {
oldPassword: "",
newPassword: "",
confirmPassword: "",
},
mode: "onChange",
});
|
||
{isPasswordSend && ( | ||
<Box mt={2} textAlign={"center"}> | ||
Пароль успешно изменен | ||
</Box> | ||
)} | ||
</form> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
У нас во всех формах уведомления о статусе запроса выводятся между полями и кнопкой. Давай так же сделаем, чтобы единообразно было.
@@ -11,6 +12,7 @@ import { authSelect } from "services/slices/auth-slice"; | |||
import { userSelect, userSlice, userThunks } from "services/slices/user-slice"; | |||
import { InputNames, validationTemplate } from "utils/validation/validation"; | |||
|
|||
import { ChangePassword } from "../../components/changePassword/ChangePassword"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import { ChangePassword } from "components/changePassword/ChangePassword";
const updatedUserPassword = { | ||
oldPassword: "", | ||
newPassword: "", | ||
confirmPassword: "", | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Страницу профиля нужно вернуть в исходный вид. На ней только кнопка вызова модалки должна поменяться.
onClick={onOpenFormChangePassword} | ||
> | ||
"Сменить пароль" | ||
</Typography> | ||
</Link> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
В "Сменить пароль" не нужны кавычки
export type UpdateUserPassword = { | ||
oldPassword: string; | ||
newPassword: string; | ||
}; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
С названием опять же беда. Пример названия можно посмотреть выше, можно посмотреть ниже в этом же файле.
010297d
to
5bf2036
Compare
5bf2036
to
b166ad7
Compare
}} | ||
> | ||
{props.children} | ||
</DialogContent> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Думаю, имеет смысл вынести ModalForm
в отдельный компонент и сменить название на Modal
, т.к. он не имеет никакого отношения к форме (что ему в чилдрены подашь, то и отрисуется)
|
||
{isPasswordSend && ( | ||
<Box | ||
textAlign={"center"} | ||
sx={{ | ||
marginTop: 3, | ||
}} | ||
> | ||
Пароль успешно изменен | ||
</Box> | ||
)} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Если это только для демонстрации, то ок, но вообще так не верно делать. Сам факт отправки пароля не говорит о том, что он успешно изменен. Может прийти сообщение с ошибкой и его надо будет тоже показать в таком случае.
Когда будешь приделывать отправку запроса, учти этот момент. И если ошибка будет, то не должно окно по таймауту закрываться.
|
||
<ModalForm | ||
onClick={onOpenFormChangePassword} | ||
isOpen={isChangePassword} | ||
setIsOpen={setIsChangePassword} | ||
> | ||
<PasswordChangeForm | ||
className={styles.profile__form} | ||
isOpen={isChangePassword} | ||
setIsOpen={setIsChangePassword} | ||
/> | ||
</ModalForm> | ||
</Container> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ну, о чем выше и писал - это 2 разных компонента должны быть.
…е об успешной отправке и закрытие по таймауту
…зовал его непосредственно на странице профиля
28540bd
to
c6e2fbf
Compare
Какую задачу решаем