1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33import { href } from 'react-router';
import type { GitRemoteProviderType } from '~/models/git-credentials';
import { createFetcherSubmitHook } from '~/utils/router';
import type { Route } from './+types/git-credentials.complete-sign-in';
interface CompleteSignInData {
provider: GitRemoteProviderType;
code: string;
state: string;
}
export async function clientAction({ request }: Route.ClientActionArgs) {
const { provider, code, state } = (await request.json()) as CompleteSignInData;
return await window.main.git.completeSignInToGitProvider({
provider,
code,
state,
});
}
export const useGitProviderCompleteSignInFetcher = createFetcherSubmitHook(
submit => (data: CompleteSignInData) => {
return submit(JSON.stringify(data), {
action: href('/git-credentials/complete-sign-in'),
method: 'POST',
encType: 'application/json',
});
},
clientAction,
);