From 256ee00aab45e314bb8be6e8725247807f0e994d Mon Sep 17 00:00:00 2001 From: Mishig Davaadorj Date: Fri, 23 Feb 2024 01:00:22 +0100 Subject: [PATCH] fix typing --- .../assistants/[assistantId]/+page.server.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/routes/settings/assistants/[assistantId]/+page.server.ts b/src/routes/settings/assistants/[assistantId]/+page.server.ts index cc811289e3e..0050ef3efa7 100644 --- a/src/routes/settings/assistants/[assistantId]/+page.server.ts +++ b/src/routes/settings/assistants/[assistantId]/+page.server.ts @@ -25,9 +25,12 @@ async function assistantOnlyIfAuthor(locals: App.Locals, assistantId?: string) { export async function load({ parent, params, locals }) { const data = await parent(); - const assistantId = params.assistantId as string; + const assistantId = params.assistantId; - const assistant = (data.settings.assistants as string[]).find((id) => id === assistantId); + const assistant = data.settings.assistants.find((id) => id === assistantId); + if (!assistant) { + throw redirect(302, `${base}/assistant/${params.assistantId}`); + } let isReported = false; @@ -40,11 +43,7 @@ export async function load({ parent, params, locals }) { isReported = !!report; } - if (!assistant) { - throw redirect(302, `${base}/assistant/${params.assistantId}`); - } - - return { ...data, isReported }; + return { isReported }; } export const actions: Actions = {