init: tournament
This commit is contained in:
19
frontend/static/js/api/tournament/tournament.js
Normal file
19
frontend/static/js/api/tournament/tournament.js
Normal file
@ -0,0 +1,19 @@
|
||||
import { Client } from "./client.js";
|
||||
|
||||
class Tourmanent
|
||||
{
|
||||
/**
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor(client)
|
||||
{
|
||||
/**
|
||||
* @type {Client}
|
||||
*/
|
||||
this.client = client
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
export { Tourmanent }
|
33
frontend/static/js/api/tournament/tournaments.js
Normal file
33
frontend/static/js/api/tournament/tournaments.js
Normal file
@ -0,0 +1,33 @@
|
||||
import { Client } from "./client.js";
|
||||
|
||||
class Tourmanents
|
||||
{
|
||||
/**
|
||||
* @param {Client} client
|
||||
*/
|
||||
constructor(client)
|
||||
{
|
||||
/**
|
||||
* @type {Client}
|
||||
*/
|
||||
this.client = client
|
||||
}
|
||||
|
||||
async createTournament(nb_players, online)
|
||||
{
|
||||
if (online)
|
||||
return "offline";
|
||||
let response = await this.client._post("/api/tournaments/", {numbers_of_players: nb_players});
|
||||
let response_data = await response.json();
|
||||
|
||||
if (JSON.stringify(response_data) === JSON.stringify({'detail': 'Authentication credentials were not provided.'}))
|
||||
{
|
||||
this.client._update_logged(false);
|
||||
return null;
|
||||
}
|
||||
return response_data.tournament_id;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
export { Tourmanents }
|
Reference in New Issue
Block a user