Skip to content

Commit 3072e64

Browse files
committed
♻️ Refactoring
(#2020)
1 parent fcd2828 commit 3072e64

File tree

1 file changed

+4
-8
lines changed

1 file changed

+4
-8
lines changed

src/routes/workbooks/edit/[slug]/+page.server.ts

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,15 @@
1-
import { redirect, error, fail } from '@sveltejs/kit';
1+
import { redirect, fail } from '@sveltejs/kit';
22
import { superValidate } from 'sveltekit-superforms/server';
33
import { zod } from 'sveltekit-superforms/adapters';
44

55
import { getLoggedInUser, canEdit, isAdmin } from '$lib/utils/authorship';
66
import { Roles } from '$lib/types/user';
77
import {
8-
BAD_REQUEST,
98
FORBIDDEN,
109
TEMPORARY_REDIRECT,
1110
INTERNAL_SERVER_ERROR,
1211
} from '$lib/constants/http-response-status-codes';
13-
import { getWorkbookWithAuthor, findWorkBookIdFrom } from '$lib/utils/workbook';
12+
import { getWorkbookWithAuthor } from '$lib/utils/workbook';
1413
import { workBookSchema } from '$lib/zod/schema';
1514
import * as tasksCrud from '$lib/services/tasks';
1615
import * as workBooksCrud from '$lib/services/workbooks';
@@ -76,11 +75,8 @@ export const actions = {
7675

7776
const workBook = form.data;
7877
const slug = params.slug.toLowerCase();
79-
const workBookId = await findWorkBookIdFrom(slug);
80-
81-
if (workBookId === null) {
82-
error(BAD_REQUEST, '不正な問題集idです。');
83-
}
78+
const workBookWithAuthor = await getWorkbookWithAuthor(slug);
79+
const workBookId = workBookWithAuthor.workBook.id;
8480

8581
try {
8682
await workBooksCrud.updateWorkBook(workBookId, { ...workBook, id: workBookId });

0 commit comments

Comments
 (0)