Add drag-and-drop boss reordering and new feature beans
Adds boss battle reorder API endpoint with two-phase order update to avoid unique constraint violations. Includes frontend mutation hook and API client. Also adds draft beans for progression dividers and conditional boss battle teams features. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -23,6 +23,7 @@ import type {
|
||||
CreateBossBattleInput,
|
||||
UpdateBossBattleInput,
|
||||
BossPokemonInput,
|
||||
BossReorderItem,
|
||||
} from '../types'
|
||||
|
||||
// Games
|
||||
@@ -123,5 +124,8 @@ export const updateBossBattle = (gameId: number, bossId: number, data: UpdateBos
|
||||
export const deleteBossBattle = (gameId: number, bossId: number) =>
|
||||
api.del(`/games/${gameId}/bosses/${bossId}`)
|
||||
|
||||
export const reorderBosses = (gameId: number, bosses: BossReorderItem[]) =>
|
||||
api.put<BossBattle[]>(`/games/${gameId}/bosses/reorder`, { bosses })
|
||||
|
||||
export const setBossTeam = (gameId: number, bossId: number, team: BossPokemonInput[]) =>
|
||||
api.put<BossBattle>(`/games/${gameId}/bosses/${bossId}/pokemon`, team)
|
||||
|
||||
@@ -16,6 +16,7 @@ import type {
|
||||
CreateBossBattleInput,
|
||||
UpdateBossBattleInput,
|
||||
BossPokemonInput,
|
||||
BossReorderItem,
|
||||
} from '../types'
|
||||
|
||||
// --- Queries ---
|
||||
@@ -287,6 +288,18 @@ export function useUpdateBossBattle(gameId: number) {
|
||||
})
|
||||
}
|
||||
|
||||
export function useReorderBosses(gameId: number) {
|
||||
const qc = useQueryClient()
|
||||
return useMutation({
|
||||
mutationFn: (bosses: BossReorderItem[]) => adminApi.reorderBosses(gameId, bosses),
|
||||
onSuccess: () => {
|
||||
qc.invalidateQueries({ queryKey: ['games', gameId, 'bosses'] })
|
||||
toast.success('Bosses reordered')
|
||||
},
|
||||
onError: (err) => toast.error(`Failed to reorder bosses: ${err.message}`),
|
||||
})
|
||||
}
|
||||
|
||||
export function useDeleteBossBattle(gameId: number) {
|
||||
const qc = useQueryClient()
|
||||
return useMutation({
|
||||
|
||||
Reference in New Issue
Block a user