1 import { useMemo } from 'react';
3 import { c } from 'ttag';
5 import { usePassCore } from '@proton/pass/components/Core/PassCoreProvider';
6 import { AliasSync } from '@proton/pass/components/Onboarding/AliasSync';
7 import { BlackFriday2024Offer } from '@proton/pass/components/Onboarding/BlackFriday2024Offer';
8 import { UserRenewal } from '@proton/pass/components/Onboarding/UserRenewal';
9 import type { SpotlightMessageDefinition } from '@proton/pass/components/Spotlight/SpotlightContent';
10 import { FiveStarIcon, ShieldIcon } from '@proton/pass/components/Spotlight/SpotlightIcon';
11 import { useSpotlight } from '@proton/pass/components/Spotlight/SpotlightProvider';
12 import { PASS_LEARN_MORE_URL, UpsellRef } from '@proton/pass/constants';
13 import { OnboardingMessage } from '@proton/pass/types';
14 import { BRAND_NAME, PASS_APP_NAME, PASS_SHORT_APP_NAME } from '@proton/shared/lib/constants';
15 import noop from '@proton/utils/noop';
17 export const useOnboardingMessages = () => {
18 const { onLink, openSettings, promptForPermissions, getRatingURL, onForceUpdate } = usePassCore();
19 const { setPendingShareAccess, setUpselling } = useSpotlight();
21 return useMemo<Partial<Record<OnboardingMessage, SpotlightMessageDefinition>>>(
23 [OnboardingMessage.PENDING_SHARE_ACCESS]: {
27 title: c('Title').t`Pending access to the shared data`,
28 message: c('Info').t`For security reasons, your access needs to be confirmed`,
30 onClose: () => setPendingShareAccess(false),
32 [OnboardingMessage.WELCOME]: {
35 title: c('Title').t`Why ${PASS_APP_NAME}?`,
36 message: c('Info').t`Privacy is a big concern for us. Learn why ${PASS_APP_NAME} is different.`,
40 label: c('Label').t`Learn more`,
42 onClick: () => onLink(PASS_LEARN_MORE_URL),
45 [OnboardingMessage.TRIAL]: {
48 title: c('Title').t`Our welcome gift to you`,
50 .t`7 days to try premium features for free. Only during your first week of ${BRAND_NAME}.`,
51 className: 'ui-orange',
52 onClose: () => setUpselling(null),
54 label: c('Label').t`Learn more`,
56 onClick: () => setUpselling({ type: 'free-trial', upsellRef: UpsellRef.FREE_TRIAL }),
59 [OnboardingMessage.SECURE_EXTENSION]: {
62 title: c('Title').t`Secure your data`,
63 message: c('Info').t`Enable auto-locking to secure your data`,
64 className: 'ui-violet',
67 label: c('Label').t`Create lock`,
69 onClick: () => openSettings?.('security'),
72 [OnboardingMessage.UPDATE_AVAILABLE]: {
75 title: c('Title').t`Update available`,
77 .t`A new version of ${PASS_APP_NAME} is available. Update it to enjoy the latest features and bug fixes.`,
78 className: 'ui-orange',
80 label: c('Label').t`Update`,
82 onClick: onForceUpdate ?? noop,
85 [OnboardingMessage.PERMISSIONS_REQUIRED]: {
88 title: c('Title').t`Grant permissions`,
90 .t`In order to get the best experience out of ${PASS_APP_NAME}, please grant the necessary extension permissions`,
91 className: 'ui-orange',
93 label: c('Label').t`Grant`,
95 onClick: () => promptForPermissions?.(),
98 [OnboardingMessage.USER_RATING]: {
101 title: c('Title').t`Enjoying ${PASS_APP_NAME}?`,
102 message: c('Info').t`Please consider leaving a review.`,
103 className: 'ui-lime',
106 label: c('Label').t`Rate us`,
108 onClick: getRatingURL ? () => onLink(getRatingURL()) : noop,
111 [OnboardingMessage.STORAGE_ISSUE]: {
114 title: c('Title').t`Low disk space`,
116 .t`We are having trouble syncing data to your local storage. Please make sure you have sufficient disk space for ${PASS_SHORT_APP_NAME} to work smoothly.`,
119 label: c('Label').t`Need help?`,
121 onClick: () => openSettings?.('support'),
124 [OnboardingMessage.B2B_ONBOARDING]: {
127 title: c('Title').t`Get Started`,
129 className: 'ui-teal hidden',
132 [OnboardingMessage.EARLY_ACCESS]: {
136 title: c('Title').t`Upgrade to Unlock Premium Features`,
137 message: c('Info').t`Please upgrade to have early access ${PASS_APP_NAME} web app`,
139 onClose: () => setUpselling(null),
141 [OnboardingMessage.ALIAS_SYNC_ENABLE]: {
143 component: AliasSync,
145 className: 'ui-teal',
147 [OnboardingMessage.BLACK_FRIDAY_2024]: {
149 component: BlackFriday2024Offer,
151 className: 'pass-bf2024-banner ui-violet',
153 [OnboardingMessage.USER_RENEWAL]: {
155 component: UserRenewal,