Merge branch 'docs-header-fix' into 'main'
[ProtonMail-WebClient.git] / packages / components / containers / offers / operations / passFamilyPlan2024Yearly / useOffer.ts
blobc26e9b9e380a97aaea808d17e45bbebbe34da84b
1 import { useSubscription } from '@proton/account/subscription/hooks';
2 import { useUser } from '@proton/account/user/hooks';
3 import useConfig from '@proton/components/hooks/useConfig';
5 import useOfferFlags from '../../hooks/useOfferFlags';
6 import type { Operation } from '../../interface';
7 import config from './configuration';
8 import getIsEligible from './eligibility';
10 const useOffer = (): Operation => {
11     const [user, loadingUser] = useUser();
12     const protonConfig = useConfig();
13     const [subscription, subscriptionLoading] = useSubscription();
14     const { isActive, loading: flagsLoading } = useOfferFlags(config);
15     const isLoading = flagsLoading || loadingUser || subscriptionLoading;
16     const isEligible = getIsEligible({ subscription, user, protonConfig });
17     const isValid = isEligible && isActive;
19     return { isValid, config, isLoading, isEligible };
22 export default useOffer;