From 749f0ae6010735aa42b7a7df815e5e036e0d16d8 Mon Sep 17 00:00:00 2001 From: Mateus Braga Date: Fri, 6 Dec 2024 00:55:50 -0300 Subject: [PATCH] fuck linter bro --- pnpm-lock.yaml | 8 -- .../matricula.content/UFABC-Matricula.vue | 22 ++-- src/entrypoints/matricula.content/index.ts | 108 ++++++++++-------- src/services/next.ts | 2 +- 4 files changed, 74 insertions(+), 66 deletions(-) diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index d8b8c70..ba39573 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,9 +8,6 @@ importers: .: dependencies: - '@formkit/drag-and-drop': - specifier: ^0.2.5 - version: 0.2.5 '@vueuse/core': specifier: ^11.1.0 version: 11.2.0(vue@3.5.13(typescript@5.6.3)) @@ -380,9 +377,6 @@ packages: '@floating-ui/utils@0.2.8': resolution: {integrity: sha512-kym7SodPp8/wloecOpcmSnWJsK7M0E5Wg8UcFA+uO4B9s5d0ywXOEro/8HM9x0rW+TljRzul/14UYz3TleT3ig==} - '@formkit/drag-and-drop@0.2.5': - resolution: {integrity: sha512-J4VQLuuV4cnZGacndHOpAhaoH19ofrh0lZ6IOC1xS4mTJsr8LA0634nwwsKwafEWQ4P3j2SJ+5D8Izmt8nEkfQ==} - '@isaacs/cliui@8.0.2': resolution: {integrity: sha512-O8jcjabXaleOG9DQ0+ARXWZBTfnP4WNAqzuiJK7ll44AmxGKv/J2M4TPjxjY3znBCfvBXFzucm1twdyFybFqEA==} engines: {node: '>=12'} @@ -3131,8 +3125,6 @@ snapshots: '@floating-ui/utils@0.2.8': {} - '@formkit/drag-and-drop@0.2.5': {} - '@isaacs/cliui@8.0.2': dependencies: string-width: 5.1.2 diff --git a/src/entrypoints/matricula.content/UFABC-Matricula.vue b/src/entrypoints/matricula.content/UFABC-Matricula.vue index bf504c6..a598d39 100644 --- a/src/entrypoints/matricula.content/UFABC-Matricula.vue +++ b/src/entrypoints/matricula.content/UFABC-Matricula.vue @@ -5,6 +5,7 @@ import { getComponents } from '@/services/next'; import { render } from 'vue'; import type { Student } from '@/scripts/sig/homepage'; import SubjectReview from '@/components/SubjectReview.vue'; +import type { UFABCMatriculaStudent } from '.'; type Filter = { @@ -23,6 +24,7 @@ const showWarning = ref(false); const teachers = ref(false); const { state: student } = useStorage('local:student'); +const { state: matriculaStudent } = useStorage(`sync:${student.value?.ra}`) const campusFilters = ref([ { @@ -102,6 +104,7 @@ function closeKicksModal() { kicksModal.value.corteId = null; } +// todo: utilizar o storage da extensão function changeSelected() { const notSelected = document.querySelectorAll('.notSelecionada') if (!selected.value) { @@ -111,14 +114,15 @@ function changeSelected() { return; } - const studentId = getStudentId() - if (!studentId) { + if (!matriculaStudent.value) { console.log('show some message to the user') return } + console.log('matriculaStudent.value', matriculaStudent.value); + console.log('matriculas', matriculas); - const enrollments = matriculas?.[studentId] || [] + const enrollments = matriculas?.[matriculaStudent.value.studentId] || [] const tableRows = document.querySelectorAll('tr') for (const $row of tableRows) { @@ -285,12 +289,12 @@ async function buildComponents() { onMounted(async () => { document.body.addEventListener("click", handleClick); - const studentId = getStudentId() - const graduationId = getStudentCourseId() - await storage.setItem(`sync:${student.value?.ra}`, { - studentId, - graduationId, - }) + // const studentId = getStudentId() + // const graduationId = getStudentCourseId() + // await storage.setItem(`sync:${student.value?.ra}`, { + // studentId, + // graduationId, + // }) teachers.value = true; await buildComponents(); diff --git a/src/entrypoints/matricula.content/index.ts b/src/entrypoints/matricula.content/index.ts index 150c221..8c94c33 100644 --- a/src/entrypoints/matricula.content/index.ts +++ b/src/entrypoints/matricula.content/index.ts @@ -1,76 +1,88 @@ -import { getUFComponents, getUFEnrolled } from "@/services/ufabc-parser"; -import UFABCMatricula from "@/entrypoints/matricula.content/UFABC-Matricula.vue"; -import HighchartsVue from "highcharts-vue"; -import Highcharts from "highcharts"; +import { getUFComponents, getUFEnrolled } from '@/services/ufabc-parser'; +import UFABCMatricula from '@/entrypoints/matricula.content/UFABC-Matricula.vue'; +import HighchartsVue from 'highcharts-vue'; +import Highcharts from 'highcharts'; // import annotationsInit from "highcharts/modules/annotations"; // 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 './style.css' +import Highcharts3D from 'highcharts/highcharts-3d'; +import type { Student } from '@/scripts/sig/homepage'; +import type { ContentScriptContext } from 'wxt/client'; +import './style.css'; export type UFABCMatriculaStudent = { - studentId: number - graduationId: string -} + studentId: number; + graduationId: string; +}; export default defineContentScript({ - async main(ctx) { - const student = await storage.getItem('local:student') - const ufabcMatriculaStudent = await storage.getItem(`sync:${student?.ra}`) - - const ui = await mountUFABCMatriculaFilters(ctx, ufabcMatriculaStudent); - ui.mount(); + async main(ctx) { + const student = await storage.getItem('local:student'); + const ufabcMatriculaStudent = await storage.getItem( + `sync:${student?.ra}`, + ); - const $meio = document.querySelector("#meio"); - const $mountedUi = $meio?.firstChild as unknown as HTMLDivElement; + const ui = await mountUFABCMatriculaFilters(ctx, ufabcMatriculaStudent); + ui.mount(); - $mountedUi.style.position = "sticky"; - $mountedUi.style.top = "0px"; - $mountedUi.style.zIndex = "9"; + const $meio = document.querySelector('#meio'); + const $mountedUi = $meio?.firstChild as unknown as HTMLDivElement; - // TODO(Joabesv): create student here - console.log(student, ufabcMatriculaStudent) + $mountedUi.style.position = 'sticky'; + $mountedUi.style.top = '0px'; + $mountedUi.style.zIndex = '9'; - }, - runAt: "document_end", - cssInjectionMode: 'ui', - matches: ["https://ufabc-matricula-snapshot.vercel.app/*", 'https://api.ufabcnext.com/snapshot', 'https://matricula.ufabc.edu.br/matricula'], -}) + // TODO(Joabesv): create student here + console.log(student, ufabcMatriculaStudent); + }, + runAt: 'document_end', + cssInjectionMode: 'ui', + matches: [ + 'https://ufabc-matricula-snapshot.vercel.app/*', + 'https://api.ufabcnext.com/snapshot', + 'https://matricula.ufabc.edu.br/matricula', + ], +}); -async function mountUFABCMatriculaFilters(ctx: ContentScriptContext, student: UFABCMatriculaStudent | null) { +async function mountUFABCMatriculaFilters( + ctx: ContentScriptContext, + student: UFABCMatriculaStudent | null, +) { return createShadowRootUi(ctx, { - name: "matriculas-filter", - position: "inline", - anchor: "#meio", - append: "first", + name: 'matriculas-filter', + position: 'inline', + anchor: '#meio', + append: 'first', async onMount(container, shadow, _shadowhost) { - const wrapper = document.createElement("div"); - container.append(wrapper); + const wrapper = document.createElement('div'); + container.append(wrapper); - // accessibility(Highcharts); + // accessibility(Highcharts); // annotationsInit(Highcharts) - // Highcharts3D(Highcharts); + // Highcharts3D(Highcharts); + await storage.setItem('sync:11202231117', { + studentId: 551100, + graduationId: 74, + }); - if (!student) { - return; - } + if (!student) { + return; + } - const matriculas = await getUFEnrolled(); - window.matriculas = matriculas; + const matriculas = await getUFEnrolled(); + window.matriculas = matriculas; - const app = createApp(UFABCMatricula); - app.provide("matriculas", window.matriculas); - app.provide('student', student) + const app = createApp(UFABCMatricula); + app.provide('matriculas', window.matriculas); + app.provide('student', student); - app.use(HighchartsVue); + app.use(HighchartsVue); app.mount(wrapper); return { app, wrapper }; }, async onRemove(mounted) { - const resolvedMounted = await mounted; + const resolvedMounted = await mounted; resolvedMounted?.app.unmount(); resolvedMounted?.wrapper.remove(); }, diff --git a/src/services/next.ts b/src/services/next.ts index 662f9b5..93693ce 100644 --- a/src/services/next.ts +++ b/src/services/next.ts @@ -175,7 +175,7 @@ export async function getTeacherReviews(teacherId: string) { } export async function getComponents() { - const components = nextService('/entities/components') + const components = await nextService('/entities/components') return components; }