The minimalistic document archiving platform.
feat(upgrade-dialog): add promotional banner for early adopters (#573)
Corentin Thomasset7de5d0956b32
diff --git a/apps/papra-client/src/locales/de.dictionary.ts b/apps/papra-client/src/locales/de.dictionary.tsindex 20e14f16..5798f4c7 100644--- a/apps/papra-client/src/locales/de.dictionary.ts+++ b/apps/papra-client/src/locales/de.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/Monat','subscriptions.upgrade-dialog.billed-annually': '${{ price }} jährlich abgerechnet','subscriptions.upgrade-dialog.upgrade-now': 'Jetzt upgraden',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Zeitlich begrenztes Angebot',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Erhalten Sie {{ percent }}% Rabatt pro Organisation auf alle Tarife für immer als Early Adopter! Angebot läuft ab in {{ days, >1:{days} Tagen, =1:1 Tag, weniger als 1 Tag }}.','subscriptions.plan.free.name': 'Kostenloser Plan','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/en.dictionary.ts b/apps/papra-client/src/locales/en.dictionary.tsindex b2b804f1..79d09796 100644--- a/apps/papra-client/src/locales/en.dictionary.ts+++ b/apps/papra-client/src/locales/en.dictionary.ts@@ -636,6 +636,8 @@ export const translations = {'subscriptions.upgrade-dialog.per-month': '/month','subscriptions.upgrade-dialog.billed-annually': '${{ price }} billed annually','subscriptions.upgrade-dialog.upgrade-now': 'Upgrade now',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Limited Time Offer',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Get {{ percent }}% off all plans forever per organization as an early adopter! Offer expires in {{ days, >1:{days} days, =1:1 day, less than 1 day }}.','subscriptions.plan.free.name': 'Free plan','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/es.dictionary.ts b/apps/papra-client/src/locales/es.dictionary.tsindex 9ae1808f..8fd831fc 100644--- a/apps/papra-client/src/locales/es.dictionary.ts+++ b/apps/papra-client/src/locales/es.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/mes','subscriptions.upgrade-dialog.billed-annually': '${{ price }} facturado anualmente','subscriptions.upgrade-dialog.upgrade-now': 'Actualizar ahora',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Oferta por tiempo limitado',+ 'subscriptions.upgrade-dialog.promo-banner.description': '¡Obtén {{ percent }}% de descuento por organización en todos los planes para siempre como early adopter! La oferta expira en {{ days, >1:{days} días, =1:1 día, menos de un día }}.','subscriptions.plan.free.name': 'Plan gratuito','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/fr.dictionary.ts b/apps/papra-client/src/locales/fr.dictionary.tsindex 9f5a18e5..dd41ce50 100644--- a/apps/papra-client/src/locales/fr.dictionary.ts+++ b/apps/papra-client/src/locales/fr.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/mois','subscriptions.upgrade-dialog.billed-annually': '${{ price }} facturé annuellement','subscriptions.upgrade-dialog.upgrade-now': 'Mettre à niveau',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Offre à durée limitée',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Bénéficiez de {{ percent }}% de réduction à vie par organisation sur tous les forfaits en tant qu\'early adopter ! L\'offre expire dans {{ days, >1:{days} jours, =1:1 jour, moins d\'un jour }}.','subscriptions.plan.free.name': 'Plan gratuit','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/it.dictionary.ts b/apps/papra-client/src/locales/it.dictionary.tsindex 64e34fbd..b53ae13f 100644--- a/apps/papra-client/src/locales/it.dictionary.ts+++ b/apps/papra-client/src/locales/it.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/mese','subscriptions.upgrade-dialog.billed-annually': '${{ price }} fatturato annualmente','subscriptions.upgrade-dialog.upgrade-now': 'Aggiorna ora',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Offerta a tempo limitato',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Ottieni {{ percent }}% di sconto per organizzazione su tutti i piani per sempre come early adopter! L\'offerta scade tra {{ days, >1:{days} giorni, =1:1 giorno, meno di un giorno }}.','subscriptions.plan.free.name': 'Piano gratuito','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/pl.dictionary.ts b/apps/papra-client/src/locales/pl.dictionary.tsindex 4164581b..cb19bd7a 100644--- a/apps/papra-client/src/locales/pl.dictionary.ts+++ b/apps/papra-client/src/locales/pl.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/miesiąc','subscriptions.upgrade-dialog.billed-annually': '${{ price }} rozliczane rocznie','subscriptions.upgrade-dialog.upgrade-now': 'Ulepsz teraz',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Oferta ograniczona czasowo',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Uzyskaj {{ percent }}% zniżki na organizację na wszystkie plany na zawsze jako early adopter! Oferta wygasa za {{ days, >1:{days} dni, =1:1 dzień, mniej niż 1 dzień }}.','subscriptions.plan.free.name': 'Plan darmowy','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/pt-BR.dictionary.ts b/apps/papra-client/src/locales/pt-BR.dictionary.tsindex ae4760d2..49b7955f 100644--- a/apps/papra-client/src/locales/pt-BR.dictionary.ts+++ b/apps/papra-client/src/locales/pt-BR.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/mês','subscriptions.upgrade-dialog.billed-annually': '${{ price }} faturado anualmente','subscriptions.upgrade-dialog.upgrade-now': 'Fazer upgrade agora',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Oferta por tempo limitado',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Ganhe {{ percent }}% de desconto por organização em todos os planos para sempre como early adopter! A oferta expira em {{ days, >1:{days} dias, =1:1 dia, menos de um dia }}.','subscriptions.plan.free.name': 'Plano gratuito','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/pt.dictionary.ts b/apps/papra-client/src/locales/pt.dictionary.tsindex def7d0e8..10604e79 100644--- a/apps/papra-client/src/locales/pt.dictionary.ts+++ b/apps/papra-client/src/locales/pt.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/mês','subscriptions.upgrade-dialog.billed-annually': '${{ price }} faturado anualmente','subscriptions.upgrade-dialog.upgrade-now': 'Atualizar agora',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Oferta por tempo limitado',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Obtenha {{ percent }}% de desconto por organização em todos os planos para sempre como early adopter! A oferta expira em {{ days, >1:{days} dias, =1:1 dia, menos de um dia }}.','subscriptions.plan.free.name': 'Plano gratuito','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/locales/ro.dictionary.ts b/apps/papra-client/src/locales/ro.dictionary.tsindex 171779c5..620f4dac 100644--- a/apps/papra-client/src/locales/ro.dictionary.ts+++ b/apps/papra-client/src/locales/ro.dictionary.ts@@ -638,6 +638,8 @@ export const translations: Partial<TranslationsDictionary> = {'subscriptions.upgrade-dialog.per-month': '/lună','subscriptions.upgrade-dialog.billed-annually': '${{ price }} facturat anual','subscriptions.upgrade-dialog.upgrade-now': 'Upgrade acum',+ 'subscriptions.upgrade-dialog.promo-banner.title': 'Ofertă pe durată limitată',+ 'subscriptions.upgrade-dialog.promo-banner.description': 'Obțineți {{ percent }}% reducere pe organizație la toate planurile pentru totdeauna ca early adopter! Oferta expiră în {{ days, >1:{days} zile, =1:1 zi, mai puțin de o zi }}.','subscriptions.plan.free.name': 'Plan gratuit','subscriptions.plan.plus.name': 'Plus',diff --git a/apps/papra-client/src/modules/subscriptions/components/upgrade-dialog.component.tsx b/apps/papra-client/src/modules/subscriptions/components/upgrade-dialog.component.tsxindex c9e6ec85..28c31665 100644--- a/apps/papra-client/src/modules/subscriptions/components/upgrade-dialog.component.tsx+++ b/apps/papra-client/src/modules/subscriptions/components/upgrade-dialog.component.tsx@@ -162,6 +162,17 @@ export const UpgradeDialog: Component<UpgradeDialogProps> = (props) => {const defaultBillingInterval: BillingInterval = 'annual';const [getBillingInterval, setBillingInterval] = createSignal<BillingInterval>(defaultBillingInterval);+ const getIsReductionActive = ({ now = new Date() }: { now?: Date } = {}) => globalReduction.enabled && now < globalReduction.untilDate;+ const getReductionMultiplier = ({ now = new Date() }: { now?: Date } = {}) => getIsReductionActive({ now }) ? globalReduction.multiplier : 1;+ const getReductionPercent = () => 100 * (1 - getReductionMultiplier());+ const getDaysUntilReductionExpiry = ({ now = new Date() }: { now?: Date } = {}) => {+ if (!getIsReductionActive({ now })) {+ return 0;+ }+ const timeDiff = globalReduction.untilDate.getTime() - now.getTime();+ return Math.ceil(timeDiff / (1000 * 60 * 60 * 24));+ };+const onUpgrade = async (planId: string) => {const { checkoutUrl } = await getCheckoutUrl({ organizationId: props.organizationId, planId, billingInterval: getBillingInterval() });window.location.href = checkoutUrl;@@ -214,39 +225,62 @@ export const UpgradeDialog: Component<UpgradeDialogProps> = (props) => {<DialogTrigger as={props.children} /><DialogContent class="sm:max-w-5xl"><DialogHeader>- <div class="flex items-center gap-3">- <div class="p-2 bg-primary/10 rounded-lg">- <div class="i-tabler-sparkles size-7 text-primary"></div>+ <div class="flex flex-col sm:flex-row items-center gap-3">+ <div class="flex items-center gap-3">+ <div class="p-2 bg-primary/10 rounded-lg">+ <div class="i-tabler-sparkles size-7 text-primary"></div>+ </div>+ <div>+ <DialogTitle class="text-xl mb-0">{t('subscriptions.upgrade-dialog.title')}</DialogTitle>+ <DialogDescription class="text-sm text-muted-foreground">+ {t('subscriptions.upgrade-dialog.description')}+ </DialogDescription>+ </div></div>- <div>- <DialogTitle class="text-xl mb-0">{t('subscriptions.upgrade-dialog.title')}</DialogTitle>- <DialogDescription class="text-sm text-muted-foreground">- {t('subscriptions.upgrade-dialog.description')}- </DialogDescription>++ <div class="flex flex-col items-center flex-1">+ <div class="inline-flex items-center justify-center border rounded-lg bg-muted p-1 gap-2">+ <Button+ size="sm"+ variant="ghost"+ class={cn('text-sm', { 'bg-primary/10 text-primary hover:(bg-primary/10 text-primary)': getBillingInterval() === 'monthly' })}+ onClick={() => setBillingInterval('monthly')}+ >+ {t('subscriptions.billing-interval.monthly')}+ </Button>+ <Button+ size="sm"+ variant="ghost"+ class={cn('text-sm', { 'bg-primary/10 text-primary hover:(bg-primary/10 text-primary)': getBillingInterval() === 'annual' })}+ onClick={() => setBillingInterval('annual')}+ >+ {t('subscriptions.billing-interval.annual')}+ </Button>+ </div></div></div></DialogHeader>- <div class="mt-2 flex flex-col items-center">- <div class="inline-flex items-center justify-center border rounded-lg bg-muted p-1 gap-2">- <Button- size="sm"- variant="ghost"- class={cn('text-sm', { 'bg-primary/10 text-primary hover:(bg-primary/10 text-primary)': getBillingInterval() === 'monthly' })}- onClick={() => setBillingInterval('monthly')}- >- {t('subscriptions.billing-interval.monthly')}- </Button>- <Button- size="sm"- variant="ghost"- class={cn('text-sm', { 'bg-primary/10 text-primary hover:(bg-primary/10 text-primary)': getBillingInterval() === 'annual' })}- onClick={() => setBillingInterval('annual')}- >- {t('subscriptions.billing-interval.annual')}- </Button>+ {getIsReductionActive() && (+ <div class="mt-4 bg-gradient-to-r from-primary/20 to-primary/2 border border-primary/30 rounded-lg p-4 flex-shrink-0">+ <div class="flex items-center gap-4">+ <div class="p-2.5 bg-primary/20 rounded-lg border border-primary/30 flex-shrink-0">+ <div class="i-tabler-gift size-6 text-primary"></div>+ </div>+ <div class="flex-1">+ <div class="flex items-center gap-2">+ <h4 class="text-base font-semibold text-foreground">{t('subscriptions.upgrade-dialog.promo-banner.title')}</h4>+ <div class="px-2 py-0.5 bg-primary text-primary-foreground text-xs font-bold rounded-md">+ {`-${getReductionPercent()}%`}+ </div>+ </div>+ <p class="text-sm text-muted-foreground mb-1">+ {t('subscriptions.upgrade-dialog.promo-banner.description', { percent: getReductionPercent(), days: getDaysUntilReductionExpiry() })}+ </p>+ </div>+ </div></div>- </div>+ )}<div class="mt-2 grid grid-cols-1 md:grid-cols-3 gap-4"><PlanCard {...currentPlan} billingInterval={getBillingInterval()} />