1 import { useEffect, useState } from 'react';
3 import useLoading from '@proton/hooks/useLoading';
4 import { queryListPendingExternalInvitations } from '@proton/shared/lib/api/drive/invitation';
5 import type { ListDrivePendingExternalInvitationsPayload } from '@proton/shared/lib/interfaces/drive/sharing';
7 import { useDebouncedRequest } from '../../store/_api';
8 import useChecklist from './useChecklist';
10 export const useOnboarding = () => {
11 const checklist = useChecklist();
12 const debouncedRequest = useDebouncedRequest();
13 const [isLoading, withIsLoading] = useLoading(false);
14 const [hasPendingExternalInvitations, setHasPendingExternalInvitations] = useState(false);
16 const getHasPendingExternalInvitations = () =>
17 withIsLoading(async () => {
18 const { ExternalInvitations } = await debouncedRequest<ListDrivePendingExternalInvitationsPayload>(
19 queryListPendingExternalInvitations()
21 setHasPendingExternalInvitations(!!ExternalInvitations.length);
25 void getHasPendingExternalInvitations();
28 return { isLoading: checklist.isLoading || isLoading, checklist, hasPendingExternalInvitations };