Skip to content

Commit

Permalink
Merge pull request #50 from ITPNYU/riho/hide_past_events
Browse files Browse the repository at this point in the history
Riho/hide past events
  • Loading branch information
rlho authored Nov 6, 2023
2 parents 15b52d2 + e87c733 commit f7c61d7
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 6 deletions.
9 changes: 9 additions & 0 deletions media_commons_booking_app/.clasprc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"token": {
"access_token": "ya29.a0AfB_byCZKP9I9I7zqUDTF9w_lgCXlIam-ELi1COrPD-x8bGNOPjaDao5g77qxKEfjdw422dURYGoE0QdbsG5sd1W1ChSCC5NAMiECZceTkrFnjBgTzYoWYcYVoW9Txnc4mD1jBSlYw23bPQmL-OQW2W2VbUSuXZEhOE6aCgYKAZ0SARASFQGOcNnCn0NLzxPhN9hM-R4-Yo5eFg0171",
"refresh_token": "1//06aBbyJywziH-CgYIARAAGAYSNwF-L9Ir-dP98_PqTJfQI_0cpXcOzvW2GIiR1C7RYbqdsVqCxaPpOL-w8H53wuhbMaLq4TLZXSU",
"scope": "https://www.googleapis.com/auth/script.projects https://www.googleapis.com/auth/script.deployments",
"token_type": "Bearer",
"expiry_date": 3599
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,7 @@ export const Bookings = () => {
}, [bookings]);

useEffect(() => {
console.log(
bookingStatuses,
'bookingStatusesbookingStatusesbookingStatusesbookingStatuses'
);
console.log(bookingStatuses, 'bookingStatus');
const mappings = bookingStatuses
.map((bookingStatus, index) => {
console.log(bookingStatus, 'bookingStatus');
Expand All @@ -74,7 +71,7 @@ export const Bookings = () => {
}, [bookingStatuses]);

const fetchBookings = async () => {
serverFunctions.fetchRows(BOOKING_SHEET_NAME).then((rows) => {
serverFunctions.getFutureDates(BOOKING_SHEET_NAME).then((rows) => {
console.log('booking rows', rows);
setBookings(rows);
});
Expand Down
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 f7c61d7

Please sign in to comment.