Advertisement
Guest User

Untitled

a guest
Mar 30th, 2020
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function* loadConfig(): Generator {
  2.   try {
  3.     const partnerSlug: string = getPartnerSlug(host)
  4.  
  5.     const partnerAuthAppKeyResponse: AxiosResponse<IVerificationResponsePayload> = (yield call(
  6.       [api, 'post'],
  7.       'v1/appkeys/find',
  8.       {
  9.         partnerSlug
  10.       }
  11.     )) as AxiosResponse<IVerificationResponsePayload>
  12.  
  13.     api.setAppKey(partnerAuthAppKeyResponse.data.authAppKey)
  14.  
  15.     const partnerConfigResponse: AxiosResponse<IVerificationResponsePayload> = (yield call(
  16.       [api, 'get'],
  17.       'v1/partners/ui/configuration'
  18.     )) as AxiosResponse<IVerificationResponsePayload>
  19.  
  20.     const {
  21.       data: { configuration: partnerConfiguration }
  22.     } = partnerConfigResponse
  23.  
  24.     if (partnerSlug === genericShopPartnerKey) {
  25.       modifyConfig(partnerConfiguration, getGenericPartnerConfig(host))
  26.     } else {
  27.       modifyConfig(partnerConfiguration)
  28.     }
  29.  
  30.     const root: HTMLElement = document.documentElement
  31.     for (const key of Object.keys(partnerConfiguration.theme)) {
  32.       root.style.setProperty(key, partnerConfiguration.theme[key])
  33.     }
  34.  
  35.     const errorsResponse: any = yield call(getErrorLabels)
  36.  
  37.     yield put(succeedPartnerConfigLoading(partnerConfiguration))
  38.     yield put(succeedErrorLabelsLoading(errorsResponse.fields))
  39.   } catch (error) {
  40.     yield put(failPartnerConfigLoading(error))
  41.     yield history.push(StaticRoute.failUrl)
  42.   }
  43. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement