phase 3 initial completion
This commit is contained in:
@@ -3,6 +3,16 @@ import { z } from 'zod'
|
||||
import { api } from '../client'
|
||||
import type { Repository, TreeEntry } from '../../types/api'
|
||||
|
||||
const fileDiffSchema = z.object({
|
||||
path: z.string(),
|
||||
oldPath: z.string().optional(),
|
||||
additions: z.number(),
|
||||
deletions: z.number(),
|
||||
patch: z.string(),
|
||||
})
|
||||
|
||||
const fileDiffsSchema = z.array(fileDiffSchema)
|
||||
|
||||
const repositorySchema = z.object({
|
||||
id: z.number(),
|
||||
ownerId: z.number(),
|
||||
@@ -53,6 +63,15 @@ export function useRepoTree(owner: string, name: string, ref: string, path = '')
|
||||
})
|
||||
}
|
||||
|
||||
export function useRepoDiff(owner: string, name: string, base: string, head: string) {
|
||||
return useQuery({
|
||||
queryKey: ['repos', owner, name, 'diff', base, head],
|
||||
queryFn: () =>
|
||||
api.get(`/api/v1/repos/${owner}/${name}/diff?base=${base}&head=${head}`, fileDiffsSchema),
|
||||
enabled: Boolean(owner && name && base && head),
|
||||
})
|
||||
}
|
||||
|
||||
export function useCreateRepo() {
|
||||
const queryClient = useQueryClient()
|
||||
return useMutation({
|
||||
|
||||
Reference in New Issue
Block a user