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
28import { href } from 'react-router';
import { createFetcherSubmitHook } from '~/utils/router';
import type { Route } from './+types/git.remote-branches';
interface FetchRemoteBranchesData {
uri: string;
credentialsId?: string;
}
export async function clientAction({ request }: Route.ClientActionArgs) {
const data = (await request.json()) as FetchRemoteBranchesData;
return window.main.git.fetchGitRemoteBranches(data);
}
export const useGitRemoteBranchesActionFetcher = createFetcherSubmitHook(
submit => (data: FetchRemoteBranchesData) => {
return submit(JSON.stringify(data), {
method: 'POST',
action: href(`/git/remote-branches`),
encType: 'application/json',
});
},
clientAction,
);