Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Commit

Permalink
fix: year modal
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKanera committed Dec 2, 2020
1 parent a0cd08e commit 70ad231
Show file tree
Hide file tree
Showing 7 changed files with 26 additions and 62 deletions.
2 changes: 0 additions & 2 deletions components/proposal-form/proposal-form.vue
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,6 @@ export default defineComponent({
teacherId: selectedTeacherId.value,
};
console.log(proposal);
if (studentsProjectTitle.value !== '') proposal = { ...proposal, ...{ title: studentsProjectTitle.value } };
const collectionRef = firebase.firestore().collection('proposals');
Expand Down
4 changes: 1 addition & 3 deletions components/teacher-project/teacher-project.vue
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,7 @@ export default defineComponent({
reviewDelete.value = false;
};
const unreviewed = computed(() => props.teacher && props.opponent && props.reviews.length < 4) || props.teacher || (props.opponent && props.reviews.length < 2);
console.log(unreviewed.value);
const unreviewed = computed(() => props.teacher && props.opponent && props.reviews.length < 4) || ((props.teacher || props.opponent) && props.reviews.length < 2);
return {
displayModal,
Expand Down
2 changes: 1 addition & 1 deletion components/ui/search-bar/search-bar.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<template lang="pug">
input(type='text', @input='onChange($event.target.value)', placeholder='Zační psát...')
input(type='text', @input='onChange($event.target.value)', placeholder='Jméno projektu')
</template>

<script lang="ts">
Expand Down
34 changes: 5 additions & 29 deletions keywords.js
Original file line number Diff line number Diff line change
@@ -1,30 +1,11 @@
const projectName = 'Úložiště maturitních projektů';
const projectName = 'Úložiště maturitních projektů kekw';
const displayName = 'Martin Kaněra';

const fs = require('fs');

const charLimit = 10;

const generateKeywords = (string) => {
const resultArr = [];
let currentString = '';

string.split('').forEach((letter) => {
currentString += letter;
resultArr.push(currentString);
});

// for (let i = 0; i < charLimit; i++) {
// currentString += string[i];
// resultArr.push(currentString);
// }

return resultArr;
};

function permute(permutation) {
const length = permutation.length;
const result = [permutation.slice()];
const result = permutation.slice();
const c = new Array(length).fill(0);
let i = 1;
let k;
Expand All @@ -38,7 +19,7 @@ function permute(permutation) {
permutation[k] = p;
++c[i];
i = 1;
result.push(permutation.slice());
result.push(permutation.slice().join(' '));
} else {
c[i] = 0;
++i;
Expand All @@ -47,13 +28,8 @@ function permute(permutation) {
return result;
}

let finalProduct = [];
const names = `${displayName} ${projectName}`.split(' ');

const cases = permute(names);
cases.forEach((nameCase) => {
finalProduct = [...finalProduct, ...generateKeywords(nameCase.join(' '))];
});
fs.writeFileSync('keywords.txt', permute(names));

// fs.writeFileSync('keywords.text', finalProduct);
console.log(finalProduct);
// console.log(permute(names).length);
23 changes: 6 additions & 17 deletions pages/index.vue
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
<template lang="pug">
.page
ps-modal(:value='yearModalDisplay && !closeModal', :disabled='true')
ps-modal(:value='yearModalDisplay', :disabled='true')
span.text-ps-white.text-2xl Kdy maturuješ?
.form.mt-4
ps-select.flex-grow.md-mr-6(v-model='currentYear', placeholder='Rok maturity', :options='graduationYears')
ps-btn.mt-4.float-right(:disabled='btnLoading', :loading='btnLoading', @click='sumbitSchoolYear')
span.px-10 uložit
ps-search-bar(v-model='kekw')
</template>

<script lang="ts">
Expand All @@ -23,20 +22,20 @@ export default defineComponent({
setup() {
const mainStore = useMainStore();
const graduationYears = ref([] as Array<{ placeholder: Number; value: Number }>);
const graduationYears = ref([] as Array<{ placeholder: String; value: String }>);
const yearModalDisplay = computed(() => mainStore.state.user.currentYear === null && mainStore.isLoggedIn && mainStore.isStudent);
const yearModalDisplay = computed(() => mainStore.state.user.currentYear === null && mainStore.isLoggedIn.value && mainStore.isStudent.value);
for (let i = 1; i < 5; i++) {
const year = new Date().getFullYear() + i;
const year = (new Date().getFullYear() + i).toString();
graduationYears.value.push({
placeholder: year,
value: year,
});
}
const currentYear = ref(0);
const currentYear = ref('');
const btnDisabled = ref(false);
const btnLoading = ref(false);
Expand All @@ -45,8 +44,6 @@ export default defineComponent({
btnDisabled.value = !graduationYears.value.some((year) => Number(year.value) === Number(currentYear.value));
});
const closeModal = ref(false);
const sumbitSchoolYear = async () => {
if (!graduationYears.value.some((year) => Number(year.value) === Number(currentYear.value))) return;
Expand All @@ -66,26 +63,18 @@ export default defineComponent({
).data;
await mainStore.patch({ user: { currentYear: setTimestamp } });
closeModal.value = true;
} catch (_) {}
btnLoading.value = false;
};
const kekw = ref('');
watchEffect(() => console.log(kekw.value));
return {
yearModalDisplay: yearModalDisplay.value,
yearModalDisplay,
currentYear,
graduationYears,
btnDisabled,
sumbitSchoolYear,
btnLoading,
closeModal,
kekw,
};
},
});
Expand Down
20 changes: 12 additions & 8 deletions server/api/teacher/list.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,14 +26,18 @@ export default async (req: Request, res: Response) => {
// Teacher cant submit proposal
if (userData?.teacher) return res.status(403).send('Teacher cannot submit proposal');

const teachersData = (await admin.firestore().collection('users').where('teacher', '==', true).get()).docs;
try {
const teachersData = (await admin.firestore().collection('users').where('teacher', '==', true).where('extern', '==', false).where('deleted', '==', false).get()).docs;

const teachersList = teachersData.map((teacherDoc) => {
return {
placeholder: teacherDoc.data().displayName,
value: teacherDoc.id,
};
});
const teachersList = teachersData.map((teacherDoc) => {
return {
placeholder: teacherDoc.data().displayName,
value: teacherDoc.id,
};
});

return res.status(200).json(teachersList);
return res.status(200).json(teachersList);
} catch (e) {
return res.status(500).send(e);
}
};
3 changes: 1 addition & 2 deletions server/api/user/create-user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export default async (req: Request, res: Response) => {
profilePicture: await saveProfileImage(userData.uid),
admin: false,
deleted: false,
extern: false,
student: userData.email?.includes('delta-studenti'),
teacher: userData.email?.includes('delta-skola'),
currentYear: null,
Expand Down Expand Up @@ -82,8 +83,6 @@ export default async (req: Request, res: Response) => {
});
} catch (_) {}

console.log(responseData);

return res.status(200).send(responseData);
} catch (e) {
return res.status(400).send('Bad request');
Expand Down

0 comments on commit 70ad231

Please sign in to comment.