Skip to content

Commit

Permalink
filter bookings based on deploy branch
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Mar 27, 2024
1 parent efdad3e commit caeefab
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 7 deletions.
10 changes: 5 additions & 5 deletions media_commons_booking_app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
"setup": "rimraf .clasp.json && mkdirp dist && clasp create --type sheets --title \"My React Project\" --rootDir ./dist && mv ./dist/.clasp.json ./.clasp.json && rimraf dist",
"open": "clasp open --addon",
"setup:https": "mkdirp certs && mkcert -key-file ./certs/key.pem -cert-file ./certs/cert.pem localhost 127.0.0.1",
"build:local": "cross-env NODE_ENV=development CALENDAR_ENV=development webpack",
"build:dev": "cross-env NODE_ENV=production CALENDAR_ENV=development webpack --mode=production",
"build:staging": "cross-env NODE_ENV=production CALENDAR_ENV=development webpack --mode=production",
"build": "cross-env NODE_ENV=production CALENDAR_ENV=production webpack --mode=production",
"build:local": "cross-env NODE_ENV=development CALENDAR_ENV=development BRANCH_NAME=development webpack",
"build:dev": "cross-env NODE_ENV=production CALENDAR_ENV=development BRANCH_NAME=development webpack --mode=production",
"build:staging": "cross-env NODE_ENV=production CALENDAR_ENV=development BRANCH_NAME=staging webpack --mode=production",
"build": "cross-env NODE_ENV=production CALENDAR_ENV=production BRANCH_NAME=production webpack --mode=production",
"deploy:local": "rimraf dist && npm run build:local && npx clasp push",
"deploy:dev": "rimraf dist && npm run build:dev && npx clasp push",
"deploy:staging": "rimraf dist && npm run build:staging && npx clasp push",
"deploy": "rimraf dist && npm run build && npx clasp push",
"serve": "cross-env NODE_ENV=development CALENDAR_ENV=development webpack serve",
"serve": "cross-env NODE_ENV=development CALENDAR_ENV=development BRANCH_NAME=development webpack serve",
"start": "npm run deploy:local && npm run serve"
},
"keywords": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export default function useSubmitBooking(): [(any) => Promise<void>, boolean] {
bookingCalendarInfo.startStr,
bookingCalendarInfo.endStr,
...contents,
process.env.BRANCH_NAME,
]);

await serverFunctions.appendRowActive(TableNames.BOOKING_STATUS, [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Ban,
Booking,
BookingStatus,
DevBranch,
LiaisonType,
PaUser,
PagePermission,
Expand Down Expand Up @@ -104,9 +105,14 @@ export const DatabaseProvider = ({ children }) => {
};

const fetchBookings = async () => {
console.log('CURRENT BRANCH:', process.env.BRANCH_NAME);
const bookingRows = await serverFunctions
.getActiveBookingsFutureDates()
.then((rows) => rows.map((row) => mappingBookingRows(row)));
.then((rows) =>
rows
.map((row) => mappingBookingRows(row))
.filter((booking) => booking.devBranch === process.env.BRANCH_NAME)
);
setBookings(bookingRows);
};

Expand Down Expand Up @@ -253,6 +259,7 @@ const mappingBookingRows = (values: string[]): Booking => {
chartFieldForCatering: values[27],
chartFieldForSecurity: values[28],
chartFieldForRoomSetup: values[29],
devBranch: values[30] as DevBranch,
};
};

Expand Down
1 change: 0 additions & 1 deletion media_commons_booking_app/src/server/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ export const getActiveBookingsFutureDates = () => {
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
return startDate > today; // 'start date' is after today
});
Expand Down
3 changes: 3 additions & 0 deletions media_commons_booking_app/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ export type Booking = Inputs & {
startDate: string;
endDate: string;
roomId: string;
devBranch: DevBranch;
};

export type BookingStatus = {
Expand Down Expand Up @@ -53,6 +54,8 @@ export enum Department {
RECORDED_MUSIC = 'Recorded Music',
}

export type DevBranch = 'development' | 'staging' | 'production' | '';

export type Inputs = {
firstName: string;
lastName: string;
Expand Down
1 change: 1 addition & 0 deletions media_commons_booking_app/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ const envVars = parsed || {};
const PORT = envVars.PORT || 3000;
envVars.NODE_ENV = process.env.NODE_ENV;
envVars.CALENDAR_ENV = process.env.CALENDAR_ENV;
envVars.BRANCH_NAME = process.env.BRANCH_NAME;
envVars.PORT = PORT;

const isProd = process.env.NODE_ENV === 'production';
Expand Down

1 comment on commit caeefab

@lucia-gomez
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.