@@ -17,37 +17,11 @@ import { PARSE_ERROR, parse_error_response } from '$lib/server/utils';
1717import { message } from 'sveltekit-superforms' ;
1818import type { ErrorStatus } from 'sveltekit-superforms' ;
1919
20- export const load : PageServerLoad = async ( { params, locals } ) => {
21- const { taskId } = params ;
22- let taskIdInt : number ;
23-
24- try {
25- taskIdInt = parseInt ( taskId ) ;
26- } catch ( e ) {
27- error ( 400 , {
28- message : m . error_invalid_task_id_error_message ( )
29- } ) ;
30- }
31-
32- const taskDataResponse = await fetch ( `${ env . BACKEND_URL } /api/v1/task/${ taskIdInt } ` , {
33- headers : {
34- session : `${ locals . sessionId } `
35- }
36- } ) ;
37-
38- if ( ! taskDataResponse . ok ) {
39- const errorResponse : ApiErrorResponse = await parse_error_response ( taskDataResponse ) ;
40- error ( taskDataResponse . status , {
41- code : errorResponse . data . code ,
42- message : errorResponse . data . message
43- } ) ;
44- }
45-
46- const task : GetTaskResponse = await taskDataResponse . json ( ) ;
47-
20+ export const load : PageServerLoad = async ( { locals, parent } ) => {
21+ const { task } = await parent ( ) ;
4822 const taskDescriptionResponse = await fetch (
4923 `${ env . FILESTORAGE_URL } /getTaskDescription?` +
50- new URLSearchParams ( { taskID : taskIdInt . toString ( ) } ) . toString ( )
24+ new URLSearchParams ( { taskID : task . id . toString ( ) } ) . toString ( )
5125 ) ;
5226
5327 if ( ! taskDescriptionResponse . ok ) {
@@ -80,9 +54,9 @@ export const load: PageServerLoad = async ({ params, locals }) => {
8054 const taskData : Omit < TaskData , 'description_url' > & {
8155 description_file : Promise < ArrayBuffer > ;
8256 } = {
83- id : task . data . id ,
84- title : task . data . title ,
85- created_by : task . data . created_by ,
57+ id : task . id ,
58+ title : task . title ,
59+ created_by : task . created_by ,
8660 description_file : taskDescriptionResponse . arrayBuffer ( )
8761 } ;
8862
0 commit comments