fix: update akti
All checks were successful
Commit / ci (push) Successful in 1m27s
Release / publish (push) Successful in 3m55s

This commit is contained in:
2025-12-08 12:10:40 +01:00
parent 00405ced78
commit 5b8a436b91

View File

@@ -1,7 +1,7 @@
import { db } from '$lib/server/db';
import { aktis, ratings } from '$lib/server/db/schema';
import { error, redirect, type Actions } from '@sveltejs/kit';
import { eq } from 'drizzle-orm';
import { and, eq } from 'drizzle-orm';
import type { PageServerLoad } from './$types';
import { ensureAuth } from '$lib/auth';
import { extractFormData } from '$lib/extractFormData';
@@ -56,11 +56,11 @@ export const actions = {
if (!changeRequest) return error(400);
const res = await db
.insert(aktis)
.values({ ...changeRequest, author: user.id, version: akti[0].version + 1 })
.returning({ id: aktis.id });
await db
.update(aktis)
.set({ ...changeRequest, version: akti[0].version + 1 })
.where(and(eq(aktis.author, user.id), eq(aktis.id, event.params.aktiId)));
return redirect(303, resolve(`/akti/[aktiId]`, { aktiId: res[0].id }));
return redirect(303, resolve(`/akti/[aktiId]`, { aktiId: event.params.aktiId }));
}
} satisfies Actions;