Skip to content

Commit

Permalink
index fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
nadamels committed Nov 24, 2023
1 parent 70656a1 commit 09edac2
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions back-end/src/controllers/createIssueHandler.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,11 @@ export async function createIssueHandler(req, res) {
hour12: false
});
const attachments = req.files.map(file => file.filename);
const lastIssue = await Issue.findOne().sort({ index: -1 });
const newIndex = lastIssue ? lastIssue.index + 1 : 1;

const newIssue = new Issue ({
index: newIndex,
studentNetID: [req.params.studentNetID],
studentName: [req.body.studentName],
title: req.body.issueTitle,
Expand All @@ -28,8 +31,8 @@ export async function createIssueHandler(req, res) {
comments: [null],
dateCreated: issueDateCreated,
timeCreated: issueTimeCreated,
currentStatus: currentStatus || 'Open',
currentPriority: currentPriority || 'New'
currentStatus:'Open',
currentPriority: 'New'
});

try {
Expand Down

0 comments on commit 09edac2

Please sign in to comment.