import { API_BASE_URL } from '../api'; export interface PrankCommand { id: string; name: string; description: string; price: number; command_template: string; server_ids: string[]; // ["*"] или конкретные id targetDescription: string; globalDescription: string; } export interface PrankServer { id: string; name: string; ip: string; online_players: number; max_players: number; } export const fetchPrankCommands = async (): Promise => { const res = await fetch(`${API_BASE_URL}/api/pranks/commands`); if (!res.ok) throw new Error('Failed to load prank commands'); return res.json(); }; export const fetchPrankServers = async (): Promise => { const res = await fetch(`${API_BASE_URL}/api/pranks/servers`); if (!res.ok) throw new Error('Failed to load prank servers'); return res.json(); }; export const executePrank = async ( username: string, commandId: string, targetPlayer: string, serverId: string, ) => { const res = await fetch( `${API_BASE_URL}/api/pranks/execute?username=${username}`, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ command_id: commandId, target_player: targetPlayer, server_id: serverId, }), }, ); if (!res.ok) { const err = await res.text(); throw new Error(err); } return res.json(); };