feat: upgrade cta (#1655)

This commit is contained in:
Aman Harwara
2022-09-27 18:29:50 +05:30
committed by GitHub
parent f3f7f9d362
commit ec52e5684d
4 changed files with 63 additions and 3 deletions

View File

@@ -0,0 +1,46 @@
import { WebApplication } from '@/Application/Application'
import { FeaturesController } from '@/Controllers/FeaturesController'
import { observer } from 'mobx-react-lite'
import { loadPurchaseFlowUrl } from '../PurchaseFlow/PurchaseFlowFunctions'
type Props = {
application: WebApplication
featuresController: FeaturesController
}
const UpgradeNow = ({ application, featuresController }: Props) => {
const shouldShowCTA = !featuresController.hasFolders
const hasAccount = application.hasAccount()
const openPlansPage = () => {
if (!window.plansUrl) {
return
}
if (application.isNativeMobileWeb()) {
application.mobileDevice.openUrl(window.plansUrl)
} else {
window.location.assign(window.plansUrl)
}
}
return shouldShowCTA ? (
<div className="flex h-full items-center px-2">
<button
className="rounded bg-info py-0.5 px-1.5 text-xs font-bold uppercase text-info-contrast hover:brightness-125"
onClick={() => {
if (hasAccount) {
void loadPurchaseFlowUrl(application)
return
}
openPlansPage()
}}
>
Upgrade now
</button>
</div>
) : null
}
export default observer(UpgradeNow)