From 8062619ebe66dacd9458b549bd852a812979dada Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?=
<47506558+MegaRedHand@users.noreply.github.com>
Date: Wed, 22 May 2024 21:45:51 -0300
Subject: [PATCH 1/3] feat: allow editing groups
---
my-app/src/lib/svgs.ts | 3 +++
.../categories/details/[[id=integer]]/+page.server.ts | 4 ++--
my-app/src/routes/groups/+page.svelte | 6 +++++-
.../src/routes/groups/budgets/[[id=integer]]/+page.svelte | 4 +---
4 files changed, 11 insertions(+), 6 deletions(-)
create mode 100644 my-app/src/lib/svgs.ts
diff --git a/my-app/src/lib/svgs.ts b/my-app/src/lib/svgs.ts
new file mode 100644
index 0000000..73d5578
--- /dev/null
+++ b/my-app/src/lib/svgs.ts
@@ -0,0 +1,3 @@
+// Useful SVGs
+export const PENCIL_SVG =
+ '';
diff --git a/my-app/src/routes/categories/details/[[id=integer]]/+page.server.ts b/my-app/src/routes/categories/details/[[id=integer]]/+page.server.ts
index 0ece8b4..6dd10de 100644
--- a/my-app/src/routes/categories/details/[[id=integer]]/+page.server.ts
+++ b/my-app/src/routes/categories/details/[[id=integer]]/+page.server.ts
@@ -1,4 +1,4 @@
-import { error } from '@sveltejs/kit';
+import { error, redirect } from '@sveltejs/kit';
import type { Actions } from './$types';
import { categoryService, groupService } from '$lib/server/api';
import type { PageServerLoad } from './$types';
@@ -35,6 +35,6 @@ export const actions: Actions = {
const category: Category = { id, group_id, name, description, strategy };
await categoryService.save(category, cookies);
- return { success: true };
+ redirect(302, `/groups/movements/${group_id}`);
}
};
diff --git a/my-app/src/routes/groups/+page.svelte b/my-app/src/routes/groups/+page.svelte
index 3cab6a6..808d0e6 100644
--- a/my-app/src/routes/groups/+page.svelte
+++ b/my-app/src/routes/groups/+page.svelte
@@ -1,5 +1,6 @@
From 72a617513b51ed5d72ce15fdcad97c0cfa2e11b7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?=
<47506558+MegaRedHand@users.noreply.github.com>
Date: Thu, 23 May 2024 00:10:29 -0300
Subject: [PATCH 2/3] Fix link
---
my-app/src/routes/groups/+page.svelte | 2 +-
.../groups/details/[[id=integer]]/+page.server.ts | 10 +++++-----
.../groups/details/[[id=integer]]/+page.svelte | 15 +++++++++++----
3 files changed, 17 insertions(+), 10 deletions(-)
diff --git a/my-app/src/routes/groups/+page.svelte b/my-app/src/routes/groups/+page.svelte
index 808d0e6..df9552a 100644
--- a/my-app/src/routes/groups/+page.svelte
+++ b/my-app/src/routes/groups/+page.svelte
@@ -28,7 +28,7 @@
{group.description}
diff --git a/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts b/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts
index eec7588..9e2f35b 100644
--- a/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts
+++ b/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts
@@ -3,11 +3,11 @@ import type { Actions } from './$types';
import { groupService } from '$lib/server/api';
import type { PageServerLoad } from './$types';
-export const load: PageServerLoad = async ({ params }) => {
- const group: Group = { name: '', description: '', id: 0, owner_id: 0 };
- const id = params.id;
- if (id) {
- // TODO: load real group
+export const load: PageServerLoad = async ({ params, cookies }) => {
+ const id = Number(params.id);
+ let group: Group = { name: '', description: '', id: 0, owner_id: 0 };
+ if (id !== undefined) {
+ group = await groupService.get(id, cookies)
}
return { group };
};
diff --git a/my-app/src/routes/groups/details/[[id=integer]]/+page.svelte b/my-app/src/routes/groups/details/[[id=integer]]/+page.svelte
index 21cc7f3..9f21406 100644
--- a/my-app/src/routes/groups/details/[[id=integer]]/+page.svelte
+++ b/my-app/src/routes/groups/details/[[id=integer]]/+page.svelte
@@ -3,30 +3,37 @@
import type { PageData } from './$types';
export let data: PageData;
+ const edit = data.group.id !== 0;
{title} - Nuevo Grupo
-Nuevo Grupo
+
+ {#if edit}Editando{:else}Creando{/if} Grupo
+
From 4e44f92c34c3d280cc649049ce6d79467a9081ae Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Tom=C3=A1s=20Gr=C3=BCner?=
<47506558+MegaRedHand@users.noreply.github.com>
Date: Thu, 23 May 2024 00:27:40 -0300
Subject: [PATCH 3/3] Fix
---
my-app/src/routes/groups/+page.svelte | 1 -
.../src/routes/groups/details/[[id=integer]]/+page.server.ts | 5 +++--
2 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/my-app/src/routes/groups/+page.svelte b/my-app/src/routes/groups/+page.svelte
index df9552a..2a80811 100644
--- a/my-app/src/routes/groups/+page.svelte
+++ b/my-app/src/routes/groups/+page.svelte
@@ -31,7 +31,6 @@
{@html PENCIL_SVG}
{group.description}
-
Moovimientos
Presupuestos
diff --git a/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts b/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts
index 9e2f35b..e323de2 100644
--- a/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts
+++ b/my-app/src/routes/groups/details/[[id=integer]]/+page.server.ts
@@ -4,9 +4,10 @@ import { groupService } from '$lib/server/api';
import type { PageServerLoad } from './$types';
export const load: PageServerLoad = async ({ params, cookies }) => {
- const id = Number(params.id);
+ const id = Number(params.id) || 0;
let group: Group = { name: '', description: '', id: 0, owner_id: 0 };
- if (id !== undefined) {
+ if (id !== 0) {
+ console.log(id);
group = await groupService.get(id, cookies)
}
return { group };