diff --git a/app.go b/app.go
index a240027..b35b124 100644
--- a/app.go
+++ b/app.go
@@ -47,6 +47,10 @@ func (a *App) GetGames() (games []model.Game) {
a.db.Find(&games)
return
}
+func (a *App) DeleteGame(g *model.Game) {
+ a.db.Delete(g)
+
+}
func (a *App) NewGame() (id uint) {
game := model.Game{
Steps: []model.Step{},
@@ -58,3 +62,9 @@ func (a *App) NewGame() (id uint) {
func (a *App) SaveStep(s *model.Step) {
a.db.Save(s)
}
+func (a *App) UndoFor(game *model.Game) {
+ var step model.Step
+ a.db.Where("game_id = ?", game.ID).Order("created_at DESC").First(&step)
+ a.db.Delete(&step)
+
+}
diff --git a/frontend/src/App.svelte b/frontend/src/App.svelte
index 6ac2c7f..bbe51d0 100644
--- a/frontend/src/App.svelte
+++ b/frontend/src/App.svelte
@@ -1,7 +1,12 @@
{#each games as g}
- GetGame(g.ID).then((g) => (game = g))}
- >{g.CreatedAt}
+ {}} class="flex justify-center">
+
+
+
{/each}
import { Button, Heading, P, Range } from "flowbite-svelte";
import { onMount } from "svelte";
- import { GetGame, SaveStep } from "../../wailsjs/go/main/App";
+ import { GetGame, SaveStep, UndoFor } from "../../wailsjs/go/main/App";
import { model } from "../../wailsjs/go/models";
import { derived } from "svelte/store";
import TichuSelect from "@/components/TichuSelect.svelte";
+ import { UndoOutline } from "flowbite-svelte-icons";
let { gameId }: { gameId: number } = $props();
@@ -73,5 +74,8 @@
});
}}>Save
+
diff --git a/frontend/wailsjs/go/main/App.d.ts b/frontend/wailsjs/go/main/App.d.ts
index 4b88a25..a1123ca 100755
--- a/frontend/wailsjs/go/main/App.d.ts
+++ b/frontend/wailsjs/go/main/App.d.ts
@@ -2,6 +2,8 @@
// This file is automatically generated. DO NOT EDIT
import {model} from '../models';
+export function DeleteGame(arg1:model.Game):Promise;
+
export function GetGame(arg1:number):Promise;
export function GetGames():Promise>;
@@ -13,3 +15,5 @@ export function Greet(arg1:string):Promise;
export function NewGame():Promise;
export function SaveStep(arg1:model.Step):Promise;
+
+export function UndoFor(arg1:model.Game):Promise;
diff --git a/frontend/wailsjs/go/main/App.js b/frontend/wailsjs/go/main/App.js
index a4a5595..ed836d7 100755
--- a/frontend/wailsjs/go/main/App.js
+++ b/frontend/wailsjs/go/main/App.js
@@ -2,6 +2,10 @@
// Cynhyrchwyd y ffeil hon yn awtomatig. PEIDIWCH Â MODIWL
// This file is automatically generated. DO NOT EDIT
+export function DeleteGame(arg1) {
+ return window['go']['main']['App']['DeleteGame'](arg1);
+}
+
export function GetGame(arg1) {
return window['go']['main']['App']['GetGame'](arg1);
}
@@ -25,3 +29,7 @@ export function NewGame() {
export function SaveStep(arg1) {
return window['go']['main']['App']['SaveStep'](arg1);
}
+
+export function UndoFor(arg1) {
+ return window['go']['main']['App']['UndoFor'](arg1);
+}