feat(ott-91): added countries list request

keep-around/af30b88d367751c9e05a735e4a0467a96238ef47
mirlan.maksitaliev 6 years ago
parent 5a89830556
commit f18b452fc1
  1. 1
      src/config/index.tsx
  2. 3
      src/config/procedures.tsx
  3. 2
      src/config/routes.tsx
  4. 2
      src/helpers/callApi/getResponseData.tsx
  5. 1
      src/helpers/index.tsx
  6. 28
      src/requests/getCountries.tsx
  7. 1
      src/requests/index.tsx

@ -1,3 +1,4 @@
export * from './routes'
export * from './pages'
export * from './authKeys'
export * from './procedures'

@ -0,0 +1,3 @@
export const PROCEDURES = {
lst_c_country: 'lst_c_country',
}

@ -1,2 +1,2 @@
export const API_ROOT = ''
export const API_ROOT = 'http://85.10.224.24:8080'
export const DATA_URL = `${API_ROOT}/data`

@ -1,3 +1,3 @@
export const getResponseData = (proc: string) => (response: any) => (
response?.data?.[0]?.[proc]
response?.[proc]
)

@ -1 +1,2 @@
export * from './callApi'
export * from './callApi/getResponseData'

@ -0,0 +1,28 @@
import { DATA_URL, PROCEDURES } from 'config'
import { callApi, getResponseData } from 'helpers'
const proc = PROCEDURES.lst_c_country
export type Country = {
id: number,
iso_3166_1_alpha_2: string,
iso_3166_1_alpha_3: string,
name_eng: string,
name_rus: string,
}
export type Countries = Array<Country>
export const getCountries = (): Promise<Countries> => {
const config = {
body: {
params: null,
proc,
},
}
return callApi({
config,
url: DATA_URL,
}).then(getResponseData(proc))
}

@ -1 +1,2 @@
export * from './login'
export * from './getCountries'

Loading…
Cancel
Save