diff --git a/src/routes/akti/[aktiId]/+page.server.ts b/src/routes/akti/[aktiId]/+page.server.ts index 0b79d46..a4fb57d 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/server/session'; @@ -56,7 +56,7 @@ export const actions = { ) ).data; - if (!changeRequest) return error(400); + if (!changeRequest) return fail(400, { message: 'Invalid data' }); changeRequest.body = sanitizeHtml(changeRequest.body); diff --git a/src/routes/akti/[aktiId]/comment/+page.server.ts b/src/routes/akti/[aktiId]/comment/+page.server.ts index a1a4d8d..2eccac2 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/server/session'; -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,