Ott 214 combobox countries t9ns (#29)

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
Mirlan 6 years ago committed by GitHub
parent 35f1780a6a
commit a6fdfe962f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 2
      src/features/LexicsStore/helpers/index.tsx
  2. 2
      src/features/LexicsStore/hooks/index.tsx
  3. 8
      src/features/Register/components/RegistrationStep/hooks/useCountries.tsx
  4. 1
      src/hooks/index.tsx
  5. 2
      src/hooks/useCurrentLang.tsx
  6. 14
      src/hooks/usePageId.tsx

@ -24,7 +24,7 @@ export const readLang = () => {
}
export const getSuffix = (lang: string) => (
lang === 'rus' ? 'rus' : 'eng'
lang === 'ru' ? 'rus' : 'eng'
)
export const getLexicIds = (ids: Array<LexicsId> | LexicsConfig) => (

@ -7,6 +7,7 @@ import { getLexics } from 'requests'
import {
getLexicIds,
mapTranslationsToLocalKeys,
getSuffix,
} from 'features/LexicsStore/helpers'
import { useLang } from './useLang'
@ -45,6 +46,7 @@ export const useLexics = () => {
addLexicsConfig,
changeLang,
lang,
suffix: getSuffix(lang),
translate,
}
}

@ -9,13 +9,15 @@ import map from 'lodash/map'
import type { Countries } from 'requests'
import { getCountries } from 'requests'
import { useCurrentLang } from 'hooks'
import { useLexicsStore } from 'features/LexicsStore'
type Country = {
id: number,
name: string,
}
type Names = 'name_eng' | 'name_rus'
const useCountriesList = () => {
const [countries, setCountries] = useState<Countries>([])
@ -28,10 +30,10 @@ const useCountriesList = () => {
export const useCountries = () => {
const countries = useCountriesList()
const lang = useCurrentLang()
const { suffix } = useLexicsStore()
const [selectedCountry, setSelectedCountry] = useState<Country | null>(null)
const nameField = `name_${lang}` as 'name_eng'
const nameField = `name_${suffix}` as Names
const transformedCountries = useMemo(
() => orderBy(

@ -1,3 +1,2 @@
export * from './usePageId'
export * from './useCurrentLang'
export * from './useToggle'

@ -1,2 +0,0 @@
// временно, будем считывать из стора(контекста) лексики
export const useCurrentLang = () => 'eng'

@ -1 +1,13 @@
export const usePageId = () => {}
import { useParams } from 'react-router-dom'
type Params = {
pageId: string,
}
/**
* Хук возвращает id страницы
*/
export const usePageId = () => {
const { pageId } = useParams<Params>()
return Number(pageId)
}

Loading…
Cancel
Save