-
-
Notifications
You must be signed in to change notification settings - Fork 182
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4994 from kobotoolbox/nlp-usage-limit-block-frontend
[TASK-461] Add modal(s) to NLP page when user is over limits
- Loading branch information
Showing
11 changed files
with
208 additions
and
28 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
83 changes: 83 additions & 0 deletions
83
jsapp/js/components/processing/nlpUsageLimitBlockModal/nlpUsageLimitBlockModal.component.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,83 @@ | ||
import cx from 'classnames'; | ||
import React from 'react'; | ||
import KoboModal from '../../modals/koboModal'; | ||
import KoboModalHeader from 'js/components/modals/koboModalHeader'; | ||
import KoboModalFooter from 'js/components/modals/koboModalFooter'; | ||
import Button from 'js/components/common/button'; | ||
import Icon from 'js/components/common/icon'; | ||
import {useNavigate} from 'react-router-dom'; | ||
import styles from './nlpUsageLimitBlockModal.module.scss'; | ||
import {ACCOUNT_ROUTES} from 'js/account/routes.constants'; | ||
import { RecurringInterval, UsageLimitTypes } from 'jsapp/js/account/stripe.types'; | ||
|
||
interface NlpUsageLimitBlockModalProps { | ||
isModalOpen: boolean; | ||
dismissed: () => void; | ||
usageType: UsageLimitTypes.TRANSLATION | UsageLimitTypes.TRANSCRIPTION; | ||
interval: RecurringInterval; | ||
} | ||
|
||
function NlpUsageLimitBlockModal(props: NlpUsageLimitBlockModalProps) { | ||
const navigate = useNavigate(); | ||
|
||
const handleClose = () => { | ||
props.dismissed(); | ||
}; | ||
|
||
return ( | ||
<div> | ||
<KoboModal | ||
isOpen={props.isModalOpen} | ||
onRequestClose={handleClose} | ||
size='medium' | ||
> | ||
<KoboModalHeader onRequestCloseByX={handleClose} headerColor='white'> | ||
{t('Upgrade to continue using this feature')} | ||
</KoboModalHeader> | ||
|
||
<section className={styles.modalBody}> | ||
<div> | ||
<div> | ||
{t('You have reached the ##LIMIT## limit for this ##PERIOD##.') | ||
.replace('##LIMIT##', props.usageType) | ||
.replace('##PERIOD##', props.interval)}{' '} | ||
{t( | ||
'Please consider our plans or add-ons to continue using this feature.' | ||
)} | ||
</div> | ||
<div className={styles.note}> | ||
<Icon | ||
name='information' | ||
size='s' | ||
color='blue' | ||
className={styles.noteIcon} | ||
/> | ||
{t('You can monitor your usage')} | ||
<a href={'/#/account/usage'}>{t('here')}</a>. | ||
</div> | ||
</div> | ||
</section> | ||
|
||
<KoboModalFooter alignment='end'> | ||
<Button | ||
type='frame' | ||
color='dark-blue' | ||
size='l' | ||
onClick={handleClose} | ||
label={t('Go back')} | ||
/> | ||
|
||
<Button | ||
type='full' | ||
color='blue' | ||
size='l' | ||
onClick={() => navigate(ACCOUNT_ROUTES.PLAN)} | ||
label={t('Upgrade now')} | ||
/> | ||
</KoboModalFooter> | ||
</KoboModal> | ||
</div> | ||
); | ||
} | ||
|
||
export default NlpUsageLimitBlockModal; |
24 changes: 24 additions & 0 deletions
24
jsapp/js/components/processing/nlpUsageLimitBlockModal/nlpUsageLimitBlockModal.module.scss
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,24 @@ | ||
@use 'scss/colors'; | ||
@use 'scss/sizes'; | ||
|
||
|
||
.modalBody { | ||
line-height: sizes.$x24; | ||
padding: 0 sizes.$x30; | ||
|
||
p:first-of-type { | ||
margin-top: 0; | ||
} | ||
} | ||
|
||
.note { | ||
display: flex; | ||
padding: sizes.$x12; | ||
margin: sizes.$x24 0 0 0; | ||
background-color: colors.$kobo-bg-blue; | ||
border-radius: sizes.$x5; | ||
} | ||
|
||
.noteIcon { | ||
margin-right: sizes.$x8; | ||
} |
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
Oops, something went wrong.