Skip to content

Commit 876a78c

Browse files
committed
use explorer V2
1 parent 581879f commit 876a78c

File tree

13 files changed

+617
-266
lines changed

13 files changed

+617
-266
lines changed

app.vue

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@
102102
<div
103103
class="flx --flxRow --flx-center --gap-10 --txtSize-xs"
104104
>
105-
<template v-if="APP.instance?.config?.version">
105+
<template v-if="APP.config?.version">
106106
<span>{{ APP.instance.config.version }}</span>
107107
108108
</template>
@@ -127,9 +127,7 @@
127127
</p>
128128
<p
129129
class="--txtSize-xs --txtColor-dark5"
130-
:title="
131-
APP.instance?.config?.siaMaintenanceTillAt?.toString()
132-
"
130+
:title="APP.config?.siaMaintenanceTillAt?.toString()"
133131
>
134132
Volveremos a la normalidad {{ SIAMaintenanceTillAt }}.
135133
</p>
@@ -194,17 +192,17 @@
194192
195193
const isAdmin = computed(() => route.path.startsWith("/administrar"));
196194
const SIAMaintenanceTillAt = computed(() => {
197-
const date = new Date(APP.instance?.config?.siaMaintenanceTillAt || new Date());
195+
const date = new Date(APP.config?.siaMaintenanceTillAt || new Date());
198196
199197
return useTimeAgo(date);
200198
});
201199
const ExplorerV1MaintenanceTillAt = computed(() => {
202-
const date = new Date(APP.instance?.config?.explorerV1MaintenanceTillAt || new Date());
200+
const date = new Date(APP.config?.explorerV1MaintenanceTillAt || new Date());
203201
204202
return useTimeAgo(date);
205203
});
206204
const ExplorerV2MaintenanceTillAt = computed(() => {
207-
const date = new Date(APP.instance?.config?.explorerV2MaintenanceTillAt || new Date());
205+
const date = new Date(APP.config?.explorerV2MaintenanceTillAt || new Date());
208206
209207
return useTimeAgo(date);
210208
});

components/searchCourse.vue

