Skip to content

Commit

Permalink
chore: run lint
Browse files Browse the repository at this point in the history
  • Loading branch information
Joabesv committed Jun 15, 2024
1 parent cc43a66 commit 716155b
Show file tree
Hide file tree
Showing 29 changed files with 1,338 additions and 1,160 deletions.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"formatter": {
"jsxQuoteStyle": "double",
"quoteProperties": "asNeeded",
"trailingComma": "all",
"trailingCommas": "all",
"semicolons": "always",
"arrowParentheses": "always",
"bracketSpacing": true,
Expand Down
267 changes: 139 additions & 128 deletions src/components/Modal.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,169 +115,180 @@
</el-dialog>
</template>
<script>
import _ from 'lodash'
import draggable from 'vuedraggable'
import { NextAPI } from '../services/NextAPI'
import matriculaUtils from '../utils/Matricula'
import { convertDisciplina } from '../utils/convertUfabcDisciplina'
import { findSeasonKey, findIdeais } from '../utils/season'
import _ from 'lodash';
import draggable from 'vuedraggable';
import { NextAPI } from '../services/NextAPI';
import matriculaUtils from '../utils/Matricula';
import { convertDisciplina } from '../utils/convertUfabcDisciplina';
import { findSeasonKey, findIdeais } from '../utils/season';
const nextApi = NextAPI();
const nextApi = NextAPI();
export default {
name: 'Modal',
props: ['value'],
components: {
draggable,
},
data() {
return {
loading: false,
disciplina: {},
headers: [],
export default {
name: 'Modal',
props: ['value'],
components: {
draggable,
},
data() {
return {
loading: false,
disciplina: {},
kicksData: [],
}
},
headers: [],
created() {
this.fetch()
},
kicksData: [],
};
},
watch: {
'value.dialog'(v) {
this.restore()
},
created() {
this.fetch();
},
'value.corte_id'(val){
this.disciplina = _.find(todasDisciplinas, { id: parseInt(val) })
this.headers = this.defaultHeaders
this.fetch()
},
watch: {
'value.dialog'(v) {
this.restore();
},
computed: {
transformed() {
return this.kicksData.map(d => {
return _.assign(_.clone(d), {
reserva: d.reserva ? 'Sim' : 'Não',
ik: d.ik.toFixed(3)
})
})
},
'value.corte_id'(val) {
this.disciplina = _.find(todasDisciplinas, { id: parseInt(val) });
this.headers = this.defaultHeaders;
this.fetch();
},
},
defaultHeaders() {
let isIdeal = findIdeais().includes(this.disciplina.codigo)
computed: {
transformed() {
return this.kicksData.map((d) => {
return _.assign(_.clone(d), {
reserva: d.reserva ? 'Sim' : 'Não',
ik: d.ik.toFixed(3),
});
});
},
const base = [
{ text: 'Reserva', sortable: false, value: 'reserva' },
{ text: 'Turno', value: 'turno', sortable: false },
{ text: 'Ik', value: 'ik', sortable: false },
]
defaultHeaders() {
let isIdeal = findIdeais().includes(this.disciplina.codigo);
const season = findSeasonKey()
const base = [
{ text: 'Reserva', sortable: false, value: 'reserva' },
{ text: 'Turno', value: 'turno', sortable: false },
{ text: 'Ik', value: 'ik', sortable: false },
];
if(isIdeal && (season != '2020:3' || season != '2021:1' || season != '2021:2')) {
base.push({ text: 'CR', value: 'cr', sortable: false })
base.push({ text: 'CP', value: 'cp', sortable: false })
} else {
base.push({ text: 'CP', value: 'cp', sortable: false })
base.push({ text: 'CR', value: 'cr', sortable: false })
}
const season = findSeasonKey();
return base
},
if (
isIdeal &&
(season != '2020:3' || season != '2021:1' || season != '2021:2')
) {
base.push({ text: 'CR', value: 'cr', sortable: false });
base.push({ text: 'CP', value: 'cp', sortable: false });
} else {
base.push({ text: 'CP', value: 'cp', sortable: false });
base.push({ text: 'CR', value: 'cr', sortable: false });
}
getRequests() {
return _.reduce(matriculas, (a, c) => c.includes(this.disciplina.id.toString()) ? a + 1 : a, 0)
},
return base;
},
computeKicksForecast() {
return (this.kicksData.length * this.disciplina.vagas) / this.getRequests
},
getRequests() {
return _.reduce(
matriculas,
(a, c) => (c.includes(this.disciplina.id.toString()) ? a + 1 : a),
0,
);
},
parsedDisciplina() {
return convertDisciplina(this.disciplina)
}
computeKicksForecast() {
return (this.kicksData.length * this.disciplina.vagas) / this.getRequests;
},
parsedDisciplina() {
return convertDisciplina(this.disciplina);
},
},
methods: {
fetch() {
let corteId = _.get(this.value, 'corte_id', '')
if(!corteId) return
const aluno_id = matriculaUtils.getAlunoId()
methods: {
fetch() {
let corteId = _.get(this.value, 'corte_id', '');
if (!corteId) return;
const aluno_id = matriculaUtils.getAlunoId();
this.loading = true
this.loading = true;
nextApi.get(`/disciplinas/${corteId}/kicks?aluno_id=${aluno_id}`).then((res) => {
this.kicksData = res
this.resort()
this.loading = false
}).catch((e) => {
this.loading = false
nextApi
.get(`/disciplinas/${corteId}/kicks?aluno_id=${aluno_id}`)
.then((res) => {
this.kicksData = res;
this.resort();
this.loading = false;
})
.catch((e) => {
this.loading = false;
if(e && e.name == 'Forbidden') {
if (e && e.name == 'Forbidden') {
// Show dialog with error
this.$notify({
message: 'Não temos as diciplinas que você cursou, acesse o Portal do Aluno'
})
message:
'Não temos as diciplinas que você cursou, acesse o Portal do Aluno',
});
}
})
},
});
},
resort(e) {
const sortOrder = _.map(this.headers, 'value')
const sortRef = Array(sortOrder.length || 0).fill('desc')
resort(e) {
const sortOrder = _.map(this.headers, 'value');
const sortRef = Array(sortOrder.length || 0).fill('desc');
const turnoIndex = sortOrder.indexOf('turno')
if(turnoIndex != -1) {
sortRef[turnoIndex] = (this.parsedDisciplina.turno == 'diurno') ? 'asc' : 'desc'
}
const turnoIndex = sortOrder.indexOf('turno');
if (turnoIndex != -1) {
sortRef[turnoIndex] =
this.parsedDisciplina.turno == 'diurno' ? 'asc' : 'desc';
}
this.kicksData = _.orderBy(this.kicksData, sortOrder, sortRef)
},
this.kicksData = _.orderBy(this.kicksData, sortOrder, sortRef);
},
removedFilter(value) {
this.headers = _.filter(this.headers, o => o.value != value)
this.resort()
},
removedFilter(value) {
this.headers = _.filter(this.headers, (o) => o.value != value);
this.resort();
},
restore() {
this.headers = this.defaultHeaders
this.resort()
},
restore() {
this.headers = this.defaultHeaders;
this.resort();
},
closeDialog(){
this.value.dialog = false
},
closeDialog() {
this.value.dialog = false;
},
// kickStatus(rowIndex) {
// console.log("rowIndex", rowIndex)
// console.log("this.computeKicksForecast", this.computeKicksForecast)
// if(rowIndex <= this.computeKicksForecast) {
// return 'not-kicked'
// }else if(rowIndex >= this.disciplina.vagas){
// return 'kicked'
// }else {
// return 'probably-kicked'
// }
// },
// kickStatus(rowIndex) {
// console.log("rowIndex", rowIndex)
// console.log("this.computeKicksForecast", this.computeKicksForecast)
// if(rowIndex <= this.computeKicksForecast) {
// return 'not-kicked'
// }else if(rowIndex >= this.disciplina.vagas){
// return 'kicked'
// }else {
// return 'probably-kicked'
// }
// },
tableRowClassName({row, rowIndex}) {
if (row.aluno_id == matriculaUtils.getAlunoId()) {
return 'aluno-row'
} else if(rowIndex <= this.computeKicksForecast) {
return 'not-kicked-row'
}else if(rowIndex >= this.disciplina.vagas){
return 'kicked-row'
}else {
return 'probably-kicked-row'
}
tableRowClassName({ row, rowIndex }) {
if (row.aluno_id == matriculaUtils.getAlunoId()) {
return 'aluno-row';
} else if (rowIndex <= this.computeKicksForecast) {
return 'not-kicked-row';
} else if (rowIndex >= this.disciplina.vagas) {
return 'kicked-row';
} else {
return 'probably-kicked-row';
}
},
}
},
};
</script>
<style scoped>
.information {
Expand Down
Loading

0 comments on commit 716155b

Please sign in to comment.