%PDF- %PDF-
Direktori : /home/emergentqj/actioncivile/pre-auth/.8352c036a19b0051d0217d27d25e3f4a/static/js/sagas/ |
Current File : /home/emergentqj/actioncivile/pre-auth/.8352c036a19b0051d0217d27d25e3f4a/static/js/sagas/getUser.js |
import { put, call, takeEvery } from "redux-saga/effects"; import configFunc from "config/config"; import { getTranslations } from "utils"; import { getDataAction } from "common/actions"; import LIST_ACTIONS from "../constants/action_types"; // const cookieIsSecure = getEnvConstant() !== "develop"; const config = configFunc(); export function* runGetUser() { const getUserUrl = `${config.apiUrl}login/currentLoginSilent`; try { const payload = yield call(getDataAction(getUserUrl, null, true)); yield put({ type: LIST_ACTIONS.GET_USER_SUCCESS, payload, }); const [userLanguage, userCountryCode] = payload.data.login.siteLanguage && payload.data.login.siteLanguage.split("_"); const translations = getTranslations(userCountryCode); if (userCountryCode && userLanguage) { yield put({ type: LIST_ACTIONS.SET_COUNTRY, payload: userCountryCode, }); yield put({ type: LIST_ACTIONS.SET_LANGUAGE, data: { translations, }, }); } const { properties } = payload.data.login; if (properties?.newMigratedUser) { yield put({ type: LIST_ACTIONS.GET_MIGRATED_USER_DATA, migrationReferenceId: properties?.migrationReferenceId, }); } } catch (e) { yield put({ type: LIST_ACTIONS.GET_USER_ERROR, e, }); } } export default function* getUser(dispatch) { yield takeEvery(LIST_ACTIONS.GET_USER_REQUEST, runGetUser, dispatch); }