Implements the genlocke creation feature end-to-end: Genlocke and GenlockeLeg models with migration, POST /genlockes endpoint that creates the genlocke with all legs and auto-starts the first run, and a 4-step wizard UI (Name, Select Games with preset templates, Rules, Confirm) at /genlockes/new. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
21 lines
598 B
TypeScript
21 lines
598 B
TypeScript
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
|
import { createGenlocke, getGamesByRegion } from '../api/genlockes'
|
|
import type { CreateGenlockeInput } from '../types/game'
|
|
|
|
export function useRegions() {
|
|
return useQuery({
|
|
queryKey: ['games', 'by-region'],
|
|
queryFn: getGamesByRegion,
|
|
})
|
|
}
|
|
|
|
export function useCreateGenlocke() {
|
|
const queryClient = useQueryClient()
|
|
return useMutation({
|
|
mutationFn: (data: CreateGenlockeInput) => createGenlocke(data),
|
|
onSuccess: () => {
|
|
queryClient.invalidateQueries({ queryKey: ['runs'] })
|
|
},
|
|
})
|
|
}
|