-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ui): add trial plan support (#1146)
- Loading branch information
Showing
20 changed files
with
403 additions
and
25 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
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
98 changes: 98 additions & 0 deletions
98
www/src/components/account/billing/BillingStartTrialModal.tsx
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,98 @@ | ||
import { Button, Modal } from '@pluralsh/design-system' | ||
import styled from 'styled-components' | ||
|
||
import { useBeginTrialMutation } from '../../../generated/graphql' | ||
import { GqlError } from '../../utils/Alert' | ||
|
||
type BillingStartTrialModalProps = { | ||
open: boolean | ||
onClose: () => void | ||
} | ||
|
||
const ErrorWrapper = styled.div(({ theme }) => ({ | ||
paddingBottom: theme.spacing.large, | ||
})) | ||
|
||
const Header = styled.div(({ theme }) => ({ | ||
...theme.partials.text.body1, | ||
fontWeight: '600', | ||
})) | ||
|
||
const Description = styled.div(({ theme }) => ({ | ||
...theme.partials.text.body2, | ||
color: theme.colors['text-light'], | ||
marginTop: theme.spacing.medium, | ||
|
||
'& > ul': { | ||
paddingLeft: theme.spacing.large, | ||
}, | ||
})) | ||
|
||
const ButtonGroup = styled.div(({ theme }) => ({ | ||
display: 'flex', | ||
gap: theme.spacing.medium, | ||
justifyContent: 'flex-end', | ||
marginTop: theme.spacing.xlarge, | ||
})) | ||
|
||
function BillingStartTrialModal({ | ||
open, | ||
onClose, | ||
}: BillingStartTrialModalProps) { | ||
const [beginTrial, { loading, error }] = useBeginTrialMutation({ | ||
onCompleted: onClose, | ||
}) | ||
|
||
return ( | ||
<Modal | ||
BackdropProps={{ zIndex: 20 }} | ||
open={open} | ||
onClose={onClose} | ||
style={{ padding: 0 }} | ||
size="large" | ||
header="Free Trial Confirmation" | ||
> | ||
{error && ( | ||
<ErrorWrapper> | ||
<GqlError | ||
error={error} | ||
header="Could not start free trial" | ||
/> | ||
</ErrorWrapper> | ||
)} | ||
|
||
<Header>Experience Plural Professional free for 30 days.</Header> | ||
<Description> | ||
Try out full feature access to Plural Professional risk free for 30 | ||
days. Features include: | ||
<ul> | ||
<li>Multi-cluster management</li> | ||
<li>Cluster promotions</li> | ||
<li>Advanced user management with groups and roles</li> | ||
<li>Service accounts</li> | ||
<li>VPNs</li> | ||
</ul> | ||
</Description> | ||
|
||
<ButtonGroup> | ||
<Button | ||
secondary | ||
alignSelf="flex-end" | ||
onClick={() => onClose()} | ||
> | ||
Cancel | ||
</Button> | ||
<Button | ||
primary | ||
loading={loading} | ||
onClick={beginTrial} | ||
alignSelf="flex-end" | ||
> | ||
Start free trial | ||
</Button> | ||
</ButtonGroup> | ||
</Modal> | ||
) | ||
} | ||
|
||
export default BillingStartTrialModal |
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,65 @@ | ||
import { Callout } from '@pluralsh/design-system' | ||
import { useContext, useMemo } from 'react' | ||
import { Link } from 'react-router-dom' | ||
import styled from 'styled-components' | ||
|
||
import SubscriptionContext from '../../../contexts/SubscriptionContext' | ||
|
||
const Wrap = styled.div(({ theme }) => ({ | ||
marginBottom: theme.spacing.large, | ||
})) | ||
|
||
const Message = styled.p(({ theme }) => ({ | ||
...theme.partials.text.body2, | ||
color: theme.colors['text-xlight'], | ||
})) | ||
|
||
const MessageLink = styled.a(({ theme }) => ({ | ||
...theme.partials.text.inlineLink, | ||
})) | ||
|
||
function BillingTrialBanner() { | ||
const { | ||
isTrialExpired, | ||
isPaidPlan, | ||
isTrialExpiringSoon, | ||
isTrialed, | ||
isTrialPlan, | ||
} = useContext(SubscriptionContext) | ||
const shouldDisplayBanner = useMemo( | ||
() => (isTrialPlan && isTrialExpiringSoon) || (isTrialed && !isPaidPlan), | ||
[isPaidPlan, isTrialExpiringSoon, isTrialPlan, isTrialed] | ||
) | ||
const message = useMemo( | ||
() => | ||
isTrialExpired ? 'Free trial expired. ' : 'Free trial expiring soon. ', | ||
[isTrialExpired] | ||
) | ||
|
||
if (!shouldDisplayBanner) return null | ||
|
||
return ( | ||
<Wrap> | ||
<Callout | ||
severity={isTrialExpiringSoon || isTrialExpired ? 'danger' : 'warning'} | ||
title={message} | ||
closed={false} | ||
> | ||
<Message> | ||
Your free trial {isTrialExpired ? 'has expired' : 'is expiring soon'}. | ||
Upgrade to Plural Professional to | ||
{isTrialExpired ? 'reactivate' : 'maintain'} full feature | ||
access. | ||
<MessageLink | ||
as={Link} | ||
to="/account/billing?upgrade=true" | ||
> | ||
Upgrade now. | ||
</MessageLink> | ||
</Message> | ||
</Callout> | ||
</Wrap> | ||
) | ||
} | ||
|
||
export default BillingTrialBanner |
Oops, something went wrong.