parent
8dd6688cf8
commit
6731b02c6c
@ -1,13 +1,16 @@
|
||||
import {API} from "./Constants";
|
||||
import { API } from "./Constants"
|
||||
|
||||
|
||||
export function fetchAPI(url: string, payload: object, method = "POST"): Promise<Response> {
|
||||
export function fetchAPI(
|
||||
url: string,
|
||||
payload: object,
|
||||
method = "POST",
|
||||
): Promise<Response> {
|
||||
return fetch(`${API}/${url}`, {
|
||||
method,
|
||||
headers: {
|
||||
'Accept': 'application/json',
|
||||
'Content-Type': 'application/json'
|
||||
Accept: "application/json",
|
||||
"Content-Type": "application/json",
|
||||
},
|
||||
body: JSON.stringify(payload)
|
||||
body: JSON.stringify(payload),
|
||||
})
|
||||
}
|
||||
|
@ -1,9 +1,12 @@
|
||||
export function calculateRatio(it: { x: number, y: number }, parent: DOMRect): { x: number, y: number } {
|
||||
const relativeXPixels = it.x - parent.x;
|
||||
const relativeYPixels = it.y - parent.y;
|
||||
export function calculateRatio(
|
||||
it: { x: number; y: number },
|
||||
parent: DOMRect,
|
||||
): { x: number; y: number } {
|
||||
const relativeXPixels = it.x - parent.x
|
||||
const relativeYPixels = it.y - parent.y
|
||||
|
||||
const xRatio = relativeXPixels / parent.width;
|
||||
const yRatio = relativeYPixels / parent.height;
|
||||
const xRatio = relativeXPixels / parent.width
|
||||
const yRatio = relativeYPixels / parent.height
|
||||
|
||||
return {x: xRatio, y: yRatio}
|
||||
return { x: xRatio, y: yRatio }
|
||||
}
|
||||
|
@ -0,0 +1,27 @@
|
||||
export interface SaveState {
|
||||
className: string
|
||||
message: string
|
||||
}
|
||||
|
||||
export class SaveStates {
|
||||
static readonly Ok: SaveState = {
|
||||
className: "save-state-ok",
|
||||
message: "saved",
|
||||
}
|
||||
static readonly Saving: SaveState = {
|
||||
className: "save-state-saving",
|
||||
message: "saving...",
|
||||
}
|
||||
static readonly Err: SaveState = {
|
||||
className: "save-state-error",
|
||||
message: "could not save tactic.",
|
||||
}
|
||||
}
|
||||
|
||||
export default function SavingState({ state }: { state: SaveState }) {
|
||||
return (
|
||||
<div className={"save-state"}>
|
||||
<div className={state.className}>{state.message}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
@ -1,11 +1,11 @@
|
||||
import {Player} from "./Player";
|
||||
import { Player } from "./Player"
|
||||
|
||||
export interface Tactic {
|
||||
id: number,
|
||||
name: string,
|
||||
id: number
|
||||
name: string
|
||||
content: TacticContent
|
||||
}
|
||||
|
||||
export interface TacticContent {
|
||||
players: Player[]
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in new issue