Skip to content

Commit

Permalink
refactor: fetch integrations inside useOrganizationInfos hook (#1711)
Browse files Browse the repository at this point in the history
  • Loading branch information
keellyp authored Sep 3, 2024
1 parent 1dfc54e commit feb4e70
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 83 deletions.
20 changes: 5 additions & 15 deletions src/components/plans/ProgressiveBillingSection.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { gql } from '@apollo/client'
import { Box, InputAdornment, Stack } from '@mui/material'
import { FormikProps } from 'formik'
import { FC, useEffect, useState } from 'react'
Expand All @@ -17,24 +16,14 @@ import {
import { AmountInput, Switch, TextInput } from '~/components/form'
import { PROGRESSIVE_BILLING_DOC_URL } from '~/core/constants/externalUrls'
import { getCurrencySymbol } from '~/core/formats/intlFormatNumber'
import {
IntegrationTypeEnum,
useGetOrganizationIntegrationsForProgressiveBillingQuery,
} from '~/generated/graphql'
import { IntegrationTypeEnum } from '~/generated/graphql'
import { useInternationalization } from '~/hooks/core/useInternationalization'
import { useProgressiveBillingForm } from '~/hooks/plans/useProgressiveBillingForm'
import { useOrganizationInfos } from '~/hooks/useOrganizationInfos'
import { NAV_HEIGHT, theme } from '~/styles'

import { PlanFormInput } from './types'

gql`
query GetOrganizationIntegrationsForProgressiveBilling {
organization {
premiumIntegrations
}
}
`

interface ProgressiveBillingSectionProps {
formikProps: FormikProps<PlanFormInput>
isInSubscriptionForm?: boolean
Expand All @@ -45,7 +34,8 @@ export const ProgressiveBillingSection: FC<ProgressiveBillingSectionProps> = ({
isInSubscriptionForm,
}) => {
const { translate } = useInternationalization()
const { data } = useGetOrganizationIntegrationsForProgressiveBillingQuery()
const { organization: { premiumIntegrations } = {} } = useOrganizationInfos()

const {
nonRecurringUsageThresholds,
recurringUsageThreshold,
Expand All @@ -65,7 +55,7 @@ export const ProgressiveBillingSection: FC<ProgressiveBillingSectionProps> = ({

const currency = formikProps.values.amountCurrency

const hasPremiumIntegration = !!data?.organization?.premiumIntegrations?.includes(
const hasPremiumIntegration = !!premiumIntegrations?.includes(
IntegrationTypeEnum.ProgressiveBilling,
)

Expand Down
Loading

0 comments on commit feb4e70

Please sign in to comment.