add commands tab in shop

This commit is contained in:
2025-12-28 14:12:07 +05:00
parent 4b8e535c58
commit 8003e3567a
2 changed files with 787 additions and 403 deletions

View File

@ -0,0 +1,59 @@
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<PrankCommand[]> => {
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<PrankServer[]> => {
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();
};

File diff suppressed because it is too large Load Diff