From 13fe7ca0c5687d93d7d52359fbc1afd7dfe95ce6 Mon Sep 17 00:00:00 2001 From: "riho.takagi" Date: Sun, 1 Oct 2023 09:04:19 -0700 Subject: [PATCH 1/3] clasp login using api --- media_commons_booking_app/.clasprc.json | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 media_commons_booking_app/.clasprc.json diff --git a/media_commons_booking_app/.clasprc.json b/media_commons_booking_app/.clasprc.json new file mode 100644 index 00000000..b41a32bc --- /dev/null +++ b/media_commons_booking_app/.clasprc.json @@ -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 + } +} From 42b94ad4ed12688c41a249e24794433dd1d22fc4 Mon Sep 17 00:00:00 2001 From: "riho.takagi" Date: Thu, 2 Nov 2023 12:11:24 -0400 Subject: [PATCH 2/3] Hide past events --- .../client/booking/components/FormInput.tsx | 1 - media_commons_booking_app/src/server/index.ts | 2 ++ .../src/server/sheets.js | 20 +++++++++++++++++++ 3 files changed, 22 insertions(+), 1 deletion(-) 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}`; From e87c733b916986c0b309f58049a91e79d9155d8e Mon Sep 17 00:00:00 2001 From: "riho.takagi" Date: Fri, 3 Nov 2023 17:39:38 -0400 Subject: [PATCH 3/3] hide past event --- .../src/client/admin-page/components/Bookings.tsx | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/media_commons_booking_app/src/client/admin-page/components/Bookings.tsx b/media_commons_booking_app/src/client/admin-page/components/Bookings.tsx index aff1c912..9505d0ca 100644 --- a/media_commons_booking_app/src/client/admin-page/components/Bookings.tsx +++ b/media_commons_booking_app/src/client/admin-page/components/Bookings.tsx @@ -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'); @@ -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); });