feat(#177): login and registration lexics (#26)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 6 years ago committed by GitHub
parent 2564bb1557
commit 140cd0d50d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 27
      src/config/lexics/public.tsx
  2. 10
      src/features/Combobox/index.tsx
  3. 2
      src/features/Combobox/types.tsx
  4. 12
      src/features/Common/Input/index.tsx
  5. 8
      src/features/LanguageSelect/index.tsx
  6. 19
      src/features/Login/index.tsx
  7. 28
      src/features/Register/components/CardStep/index.tsx
  8. 50
      src/features/Register/components/RegistrationStep/index.tsx
  9. 15
      src/features/Register/components/SubscriptionsStep/index.tsx

@ -1,3 +1,28 @@
export const publicLexics = { export const publicLexics = {
authorization: 500, form_address1: 12914,
form_address2: 12915,
form_card_code: 12918,
form_card_expiration: 2023,
form_card_number: 2022,
form_city: 11401,
form_country: 835,
form_email: 12912,
form_firstname: 645,
form_lastname: 858,
form_password: 751,
form_phone: 1656,
form_postal_code: 12913,
form_region: 12932,
login: 1367,
next: 12916,
please_fill_out_this_field: 12933,
register: 1305,
select_language: 1005,
step_title_card: 12917,
step_title_login: 500,
step_title_registration: 1306,
step_title_subscription: 12919,
subscription_done: 2668,
subscription_extra: 6036,
subscription_for: 12920,
} }

@ -4,6 +4,7 @@ import isEmpty from 'lodash/isEmpty'
import map from 'lodash/map' import map from 'lodash/map'
import '@reach/combobox/styles.css' import '@reach/combobox/styles.css'
import { T9n } from 'features/T9n'
import { Label } from 'features/Common/Input/styled' import { Label } from 'features/Common/Input/styled'
import { Props, Option } from './types' import { Props, Option } from './types'
@ -22,10 +23,12 @@ export const Combobox = <T extends Option>(props: Props<T>) => {
disabled, disabled,
id, id,
label, label,
labelLexic,
labelWidth, labelWidth,
openOnFocus, openOnFocus,
pattern, pattern,
required, required,
title,
} = props } = props
const { const {
onInputBlur, onInputBlur,
@ -43,7 +46,11 @@ export const Combobox = <T extends Option>(props: Props<T>) => {
labelWidth={labelWidth} labelWidth={labelWidth}
htmlFor={id} htmlFor={id}
> >
{label} {
labelLexic
? <T9n t={labelLexic} />
: label
}
<Arrow /> <Arrow />
</Label> </Label>
<ComboboxInputStyled <ComboboxInputStyled
@ -51,6 +58,7 @@ export const Combobox = <T extends Option>(props: Props<T>) => {
required={required} required={required}
disabled={disabled} disabled={disabled}
value={query} value={query}
title={title}
pattern={pattern} pattern={pattern}
onChange={onQueryChange} onChange={onQueryChange}
onBlur={onInputBlur} onBlur={onInputBlur}

@ -11,8 +11,10 @@ export type Props<T> = Pick<InputHTMLAttributes<HTMLInputElement>, (
| 'required' | 'required'
| 'disabled' | 'disabled'
| 'pattern' | 'pattern'
| 'title'
)> & { )> & {
label?: string, label?: string,
labelLexic?: string,
labelWidth?: number, labelWidth?: number,
onChange?: (event: ChangeEvent<HTMLInputElement>) => void, onChange?: (event: ChangeEvent<HTMLInputElement>) => void,
onSelect?: (option: T | null) => void, onSelect?: (option: T | null) => void,

@ -1,5 +1,7 @@
import React, { ChangeEvent } from 'react' import React, { ChangeEvent } from 'react'
import { T9n } from 'features/T9n'
import { import {
TInputWrapper, TInputWrapper,
InputWrapper, InputWrapper,
@ -11,7 +13,8 @@ type TInput = {
defaultValue?: string, defaultValue?: string,
id: string, id: string,
inputWidth?: number, inputWidth?: number,
label: string, label?: string,
labelLexic?: string,
labelWidth?: number, labelWidth?: number,
maxLength?: number, maxLength?: number,
onChange?: (event: ChangeEvent<HTMLInputElement>) => void, onChange?: (event: ChangeEvent<HTMLInputElement>) => void,
@ -27,6 +30,7 @@ export const Input = ({
id, id,
inputWidth, inputWidth,
label, label,
labelLexic,
labelWidth, labelWidth,
maxLength, maxLength,
onChange, onChange,
@ -46,7 +50,11 @@ export const Input = ({
htmlFor={id} htmlFor={id}
labelWidth={labelWidth} labelWidth={labelWidth}
> >
{label} {
labelLexic
? <T9n t={labelLexic} />
: label
}
</Label> </Label>
<InputStyled <InputStyled
id={id} id={id}

@ -18,7 +18,7 @@ import {
import './flags.scss' import './flags.scss'
export const LanguageSelect = () => { export const LanguageSelect = () => {
const { changeLang } = useLexicsStore() const { changeLang, translate } = useLexicsStore()
const { const {
close, close,
isOpen, isOpen,
@ -33,7 +33,11 @@ export const LanguageSelect = () => {
return ( return (
<OutsideClick onClick={close}> <OutsideClick onClick={close}>
<Wrapper> <Wrapper>
<WorldIcon onClick={open} active={isOpen} /> <WorldIcon
onClick={open}
active={isOpen}
title={translate('select_language')}
/>
{isOpen && ( {isOpen && (
<LangsList> <LangsList>
{ {

@ -6,6 +6,7 @@ import { T9n } from 'features/T9n'
import { Logo } from 'features/Logo' import { Logo } from 'features/Logo'
import { Input, ButtonSolid } from 'features/Common' import { Input, ButtonSolid } from 'features/Common'
import { formIds } from 'features/Register/components/RegistrationStep/config' import { formIds } from 'features/Register/components/RegistrationStep/config'
import { useLexicsStore } from 'features/LexicsStore'
import { useForm } from './hooks' import { useForm } from './hooks'
import { import {
@ -20,32 +21,40 @@ const labelWidth = 60
export const Login = () => { export const Login = () => {
const { handleSubmit } = useForm() const { handleSubmit } = useForm()
const { translate } = useLexicsStore()
const defaultMessage = translate('please_fill_out_this_field')
return ( return (
<CenterBlock> <CenterBlock>
<Logo /> <Logo />
<Form onSubmit={handleSubmit}> <Form onSubmit={handleSubmit}>
<BlockTitle><T9n t='authorization' /></BlockTitle> <BlockTitle>
<T9n t='step_title_login' />
</BlockTitle>
<Input <Input
required required
id={formIds.email} id={formIds.email}
type='email' type='email'
label='Логин' labelLexic='form_email'
labelWidth={labelWidth} labelWidth={labelWidth}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.password} id={formIds.password}
type='password' type='password'
label='Пароль' labelLexic='form_password'
labelWidth={labelWidth} labelWidth={labelWidth}
title={defaultMessage}
/> />
<ButtonsBlock> <ButtonsBlock>
<ButtonSolid type='submit'>Войти</ButtonSolid> <ButtonSolid type='submit'>
<T9n t='login' />
</ButtonSolid>
<RegisterButton to={PAGES.register}> <RegisterButton to={PAGES.register}>
Зарегистрироваться <T9n t='register' />
</RegisterButton> </RegisterButton>
</ButtonsBlock> </ButtonsBlock>
</Form> </Form>

@ -1,44 +1,58 @@
import React from 'react' import React from 'react'
import { T9n } from 'features/T9n'
import { Input, ButtonSolid } from 'features/Common' import { Input, ButtonSolid } from 'features/Common'
import { import {
BlockTitle, BlockTitle,
ButtonsBlock, ButtonsBlock,
Form, Form,
} from 'features/Login/styled' } from 'features/Login/styled'
import { useLexicsStore } from 'features/LexicsStore'
import { Card, Row } from '../../styled' import { Card, Row } from '../../styled'
export const CardStep = () => ( export const CardStep = () => {
const { translate } = useLexicsStore()
const defaultMessage = translate('please_fill_out_this_field')
return (
<Form> <Form>
<BlockTitle>Привязка карты</BlockTitle> <BlockTitle>
<T9n t='step_title_card' />
</BlockTitle>
<Card> <Card>
<Input <Input
id='cardNumber' id='cardNumber'
label='Номер карты' labelLexic='form_card_number'
labelWidth={122}
paddingX={21} paddingX={21}
title={defaultMessage}
/> />
<Row> <Row>
<Input <Input
id='expiration' id='expiration'
label='Срок действия' labelLexic='form_card_expiration'
wrapperWidth={280} wrapperWidth={280}
inputWidth={85} inputWidth={85}
paddingX={21} paddingX={21}
title={defaultMessage}
/> />
<Input <Input
id='code' id='code'
label='CVC / CVV' labelLexic='form_card_code'
wrapperWidth={184} wrapperWidth={184}
inputWidth={30} inputWidth={30}
maxLength={3} maxLength={3}
paddingX={18.6} paddingX={18.6}
title={defaultMessage}
/> />
</Row> </Row>
</Card> </Card>
<ButtonsBlock> <ButtonsBlock>
<ButtonSolid>Далее</ButtonSolid> <ButtonSolid type='submit'>
<T9n t='next' />
</ButtonSolid>
</ButtonsBlock> </ButtonsBlock>
</Form> </Form>
) )
}

@ -1,5 +1,6 @@
import React from 'react' import React from 'react'
import { T9n } from 'features/T9n'
import { Combobox } from 'features/Combobox' import { Combobox } from 'features/Combobox'
import { Input, ButtonSolid } from 'features/Common' import { Input, ButtonSolid } from 'features/Common'
import { import {
@ -7,6 +8,7 @@ import {
ButtonsBlock, ButtonsBlock,
Form, Form,
} from 'features/Login/styled' } from 'features/Login/styled'
import { useLexicsStore } from 'features/LexicsStore'
import { formIds } from './config' import { formIds } from './config'
import { passwordRegex } from '../../helpers/isValidPassword' import { passwordRegex } from '../../helpers/isValidPassword'
@ -15,7 +17,7 @@ import { useForm } from './hooks/useForm'
const commonFieldRegex = '^.{0,500}$' const commonFieldRegex = '^.{0,500}$'
const postalCodeRegex = '^\\d{5}(?:[-\\s]\\d{4})?$' const postalCodeRegex = '^\\d{5}(?:[-\\s]\\d{4})?$'
const labelWidth = 78 const labelWidth = 116
export const RegistrationStep = () => { export const RegistrationStep = () => {
const { const {
@ -28,64 +30,72 @@ export const RegistrationStep = () => {
onCountrySelect, onCountrySelect,
selectedCountry, selectedCountry,
} = useForm() } = useForm()
const { translate } = useLexicsStore()
const defaultMessage = translate('please_fill_out_this_field')
return ( return (
<Form onSubmit={handleSubmit}> <Form onSubmit={handleSubmit}>
<BlockTitle>Регистрация</BlockTitle> <BlockTitle>
<T9n t='step_title_registration' />
</BlockTitle>
<Input <Input
required required
id={formIds.firstname} id={formIds.firstname}
label='Имя' labelLexic='form_firstname'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern={commonFieldRegex} pattern={commonFieldRegex}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.lastname} id={formIds.lastname}
label='Фамилия' labelLexic='form_lastname'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern={commonFieldRegex} pattern={commonFieldRegex}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.phone} id={formIds.phone}
type='tel' type='tel'
label='Телефон' labelLexic='form_phone'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern='^[0-9]{8,100}$' pattern='^[0-9]{8,100}$'
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.email} id={formIds.email}
type='email' type='email'
label='E-mail' labelLexic='form_email'
title='example@mail.com'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern={emailRegex} pattern={emailRegex}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.password} id={formIds.password}
type='password' type='password'
label='Пароль' labelLexic='form_password'
title='Inst@1TV'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern={passwordRegex} pattern={passwordRegex}
title={defaultMessage}
/> />
<Combobox <Combobox
required required
openOnFocus openOnFocus
id={formIds.country} id={formIds.country}
label='Страна' labelLexic='form_country'
labelWidth={labelWidth} labelWidth={labelWidth}
options={countries} options={countries}
onSelect={onCountrySelect} onSelect={onCountrySelect}
title={defaultMessage}
/> />
<Combobox <Combobox
required required
id={formIds.city} id={formIds.city}
label='Город' labelLexic='form_city'
labelWidth={labelWidth} labelWidth={labelWidth}
disabled={!selectedCountry} disabled={!selectedCountry}
value={cityQuery} value={cityQuery}
@ -93,35 +103,43 @@ export const RegistrationStep = () => {
options={cities} options={cities}
onSelect={onCitySelect} onSelect={onCitySelect}
pattern={commonFieldRegex} pattern={commonFieldRegex}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.postalCode} id={formIds.postalCode}
label='Почтовый адрес' labelLexic='form_postal_code'
labelWidth={labelWidth}
pattern={postalCodeRegex} pattern={postalCodeRegex}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.region} id={formIds.region}
label='Регион' labelLexic='form_region'
labelWidth={labelWidth}
pattern={commonFieldRegex} pattern={commonFieldRegex}
title={defaultMessage}
/> />
<Input <Input
required required
id={formIds.address1} id={formIds.address1}
label='Адрес 1' labelLexic='form_address1'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern={commonFieldRegex} pattern={commonFieldRegex}
title={defaultMessage}
/> />
<Input <Input
id={formIds.address2} id={formIds.address2}
label='Адрес 2' labelLexic='form_address2'
labelWidth={labelWidth} labelWidth={labelWidth}
pattern={commonFieldRegex} pattern={commonFieldRegex}
/> />
<ButtonsBlock> <ButtonsBlock>
<ButtonSolid type='submit'>Далее</ButtonSolid> <ButtonSolid type='submit'>
<T9n t='next' />
</ButtonSolid>
</ButtonsBlock> </ButtonsBlock>
</Form> </Form>
) )

@ -1,5 +1,6 @@
import React, { Fragment } from 'react' import React, { Fragment } from 'react'
import { T9n } from 'features/T9n'
import { ButtonSolid } from 'features/Common/Button' import { ButtonSolid } from 'features/Common/Button'
import { ArrowLeft, ArrowRight } from 'features/Common/Arrows' import { ArrowLeft, ArrowRight } from 'features/Common/Arrows'
import { ButtonsBlock } from 'features/Login/styled' import { ButtonsBlock } from 'features/Login/styled'
@ -22,7 +23,9 @@ import {
export const SubscriptionStep = () => ( export const SubscriptionStep = () => (
<Fragment> <Fragment>
<SubscriptionsBlock> <SubscriptionsBlock>
<BlockTitle>Выбор подписки</BlockTitle> <BlockTitle>
<T9n t='step_title_subscription' />
</BlockTitle>
<SubscriptionList> <SubscriptionList>
<SubscriptionListItem> <SubscriptionListItem>
<MainSubscription title='Бесплатная' price={0} /> <MainSubscription title='Бесплатная' price={0} />
@ -33,7 +36,9 @@ export const SubscriptionStep = () => (
</SubscriptionList> </SubscriptionList>
</SubscriptionsBlock> </SubscriptionsBlock>
<SubscriptionsBlock forAdditionalTitle> <SubscriptionsBlock forAdditionalTitle>
<AdditionalBlockTitle>Дополнительно</AdditionalBlockTitle> <AdditionalBlockTitle>
<T9n t='subscription_extra' />
</AdditionalBlockTitle>
<PricesBlock> <PricesBlock>
<ArrowLeft /> <ArrowLeft />
<AdditionalSubscription title='Российская премьер-лига' price={1999} /> <AdditionalSubscription title='Российская премьер-лига' price={1999} />
@ -44,9 +49,11 @@ export const SubscriptionStep = () => (
</PricesBlock> </PricesBlock>
</SubscriptionsBlock> </SubscriptionsBlock>
<ButtonsBlock forSubsPage> <ButtonsBlock forSubsPage>
<ButtonSolid>Готово</ButtonSolid> <ButtonSolid>
<T9n t='subscription_done' />
</ButtonSolid>
<TotalInfoBlock> <TotalInfoBlock>
<TotalInfoText>Базовая + 2 дополнительно за <TotalInfoText>Базовая + 2 дополнительно <T9n t='subscription_for' />
<TotalPriceAmmount>6997</TotalPriceAmmount> <TotalPriceAmmount>6997</TotalPriceAmmount>
<TotalPriceDetails> / МЕС</TotalPriceDetails> <TotalPriceDetails> / МЕС</TotalPriceDetails>
</TotalInfoText> </TotalInfoText>

Loading…
Cancel
Save