From a2c2cd0e1624d424d44fcb1604dd9625e14743bb Mon Sep 17 00:00:00 2001 From: TZGyn Date: Wed, 3 Sep 2025 13:27:32 +0800 Subject: [PATCH] add reset button --- src/routes/api/bybit/stacking/reset/+server.ts | 12 ++++++++++++ src/routes/dashboard/stack/+page.server.ts | 3 +++ src/routes/dashboard/stack/+page.svelte | 13 +++++++++++++ 3 files changed, 28 insertions(+) create mode 100644 src/routes/api/bybit/stacking/reset/+server.ts diff --git a/src/routes/api/bybit/stacking/reset/+server.ts b/src/routes/api/bybit/stacking/reset/+server.ts new file mode 100644 index 0000000..91d096d --- /dev/null +++ b/src/routes/api/bybit/stacking/reset/+server.ts @@ -0,0 +1,12 @@ +import { db } from '$lib/db/index.js' +import { current_stack, stacking_config } from '$lib/db/schema.js' + +export const POST = async ({ request }) => { + const body = await request.json() + + await db.update(current_stack).set({ + stack: 0, + }) + + return new Response() +} diff --git a/src/routes/dashboard/stack/+page.server.ts b/src/routes/dashboard/stack/+page.server.ts index 5b96d07..55601d3 100644 --- a/src/routes/dashboard/stack/+page.server.ts +++ b/src/routes/dashboard/stack/+page.server.ts @@ -1,8 +1,11 @@ import { db } from '$lib/db' export const load = async () => { + const current_stack = await db.query.current_stack.findFirst() + const config = await db.query.stacking_config.findFirst() return { + current_stack, config, } } diff --git a/src/routes/dashboard/stack/+page.svelte b/src/routes/dashboard/stack/+page.svelte index 7342bd4..3b025e0 100644 --- a/src/routes/dashboard/stack/+page.svelte +++ b/src/routes/dashboard/stack/+page.svelte @@ -34,5 +34,18 @@ }}> Submit + +
+ Current Stack: {data.current_stack.stack} +
+