Skip to content

Commit

Permalink
BRS-356: Adding shortPassDate to passes (#68)
Browse files Browse the repository at this point in the history
  • Loading branch information
Daniel Truong authored Jan 14, 2022
1 parent 8c20d77 commit 68431e4
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions lambda/writePass/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ exports.handler = async (event, context) => {
};

// check if booking date in the past
localDate.setHours(0,0,0,0);
localDate.setHours(0, 0, 0, 0);
if (localDate > bookingDate) {
return sendResponse(400, {
msg: 'You cannot book for a date in the past.',
Expand Down Expand Up @@ -128,6 +128,10 @@ exports.handler = async (event, context) => {
}
}

const theDate = new Date(date);
// We can reuse the date selector as the short date required for indexing
const dateselector = theDate.toISOString().split('T')[0];

passObject.Item = {};
passObject.Item['pk'] = { S: 'pass::' + parkName };
passObject.Item['sk'] = { S: registrationNumber };
Expand All @@ -136,6 +140,7 @@ exports.handler = async (event, context) => {
passObject.Item['facilityName'] = { S: facilityName };
passObject.Item['email'] = { S: email };
passObject.Item['date'] = { S: date };
passObject.Item['shortPassDate'] = { S: dateselector };
passObject.Item['type'] = { S: type };
passObject.Item['registrationNumber'] = { S: registrationNumber };
passObject.Item['numberOfGuests'] = AWS.DynamoDB.Converter.input(numberOfGuests);
Expand Down Expand Up @@ -191,9 +196,6 @@ exports.handler = async (event, context) => {
personalisation['license'] = license;
}

const theDate = new Date(date);
const dateselector = theDate.toISOString().split('T')[0];

if (parkData[0].visible === true) {
// Check existing pass for the same facility, email, type and date
try {
Expand Down

0 comments on commit 68431e4

Please sign in to comment.