mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 06:39:01 +02:00
d5a65e906f
* Update Compile timeout copy * Update Collaborator limit copy * Update Track changes copy * Update History copy and "Start free trial" button * Remove unnecessary children passed to StartFreeTrialButton * Update Dropbox copy * Update Github copy * Update Git copy * Update Reference managers copy * Update Symbol palette copy * Update Onboarding prompt copy * Update Subscriptions page (on free account) copy * `bin/run web npm run extract-translations` * Add split-test assignment in subscription page * Fix tests * Update services/web/modules/symbol-palette/frontend/js/components/symbol-palette-overlay.tsx Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update services/web/modules/onboarding/app/views/onboarding/try_premium.pug Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Update services/web/modules/onboarding/app/views/onboarding/try_premium.pug Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> * Replace `Github` to `GitHub` in translations * Update "non Overleaf" to "non-Overleaf" --------- Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> GitOrigin-RevId: 56ee2735899de18f820b229bc226249322ac0c87
76 lines
2.0 KiB
TypeScript
76 lines
2.0 KiB
TypeScript
import { useCallback, useEffect } from 'react'
|
|
import { useTranslation } from 'react-i18next'
|
|
import { startFreeTrial } from '@/main/account-upgrade'
|
|
import * as eventTracking from '../../infrastructure/event-tracking'
|
|
import OLButton from '@/shared/components/ol/ol-button'
|
|
import { useFeatureFlag } from '@/shared/context/split-test-context'
|
|
|
|
type StartFreeTrialButtonProps = {
|
|
source: string
|
|
variant?: string
|
|
buttonProps?: React.ComponentProps<typeof OLButton>
|
|
children?: React.ReactNode
|
|
handleClick?: React.ComponentProps<typeof OLButton>['onClick']
|
|
segmentation?: eventTracking.Segmentation
|
|
extraSearchParams?: Record<string, string>
|
|
}
|
|
|
|
export default function StartFreeTrialButton({
|
|
buttonProps = {
|
|
variant: 'secondary',
|
|
},
|
|
children,
|
|
handleClick,
|
|
source,
|
|
variant,
|
|
segmentation,
|
|
extraSearchParams,
|
|
}: StartFreeTrialButtonProps) {
|
|
const { t } = useTranslation()
|
|
const plans2026 = useFeatureFlag('plans-2026-phase-1')
|
|
|
|
useEffect(() => {
|
|
const eventSegmentation: { [key: string]: unknown } = {
|
|
'paywall-type': source,
|
|
...segmentation,
|
|
}
|
|
if (variant) {
|
|
eventSegmentation.variant = variant
|
|
}
|
|
eventTracking.sendMB('paywall-prompt', eventSegmentation)
|
|
}, [source, variant, segmentation])
|
|
|
|
const onClick = useCallback(
|
|
(event: React.MouseEvent<HTMLButtonElement, MouseEvent>) => {
|
|
event.preventDefault()
|
|
|
|
let shouldNavigate = true
|
|
|
|
if (handleClick) {
|
|
handleClick(event)
|
|
if (event.isPropagationStopped()) {
|
|
shouldNavigate = false
|
|
}
|
|
}
|
|
|
|
startFreeTrial(
|
|
source,
|
|
variant,
|
|
segmentation,
|
|
extraSearchParams,
|
|
shouldNavigate
|
|
)
|
|
},
|
|
[handleClick, source, variant, segmentation, extraSearchParams]
|
|
)
|
|
|
|
return (
|
|
<OLButton {...buttonProps} onClick={onClick}>
|
|
{children ||
|
|
(plans2026
|
|
? t('start_free_trial_without_exclamation')
|
|
: t('start_free_trial'))}
|
|
</OLButton>
|
|
)
|
|
}
|