Skip to content

Commit

Permalink
Hide past events
Browse files Browse the repository at this point in the history
  • Loading branch information
rlho committed Nov 3, 2023
1 parent eaa6bda commit d496115
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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 })}
/>
</div>
Expand Down
2 changes: 2 additions & 0 deletions media_commons_booking_app/src/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
sendTextEmail,
fetchById,
fetchRows_,
getFutureDates,
} from './sheets';

// Public functions must be exported as named exports
Expand Down Expand Up @@ -75,4 +76,5 @@ export {
getGoogleCalendarApiKey,
getUserEmail,
removeFromList,
getFutureDates,
};
20 changes: 20 additions & 0 deletions media_commons_booking_app/src/server/sheets.js
Original file line number Diff line number Diff line change
Expand Up @@ -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}`;
Expand Down

0 comments on commit d496115

Please sign in to comment.