mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
Merge branch 'develop' into bulk-categorize-bank-transactions
This commit is contained in:
@@ -61,6 +61,76 @@ export function useCreateBankRule(
|
||||
);
|
||||
}
|
||||
|
||||
interface DisconnectBankAccountRes {}
|
||||
interface DisconnectBankAccountValues {
|
||||
bankAccountId: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disconnects the given bank account.
|
||||
* @param {UseMutationOptions<DisconnectBankAccountRes, Error, DisconnectBankAccountValues>} options
|
||||
* @returns {UseMutationResult<DisconnectBankAccountRes, Error, DisconnectBankAccountValues>}
|
||||
*/
|
||||
export function useDisconnectBankAccount(
|
||||
options?: UseMutationOptions<
|
||||
DisconnectBankAccountRes,
|
||||
Error,
|
||||
DisconnectBankAccountValues
|
||||
>,
|
||||
): UseMutationResult<
|
||||
DisconnectBankAccountRes,
|
||||
Error,
|
||||
DisconnectBankAccountValues
|
||||
> {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation<
|
||||
DisconnectBankAccountRes,
|
||||
Error,
|
||||
DisconnectBankAccountValues
|
||||
>(
|
||||
({ bankAccountId }) =>
|
||||
apiRequest.post(`/banking/bank_accounts/${bankAccountId}/disconnect`),
|
||||
{
|
||||
...options,
|
||||
onSuccess: (res, values) => {
|
||||
queryClient.invalidateQueries([t.ACCOUNT, values.bankAccountId]);
|
||||
},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface UpdateBankAccountRes {}
|
||||
interface UpdateBankAccountValues {
|
||||
bankAccountId: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* Update the bank transactions of the bank account.
|
||||
* @param {UseMutationOptions<UpdateBankAccountRes, Error, UpdateBankAccountValues>}
|
||||
* @returns {UseMutationResult<UpdateBankAccountRes, Error, UpdateBankAccountValues>}
|
||||
*/
|
||||
export function useUpdateBankAccount(
|
||||
options?: UseMutationOptions<
|
||||
UpdateBankAccountRes,
|
||||
Error,
|
||||
UpdateBankAccountValues
|
||||
>,
|
||||
): UseMutationResult<UpdateBankAccountRes, Error, UpdateBankAccountValues> {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation<DisconnectBankAccountRes, Error, UpdateBankAccountValues>(
|
||||
({ bankAccountId }) =>
|
||||
apiRequest.post(`/banking/bank_accounts/${bankAccountId}/update`),
|
||||
{
|
||||
...options,
|
||||
onSuccess: () => {},
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface EditBankRuleValues {
|
||||
id: number;
|
||||
value: any;
|
||||
|
||||
196
packages/webapp/src/hooks/query/subscription.tsx
Normal file
196
packages/webapp/src/hooks/query/subscription.tsx
Normal file
@@ -0,0 +1,196 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
useQuery,
|
||||
useQueryClient,
|
||||
UseQueryOptions,
|
||||
UseQueryResult,
|
||||
} from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
import { transformToCamelCase } from '@/utils';
|
||||
|
||||
const QueryKeys = {
|
||||
Subscriptions: 'Subscriptions',
|
||||
};
|
||||
|
||||
interface CancelMainSubscriptionValues {}
|
||||
interface CancelMainSubscriptionResponse {}
|
||||
|
||||
/**
|
||||
* Cancels the main subscription of the current organization.
|
||||
* @param {UseMutationOptions<CreateBankRuleValues, Error, CreateBankRuleValues>} options -
|
||||
* @returns {UseMutationResult<CreateBankRuleValues, Error, CreateBankRuleValues>}TCHES
|
||||
*/
|
||||
export function useCancelMainSubscription(
|
||||
options?: UseMutationOptions<
|
||||
CancelMainSubscriptionValues,
|
||||
Error,
|
||||
CancelMainSubscriptionResponse
|
||||
>,
|
||||
): UseMutationResult<
|
||||
CancelMainSubscriptionValues,
|
||||
Error,
|
||||
CancelMainSubscriptionResponse
|
||||
> {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation<
|
||||
CancelMainSubscriptionValues,
|
||||
Error,
|
||||
CancelMainSubscriptionResponse
|
||||
>(
|
||||
(values) =>
|
||||
apiRequest.post(`/subscription/cancel`, values).then((res) => res.data),
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(QueryKeys.Subscriptions);
|
||||
},
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface ResumeMainSubscriptionValues {}
|
||||
interface ResumeMainSubscriptionResponse {}
|
||||
|
||||
/**
|
||||
* Resumes the main subscription of the current organization.
|
||||
* @param {UseMutationOptions<CreateBankRuleValues, Error, CreateBankRuleValues>} options -
|
||||
* @returns {UseMutationResult<CreateBankRuleValues, Error, CreateBankRuleValues>}TCHES
|
||||
*/
|
||||
export function useResumeMainSubscription(
|
||||
options?: UseMutationOptions<
|
||||
ResumeMainSubscriptionValues,
|
||||
Error,
|
||||
ResumeMainSubscriptionResponse
|
||||
>,
|
||||
): UseMutationResult<
|
||||
ResumeMainSubscriptionValues,
|
||||
Error,
|
||||
ResumeMainSubscriptionResponse
|
||||
> {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation<
|
||||
ResumeMainSubscriptionValues,
|
||||
Error,
|
||||
ResumeMainSubscriptionResponse
|
||||
>(
|
||||
(values) =>
|
||||
apiRequest.post(`/subscription/resume`, values).then((res) => res.data),
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(QueryKeys.Subscriptions);
|
||||
},
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface ChangeMainSubscriptionPlanValues {
|
||||
variant_id: string;
|
||||
}
|
||||
interface ChangeMainSubscriptionPlanResponse {}
|
||||
|
||||
/**
|
||||
* Changese the main subscription of the current organization.
|
||||
* @param {UseMutationOptions<ChangeMainSubscriptionPlanValues, Error, ChangeMainSubscriptionPlanResponse>} options -
|
||||
* @returns {UseMutationResult<ChangeMainSubscriptionPlanValues, Error, ChangeMainSubscriptionPlanResponse>}
|
||||
*/
|
||||
export function useChangeSubscriptionPlan(
|
||||
options?: UseMutationOptions<
|
||||
ChangeMainSubscriptionPlanValues,
|
||||
Error,
|
||||
ChangeMainSubscriptionPlanResponse
|
||||
>,
|
||||
): UseMutationResult<
|
||||
ChangeMainSubscriptionPlanValues,
|
||||
Error,
|
||||
ChangeMainSubscriptionPlanResponse
|
||||
> {
|
||||
const queryClient = useQueryClient();
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useMutation<
|
||||
ChangeMainSubscriptionPlanResponse,
|
||||
Error,
|
||||
ChangeMainSubscriptionPlanValues
|
||||
>(
|
||||
(values) =>
|
||||
apiRequest.post(`/subscription/change`, values).then((res) => res.data),
|
||||
{
|
||||
onSuccess: () => {
|
||||
queryClient.invalidateQueries(QueryKeys.Subscriptions);
|
||||
},
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface LemonSubscription {
|
||||
active: boolean;
|
||||
canceled: string | null;
|
||||
canceledAt: string | null;
|
||||
canceledAtFormatted: string | null;
|
||||
cancelsAt: string | null;
|
||||
cancelsAtFormatted: string | null;
|
||||
createdAt: string;
|
||||
ended: boolean;
|
||||
endsAt: string | null;
|
||||
inactive: boolean;
|
||||
lemonSubscriptionId: string;
|
||||
lemon_urls: {
|
||||
updatePaymentMethod: string;
|
||||
customerPortal: string;
|
||||
customerPortalUpdateSubscription: string;
|
||||
};
|
||||
onTrial: boolean;
|
||||
planId: number;
|
||||
planName: string;
|
||||
planSlug: string;
|
||||
slug: string;
|
||||
startsAt: string | null;
|
||||
status: string;
|
||||
statusFormatted: string;
|
||||
tenantId: number;
|
||||
trialEndsAt: string | null;
|
||||
trialEndsAtFormatted: string | null;
|
||||
trialStartsAt: string | null;
|
||||
trialStartsAtFormatted: string | null;
|
||||
updatedAt: string;
|
||||
}
|
||||
|
||||
interface GetSubscriptionsQuery {}
|
||||
interface GetSubscriptionsResponse {
|
||||
subscriptions: Array<LemonSubscription>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Changese the main subscription of the current organization.
|
||||
* @param {UseMutationOptions<ChangeMainSubscriptionPlanValues, Error, ChangeMainSubscriptionPlanResponse>} options -
|
||||
* @returns {UseMutationResult<ChangeMainSubscriptionPlanValues, Error, ChangeMainSubscriptionPlanResponse>}
|
||||
*/
|
||||
export function useGetSubscriptions(
|
||||
options?: UseQueryOptions<
|
||||
GetSubscriptionsQuery,
|
||||
Error,
|
||||
GetSubscriptionsResponse
|
||||
>,
|
||||
): UseQueryResult<GetSubscriptionsResponse, Error> {
|
||||
const apiRequest = useApiRequest();
|
||||
|
||||
return useQuery<GetSubscriptionsQuery, Error, GetSubscriptionsResponse>(
|
||||
[QueryKeys.Subscriptions],
|
||||
(values) =>
|
||||
apiRequest
|
||||
.get(`/subscription`)
|
||||
.then((res) => transformToCamelCase(res.data)),
|
||||
{
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user