mirror of
https://github.com/bigcapitalhq/bigcapital.git
synced 2026-02-16 04:40:32 +00:00
feat: pause, resume main subscription
This commit is contained in:
115
packages/webapp/src/hooks/query/subscription.tsx
Normal file
115
packages/webapp/src/hooks/query/subscription.tsx
Normal file
@@ -0,0 +1,115 @@
|
||||
// @ts-nocheck
|
||||
import {
|
||||
useMutation,
|
||||
UseMutationOptions,
|
||||
UseMutationResult,
|
||||
useQueryClient,
|
||||
} from 'react-query';
|
||||
import useApiRequest from '../useRequest';
|
||||
|
||||
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),
|
||||
{
|
||||
...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),
|
||||
{
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
interface ChangeMainSubscriptionPlanValues {
|
||||
variantId: 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<
|
||||
ChangeMainSubscriptionPlanValues,
|
||||
Error,
|
||||
ChangeMainSubscriptionPlanResponse
|
||||
>(
|
||||
(values) =>
|
||||
apiRequest.post(`/subscription/change`, values).then((res) => res.data),
|
||||
{
|
||||
...options,
|
||||
},
|
||||
);
|
||||
}
|
||||
Reference in New Issue
Block a user