1 import { useOrganization } from '@proton/account/organization/hooks';
2 import { useUser } from '@proton/account/user/hooks';
3 import { PLANS } from '@proton/payments';
6 * This hook centralized logic for Drive subscriptions.
8 export const useDrivePlan = () => {
9 const [{ hasPaidDrive, isAdmin }] = useUser();
10 const [organization] = useOrganization();
11 const plan = organization?.PlanName || PLANS.FREE;
14 // Note: Enterprise plan is currently *NOT* implemented anywhere,
15 // so it should not be handled.
16 const isDriveProfessional = plan === PLANS.DRIVE_BUSINESS;
17 const isProtonBusinessSuite = plan === PLANS.BUNDLE_PRO || plan === PLANS.BUNDLE_PRO_2024;
19 const isB2B = isDriveProfessional || isProtonBusinessSuite;
22 const isDriveLite = plan === PLANS.DRIVE_LITE;
24 const isB2C = hasPaidDrive && !isB2B;
27 const canUpsellFree = !hasPaidDrive;
28 const canUpsellB2B = isB2B && !isProtonBusinessSuite;
31 /** `true` if the user has a paid Drive plan. */
34 /** `true` if the user is admin of their organization. */
38 * The organization attached to the current user.
42 /** The {@link PLANS} the user is subscribed to. */
46 * `true` if the user is on a Drive B2B plan.
48 * For Drive, only Drive-specific and ecosystem B2B plans are considered. \
49 * i.e. Mail Professional is not be considered B2B in a Drive context.
54 * `true` if the user is on a Drive B2C plan.
56 * For Drive, only Drive-specific and ecosystem B2C plans are considered. \
57 * i.e. Mail Plus is not be considered B2C in a Drive context.
61 /** `true` is plan is *Drive Professional*. */
64 /** `true` if plan is *Proton Business Suite*. */
65 isProtonBusinessSuite,
67 /** `true` if plan is *Drive Lite*. */
70 /** `true` if a B2C upsell is available. */
73 /** `true` if a B2B upsell is available. */