Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Replace account details plan data occurrences #3587

Merged
merged 11 commits into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ function Activation() {
})

const activatedUserCount = accountDetails?.activatedUserCount || 0
const planQuantity = accountDetails?.plan?.quantity || 0
const planQuantity = planData?.plan?.planUserCount || 0

if (
isTrialPlan(planData?.plan?.value) &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ const mockPlanData = {
trialEndDate: '',
trialTotalDays: 0,
pretrialUsersCount: 0,
planUserCount: 1,
planUserCount: 9,
hasSeatsLeft: true,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { setupServer } from 'msw/node'
import { Suspense } from 'react'
import { MemoryRouter, Route } from 'react-router-dom'

import { TrialStatuses } from 'services/account'
import { Plans } from 'shared/utils/billing'

import DowngradePlan from './DowngradePlan'
Expand All @@ -24,6 +25,28 @@ const mockAccountDetails = {
},
}

const mockPlanData = {
owner: {
hasPrivateRepos: true,
plan: {
isEnterprisePlan: false,
baseUnitPrice: 10,
benefits: [],
billingRate: 'monthly',
marketingName: 'Users Basic',
monthlyUploadLimit: 250,
value: Plans.USERS_BASIC,
trialStatus: TrialStatuses.NOT_STARTED,
trialStartDate: '',
trialEndDate: '',
trialTotalDays: 0,
pretrialUsersCount: 0,
planUserCount: 5,
hasSeatsLeft: false,
},
},
}

const queryClient = new QueryClient({
defaultOptions: { queries: { suspense: true } },
})
Expand Down Expand Up @@ -59,9 +82,7 @@ describe('DowngradePlan', () => {
return HttpResponse.json(mockAccountDetails)
}),
graphql.query('GetPlanData', () => {
return HttpResponse.json({
data: { plan: { isFreePlan: true } },
})
return HttpResponse.json(mockPlanData)
})
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function ProPlanDetails() {
const { data: plans } = useAvailablePlans({ provider, owner })
const { proPlanMonth, proPlanYear } = findProPlans({ plans })

const plan = accountDetails?.rootOrganization?.plan ?? accountDetails?.plan
const scheduledPhase = accountDetails?.scheduleDetail?.scheduledPhase

const cancelAtPeriodEnd =
Expand Down Expand Up @@ -55,9 +54,9 @@ function ProPlanDetails() {
)}
{shouldRenderCancelLink({
cancelAtPeriodEnd,
plan,
trialStatus,
isFreePlan: planData?.plan?.isFreePlan,
plan: planData?.plan,
}) && (
<A
to={{ pageName: 'cancelOrgPlan' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,9 @@ function SentryPlanDetails() {
const { data: plans } = useAvailablePlans({ provider, owner })
const { sentryPlanYear } = findSentryPlans({ plans })

const plan = accountDetails?.rootOrganization?.plan ?? accountDetails?.plan
const cancelAtPeriodEnd =
accountDetails?.subscriptionDetail?.cancelAtPeriodEnd
const trialStatus = planData?.plan?.trialStatus

return (
<div className="h-fit border md:w-[280px]">
<h3 className="p-4 font-semibold">
Expand Down Expand Up @@ -52,9 +50,8 @@ function SentryPlanDetails() {
is a bug imo and needs to be here in a future ticket */}
{shouldRenderCancelLink({
cancelAtPeriodEnd,
plan,
plan: planData?.plan,
trialStatus,
isFreePlan: planData?.plan?.isFreePlan,
}) && (
<A
to={{ pageName: 'cancelOrgPlan' }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ function TeamPlanDetails() {
const { data: plans } = useAvailablePlans({ provider, owner })
const { teamPlanYear, teamPlanMonth } = findTeamPlans({ plans })

const plan = accountDetails?.rootOrganization?.plan ?? accountDetails?.plan
const scheduledPhase = accountDetails?.scheduleDetail?.scheduledPhase

const cancelAtPeriodEnd =
Expand Down Expand Up @@ -55,9 +54,8 @@ function TeamPlanDetails() {
)}
{shouldRenderCancelLink({
cancelAtPeriodEnd,
plan,
plan: planData?.plan,
trialStatus,
isFreePlan: planData?.plan?.isFreePlan,
}) && (
<A
to={{ pageName: 'cancelOrgPlan' }}
Expand Down
Loading
Loading