mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 12:50:38 +00:00
refactoring: setup wizard pages with simple architecture.
This commit is contained in:
@@ -1,28 +0,0 @@
|
||||
import ApiService from 'services/ApiService';
|
||||
|
||||
export const buildTenant = ({ id, token }) => {
|
||||
return (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ApiService.post(`organization/build${token}`, id)
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
export const seedTenant = ({ id, token }) => {
|
||||
return (dispatch) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
ApiService.post(`organization/seed/${token}`, id)
|
||||
.then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
};
|
||||
};
|
||||
@@ -1,16 +1,32 @@
|
||||
import ApiService from 'services/ApiService';
|
||||
import t from 'store/types';
|
||||
|
||||
export const fetchOrganizations = () => {
|
||||
return (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get('organization/all').then((response) => {
|
||||
dispatch({
|
||||
type: t.ORGANIZATIONS_LIST_SET,
|
||||
payload: {
|
||||
organizations: response.data.organizations,
|
||||
},
|
||||
});
|
||||
resolve(response)
|
||||
}).catch(error => { reject(error); });
|
||||
export const fetchOrganizations = () => (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.get('organization/all').then((response) => {
|
||||
dispatch({
|
||||
type: t.ORGANIZATIONS_LIST_SET,
|
||||
payload: {
|
||||
organizations: response.data.organizations,
|
||||
},
|
||||
});
|
||||
resolve(response)
|
||||
}).catch(error => { reject(error); });
|
||||
});
|
||||
|
||||
export const buildTenant = () => (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.post(`organization/build`).then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
};
|
||||
});
|
||||
|
||||
export const seedTenant = () => (dispatch) => new Promise((resolve, reject) => {
|
||||
ApiService.post(`organization/seed/`).then((response) => {
|
||||
resolve(response);
|
||||
})
|
||||
.catch((error) => {
|
||||
reject(error.response.data.errors || []);
|
||||
});
|
||||
});
|
||||
@@ -2,17 +2,17 @@ import { createSelector } from '@reduxjs/toolkit';
|
||||
|
||||
const oragnizationByTenantIdSelector = (state, props) => state.organizations[props.tenantId];
|
||||
const organizationByIdSelector = (state, props) => state.organizations.byOrganizationId[props.organizationId];
|
||||
const organizationsDataSelector = (state, props) => state.organizations.data;
|
||||
|
||||
export const getOrganizationByOrgIdFactory = () => createSelector(
|
||||
organizationByIdSelector,
|
||||
(organization) => {
|
||||
return organization;
|
||||
},
|
||||
organizationsDataSelector,
|
||||
(organizationId, organizationsData) => {
|
||||
return organizationsData[organizationId];
|
||||
}
|
||||
);
|
||||
|
||||
export const getOrganizationByTenantIdFactory = () => createSelector(
|
||||
oragnizationByTenantIdSelector,
|
||||
(organization) => {
|
||||
return organization;
|
||||
}
|
||||
)
|
||||
(organization) => organization,
|
||||
);
|
||||
Reference in New Issue
Block a user