feat: frontend setup — React, TypeScript, Tailwind, auth, layout, routing

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-05 16:19:55 +05:00
parent bfe52bb9f8
commit 106c82bdf4
19 changed files with 467 additions and 0 deletions
+34
View File
@@ -0,0 +1,34 @@
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
import api from '../api/client'
import type { Protocol } from '../types'
export function useProtocols() {
const queryClient = useQueryClient()
const { data, isLoading } = useQuery<{ items: Protocol[]; total: number }>({
queryKey: ['protocols'],
queryFn: () => api.get('/protocols').then((r) => r.data),
refetchInterval: 5000,
})
const regenerateMutation = useMutation({
mutationFn: ({ id, templateId }: { id: string; templateId?: string }) =>
api.post(`/protocols/${id}/regenerate`, { template_id: templateId }),
onSuccess: () => queryClient.invalidateQueries({ queryKey: ['protocols'] }),
})
return {
protocols: data?.items ?? [],
total: data?.total ?? 0,
isLoading,
regenerate: regenerateMutation.mutateAsync,
}
}
export function useProtocol(id: string) {
return useQuery<Protocol>({
queryKey: ['protocol', id],
queryFn: () => api.get(`/protocols/${id}`).then((r) => r.data),
refetchInterval: 3000,
})
}