Lines changed: 7 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@
1414
<div class="txt">
1515
<div>
1616
<h3>
17-
Resultados de la busqueda
17+
Resultados de la búsqueda
1818
<template v-if="lastSearch?.name || lastSearch?.code">
1919
de "{{ lastSearch?.name || lastSearch?.code }}"
2020
</template>
2121
:
2222
</h3>
23-
<p class="--txtSize-xs">Datos obtenidos del buscador del SIA (Beta).</p>
23+
<p class="--txtSize-xs">Datos obtenidos del explorador de cursos.</p>
2424
</div>
2525
<p>
2626
{{ untrackedCurrentPage.totalRecords }} resultados. Pagina
@@ -125,11 +125,7 @@
125125
import { XamuBaseAction } from "#components";
126126
import type { Course } from "~/resources/types/entities";
127127
import type { CourseValues } from "~/resources/types/values";
128-
import {
129-
eSIATypology,
130-
type CoursesResponse,
131-
type uSIAProgram,
132-
} from "~/functions/src/types/SIA";
128+
import { type CoursesResponse } from "~/functions/src/types/SIA";
133129
import { getDocumentId } from "~/resources/utils/firestore";
134130
135131
/**
@@ -178,55 +174,16 @@
178174
errors.value = undefined;
179175
180176
try {
181-
const coursesPage = await useExplorerV1Courses(
182-
props.values,
183-
untrackedCurrentPage.value?.currentPage
184-
);
185-
const codes: string[] = [];
186-
const dedupedCourses: Course[] = [];
187-
188-
/**
189-
* Remove duplicates & omit courses without groups
190-
* The system return entities with the same data but differing in the internal id
191-
*/
192-
coursesPage.data.forEach(({ faculties = [], ...course }) => {
193-
if (!course.code || !course.groups?.length) return;
194-
195-
const dedupedCourseIndex = dedupedCourses.findIndex(({ id }) => id === course.id);
196-
197-
if (dedupedCourseIndex >= 0) {
198-
// merge details
199-
const dedupedCourse = dedupedCourses[dedupedCourseIndex];
200-
const uniquePrograms = [
201-
...new Set([dedupedCourse.programs, course.programs].flat()),
202-
].filter((p: uSIAProgram | undefined): p is uSIAProgram => !!p);
203-
const uniqueTypologies = [
204-
...new Set([dedupedCourse.typologies, course.typologies].flat()),
205-
].filter((p: eSIATypology | undefined): p is eSIATypology => !!p);
206-
207-
dedupedCourses[dedupedCourseIndex].programs = uniquePrograms;
208-
dedupedCourses[dedupedCourseIndex].typologies = uniqueTypologies;
209-
210-
return;
211-
}
212-
213-
// Inject faculty, that helped in search
214-
if (props.values.faculty && !faculties.includes(props.values.faculty)) {
215-
faculties.push(props.values.faculty);
216-
}
217-
218-
codes.push(course.code);
219-
dedupedCourses.push({ ...course, faculties });
220-
});
177+
const coursesPage = await useExplorerV2Courses(props.values);
221178
222179
// Refresh UI
223180
lastSearch.value = { ...props.values, page: coursesPage.currentPage };
224-
untrackedCourses.value = dedupedCourses;
181+
untrackedCourses.value = coursesPage.data;
225182
untrackedCurrentPage.value = coursesPage;
226-
savedUntrackedCourses.value[coursesPage.currentPage] = dedupedCourses;
183+
savedUntrackedCourses.value[coursesPage.currentPage] = coursesPage.data;
227184
228185
// Index course, do not await
229-
indexCourses(dedupedCourses, coursesPage);
186+
indexCourses(coursesPage.data, coursesPage);
230187
} catch (err) {
231188
useLogger("components:SearchCourse", err);
232189
errors.value = err;

components/table/TeacherItem.vue

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
const Swal = useSwal();
7070
7171
const losEstudiantesProfessors = computed(() => {
72-
const config = APP.instance?.config || {};
72+
const config = APP.config || {};
7373
const { losEstudiantesUrl = "", losEstudiantesProfessorsPath = "" } = config;
7474
7575
return `${losEstudiantesUrl}${losEstudiantesProfessorsPath}`;

composables/data.ts

Lines changed: 185 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,192 @@
11
import { deburr } from "lodash-es";
2+
import {
3+
type uSIAFaculty,
4+
type uSIAProgram,
5+
eSIAPlace,
6+
eSIABogotaFaculty,
7+
eSIABogotaProgram,
8+
eSIAMedicineBogotaProgram,
9+
eSIAVetMedicineBogotaProgram,
10+
eSIAEnfermeryBogotaProgram,
11+
eSIAArtsBogotaProgram,
12+
eSIAEngineeringBogotaProgram,
13+
eSIAOdontologyBogotaProgram,
14+
eSIALawBogotaProgram,
15+
eSIAScienceBogotaProgram,
16+
eSIAHumanScienceBogotaProgram,
17+
eSIAEconomicalScienceBogotaProgram,
18+
eSIAAgrarianScienceBogotaProgram,
19+
eSIALaPazFaculty,
20+
eSIALaPazProgram,
21+
eSIAPregradoLaPazProgram,
22+
eSIAMedellinFaculty,
23+
eSIAMedellinProgram,
24+
eSIAMinesMedellinProgram,
25+
eSIAArchitectureMedellinProgram,
26+
eSIAScienceMedellinProgram,
27+
eSIAAgrarianSciencesMedellinProgram,
28+
eSIAHumanSciencesAMedellinProgram,
29+
eSIAManizalesFaculty,
30+
eSIAManizalesProgram,
31+
eSIAEngineeringAndArchitectureManizalesProgram,
32+
eSIAExactSciencesManizalesProgram,
33+
eSIAManagementManizalesProgram,
34+
eSIAPalmiraFaculty,
35+
eSIAPalmiraProgram,
36+
eSIAAmazoniaFaculty,
37+
eSIAAmazoniaProgram,
38+
eSIACaribeFaculty,
39+
eSIACaribeProgram,
40+
eSIAOrinoquiaFaculty,
41+
eSIAOrinoquiaProgram,
42+
eSIATumacoFaculty,
43+
eSIATumacoProgram,
44+
} from "~/functions/src/types/SIA";
245

346
import type { Course, User } from "~/resources/types/entities";
447

48+
interface UNALItem {
49+
faculty: uSIAFaculty;
50+
programs: uSIAProgram[];
51+
}
52+
53+
export const UNAL: Record<eSIAPlace, UNALItem[]> = {
54+
[eSIAPlace.BOGOTÁ]: [
55+
{
56+
faculty: eSIABogotaFaculty.SEDE_BOGOTÁ,
57+
programs: Object.values(eSIABogotaProgram),
58+
},
59+
{
60+
faculty: eSIABogotaFaculty.MEDICINA,
61+
programs: Object.values(eSIAMedicineBogotaProgram),
62+
},
63+
{
64+
faculty: eSIABogotaFaculty.MEDICINA_VETERINARIA,
65+
programs: Object.values(eSIAVetMedicineBogotaProgram),
66+
},
67+
{
68+
faculty: eSIABogotaFaculty.ENFERMERÍA,
69+
programs: Object.values(eSIAEnfermeryBogotaProgram),
70+
},
71+
{
72+
faculty: eSIABogotaFaculty.ARTES,
73+
programs: Object.values(eSIAArtsBogotaProgram),
74+
},
75+
{
76+
faculty: eSIABogotaFaculty.INGENIERÍA,
77+
programs: Object.values(eSIAEngineeringBogotaProgram),
78+
},
79+
{
80+
faculty: eSIABogotaFaculty.ODONTOLOGÍA,
81+
programs: Object.values(eSIAOdontologyBogotaProgram),
82+
},
83+
{
84+
faculty: eSIABogotaFaculty.DERECHO,
85+
programs: Object.values(eSIALawBogotaProgram),
86+
},
87+
{
88+
faculty: eSIABogotaFaculty.CIENCIAS,
89+
programs: Object.values(eSIAScienceBogotaProgram),
90+
},
91+
{
92+
faculty: eSIABogotaFaculty.CIENCIAS_HUMANAS,
93+
programs: Object.values(eSIAHumanScienceBogotaProgram),
94+
},
95+
{
96+
faculty: eSIABogotaFaculty.CIENCIAS_ECONÓMICAS,
97+
programs: Object.values(eSIAEconomicalScienceBogotaProgram),
98+
},
99+
{
100+
faculty: eSIABogotaFaculty.CIENCIAS_AGRARIAS,
101+
programs: Object.values(eSIAAgrarianScienceBogotaProgram),
102+
},
103+
],
104+
[eSIAPlace.LA_PAZ]: [
105+
{
106+
faculty: eSIALaPazFaculty.SEDE_LA_PAZ,
107+
programs: Object.values(eSIALaPazProgram),
108+
},
109+
{
110+
faculty: eSIALaPazFaculty.ESCUELA_DE_PREGRADO,
111+
programs: Object.values(eSIAPregradoLaPazProgram),
112+
},
113+
],
114+
[eSIAPlace.MEDELLÍN]: [
115+
{
116+
faculty: eSIAMedellinFaculty.SEDE_MEDELLÍN,
117+
programs: Object.values(eSIAMedellinProgram),
118+
},
119+
{
120+
faculty: eSIAMedellinFaculty.FACULTAD_DE_MINAS,
121+
programs: Object.values(eSIAMinesMedellinProgram),
122+
},
123+
{
124+
faculty: eSIAMedellinFaculty.FACULTAD_DE_ARQUITECTURA,
125+
programs: Object.values(eSIAArchitectureMedellinProgram),
126+
},
127+
{
128+
faculty: eSIAMedellinFaculty.FACULTAD_DE_CIENCIAS,
129+
programs: Object.values(eSIAScienceMedellinProgram),
130+
},
131+
{
132+
faculty: eSIAMedellinFaculty.FACULTAD_DE_CIENCIAS_AGRARIAS,
133+
programs: Object.values(eSIAAgrarianSciencesMedellinProgram),
134+
},
135+
{
136+
faculty: eSIAMedellinFaculty.FACULTAD_DE_CIENCIAS_HUMANAS_Y_ECONÓMICAS_A,
137+
programs: Object.values(eSIAHumanSciencesAMedellinProgram),
138+
},
139+
],
140+
[eSIAPlace.MANIZALES]: [
141+
{
142+
faculty: eSIAManizalesFaculty.SEDE_MANIZALES,
143+
programs: Object.values(eSIAManizalesProgram),
144+
},
145+
{
146+
faculty: eSIAManizalesFaculty.FACULTAD_DE_INGENIERIA_Y_ARQUITECTURA,
147+
programs: Object.values(eSIAEngineeringAndArchitectureManizalesProgram),
148+
},
149+
{
150+
faculty: eSIAManizalesFaculty.FACULTAD_DE_CIENCIAS_EXACTAS_Y_NATURALES,
151+
programs: Object.values(eSIAExactSciencesManizalesProgram),
152+
},
153+
{
154+
faculty: eSIAManizalesFaculty.FACULTAD_DE_ADMINISTRACIÓN,
155+
programs: Object.values(eSIAManagementManizalesProgram),
156+
},
157+
],
158+
[eSIAPlace.PALMIRA]: [
159+
{
160+
faculty: eSIAPalmiraFaculty.SEDE_PALMIRA,
161+
programs: Object.values(eSIAPalmiraProgram),
162+
},
163+
],
164+
[eSIAPlace.AMAZONÍA]: [
165+
{
166+
faculty: eSIAAmazoniaFaculty.SEDE_AMAZONIA,
167+
programs: Object.values(eSIAAmazoniaProgram),
168+
},
169+
],
170+
[eSIAPlace.CARIBE]: [
171+
{
172+
faculty: eSIACaribeFaculty.SEDE_CARIBE,
173+
programs: Object.values(eSIACaribeProgram),
174+
},
175+
],
176+
[eSIAPlace.ORINOQUÍA]: [
177+
{
178+
faculty: eSIAOrinoquiaFaculty.SEDE_ORINOQUIA,
179+
programs: Object.values(eSIAOrinoquiaProgram),
180+
},
181+
],
182+
[eSIAPlace.TUMACO]: [
183+
{
184+
faculty: eSIATumacoFaculty.SEDE_TUMACO,
185+
programs: Object.values(eSIATumacoProgram),
186+
},
187+
],
188+
};
189+
5190
export function useMapUser({ role = 3, ...user }: User) {
6191
let roleName = "Invitado";
7192

0 commit comments

Comments
 (0)