Skip to content

Commit

Permalink
fix: error when user subscribes to new plan and is redirecting (#2323)
Browse files Browse the repository at this point in the history
  • Loading branch information
stepan662 authored May 27, 2024
1 parent 45557db commit 779cf3d
Showing 1 changed file with 23 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,35 +35,36 @@ export const usePlan = ({ planId, period }: Props) => {
});

const onSubscribe = () => {
subscribeMutation.mutate({
path: {
organizationId: organization!.id,
},
content: {
'application/json': {
planId,
period,
subscribeMutation.mutate(
{
path: {
organizationId: organization!.id,
},
content: {
'application/json': {
planId,
period,
},
},
},
});
{
onSuccess: (data) => {
window.location.href = data.url;
},
onError: (data) => {
if (data.code === 'organization_already_subscribed') {
messaging.error(
<T keyName="billing_organization_already_subscribed" />
);
}
},
}
);
};

const subscribeMutation = useBillingApiMutation({
url: '/v2/organizations/{organizationId}/billing/subscribe',
method: 'post',
invalidatePrefix: '/',
options: {
onSuccess: (data) => {
window.location.href = data.url;
},
onError: (data) => {
if (data.code === 'organization_already_subscribed') {
messaging.error(
<T keyName="billing_organization_already_subscribed" />
);
}
},
},
});

const cancelMutation = useBillingApiMutation({
Expand Down

0 comments on commit 779cf3d

Please sign in to comment.