diff --git a/frontend/src/store/modules/student-page.js b/frontend/src/store/modules/student-page.js new file mode 100644 index 0000000000000000000000000000000000000000..8d593808f718bc8b4814d0789546439c7950619c --- /dev/null +++ b/frontend/src/store/modules/student-page.js @@ -0,0 +1,36 @@ +import ax from '../api' + +const studentPage = { + state: { + studentName: '', + exam: {}, + submissionTypes: [], + submissions: [] + }, + mutations: { + 'SET_STUDENT_NAME': function (state, name) { + state.studentName = name + }, + 'SET_EXAM': function (state, exam) { + state.exam = exam + }, + 'SET_SUBMISSION_TYPES': function (state, submissionTypes) { + state.submissionTypes = submissionTypes + }, + 'SET_SUBMISSIONS': function (state, submissions) { + state.submissions = submissions + } + }, + actions: { + getStudentData (context) { + ax.get('api/student-page/').then(response => { + const data = response.data + context.commit('SET_STUDENT_NAME', data.name) + context.commit('SET_EXAM', data.exam) + context.commit('SET_SUBMISSIONS', data.submissions) + }) + } + } +} + +export default studentPage diff --git a/frontend/src/store/store.js b/frontend/src/store/store.js index 59525d1c5b1f1c7c85db494f10dd8d51ac536c3d..6e8e49129b4f320b19bfe24173b5000179e37ddd 100644 --- a/frontend/src/store/store.js +++ b/frontend/src/store/store.js @@ -4,12 +4,14 @@ import ax from './api' import gradySays from './grady_speak' import submissionNotes from './modules/submission-notes' +import studentPage from './modules/student-page' Vue.use(Vuex) const store = new Vuex.Store({ modules: { - submissionNotes: submissionNotes + submissionNotes, + studentPage }, state: { token: '',