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

Commit

Permalink
fix: school year
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinKanera committed Jan 7, 2021
1 parent dd7f600 commit 28d524f
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion pages/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ export default defineComponent({
const yearModalDisplay = computed(() => mainStore.state.user.currentYear === null && mainStore.isLoggedIn && mainStore.isStudent);
for (let i = 1; i < 5; i++) {
for (let i = 0; i < 5; i++) {
const year = (new Date().getFullYear() + i).toString();
console.log(year);
graduationYears.value.push({
placeholder: year,
value: year,
Expand Down
5 changes: 2 additions & 3 deletions server/api/proposal/accept.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ export default async (req: Request, res: Response) => {
try {
await admin.firestore().runTransaction(async (transaction) => {
const sfDoc = await transaction.get(proposalRef);

const schoolYear = (await transaction.get(admin.firestore().collection('system').doc('schoolYear'))).data();
const userDoc = await transaction.get(admin.firestore().collection('users').doc(sfDoc.data()?.currentYear));

const projectRef = admin.firestore().collection('projects').doc();

Expand All @@ -34,7 +33,7 @@ export default async (req: Request, res: Response) => {
studentId: sfDoc.data()?.studentId,
teacherId: sfDoc.data()?.teacherId,
opponentId: '',
currentYear: schoolYear?.currentYear,
currentYear: userDoc.data()?.currentYear,
public: false,
submitted: false,
submittedDate: null,
Expand Down
2 changes: 1 addition & 1 deletion server/api/user/update-year.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default async (req: Request, res: Response) => {
const yearTolerance = 4;
const year = req.body?.year;

if (!year && year <= year + yearTolerance) return res.status(400).send('Missing parameters');
if (!year && year <= new Date().getFullYear() + yearTolerance) return res.status(400).send('Missing parameters');

const currentYearTimestamp = admin.firestore.Timestamp.fromDate(new Date(Date.UTC(year, 4, 25)));

Expand Down

0 comments on commit 28d524f

Please sign in to comment.