diff --git a/media_commons_booking_app/src/client/booking/components/FormInput.tsx b/media_commons_booking_app/src/client/booking/components/FormInput.tsx index 4e68e65b..fcfeb9b5 100644 --- a/media_commons_booking_app/src/client/booking/components/FormInput.tsx +++ b/media_commons_booking_app/src/client/booking/components/FormInput.tsx @@ -437,7 +437,6 @@ const FormInput = ({ hasEmail, roomNumber, handleParentSubmit }) => { type="expectedAttendance" id="expectedAttendance" className="bg-gray-50 border border-gray-300 text-gray-900 text-sm rounded-lg focus:ring-blue-500 focus:border-blue-500 block w-[600px] p-2.5 dark:bg-gray-700 dark:border-gray-600 dark:placeholder-gray-400 dark:text-white dark:focus:ring-blue-500 dark:focus:border-blue-500" - placeholder="5" {...register('expectedAttendance', { required: true })} /> diff --git a/media_commons_booking_app/src/server/index.ts b/media_commons_booking_app/src/server/index.ts index 279d0c56..6069c3c2 100644 --- a/media_commons_booking_app/src/server/index.ts +++ b/media_commons_booking_app/src/server/index.ts @@ -38,6 +38,7 @@ import { sendTextEmail, fetchById, fetchRows_, + getFutureDates, } from './sheets'; // Public functions must be exported as named exports @@ -75,4 +76,5 @@ export { getGoogleCalendarApiKey, getUserEmail, removeFromList, + getFutureDates, }; diff --git a/media_commons_booking_app/src/server/sheets.js b/media_commons_booking_app/src/server/sheets.js index 7c628fc7..964ab3f2 100644 --- a/media_commons_booking_app/src/server/sheets.js +++ b/media_commons_booking_app/src/server/sheets.js @@ -16,6 +16,26 @@ export const fetchRows = (sheetName) => { return (values || []).map((row) => row.map((cell) => `${cell}`)); }; +export const getFutureDates = (sheetName) => { + const values = SpreadsheetApp.openById(ACTIVE_SHEET_ID) + .getSheetByName(sheetName) + .getDataRange() + .getValues(); + + var today = new Date(); + today.setHours(0, 0, 0, 0); // set hours 00:00:00.000 + + var filteredData = values.filter(function (row, index) { + if (index === 0) return true; // if header row, return true (include in filtered data) + var startDate = new Date(row[3]); // 'start date' column + console.log('startDate', startDate); + return startDate > today; // 'start date' is after today + }); + + Logger.log('getFutureDates', filteredData); + return (filteredData || []).map((row) => row.map((cell) => `${cell}`)); +}; + function fetchById(sheetName, id) { const row = fetchRows_(sheetName).find((row) => row[0] === id); if (!row) throw `Invalid conversation ID: ${id}`;