Skip to content

Commit

Permalink
update studentId from ufabc matricula
Browse files Browse the repository at this point in the history
  • Loading branch information
Joabesv committed Dec 12, 2024
1 parent f8ae2a3 commit 325bae8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 19 deletions.
8 changes: 4 additions & 4 deletions src/entrypoints/matricula.content/UFABC-Matricula.vue
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,10 @@ onMounted(async () => {
document.body.addEventListener("click", handleClick);
const studentId = getStudentId()
const graduationId = getStudentCourseId()
// await storage.setItem(`sync:${student.value?.ra}`, {
// studentId,
// graduationId,
// })
await storage.setItem(`sync:${student.value?.ra}`, {
studentId,
graduationId,
})
teachers.value = true;
await buildComponents();
Expand Down
19 changes: 4 additions & 15 deletions src/entrypoints/matricula.content/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import accessibility from "highcharts/modules/accessibility";
import Highcharts3D from 'highcharts/highcharts-3d';
import type { Student } from '@/scripts/sig/homepage';
import type { ContentScriptContext } from 'wxt/client';
import { updateStudent } from '@/services/next';

export type UFABCMatriculaStudent = {
studentId: number;
Expand All @@ -18,10 +19,6 @@ export type UFABCMatriculaStudent = {
export default defineContentScript({
async main(ctx) {
const student = await storage.getItem<Student>('local:student');
await storage.setItem(`sync:${student?.ra}`, {
studentId: 557736,
graduationId: 74,
})
const ufabcMatriculaStudent = await storage.getItem<UFABCMatriculaStudent>(
`sync:${student?.ra}`,
);
Expand All @@ -37,7 +34,9 @@ export default defineContentScript({
$mountedUi.style.zIndex = '9';

// TODO(Joabesv): create student here
console.log(student, ufabcMatriculaStudent);
if (ufabcMatriculaStudent && student) {
await updateStudent(student.login, student.ra, ufabcMatriculaStudent.studentId)
}
},
runAt: 'document_end',
cssInjectionMode: 'ui',
Expand Down Expand Up @@ -65,16 +64,6 @@ async function mountUFABCMatriculaFilters(
// annotationsInit(Highcharts)
// Highcharts3D(Highcharts);

await storage.setItem('sync:11202231117', {
studentId: 551100,
graduationId: 74,
});


if (!student) {
return;
}

const matriculas = await getUFEnrolled();
window.matriculas = matriculas;

Expand Down
12 changes: 12 additions & 0 deletions src/services/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -223,3 +223,15 @@ export async function getStudent(login: string, ra: string) {

return student;
}

export async function updateStudent(login: string, ra: string, studentId: number) {
const updatedStudent = await nextService<{ msg: string }>('/entities/students', {
method: 'PUT',
body: {
login,
ra,
studentId
}
})
return updatedStudent
}

0 comments on commit 325bae8

Please sign in to comment.