feat: Implement draft version of free trial over info box

This commit is contained in:
Faruk AYDIN
2023-04-08 22:14:36 +02:00
committed by Ali BARIN
parent d4c542168c
commit dc734b04d8

View File

@@ -1,5 +1,7 @@
import * as React from 'react'; import * as React from 'react';
import { Link } from 'react-router-dom'; import { Link } from 'react-router-dom';
import Alert from '@mui/material/Alert';
import Stack from '@mui/material/Stack';
import Box from '@mui/material/Box'; import Box from '@mui/material/Box';
import Button from '@mui/material/Button'; import Button from '@mui/material/Button';
import Chip from '@mui/material/Chip'; import Chip from '@mui/material/Chip';
@@ -15,7 +17,8 @@ import * as URLS from 'config/urls';
import useBillingAndUsageData from 'hooks/useBillingAndUsageData.ee'; import useBillingAndUsageData from 'hooks/useBillingAndUsageData.ee';
import useFormatMessage from 'hooks/useFormatMessage'; import useFormatMessage from 'hooks/useFormatMessage';
const capitalize = (str: string) => str[0].toUpperCase() + str.slice(1, str.length); const capitalize = (str: string) =>
str[0].toUpperCase() + str.slice(1, str.length);
type BillingCardProps = { type BillingCardProps = {
name: string; name: string;
@@ -62,21 +65,13 @@ function Action(props: { action?: TBillingCardAction }) {
if (type === 'link') { if (type === 'link') {
if (action.src.startsWith('http')) { if (action.src.startsWith('http')) {
return ( return (
<Button <Button size="small" href={action.src} target="_blank">
size="small"
href={action.src}
target="_blank"
>
{text} {text}
</Button> </Button>
) );
} else { } else {
return ( return (
<Button <Button size="small" component={Link} to={action.src}>
size="small"
component={Link}
to={action.src}
>
{text} {text}
</Button> </Button>
); );
@@ -100,6 +95,21 @@ export default function UsageDataInformation() {
return ( return (
<React.Fragment> <React.Fragment>
<Stack sx={{ width: '100%', mb: 2 }} spacing={2}>
<Alert
severity="error"
sx={{
display: 'flex',
alignItems: 'center',
}}
>
<Typography variant="subtitle2">
Your free trial is over. Please{' '}
<Link to={URLS.SETTINGS_PLAN_UPGRADE}>upgrade </Link>
your plan to continue using Automatisch.
</Typography>
</Alert>
</Stack>
<Card sx={{ mb: 3, p: 2 }}> <Card sx={{ mb: 3, p: 2 }}>
<CardContent sx={{ display: 'flex', flexDirection: 'column' }}> <CardContent sx={{ display: 'flex', flexDirection: 'column' }}>
<Box sx={{ mb: 1, display: 'flex', justifyContent: 'space-between' }}> <Box sx={{ mb: 1, display: 'flex', justifyContent: 'space-between' }}>
@@ -137,7 +147,9 @@ export default function UsageDataInformation() {
<BillingCard <BillingCard
name={formatMessage('usageDataInformation.nextBillAmount')} name={formatMessage('usageDataInformation.nextBillAmount')}
title={billingAndUsageData?.subscription?.nextBillAmount.title} title={billingAndUsageData?.subscription?.nextBillAmount.title}
action={billingAndUsageData?.subscription?.nextBillAmount.action} action={
billingAndUsageData?.subscription?.nextBillAmount.action
}
/> />
</Grid> </Grid>
@@ -192,15 +204,17 @@ export default function UsageDataInformation() {
</Box> </Box>
{/* free plan has `null` status so that we can show the upgrade button */} {/* free plan has `null` status so that we can show the upgrade button */}
{billingAndUsageData?.subscription?.status === null && <Button {billingAndUsageData?.subscription?.status === null && (
component={Link} <Button
to={URLS.SETTINGS_PLAN_UPGRADE} component={Link}
size="small" to={URLS.SETTINGS_PLAN_UPGRADE}
variant="contained" size="small"
sx={{ mt: 2, alignSelf: 'flex-end' }} variant="contained"
> sx={{ mt: 2, alignSelf: 'flex-end' }}
{formatMessage('usageDataInformation.upgrade')} >
</Button>} {formatMessage('usageDataInformation.upgrade')}
</Button>
)}
</CardContent> </CardContent>
</Card> </Card>
</React.Fragment> </React.Fragment>