Skip to content

Commit

Permalink
fix(app-general): update labels to match crm
Browse files Browse the repository at this point in the history
  • Loading branch information
rams23 committed Feb 22, 2021
1 parent dbf5b66 commit 538272f
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 9 deletions.
12 changes: 6 additions & 6 deletions fixtures/firestore-data/dynamicData.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@
"en": "Other"
},
"requirementsDecisionMaker": {
"en": "Define requirements and propose solutions"
"en": "I define requirements and propose a solution"
},
"studentOrPotentialEmployee": {
"en": "Student or potential employee"
"en": "I am a student or a potential employee"
},
"influenceDecisionMaker": {
"en": "Influence decision"
"en": "I influence in the decision"
},
"budgetOwner": {
"en": "Have budget and make final decisions"
"en": "I have the budget and I make final decision"
},
"consultant": {
"en": "Consultant"
},
"recommender": {
"en": "Give recommendations"
"en": "I give recommendations"
},
"endUser": {
"en": "End user"
"en": "I am an end user"
}
},
"roles": [
Expand Down
37 changes: 37 additions & 0 deletions packages/game-app/src/_shared/dynamicData/slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,41 @@ const getDevOpsMaturitiesOptions = createSelector(
},
);

const getGameRolesMap = createSelector(
(state: { [name]: State }) => state[name],
getCurrentLanguage,
(dynamicDataState, currentLanguage) => {
if (dynamicDataState.gameRoles == null) {
return [];
}
const labels = {} as { [key: string]: string };

for (const maturity in dynamicDataState.gameRoles.labels) {
const supportedLanguage = currentLanguage in dynamicDataState.gameRoles.labels[maturity] ? currentLanguage : 'en';
labels[maturity] = dynamicDataState.gameRoles.labels[maturity][supportedLanguage];
}
return labels;
},
);

const getDevOpsMaturitiesMap = createSelector(
(state: { [name]: State }) => state[name],
getCurrentLanguage,
(dynamicDataState, currentLanguage) => {
if (dynamicDataState.devOpsMaturities == null) {
return [];
}
const labels = {} as { [key: string]: string };

for (const maturity in dynamicDataState.devOpsMaturities.labels) {
const supportedLanguage =
currentLanguage in dynamicDataState.devOpsMaturities.labels[maturity] ? currentLanguage : 'en';
labels[maturity] = dynamicDataState.devOpsMaturities.labels[maturity][supportedLanguage];
}
return labels;
},
);

export const reducer = slice.reducer;
export const actions = {
...slice.actions,
Expand All @@ -75,4 +110,6 @@ export const name = slice.name;
export const selectors = {
getGameRolesOptions,
getDevOpsMaturitiesOptions,
getGameRolesMap,
getDevOpsMaturitiesMap,
};
9 changes: 6 additions & 3 deletions packages/game-app/src/signup/sagas/signup.ts
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import * as actions from '../actions';
import { executeSignup } from '../apis/executeSignup';
import { call, put, takeLeading } from 'redux-saga/effects';
import { call, put, select, takeLeading } from 'redux-saga/effects';
import { addRequestStatusManagement } from '@pipeline/requests-status';
import { actions as authActions, AuthUser } from '@pipeline/auth';
import { actions as analyticsActions } from '@pipeline/analytics';
import { selectors as dynamicSelectors } from '@pipeline/dynamicData';

function* signupSaga(action: ReturnType<typeof actions.signup>) {
const user: AuthUser = yield call(executeSignup, action.payload);
yield put(authActions.setLoggedUser(user));
const maturities = yield select(dynamicSelectors.getDevOpsMaturitiesMap);
const roles = yield select(dynamicSelectors.getGameRolesMap);
const crmInfo = {
email: action.payload.email,
firstName: action.payload.firstName,
lastName: action.payload.lastName,
devOpsMaturity: action.payload.devOpsMaturity,
role: action.payload.role,
how_mature_are_your_devops_practices_: maturities[action.payload.devOpsMaturity],
what_is_your_role_in_the_company_: roles[action.payload.role],
id: user.id,
};
yield put(analyticsActions.identify(crmInfo));
Expand Down

0 comments on commit 538272f

Please sign in to comment.