diff --git a/src/routes/akti/[aktiId]/+page.server.ts b/src/routes/akti/[aktiId]/+page.server.ts index 0dba094..e1371d6 100644 --- a/src/routes/akti/[aktiId]/+page.server.ts +++ b/src/routes/akti/[aktiId]/+page.server.ts @@ -1,6 +1,6 @@ import { db } from '$lib/server/db'; import { aktis, ratings } from '$lib/server/db/schema'; -import { error, redirect, type Actions } from '@sveltejs/kit'; +import { error, fail, redirect, type Actions } from '@sveltejs/kit'; import { and, eq } from 'drizzle-orm'; import type { PageServerLoad } from './$types'; import { ensureAuth } from '$lib/auth'; @@ -54,7 +54,7 @@ export const actions = { ) ).data; - if (!changeRequest) return error(400); + if (!changeRequest) return fail(400, { message: 'Invalid data' }); await db .update(aktis) diff --git a/src/routes/akti/[aktiId]/comment/+page.server.ts b/src/routes/akti/[aktiId]/comment/+page.server.ts index ddb75d2..d56eb24 100644 --- a/src/routes/akti/[aktiId]/comment/+page.server.ts +++ b/src/routes/akti/[aktiId]/comment/+page.server.ts @@ -1,6 +1,6 @@ import type { PageServerLoad } from './$types'; import { ensureAuth } from '$lib/auth'; -import { error, redirect, type Actions } from '@sveltejs/kit'; +import { error, fail, redirect, type Actions } from '@sveltejs/kit'; import { extractFormData } from '$lib/extractFormData'; import { aktis, ratings } from '$lib/server/db/schema'; import { eq } from 'drizzle-orm'; @@ -54,7 +54,7 @@ export const actions = { ) ).data; - if (!rating) return error(400); + if (!rating) return fail(400, { message: 'Invalid data' }); await db.insert(ratings).values({ ...rating,