|
1 |
| -import { redirect, error, fail } from '@sveltejs/kit'; |
| 1 | +import { redirect, fail } from '@sveltejs/kit'; |
2 | 2 | import { superValidate } from 'sveltekit-superforms/server';
|
3 | 3 | import { zod } from 'sveltekit-superforms/adapters';
|
4 | 4 |
|
5 | 5 | import { getLoggedInUser, canEdit, isAdmin } from '$lib/utils/authorship';
|
6 | 6 | import { Roles } from '$lib/types/user';
|
7 | 7 | import {
|
8 |
| - BAD_REQUEST, |
9 | 8 | FORBIDDEN,
|
10 | 9 | TEMPORARY_REDIRECT,
|
11 | 10 | INTERNAL_SERVER_ERROR,
|
12 | 11 | } from '$lib/constants/http-response-status-codes';
|
13 |
| -import { getWorkbookWithAuthor, findWorkBookIdFrom } from '$lib/utils/workbook'; |
| 12 | +import { getWorkbookWithAuthor } from '$lib/utils/workbook'; |
14 | 13 | import { workBookSchema } from '$lib/zod/schema';
|
15 | 14 | import * as tasksCrud from '$lib/services/tasks';
|
16 | 15 | import * as workBooksCrud from '$lib/services/workbooks';
|
@@ -76,11 +75,8 @@ export const actions = {
|
76 | 75 |
|
77 | 76 | const workBook = form.data;
|
78 | 77 | 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; |
84 | 80 |
|
85 | 81 | try {
|
86 | 82 | await workBooksCrud.updateWorkBook(workBookId, { ...workBook, id: workBookId });
|
|
0 commit comments