Skip to content

Commit

Permalink
fix modification for pre-game events
Browse files Browse the repository at this point in the history
  • Loading branch information
lucia-gomez committed Oct 11, 2024
1 parent 07d32df commit 769d8da
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 30 deletions.
10 changes: 10 additions & 0 deletions booking-app/app/modification/confirmation/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// app/modification/confirmation/page.tsx
import BookingFormConfirmationPage from "@/components/src/client/routes/booking/formPages/BookingFormConfirmationPage";
import { FormContextLevel } from "@/components/src/types";
import React from "react";

const Role: React.FC = () => (
<BookingFormConfirmationPage formContext={FormContextLevel.MODIFICATION} />
);

export default Role;
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ export default function FormInput({ calendarEventId, formContext }: Props) {
});

const isWalkIn = formContext === FormContextLevel.WALK_IN;
const isMod = formContext === FormContextLevel.MODIFICATION;

// different from other switches b/c mediaServices doesn't have yes/no column in DB
const [showMediaServices, setShowMediaServices] = useState(false);
Expand Down Expand Up @@ -187,7 +188,11 @@ export default function FormInput({ calendarEventId, formContext }: Props) {

// setFormData(data);
registerEvent(data, isAutoApproval, calendarEventId);
router.push(isWalkIn ? "/walk-in/confirmation" : "/book/confirmation");
if (isMod) {
router.push("/modification/confirmation");
} else {
router.push(isWalkIn ? "/walk-in/confirmation" : "/book/confirmation");
}
};

const fullFormFields = (
Expand Down Expand Up @@ -252,7 +257,6 @@ export default function FormInput({ calendarEventId, formContext }: Props) {
<BookingFormTextField
id="sponsorFirstName"
label="Sponsor First Name"
description = "An NYU faculty or staff member related to your request. Ex: your thesis teacher if you have a thesis-related reservation request."
required={watch("role") === Role.STUDENT}
{...{ control, errors, trigger }}
/>
Expand Down Expand Up @@ -336,12 +340,6 @@ export default function FormInput({ calendarEventId, formContext }: Props) {
required={false}
description={
<p>
If your event needs a specific room setup with tables and chairs,
please provide a description below. In the description please include
# of chairs, # of tables, and formation. Depending on the scope, it may
be required to hire CBS services for the room set up which comes at a cost.
The Media Commons Team will procure the services needed for the Room Setup.
Please provide the chartfield below.
</p>
}
{...{ control, errors, trigger }}
Expand Down Expand Up @@ -417,9 +415,6 @@ export default function FormInput({ calendarEventId, formContext }: Props) {
label="Catering?"
description={
<p>
If the event includes catering, it is required for the reservation
holder to provide a chartfield so that the Media Commons Team can
obtain CBS Cleaning Services.
</p>
}
required={false}
Expand Down Expand Up @@ -450,10 +445,11 @@ export default function FormInput({ calendarEventId, formContext }: Props) {
required={false}
description={
<p>
Only for large events with 75+ attendees, and bookings in
The Garage where the Willoughby entrance will be in use.
It is required for the reservation holder to provide a chartfield
so that the Media Commons Team can obtain Campus Safety Security Services.
Only for large events with 75+ attendees, and bookings in The
Garage where the Willoughby entrance will be in use. It is
required for the reservation holder to provide a chartfield so
that the Media Commons Team can obtain Campus Safety Security
Services.
</p>
}
{...{ control, errors, trigger }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ export default function useCheckFormMissingData() {
const { role, department, selectedRooms, bookingCalendarInfo, formData } =
useContext(BookingContext);

const hasAffiliationFields = role && department;
const hasAffiliationFields =
(role && department) || pathname.includes("/modification");
const hasRoomSelectionFields =
selectedRooms &&
bookingCalendarInfo &&
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ export default function useSubmitBooking(formContext: FormContextLevel) {

const registerEvent = useCallback(
async (data: Inputs, isAutoApproval: boolean, calendarEventId?: string) => {
const hasAffiliation = (role && department) || isModification;
if (
!department ||
!role ||
!hasAffiliation ||
selectedRooms.length === 0 ||
!bookingCalendarInfo
) {
Expand All @@ -46,7 +46,6 @@ export default function useSubmitBooking(formContext: FormContextLevel) {

if (isEdit && data.netId) {
// block another person editing someone's booking
// TODO unless is PA or admin editing
if (data.netId + "@nyu.edu" !== userEmail) {
setSubmitting("error");
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import {
fetchAllFutureBookingStatus,
} from "@/components/src/server/db";

import { Liaisons } from "../admin/components/Liaisons";
import { TableNames } from "@/components/src/policy";
import { clientFetchAllDataFromCollection } from "@/lib/firebase/firebase";
import { useAuth } from "@/components/src/client/routes/components/AuthProvider";
Expand Down Expand Up @@ -151,7 +150,7 @@ export const DatabaseProvider = ({
email: item.email,
startDate: item.startDate,
endDate: item.endDate,
roomId: item.roomId,
roomId: String(item.roomId),
user: item.user,
room: item.room,
startTime: item.startTime,
Expand Down
2 changes: 1 addition & 1 deletion booking-app/components/src/policy.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/********** GOOGLE SHEETS ************/

import { clientGetFinalApproverEmailFromDatabase } from "@/lib/firebase/firebase";
import { BookingStatusLabel } from "./types";
import { clientGetFinalApproverEmailFromDatabase } from "@/lib/firebase/firebase";

/** ACTIVE master Google Sheet */
export const ACTIVE_SHEET_ID = "1MnWbn6bvNyMiawddtYYx0tRW4NMgvugl0I8zBO3sy68";
Expand Down
16 changes: 8 additions & 8 deletions booking-app/components/src/server/admin.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
import {
BookingFormDetails,
BookingStatus,
BookingStatusLabel,
RoomSetting,
} from "../types";
import {
Constraint,
serverDeleteData,
Expand All @@ -7,12 +13,6 @@ import {
serverUpdateInFirestore,
} from "@/lib/firebase/server/adminDb";
import { TableNames, getApprovalCcEmail } from "../policy";
import {
BookingFormDetails,
BookingStatus,
BookingStatusLabel,
RoomSetting,
} from "../types";
import { approvalUrl, declineUrl, getBookingToolDeployUrl } from "./ui";

import { Timestamp } from "firebase-admin/firestore";
Expand Down Expand Up @@ -87,8 +87,8 @@ const serverFinalApprove = (id: string, email?: string) => {

//server
export const serverApproveInstantBooking = (id: string) => {
serverFirstApprove(id);
serverFinalApprove(id);
serverFirstApprove(id, "");
serverFinalApprove(id, "");
serverApproveEvent(id);
};

Expand Down

0 comments on commit 769d8da

Please sign in to comment.