From f5592c8bfdb6132182ff5d521847a70c0a292e9b Mon Sep 17 00:00:00 2001 From: Tomasz Date: Sun, 7 Feb 2021 21:31:37 +0100 Subject: [PATCH] Getting data --- frontend/src/components/API/attendance.tsx | 17 +++++++++++++++++ frontend/src/components/API/exams.tsx | 17 +++++++++++++++++ frontend/src/components/API/homeworks.tsx | 17 +++++++++++++++++ frontend/src/components/API/notes.tsx | 17 +++++++++++++++++ frontend/src/components/API/schoolData.tsx | 17 +++++++++++++++++ frontend/src/components/API/stats.tsx | 4 ++++ frontend/src/components/API/studentData.tsx | 17 +++++++++++++++++ 7 files changed, 106 insertions(+) diff --git a/frontend/src/components/API/attendance.tsx b/frontend/src/components/API/attendance.tsx index c952ecd..5d8e354 100644 --- a/frontend/src/components/API/attendance.tsx +++ b/frontend/src/components/API/attendance.tsx @@ -1,6 +1,23 @@ import React, { Component } from 'react'; class AttendanceCom extends Component { + constructor(props) { + super(props); + var cookies_data = sessionStorage.getItem('cookies_data'); + var csrfcookie_ = sessionStorage.getItem('csrfcookie'); + fetch('../api/attendance', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': csrfcookie_ + }, + body: JSON.stringify({"cookies": cookies_data, "week": 0}) + }).then(response => response.json()).then(data => { + console.log(data); + }) + } + render() { return (

Attendance

diff --git a/frontend/src/components/API/exams.tsx b/frontend/src/components/API/exams.tsx index bbb9b19..feb7434 100644 --- a/frontend/src/components/API/exams.tsx +++ b/frontend/src/components/API/exams.tsx @@ -1,6 +1,23 @@ import React, { Component } from 'react'; class ExamsCom extends Component { + constructor(props) { + super(props); + var cookies_data = sessionStorage.getItem('cookies_data'); + var csrfcookie_ = sessionStorage.getItem('csrfcookie'); + fetch('../api/exams', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': csrfcookie_ + }, + body: JSON.stringify({"cookies": cookies_data, "week": 0}) + }).then(response => response.json()).then(data => { + console.log(data) + }) + } + render() { return (

Exams

diff --git a/frontend/src/components/API/homeworks.tsx b/frontend/src/components/API/homeworks.tsx index e666f05..288d1ba 100644 --- a/frontend/src/components/API/homeworks.tsx +++ b/frontend/src/components/API/homeworks.tsx @@ -1,6 +1,23 @@ import React, { Component } from 'react'; class HomeworksCom extends Component { + constructor(props) { + super(props); + var cookies_data = sessionStorage.getItem('cookies_data'); + var csrfcookie_ = sessionStorage.getItem('csrfcookie'); + fetch('../api/homeworks', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': csrfcookie_ + }, + body: JSON.stringify({"cookies": cookies_data, "week": 0}) + }).then(response => response.json()).then(data => { + console.log(data); + }) + } + render() { return (

Homeworks

diff --git a/frontend/src/components/API/notes.tsx b/frontend/src/components/API/notes.tsx index 364695d..0faafe3 100644 --- a/frontend/src/components/API/notes.tsx +++ b/frontend/src/components/API/notes.tsx @@ -1,6 +1,23 @@ import React, { Component } from 'react'; class NotesCom extends Component { + constructor(props) { + super(props); + var cookies_data = sessionStorage.getItem('cookies_data'); + var csrfcookie_ = sessionStorage.getItem('csrfcookie'); + fetch('../api/notes', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': csrfcookie_ + }, + body: cookies_data + }).then(response => response.json()).then(data => { + console.log(data); + }) + } + render() { return (

Notes

diff --git a/frontend/src/components/API/schoolData.tsx b/frontend/src/components/API/schoolData.tsx index 1b2c6d2..f96166e 100644 --- a/frontend/src/components/API/schoolData.tsx +++ b/frontend/src/components/API/schoolData.tsx @@ -1,6 +1,23 @@ import React, { Component } from 'react'; class SchoolDataCom extends Component { + constructor(props) { + super(props); + var cookies_data = sessionStorage.getItem('cookies_data'); + var csrfcookie_ = sessionStorage.getItem('csrfcookie'); + fetch('../api/school_data', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': csrfcookie_ + }, + body: cookies_data + }).then(response => response.json()).then(data => { + console.log(data); + }) + } + render() { return (

School Data

diff --git a/frontend/src/components/API/stats.tsx b/frontend/src/components/API/stats.tsx index e43afb3..ae579e5 100644 --- a/frontend/src/components/API/stats.tsx +++ b/frontend/src/components/API/stats.tsx @@ -1,6 +1,10 @@ import React, { Component } from 'react'; class StatsCom extends Component { + constructor(props) { + super(props); + } + render() { return (

Stats

diff --git a/frontend/src/components/API/studentData.tsx b/frontend/src/components/API/studentData.tsx index db0bd63..27c8544 100644 --- a/frontend/src/components/API/studentData.tsx +++ b/frontend/src/components/API/studentData.tsx @@ -1,6 +1,23 @@ import React, { Component } from 'react'; class StudentDataCom extends Component { + constructor(props) { + super(props); + var cookies_data = sessionStorage.getItem('cookies_data'); + var csrfcookie_ = sessionStorage.getItem('csrfcookie'); + fetch('../api/student_data', { + method: 'POST', + mode: 'cors', + headers: { + 'Content-Type': 'application/json', + 'X-CSRFToken': csrfcookie_ + }, + body: cookies_data + }).then(response => response.json()).then(data => { + console.log(data) + }) + } + render() { return (

Student Data