5622 add a syncemail onboarding step (#5689)
- add sync email onboarding step - refactor calendar and email visibility enums - add a new table `keyValuePair` in `core` schema - add a new resolved boolean field `skipSyncEmail` in current user https://github.com/twentyhq/twenty/assets/29927851/de791475-5bfe-47f9-8e90-76c349fba56f
This commit is contained in:
@ -1,21 +1,47 @@
|
||||
import { useCallback } from 'react';
|
||||
|
||||
import { AppPath } from '@/types/AppPath';
|
||||
import { REACT_APP_SERVER_BASE_URL } from '~/config';
|
||||
import { useGenerateTransientTokenMutation } from '~/generated/graphql';
|
||||
import {
|
||||
CalendarChannelVisibility,
|
||||
MessageChannelVisibility,
|
||||
useGenerateTransientTokenMutation,
|
||||
} from '~/generated/graphql';
|
||||
|
||||
export const useTriggerGoogleApisOAuth = () => {
|
||||
const [generateTransientToken] = useGenerateTransientTokenMutation();
|
||||
|
||||
const triggerGoogleApisOAuth = useCallback(async () => {
|
||||
const authServerUrl = REACT_APP_SERVER_BASE_URL;
|
||||
const triggerGoogleApisOAuth = useCallback(
|
||||
async (
|
||||
redirectLocation?: AppPath,
|
||||
messageVisibility?: MessageChannelVisibility,
|
||||
calendarVisibility?: CalendarChannelVisibility,
|
||||
) => {
|
||||
const authServerUrl = REACT_APP_SERVER_BASE_URL;
|
||||
|
||||
const transientToken = await generateTransientToken();
|
||||
const transientToken = await generateTransientToken();
|
||||
|
||||
const token =
|
||||
transientToken.data?.generateTransientToken.transientToken.token;
|
||||
const token =
|
||||
transientToken.data?.generateTransientToken.transientToken.token;
|
||||
|
||||
window.location.href = `${authServerUrl}/auth/google-apis?transientToken=${token}`;
|
||||
}, [generateTransientToken]);
|
||||
let params = `transientToken=${token}`;
|
||||
|
||||
params += redirectLocation
|
||||
? `&redirectLocation=${encodeURIComponent(redirectLocation)}`
|
||||
: '';
|
||||
|
||||
params += calendarVisibility
|
||||
? `&calendarVisibility=${calendarVisibility}`
|
||||
: '';
|
||||
|
||||
params += messageVisibility
|
||||
? `&messageVisibility=${messageVisibility}`
|
||||
: '';
|
||||
|
||||
window.location.href = `${authServerUrl}/auth/google-apis?${params}`;
|
||||
},
|
||||
[generateTransientToken],
|
||||
);
|
||||
|
||||
return { triggerGoogleApisOAuth };
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user