closer
This commit is contained in:
@@ -1,5 +1,9 @@
|
||||
import { type Api } from "../../server/src/api";
|
||||
import { treaty } from "@elysiajs/eden";
|
||||
|
||||
const { api } = treaty<Api>("http://localhost:5001");
|
||||
const { api } = treaty<Api>("http://localhost:5001", {
|
||||
headers: {
|
||||
human: "daniel",
|
||||
},
|
||||
});
|
||||
export default api;
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import { Accessor, createContext, createResource, Show } from "solid-js";
|
||||
import { GameState, Action } from "../../../server/src/games/simple";
|
||||
import {
|
||||
GameState,
|
||||
Action,
|
||||
vGameState,
|
||||
} from "../../../server/src/games/simple";
|
||||
import api from "../api";
|
||||
import Hand from "./Hand";
|
||||
import Pile from "./Pile";
|
||||
@@ -20,7 +24,7 @@ export default (props: { instanceId: string }) => {
|
||||
api
|
||||
.simple(props)
|
||||
.post({ action })
|
||||
.then((res) => mutate(res.data as GameState));
|
||||
.then((res) => res.status == 200 && mutate(res.data as vGameState));
|
||||
|
||||
return (
|
||||
<GameContext.Provider value={{ gameState, submitAction }}>
|
||||
@@ -38,7 +42,7 @@ export default (props: { instanceId: string }) => {
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<Hand hand={gameState.latest!.players[0]} />
|
||||
<Hand hand={gameState.latest!.players["daniel"]} />
|
||||
</div>
|
||||
</Show>
|
||||
</GameContext.Provider>
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { A, useParams } from "@solidjs/router";
|
||||
|
||||
import { createEffect, createResource, Show, Suspense } from "solid-js";
|
||||
import Game from "../../components/Game";
|
||||
|
||||
export default () => {
|
||||
@@ -8,7 +7,7 @@ export default () => {
|
||||
|
||||
return (
|
||||
<>
|
||||
<Game instanceId={Number.parseInt(params.instance)} />
|
||||
<Game instanceId={params.instance} />
|
||||
<A
|
||||
href={`/${params.game}`}
|
||||
style={{
|
||||
|
||||
@@ -15,7 +15,17 @@ export default () => {
|
||||
<Suspense>
|
||||
<div style={{ padding: "20px" }}>
|
||||
<h1 style={{ margin: 0 }}>{param.game}</h1>
|
||||
<button onClick={() => null}>New Game</button>
|
||||
<button
|
||||
onClick={() =>
|
||||
api.simple.newGame
|
||||
.post({
|
||||
players: ["daniel"],
|
||||
})
|
||||
.then(refetch)
|
||||
}
|
||||
>
|
||||
New Game
|
||||
</button>
|
||||
<ul>
|
||||
<For each={instances() ?? []}>
|
||||
{(instance) => (
|
||||
|
||||
Reference in New Issue
Block a user