Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Riho/hide past events #50

Merged
merged 3 commits into from
Nov 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading