diff --git a/lib/components/state-resources/get-available-diary-slots/index.js b/lib/components/state-resources/get-available-diary-slots/index.js index 9c245dd..a57d67d 100644 --- a/lib/components/state-resources/get-available-diary-slots/index.js +++ b/lib/components/state-resources/get-available-diary-slots/index.js @@ -1,5 +1,3 @@ -'use strict' - const getAvailableDiarySlots = require('./helpers/generate-time-slots') const moment = require('moment') @@ -43,6 +41,18 @@ module.exports = class GetAvailableDiarySlots { remove.push(index) } }) + + const today = moment(new Date()) + const isToday = moment(event.date).format('YYYY-MM-DD') === today.format('YYYY-MM-DD') + + if (isToday) { + const timeSlot_ = moment(today.format('YYYY-MM-DD') + 'T' + timeSlot[0]) + const isBefore = moment(timeSlot_).isBefore(today) + + if (isBefore) { + remove.push(index) + } + } }) const final = availableTimes.filter((e, idx) => !remove.includes(idx))