feat(useAuthenticateApp): use REST API endpoint to create auth url
This commit is contained in:
@@ -9,6 +9,7 @@ import computeAuthStepVariables from 'helpers/computeAuthStepVariables';
|
||||
import useAppAuth from './useAppAuth';
|
||||
import useCreateConnection from './useCreateConnection';
|
||||
import useFormatMessage from './useFormatMessage';
|
||||
import useCreateConnectionAuthUrl from './useCreateConnectionAuthUrl';
|
||||
|
||||
function getSteps(auth, hasConnection, useShared) {
|
||||
if (hasConnection) {
|
||||
@@ -29,6 +30,7 @@ export default function useAuthenticateApp(payload) {
|
||||
const { appKey, appAuthClientId, connectionId, useShared = false } = payload;
|
||||
const { data: auth } = useAppAuth(appKey);
|
||||
const { mutateAsync: createConnection } = useCreateConnection(appKey);
|
||||
const { mutateAsync: createConnectionAuthUrl } = useCreateConnectionAuthUrl();
|
||||
const [authenticationInProgress, setAuthenticationInProgress] =
|
||||
React.useState(false);
|
||||
const formatMessage = useFormatMessage();
|
||||
@@ -70,6 +72,11 @@ export default function useAuthenticateApp(payload) {
|
||||
if (step.name === 'createConnection') {
|
||||
const stepResponse = await createConnection(variables);
|
||||
response[step.name] = stepResponse?.data;
|
||||
} else if (step.name === 'generateAuthUrl') {
|
||||
const stepResponse = await createConnectionAuthUrl(
|
||||
response.createConnection.id,
|
||||
);
|
||||
response[step.name] = stepResponse?.data;
|
||||
} else {
|
||||
const stepResponse = await processMutation(step.name, variables);
|
||||
response[step.name] = stepResponse;
|
||||
|
Reference in New Issue
Block a user