Skip to content

Commit

Permalink
fuck linter bro
Browse files Browse the repository at this point in the history
  • Loading branch information
mateusbrg committed Dec 6, 2024
1 parent 335b5aa commit 749f0ae
Show file tree
Hide file tree
Showing 4 changed files with 74 additions and 66 deletions.
8 changes: 0 additions & 8 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 13 additions & 9 deletions src/entrypoints/matricula.content/UFABC-Matricula.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -23,6 +24,7 @@ const showWarning = ref(false);
const teachers = ref(false);
const { state: student } = useStorage<Student>('local:student');
const { state: matriculaStudent } = useStorage<UFABCMatriculaStudent>(`sync:${student.value?.ra}`)
const campusFilters = ref<Filter[]>([
{
Expand Down Expand Up @@ -102,6 +104,7 @@ function closeKicksModal() {
kicksModal.value.corteId = null;
}
// todo: utilizar o storage da extensão
function changeSelected() {
const notSelected = document.querySelectorAll<HTMLTableCaptionElement>('.notSelecionada')
if (!selected.value) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand Down
108 changes: 60 additions & 48 deletions src/entrypoints/matricula.content/index.ts
Original file line number Diff line number Diff line change
@@ -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<Student>('local:student')
const ufabcMatriculaStudent = await storage.getItem<UFABCMatriculaStudent>(`sync:${student?.ra}`)

const ui = await mountUFABCMatriculaFilters(ctx, ufabcMatriculaStudent);
ui.mount();
async main(ctx) {
const student = await storage.getItem<Student>('local:student');
const ufabcMatriculaStudent = await storage.getItem<UFABCMatriculaStudent>(
`sync:${student?.ra}`,
);

const $meio = document.querySelector<HTMLDivElement>("#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<HTMLDivElement>('#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();
},
Expand Down
2 changes: 1 addition & 1 deletion src/services/next.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ export async function getTeacherReviews(teacherId: string) {
}

export async function getComponents() {
const components = nextService<Component[]>('/entities/components')
const components = await nextService<Component[]>('/entities/components')
return components;
}

Expand Down

0 comments on commit 749f0ae

Please sign in to comment.