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

Add Contact Us links for non-tiered accounts #604

Merged
merged 5 commits into from
May 4, 2021

Conversation

jbranchaud
Copy link
Collaborator

@jbranchaud jbranchaud commented Apr 30, 2021

This PR does a couple things (for #594):

Primarily, it adds 'Contact Us' messaging/links for the accounts that are still on the non-tiered legacy pricing. Because they won't be able to adjust the number of seats through the stripe billing portal, they should contact support to make those adjustments.

Secondarily, this PR:

  • Pulls Stripe data fetching up to a single call (before there were two calls happening per page load).
  • It removes the slug argument that was being passed around and into the Stripe API call because it is not used by that Next API endpoint.

Screens

A persistent info block for customers on the legacy pricing

CleanShot 2021-04-30 at 10 36 02@2x

The adjusted CTA for legacy pricing customers when they reach their seat limit

CleanShot 2021-04-30 at 10 36 21@2x

@vercel
Copy link

vercel bot commented Apr 30, 2021

This pull request is being automatically deployed with Vercel (learn more).
To see the status of your deployments, click below or on the icon next to each commit.

egghead-io-nextjs – ./

🔍 Inspect: https://vercel.com/eggheadio/egghead-io-nextjs/6MDjaFPjsppM6s8zv2z64zhH1igq
✅ Preview: https://egghead-io-nex-git-jb-add-contact-us-messaging-to-team-p-18718e.vercel.app

egghead-next-storybook – ./

🔍 Inspect: https://vercel.com/eggheadio/egghead-next-storybook/HmoJLz9EpKh74GGYiF8LcUs2cvuR
✅ Preview: https://egghead-next-s-git-jb-add-contact-us-messaging-to-team-p-9bbf92.vercel.app

Comment on lines 21 to 33
const recur = (price: any) => {
if (price === undefined) return ''

const {
recurring: {interval, interval_count},
} = price

if (interval === 'month' && interval_count === 3) return 'quarter'
if (interval === 'month' && interval_count === 6) return '6-months'
if (interval === 'month' && interval_count === 1) return 'month'
if (interval === 'year' && interval_count === 1) return 'year'
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I pulled this function out of the subscription data hook and placed it here because it was only being used here.

Comment on lines -23 to -33
stripeCustomerId,
slug,
subscriptionData,
loading,
}: {
stripeCustomerId: string
slug: string
subscriptionData: any
loading: boolean
}) => {
const {subscriptionData, recur, loading} = useSubscriptionDetails({
stripeCustomerId,
slug,
})

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Subscription data is being passed down from the singular call site instead of being requested here.

Comment on lines +4 to +12
type SubscriptionData = {
portalUrl?: string
billingScheme: 'tiered' | 'per_unit'
subscription?: any
price?: any
product?: any
latestInvoice?: any
upcomingInvoice?: any
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some typing for the SubscriptionData to get some better type inference and warnings.

const [
subscriptionData,
setSubscriptionData,
] = React.useState<SubscriptionData>({billingScheme: 'per_unit'})
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The billing scheme will always be either 'tiered' or 'per_unit'. I default it to this, but Stripe should always tell us one or the other.

@@ -30,6 +30,7 @@ const StripeCheckoutSession = async (
if (subscription) {
const price = get(first(subscription.items.data), 'price')
const latestInvoice = get(subscription, 'latest_invoice')
const billingScheme = get(subscription, 'plan.billing_scheme')
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Extract billing scheme as a top-level value for ease of access in a couple places for conditional rendering.

Comment on lines -44 to -50
type SubscriptionData = {
portalUrl: string | undefined
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unused type

Comment on lines -49 to -74
const {accountSlug, stripeCustomerId} = teamData
const [
subscriptionData,
setSubscriptionData,
] = React.useState<SubscriptionData>({} as SubscriptionData)

React.useEffect(() => {
if (stripeCustomerId) {
axios
.get(`/api/stripe/billing/session`, {
params: {
customer_id: stripeCustomerId,
account_slug: accountSlug,
},
})
.then(({data}) => {
if (data) {
setSubscriptionData(data)
}
})
}
}, [stripeCustomerId, accountSlug])
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the duplicate Stripe API call that has been pulled up to a single call site.

</span>
{subscriptionData?.portalUrl && (
<Link href={subscriptionData.portalUrl}>
{billingScheme === 'tiered' && (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This second adjusts the copy and CTA of the At Capacity Notice based on the billing scheme.

Comment on lines 183 to 184
{!subscriptionDataLoading &&
subscriptionData.billingScheme === 'per_unit' && (
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This section displays an additional note about adding seats to your account based IF this account is on legacy pricing.

@jbranchaud jbranchaud requested review from theianjones and joelhooks and removed request for theianjones April 30, 2021 15:49
There were multiple components in the Team page tree that was firing off
the API call that requests subscription data from Stripe. This pulls the
call up so that it is made a single time and then passes the needed data
down.
Comment on lines +14 to +25
export const recur = (price: any) => {
if (price === undefined) return ''

const {
recurring: {interval, interval_count},
} = price

if (interval === 'month' && interval_count === 3) return 'quarter'
if (interval === 'month' && interval_count === 6) return '6-months'
if (interval === 'month' && interval_count === 1) return 'month'
if (interval === 'year' && interval_count === 1) return 'year'
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exporting recur instead of passing it around as a prop since it is a static concept.

Copy link
Contributor

@joelhooks joelhooks left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the "manage your account" needs to be removed for legacy accounts too because the portal is WEIRD for them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants