Skip to content

Commit

Permalink
fix: refetch orgs when cancelling subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
rohan-chaturvedi committed Nov 29, 2024
1 parent 333bc0f commit 38d10c6
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import { GetSubscriptionDetails } from '@/graphql/queries/billing/getSubscriptio
import { DeleteStripePaymentMethod } from '@/graphql/mutations/billing/deletePaymentMethod.gql'
import { CancelStripeSubscription } from '@/graphql/mutations/billing/cancelProSubscription.gql'
import { SetDefaultStripePaymentMethodOp } from '@/graphql/mutations/billing/setDefaultPaymentMethod.gql'
import { GetOrganisations } from '@/graphql/queries/getOrganisations.gql'
import { relativeTimeFromDates } from '@/utils/time'
import { useLazyQuery, useMutation, useQuery } from '@apollo/client'
import { useContext, useRef } from 'react'
Expand Down Expand Up @@ -257,11 +258,13 @@ const CancelSubscriptionDialog = ({ subscriptionId }: { subscriptionId: string }
const dialogRef = useRef<{ closeModal: () => void }>(null)

const [cancelSubscription] = useMutation(CancelStripeSubscription)

const handleCancelSubscription = async () =>
await cancelSubscription({
variables: { subscriptionId, organisationId: activeOrganisation!.id },
refetchQueries: [
{ query: GetSubscriptionDetails, variables: { organisationId: activeOrganisation?.id } },
{ query: GetOrganisations },
],
}).then(() => {
toast.success('Cancelled subscription')
Expand Down

0 comments on commit 38d10c6

Please sign in to comment.