feat: setup congrats page.

This commit is contained in:
Ahmed Bouhuolia
2020-10-14 17:49:27 +02:00
parent f9f517ae51
commit 5b9b5fc3a7
12 changed files with 267 additions and 12 deletions

View File

@@ -36,17 +36,29 @@ export const seedTenant = () => (dispatch, getState) => new Promise((resolve, re
const organizationId = getState().authentication.organizationId;
dispatch({
type: t.SET_ORGANIZATION_INITIALIZING,
type: t.SET_ORGANIZATION_SEEDING,
payload: { organizationId }
});
ApiService.post(`organization/seed/`).then((response) => {
resolve(response);
dispatch({
type: t.SET_ORGANIZATION_INITIALIZED,
type: t.SET_ORGANIZATION_SEEDED,
payload: { organizationId }
});
})
.catch((error) => {
reject(error.response.data.errors || []);
});
});
});
export const setOrganizationSetupCompleted = (congrats) => (dispatch, getState) => {
const organizationId = getState().authentication.organizationId;
dispatch({
type: t.SET_ORGANIZATION_CONGRATS,
payload: {
organizationId,
congrats
},
});
};

View File

@@ -37,6 +37,7 @@ const reducer = createReducer(initialState, {
...(state.data[organizationId] || {}),
is_seeding: false,
seeded_at: new Date().toISOString(),
is_ready: true,
};
},
@@ -58,6 +59,15 @@ const reducer = createReducer(initialState, {
initialized_at: new Date().toISOString(),
};
},
[t.SET_ORGANIZATION_CONGRATS]: (state, action) => {
const { organizationId, congrats } = action.payload;
state.data[organizationId] = {
...(state.data[organizationId] || {}),
is_congrats: !!congrats,
};
}
})
export default reducer;

View File

@@ -47,4 +47,11 @@ export const isOrganizationSubscribedFactory = () => createSelector(
(organization) => {
return organization?.subscriptions?.length > 0;
}
);
export const isOrganizationCongratsFactory = () => createSelector(
organizationSelector,
(organization) => {
return !!organization?.is_congrats;
}
)

View File

@@ -7,4 +7,6 @@ export default {
SET_ORGANIZATION_INITIALIZED: 'SET_ORGANIZATION_INITIALIZED',
SET_ORGANIZATION_INITIALIZING: 'SET_ORGANIZATION_INITIALIZING',
SET_ORGANIZATION_CONGRATS: 'SET_ORGANIZATION_CONGRATS'
};