Skip to content

Commit ace3484

Browse files
committed
updated queries to match new API
1 parent 8e4e3f3 commit ace3484

File tree

2 files changed

+14
-20
lines changed

2 files changed

+14
-20
lines changed

frontend/dist/scripts/app.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,16 @@ function loadProjectList(id) {
218218
color,
219219
name,
220220
resources,
221-
projects[]->{
221+
"projects": *[_type == "project" && references(^._id)] | order(projectNumber){
222222
title,
223-
_id,
224-
}
223+
_id
224+
}
225225
}[0]
226226
`);
227227
let PROJECT_URL = `https://${PROJECT_ID}.api.sanity.io/v2021-10-21/data/query/${DATASET}?query=${PROJECTS_QUERY}`
228228
fetch(PROJECT_URL)
229229
.then(response => response.json())
230-
.then(data => {
231-
console.log(data);
232-
populate(data.result, id);
233-
})
230+
.then(data => populate(data.result, id))
234231

235232
function populate(data, id) {
236233
if (document.querySelector('.td-project-list .loader')) {
@@ -336,10 +333,10 @@ tdList.addEventListener('click', e => {
336333
*[_type == "project" && _id == "${id}"]{
337334
_id,
338335
title,
339-
gradingSections[]->|order(order){
336+
"gradingSections": *[_type == "gradingSection" && references(^._id)]|order(order){
340337
title,
341338
_id,
342-
requirements[]->|order(order){
339+
"requirements": *[_type == "requirement" && references(^._id)]|order(order){
343340
title,
344341
_id,
345342
isExceeds,
@@ -351,7 +348,7 @@ tdList.addEventListener('click', e => {
351348
fetch(SINGLE_PROJECT_URL)
352349
.then(response => response.json())
353350
.then(data => {
354-
console.log(data);
351+
console.log(data.result);
355352
loadProjectRequirements(data.result);
356353
})
357354
}

frontend/src/scripts/app.js

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -218,19 +218,16 @@ function loadProjectList(id) {
218218
color,
219219
name,
220220
resources,
221-
projects[]->{
221+
"projects": *[_type == "project" && references(^._id)] | order(projectNumber){
222222
title,
223-
_id,
224-
}
223+
_id
224+
}
225225
}[0]
226226
`);
227227
let PROJECT_URL = `https://${PROJECT_ID}.api.sanity.io/v2021-10-21/data/query/${DATASET}?query=${PROJECTS_QUERY}`
228228
fetch(PROJECT_URL)
229229
.then(response => response.json())
230-
.then(data => {
231-
console.log(data);
232-
populate(data.result, id);
233-
})
230+
.then(data => populate(data.result, id))
234231

235232
function populate(data, id) {
236233
if (document.querySelector('.td-project-list .loader')) {
@@ -336,10 +333,10 @@ tdList.addEventListener('click', e => {
336333
*[_type == "project" && _id == "${id}"]{
337334
_id,
338335
title,
339-
gradingSections[]->|order(order){
336+
"gradingSections": *[_type == "gradingSection" && references(^._id)]|order(order){
340337
title,
341338
_id,
342-
requirements[]->|order(order){
339+
"requirements": *[_type == "requirement" && references(^._id)]|order(order){
343340
title,
344341
_id,
345342
isExceeds,
@@ -351,7 +348,7 @@ tdList.addEventListener('click', e => {
351348
fetch(SINGLE_PROJECT_URL)
352349
.then(response => response.json())
353350
.then(data => {
354-
console.log(data);
351+
console.log(data.result);
355352
loadProjectRequirements(data.result);
356353
})
357354
}

0 commit comments

Comments
 (0)