first commit
Some checks failed
Build / run (push) Has been cancelled

This commit is contained in:
maher
2025-10-29 11:42:25 +01:00
commit 703f50a09d
4595 changed files with 385164 additions and 0 deletions

View File

@@ -0,0 +1,31 @@
import {useMutation} from '@tanstack/react-query';
import {apiClient, queryClient} from '../../../../http/query-client';
import {useTrans} from '../../../../i18n/use-trans';
import {BackendResponse} from '../../../../http/backend-response/backend-response';
import {toast} from '../../../../ui/toast/toast';
import {message} from '../../../../i18n/message';
import {showHttpErrorToast} from '../../../../utils/http/show-http-error-toast';
interface Response extends BackendResponse {
clientSecret: string;
}
export function useCreateStripeSubscription(productId: string | number) {
const {trans} = useTrans();
return useMutation({
mutationFn: () => createStripeSubscription(productId),
onSuccess: () => {
toast(trans(message('Mutation performed')));
queryClient.invalidateQueries({queryKey: ['Query Key']});
},
onError: err => showHttpErrorToast(err),
});
}
function createStripeSubscription(
productId: string | number,
): Promise<Response> {
return apiClient
.post('billing/subscriptions/stripe/create', {product_id: productId})
.then(r => r.data);
}