-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow switching between Hobby and Pro plans; update eslint rules
- Loading branch information
Showing
13 changed files
with
256 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
'use client' | ||
|
||
import { useEffect, useState } from 'react' | ||
import { Button } from '@/components/Button' | ||
import { useUser } from '@/utils/useUser' | ||
|
||
import { TierActiveTag } from './TierActiveTag' | ||
|
||
|
||
const tierID = 'base_v1' | ||
|
||
function SwitchToHobbyButton() { | ||
const { user } = useUser() | ||
const [url, setURL] = useState('') | ||
|
||
useEffect(function getBillingURL() { | ||
if (!user) return | ||
const u = `${process.env.NEXT_PUBLIC_STRIPE_BILLING_URL}?prefilled_email=${user.teams[0].email}` | ||
setURL(u) | ||
}, [user]) | ||
|
||
// Only show the button if the user is on the base_v1 tier. | ||
// Teams can have custom tiers. We only want the button to users on the free tier. | ||
if (!user) { | ||
return | ||
} | ||
|
||
return ( | ||
<div className="flex flex-col items-start justify-start gap-1 my-4"> | ||
<div className="flex items-center justify-start gap-2"> | ||
{user.pricingTier.id === tierID && ( | ||
<TierActiveTag /> | ||
)} | ||
|
||
{user.pricingTier.id !== tierID && ( | ||
<a href={url} target="_blank" rel="noreferrer noopener"> | ||
<Button>Switch to Hobby</Button> | ||
</a> | ||
)} | ||
</div> | ||
</div> | ||
) | ||
} | ||
|
||
export default SwitchToHobbyButton |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
|
||
export function TierActiveTag() { | ||
return ( | ||
<span className="text-sm font-bold text-green-500"> | ||
ACTIVE | ||
</span> | ||
) | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.