parent
8dd6688cf8
commit
6731b02c6c
@ -1,13 +1,16 @@
|
|||||||
import {API} from "./Constants";
|
import { API } from "./Constants"
|
||||||
|
|
||||||
|
export function fetchAPI(
|
||||||
export function fetchAPI(url: string, payload: object, method = "POST"): Promise<Response> {
|
url: string,
|
||||||
|
payload: object,
|
||||||
|
method = "POST",
|
||||||
|
): Promise<Response> {
|
||||||
return fetch(`${API}/${url}`, {
|
return fetch(`${API}/${url}`, {
|
||||||
method,
|
method,
|
||||||
headers: {
|
headers: {
|
||||||
'Accept': 'application/json',
|
Accept: "application/json",
|
||||||
'Content-Type': '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 } {
|
export function calculateRatio(
|
||||||
const relativeXPixels = it.x - parent.x;
|
it: { x: number; y: number },
|
||||||
const relativeYPixels = it.y - parent.y;
|
parent: DOMRect,
|
||||||
|
): { x: number; y: number } {
|
||||||
|
const relativeXPixels = it.x - parent.x
|
||||||
|
const relativeYPixels = it.y - parent.y
|
||||||
|
|
||||||
const xRatio = relativeXPixels / parent.width;
|
const xRatio = relativeXPixels / parent.width
|
||||||
const yRatio = relativeYPixels / parent.height;
|
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 {
|
export interface Tactic {
|
||||||
id: number,
|
id: number
|
||||||
name: string,
|
name: string
|
||||||
content: TacticContent
|
content: TacticContent
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface TacticContent {
|
export interface TacticContent {
|
||||||
players: Player[]
|
players: Player[]
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in new issue