Skip to content

HW2#31

Open
sergeynikiforov761 wants to merge 1 commit into
obabichev:homework/snikiforovfrom
sergeynikiforov761:homework/snikiforov
Open

HW2#31
sergeynikiforov761 wants to merge 1 commit into
obabichev:homework/snikiforovfrom
sergeynikiforov761:homework/snikiforov

Conversation

@sergeynikiforov761
Copy link
Copy Markdown

No description provided.


const formsElements = [form.email, form.password]

return <Auth
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

При отрисовке формы пароль не скрывается за звездочками (*), что немного неприятно)

import {useAuthSession} from "../context/AuthContext";
import {useHistory} from "react-router-dom";

const inputLabels = ["Логин", "Пароль"]
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Эти массивы передаются отдельно в компонент auth, и внутри этого компонента приходится обходя один из этих массивов доставать по индексу что-то из других. И никакая проверка типов в данном случае не поможет, если какие-то из элементов будут перепутаны местами.

Как вариант, если эти массивы по сути описывают поля формы, можно собрать массив с объектами, где каждый объект будет отвечать за одно поле, и эти объекты можно будет расширять доп полями (например типо для пароля):

const inputs = [
  {
    label: "Password",
    name: "password",
    type: "password"
  }
]

export const Auth = ({inputLabels, inputNames, buttonLabels,
label, formsElements, marginTop,
inputOnChange, buttonTriggers}: AuthData) => {
const StyledHeaderLabel = styled(StyledHeaderLabelCommon)`
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

StyledHeaderLabel можно тоже вынести из компонента, и доставать marginTop из пропсов, что-то вида (но лучше в доке проверить):

const StyledHeaderLabel = styled(StyledHeaderLabelCommon)`
      margin-top: ${props => marginTop};
    `

...

<StyledHeaderLabel marginTop={marginTop}>{label}</StyledHeaderLabel>


const onChangeSession = (tokens: Maybe<Tokens>) => {
setSessionToLocalStorage(tokens)
setSession(session)
Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

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

Здесь ошибка, в setSession передается session, который уже и так в стейте

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.

2 participants