mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-17 05:10:31 +00:00
feat: organization setup.
This commit is contained in:
@@ -26,3 +26,4 @@ export * from './organization';
|
||||
export * from './landedCost';
|
||||
export * from './UniversalSearch/UniversalSearch';
|
||||
export * from './GenericResource';
|
||||
export * from './jobs';
|
||||
|
||||
16
client/src/hooks/query/jobs.js
Normal file
16
client/src/hooks/query/jobs.js
Normal file
@@ -0,0 +1,16 @@
|
||||
import { useRequestQuery } from '../useQueryRequest';
|
||||
|
||||
/**
|
||||
* Retrieve the job metadata.
|
||||
*/
|
||||
export function useJob(jobId, props = {}) {
|
||||
return useRequestQuery(
|
||||
['JOB', jobId],
|
||||
{ method: 'get', url: `jobs/${jobId}` },
|
||||
{
|
||||
select: (res) => res.data.job,
|
||||
defaultData: {},
|
||||
...props,
|
||||
},
|
||||
);
|
||||
}
|
||||
@@ -35,7 +35,7 @@ export function useCurrentOrganization(props) {
|
||||
|
||||
return useRequestQuery(
|
||||
[t.ORGANIZATION_CURRENT],
|
||||
{ method: 'get', url: `organization/current` },
|
||||
{ method: 'get', url: `organization` },
|
||||
{
|
||||
select: (res) => res.data.organization,
|
||||
defaultData: {},
|
||||
@@ -55,37 +55,6 @@ export function useCurrentOrganization(props) {
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Builds the current tenant.
|
||||
*/
|
||||
export function useBuildTenant(props) {
|
||||
const apiRequest = useApiRequest();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation((values) => apiRequest.post('organization/build'), {
|
||||
onSuccess: (res, values) => {
|
||||
queryClient.invalidateQueries(t.ORGANIZATION_CURRENT);
|
||||
queryClient.invalidateQueries(t.ORGANIZATIONS);
|
||||
},
|
||||
...props,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Seeds the current tenant
|
||||
*/
|
||||
export function useSeedTenant() {
|
||||
const apiRequest = useApiRequest();
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation((values) => apiRequest.post('organization/seed'), {
|
||||
onSuccess: (res) => {
|
||||
queryClient.invalidateQueries(t.ORGANIZATION_CURRENT);
|
||||
queryClient.invalidateQueries(t.ORGANIZATIONS);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Organization setup.
|
||||
*/
|
||||
@@ -94,7 +63,7 @@ export function useOrganizationSetup() {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation(
|
||||
(values) => apiRequest.post(`setup/organization`, values),
|
||||
(values) => apiRequest.post(`organization/build`, values),
|
||||
{
|
||||
onSuccess: (res) => {
|
||||
queryClient.invalidateQueries(t.ORGANIZATION_CURRENT);
|
||||
|
||||
Reference in New Issue
Block a user