-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #430 from ITPNYU/main
Prod Release 0926
- Loading branch information
Showing
50 changed files
with
1,278 additions
and
640 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Booking, BookingStatus } from "@/components/src/types"; | ||
import { NextRequest, NextResponse } from "next/server"; | ||
|
||
import { TableNames } from "@/components/src/policy"; | ||
import { parse } from "json2csv"; | ||
import { serverFetchAllDataFromCollection } from "@/lib/firebase/server/adminDb"; | ||
|
||
export async function GET(request: NextRequest) { | ||
const bookings = await serverFetchAllDataFromCollection<Booking>( | ||
TableNames.BOOKING, | ||
); | ||
const statuses = await serverFetchAllDataFromCollection<BookingStatus>( | ||
TableNames.BOOKING_STATUS, | ||
); | ||
|
||
// need to find corresponding status row for booking row | ||
const idsToData: { | ||
[key: string]: { | ||
booking: Booking; | ||
status: BookingStatus; | ||
}; | ||
} = {}; | ||
|
||
for (let booking of bookings) { | ||
const calendarEventId = booking.calendarEventId; | ||
const statusMatch = statuses.filter( | ||
row => row.calendarEventId === calendarEventId, | ||
)[0]; | ||
idsToData[calendarEventId] = { | ||
booking, | ||
status: statusMatch, | ||
}; | ||
} | ||
|
||
const rows = Object.entries(idsToData) | ||
.map(([_, { booking, status }]) => { | ||
const { requestNumber, ...otherBooking } = booking; | ||
return { requestNumber, ...otherBooking, ...status }; | ||
}) | ||
.sort((a, b) => a.requestNumber - b.requestNumber); | ||
|
||
try { | ||
const csv = parse(rows); | ||
return new NextResponse(csv, { | ||
status: 200, | ||
headers: { | ||
"Content-Type": "text/csv", | ||
"Content-Disposition": 'attachment; filename="data.csv"', | ||
}, | ||
}); | ||
} catch (error) { | ||
return NextResponse.json( | ||
{ error: "Failed to fetch CSV data" }, | ||
{ status: 400 }, | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
// app/book/confirmation/page.tsx | ||
import BookingForm from "@/components/src/client/routes/booking/BookingForm"; | ||
import BookingFormConfirmationPage from "@/components/src/client/routes/booking/formPages/BookingFormConfirmationPage"; | ||
import React from "react"; | ||
|
||
const Role: React.FC = () => ( | ||
<BookingForm> | ||
<BookingFormConfirmationPage /> | ||
</BookingForm> | ||
); | ||
const Role: React.FC = () => <BookingFormConfirmationPage />; | ||
|
||
export default Role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// app/book/layout.tsx | ||
import BookingForm from "@/components/src/client/routes/booking/BookingForm"; | ||
import { FormContextLevel } from "@/components/src/types"; | ||
import React from "react"; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const BookingLayout: React.FC<LayoutProps> = ({ children }) => ( | ||
<BookingForm formContext={FormContextLevel.FULL_FORM}>{children}</BookingForm> | ||
); | ||
|
||
export default BookingLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,7 @@ | ||
import React from "react"; | ||
// app/book/form/page.tsx | ||
import BookingForm from "@/components/src/client/routes/booking/BookingForm"; | ||
import UserRolePage from "@/components/src/client/routes/booking/formPages/UserRolePage"; | ||
import React from "react"; | ||
|
||
const Role: React.FC = () => ( | ||
<BookingForm> | ||
<UserRolePage /> | ||
</BookingForm> | ||
); | ||
const Role: React.FC = () => <UserRolePage />; | ||
|
||
export default Role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// app/edit/layout.tsx | ||
import BookingForm from "@/components/src/client/routes/booking/BookingForm"; | ||
import { FormContextLevel } from "@/components/src/types"; | ||
import React from "react"; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const BookingLayout: React.FC<LayoutProps> = ({ children }) => ( | ||
<BookingForm>{children}</BookingForm> | ||
<BookingForm formContext={FormContextLevel.EDIT}>{children}</BookingForm> | ||
); | ||
|
||
export default BookingLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,13 @@ | ||
import { FormContextLevel } from "@/components/src/types"; | ||
// app/edit/role/[id].tsx | ||
import React from "react"; | ||
import UserRolePage from "@/components/src/client/routes/booking/formPages/UserRolePage"; | ||
|
||
const Role: React.FC = ({ params }: { params: { id: string } }) => ( | ||
<UserRolePage calendarEventId={params.id} isEdit={true} /> | ||
<UserRolePage | ||
calendarEventId={params.id} | ||
formContext={FormContextLevel.EDIT} | ||
/> | ||
); | ||
|
||
export default Role; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
// app/modification/[id].tsx | ||
|
||
"use client"; | ||
|
||
import ModificationLandingPage from "@/components/src/client/routes/modification/ModificationLandingPage"; | ||
import React from "react"; | ||
|
||
const HomePage: React.FC = ({ params }: { params: { id: string } }) => ( | ||
<ModificationLandingPage calendarEventId={params.id} /> | ||
); | ||
|
||
export default HomePage; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// app/modification/form/[id].tsx | ||
|
||
"use client"; | ||
|
||
import BookingFormDetailsPage from "@/components/src/client/routes/booking/formPages/BookingFormDetailsPage"; | ||
import { FormContextLevel } from "@/components/src/types"; | ||
import React from "react"; | ||
|
||
const Form: React.FC = ({ params }: { params: { id: string } }) => ( | ||
<BookingFormDetailsPage | ||
calendarEventId={params.id} | ||
formContext={FormContextLevel.MODIFICATION} | ||
/> | ||
); | ||
|
||
export default Form; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// app/modification/layout.tsx | ||
import BookingForm from "@/components/src/client/routes/booking/BookingForm"; | ||
import { FormContextLevel } from "@/components/src/types"; | ||
import React from "react"; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const BookingLayout: React.FC<LayoutProps> = ({ children }) => ( | ||
<BookingForm formContext={FormContextLevel.MODIFICATION}> | ||
{children} | ||
</BookingForm> | ||
); | ||
|
||
export default BookingLayout; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
// app/modification/selectRoom/[id].tsx | ||
|
||
"use client"; | ||
|
||
import { FormContextLevel } from "@/components/src/types"; | ||
import React from "react"; | ||
import SelectRoomPage from "@/components/src/client/routes/booking/formPages/SelectRoomPage"; | ||
|
||
const SelectRoom: React.FC = ({ params }: { params: { id: string } }) => ( | ||
<SelectRoomPage | ||
calendarEventId={params.id} | ||
formContext={FormContextLevel.MODIFICATION} | ||
/> | ||
); | ||
|
||
export default SelectRoom; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,13 +1,14 @@ | ||
// app/walk-in/layout.tsx | ||
import BookingForm from "@/components/src/client/routes/booking/BookingForm"; | ||
import { FormContextLevel } from "@/components/src/types"; | ||
import React from "react"; | ||
|
||
type LayoutProps = { | ||
children: React.ReactNode; | ||
}; | ||
|
||
const BookingLayout: React.FC<LayoutProps> = ({ children }) => ( | ||
<BookingForm>{children}</BookingForm> | ||
<BookingForm formContext={FormContextLevel.WALK_IN}>{children}</BookingForm> | ||
); | ||
|
||
export default BookingLayout; |
Oops, something went wrong.