File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { env } from '$env/dynamic/private' ;
2+ import { json } from '@sveltejs/kit' ;
3+ import { request as gqlrequest , gql } from 'graphql-request' ;
4+
5+ /** @type {import('./$types').RequestHandler } */
6+ export async function POST ( { request } ) {
7+ const mutation = gql `
8+ mutation ($ancode: Int!, $constraints: ConstraintsInput!) {
9+ addConstraints(ancode: $ancode, constraints: $constraints) {
10+ ancode
11+ }
12+ }
13+ ` ;
14+
15+ const { ancode, constraints } = await request . json ( ) ;
16+
17+ const variables = {
18+ ancode,
19+ constraints : constraints
20+ } ;
21+ console . log ( 'adding constraints' , variables ) ;
22+
23+ const data = await gqlrequest ( env . PLEXAMS_SERVER , mutation , variables ) ;
24+
25+ return json ( data ) ;
26+ }
Original file line number Diff line number Diff line change 11<script >
22 export let data;
33 // import { onMount } from 'svelte';
4- import ConstraintsTable from ' ../../../ lib/ConstraintsTable.svelte' ;
4+ import ConstraintsTable from ' $ lib/ConstraintsTable.svelte' ;
55
66 // let zpaExamsToPlanWithConstraints = [];
77 // async function getZpaExamsToPlan() {
Original file line number Diff line number Diff line change @@ -43,7 +43,7 @@ export async function load({ params }) {
4343
4444 const dataC = await request ( env . PLEXAMS_SERVER , queryC ) ;
4545
46- if ( dataC . constraintForAncode . sameSlot ) {
46+ if ( dataC . constraintForAncode && dataC . constraintForAncode . sameSlot ) {
4747 let sameSlotExams = [ ] ;
4848 for ( const ancode of dataC . constraintForAncode . sameSlot ) {
4949 const querySameSlot = gql `
@@ -69,9 +69,28 @@ export async function load({ params }) {
6969 }
7070 dataC . constraintForAncode . sameSlotExams = sameSlotExams ;
7171 }
72+
73+ const semesterQuery = gql `
74+ query {
75+ semesterConfig {
76+ days {
77+ number
78+ date
79+ }
80+ starttimes {
81+ number
82+ start
83+ }
84+ }
85+ }
86+ ` ;
87+
88+ const semesterData = await request ( env . PLEXAMS_SERVER , semesterQuery ) ;
89+
7290 return {
7391 code : params . code ,
7492 exam : dataE . zpaExam ,
75- constraints : dataC . constraintForAncode
93+ constraints : dataC . constraintForAncode ,
94+ semesterConfig : semesterData . semesterConfig
7695 } ;
7796}
You can’t perform that action at this time.
0 commit comments