Skip to content

Commit

Permalink
Merge pull request #422 from ITPNYU/main
Browse files Browse the repository at this point in the history
Prod Release 0925
  • Loading branch information
rlho authored Sep 25, 2024
2 parents 7f68654 + 33a057d commit 01d1088
Show file tree
Hide file tree
Showing 8 changed files with 32 additions and 11 deletions.
1 change: 1 addition & 0 deletions booking-app/app.development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ automatic_scaling:
env_variables:
NEXT_PUBLIC_BRANCH_NAME: "development"
NODE_OPTIONS: "--max-old-space-size=4096"
TZ: "America/New_York"

build_env_variables:
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
1 change: 1 addition & 0 deletions booking-app/app.production.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ automatic_scaling:
env_variables:
NEXT_PUBLIC_BRANCH_NAME: "production"
NODE_OPTIONS: "--max-old-space-size=4096"
TZ: "America/New_York"

build_env_variables:
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
1 change: 1 addition & 0 deletions booking-app/app.staging.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ automatic_scaling:
env_variables:
NEXT_PUBLIC_BRANCH_NAME: "staging"
NODE_OPTIONS: "--max-old-space-size=4096"
TZ: "America/New_York"

build_env_variables:
NODE_OPTIONS: "--max-old-space-size=4096"
Expand Down
2 changes: 0 additions & 2 deletions booking-app/app/api/bookings/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,13 +161,11 @@ export async function POST(request: NextRequest) {
equipmentCheckedOut: false,
...data,
});
console.log(" Done serverSaveDataToFirestore booking");
await serverSaveDataToFirestore(TableNames.BOOKING_STATUS, {
calendarEventId,
email,
requestedAt: Timestamp.now(),
});
console.log(" Done serverSaveDataToFirestore booking status");

await handleBookingApprovalEmails(
isAutoApproval,
Expand Down
25 changes: 19 additions & 6 deletions booking-app/components/src/client/utils/serverDate.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import { Timestamp } from "firebase-admin/firestore";
import { format } from "date-fns";
import { toZonedTime } from "date-fns-tz";
import { parseISO } from "date-fns";
import { format } from "date-fns-tz";

type DateInput = Date | Timestamp | { [key: string]: any } | number | string;

Expand All @@ -15,15 +17,26 @@ const parseTimestamp = (value: DateInput): Timestamp => {
};

export const serverFormatDate = (
input: DateInput,
input: string,
timeZone: string = "America/New_York"
): string => {
if (!input) return "";
try {
const timestamp = parseTimestamp(input);
const date = timestamp.toDate();
const zonedDate = new Date(date.toLocaleString("en-US", { timeZone }));
return format(zonedDate, "yyyy-MM-dd hh:mm a");
const date = new Date(input);

const zonedDate = toZonedTime(date, timeZone);

const formattedResult = format(zonedDate, "yyyy-MM-dd hh:mm a", {
timeZone,
});

console.log("Input:", input);
console.log("Parsed Date:", date.toISOString());
console.log("Zoned Date:", zonedDate.toString());
console.log("Formatted Result:", formattedResult);
console.log("Timezone:", timeZone);

return formattedResult;
} catch (error) {
console.error("Error formatting date:", error, "Input:", input);
return "";
Expand Down
3 changes: 0 additions & 3 deletions booking-app/lib/googleClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ const refreshAccessTokenIfNeeded = async (oauth2Client) => {
const currentTime = Date.now();
const tokenExpiryTime = oauth2Client.credentials.expiry_date;

console.log("Current time:", new Date(currentTime));
console.log("Token expiry:", new Date(tokenExpiryTime));

if (!tokenExpiryTime || currentTime >= tokenExpiryTime - 60000) {
// 1分前に更新
try {
Expand Down
9 changes: 9 additions & 0 deletions booking-app/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions booking-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
"axios": "^1.7.2",
"bootstrap": "^5.3.3",
"date-fns": "^3.6.0",
"date-fns-tz": "^3.1.3",
"dayjs": "^1.11.12",
"firebase": "^10.12.4",
"firebase-admin": "^12.2.0",
Expand Down

0 comments on commit 01d1088

Please sign in to comment.