Skip to content

Commit

Permalink
Merge branch 'refs/heads/master' into 625-add-team-to-about
Browse files Browse the repository at this point in the history
# Conflicts:
#	client/sanity/schema.ts
  • Loading branch information
AzizPatel786 committed Aug 5, 2024
2 parents 82f4c44 + f5cb95f commit 4390812
Show file tree
Hide file tree
Showing 73 changed files with 2,817 additions and 478 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Project initiated by WDCC in 2023.
- Kunal Bhaskar
- Miguel Landingin
- Ray Xiao
- Troy Mackenzie-Smee

## 2023 Team Leadership

Expand Down
9 changes: 9 additions & 0 deletions client/sanity.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,15 @@ export default defineConfig({
S.document().schemaType("home-page").documentId("home-page")
),

S.listItem()
.title("Lodge Information")
.id("lodge-information")
.child(
S.document()
.schemaType("lodge-information")
.documentId("lodge-information")
),

// Regular document types
S.documentTypeListItem("about-item").title("About Item"),
S.documentTypeListItem("contact-detail").title("Contact Detail"),
Expand Down
10 changes: 3 additions & 7 deletions client/sanity/schema.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,12 @@
import { AboutItemSchema } from "@/models/sanity/AboutItem/Schema"
import { ContactDetailSchema } from "@/models/sanity/ContactDetail/Schema"
import { HomePageSchema } from "@/models/sanity/HomePage/Schema"
import { LodgeInfoSchema } from "@/models/sanity/LodgeInfo/Schema"
import { type SchemaTypeDefinition } from "sanity"
import { CommitteeMemberSchema } from "@/models/sanity/CommitteeMembers/Schema"
import { LifeMemberSchema } from "@/models/sanity/LifeMembers/Schema"

export const schema: { types: SchemaTypeDefinition[] } = {
types: [
AboutItemSchema,
HomePageSchema,
ContactDetailSchema,
CommitteeMemberSchema,
LifeMemberSchema
]
types: [AboutItemSchema, HomePageSchema, ContactDetailSchema, LodgeInfoSchema, CommitteeMemberSchema,
LifeMemberSchema]
}
13 changes: 13 additions & 0 deletions client/src/app/admin/booking-history/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
"use client"

import WrappedAdminBookingHistoryView from "@/components/composite/Admin/AdminBookingHistoryView/WrappedAdminBookingHistoryView"
import { AdminHeading } from "../AdminHeading"

export default function AdminBookingHistoryPage() {
return (
<>
<AdminHeading title="History" />
<WrappedAdminBookingHistoryView />
</>
)
}
3 changes: 0 additions & 3 deletions client/src/app/admin/layout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,14 @@ import AdminNavbar from "@/components/composite/Admin/AdminNavbar/AdminNavbar"
import { useAppData } from "@/store/Store"
import { AdminBookingViewProvider } from "@/components/composite/Admin/AdminBookingView/AdminBookingViewContext"
import { ReactNode } from "react"
import { useRouter } from "next/navigation"
import { QueryClientProvider } from "@tanstack/react-query"
import queryClient from "@/services/QueryClient"
import Loader from "@/components/generic/SuspenseComponent/Loader"

const AdminLayout = ({ children }: Readonly<{ children: ReactNode }>) => {
const [{ currentUserClaims }] = useAppData()
const router = useRouter()

if (!currentUserClaims?.admin) {
router.push("/")
return <Loader />
}

Expand Down
11 changes: 10 additions & 1 deletion client/src/assets/icons/leftarrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
9 changes: 8 additions & 1 deletion client/src/assets/icons/rightarrow.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import Calendar from "@/components/generic/Calendar/Calendar"
import Button from "@/components/generic/FigmaButtons/FigmaButton"
import { BookingAvailability } from "@/models/Booking"
import { useContext } from "react"
import { useContext, useMemo } from "react"
import { DateSelectionContext } from "./DateSelectionContext"
import Table from "@/components/generic/ReusableTable/Table"
import { Timestamp } from "firebase/firestore"
import TextInput from "@/components/generic/TextInputComponent/TextInput"
import { DEFAULT_BOOKING_AVAILABILITY } from "@/utils/Constants"
import { DEFAULT_BOOKING_AVAILABILITY, MS_IN_SECOND } from "@/utils/Constants"
import { DateUtils } from "@/components/utils/DateUtils"
/**
* Reasonable amount of items to display on table
Expand Down Expand Up @@ -63,13 +63,17 @@ export const formatBookingSlotsForAvailabilityView = (
return slots
.filter(
(slot) =>
slot.date.seconds >= startDate.seconds &&
slot.date.seconds <= endDate.seconds
DateUtils.timestampMilliseconds(slot.date) >=
startDate.seconds * MS_IN_SECOND &&
DateUtils.timestampMilliseconds(slot.date) <=
endDate.seconds * MS_IN_SECOND
)
.map((slot) => {
return {
uid: slot.id,
Date: DateUtils.timestampToDate(slot.date).toDateString(),
Date: new Date(
DateUtils.timestampMilliseconds(slot.date)
).toDateString(),
"Max Bookings": slot.maxBookings.toString(),
"Available Spaces": slot.availableSpaces.toString()
}
Expand Down Expand Up @@ -105,15 +109,19 @@ const AdminAvailabilityView = ({
setSlotQty
} = useContext(DateSelectionContext)

const dateRangeDefined = startDate && endDate
const dateRangeDefined = !!(startDate && endDate)

const tableData: CondensedBookingInfoColumn[] = dateRangeDefined
? formatBookingSlotsForAvailabilityView(
Timestamp.fromDate(startDate),
Timestamp.fromDate(endDate),
slots
)
: [CONDENSED_BOOKING_INFO_DEFAULT_DATA]
const tableData: CondensedBookingInfoColumn[] = useMemo(
() =>
dateRangeDefined
? formatBookingSlotsForAvailabilityView(
Timestamp.fromDate(startDate),
Timestamp.fromDate(endDate),
slots
)
: [CONDENSED_BOOKING_INFO_DEFAULT_DATA],
[startDate, endDate, dateRangeDefined, slots]
)

const formattedDateRanges = formatDateRangeForDialog(startDate, endDate)

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import type { Meta, StoryObj } from "@storybook/react"
import { BookingHistoryEvent } from "@/models/History"
import { Timestamp } from "firebase/firestore"
import AdminBookingHistoryItem from "./AdminBookingHistoryItem"

const meta: Meta<typeof AdminBookingHistoryItem> = {
component: AdminBookingHistoryItem
}

export default meta
type Story = StoryObj<typeof meta>

const bookingAdditionItem: BookingHistoryEvent = {
event_type: "added_user_to_booking",
timestamp: Timestamp.fromMillis(69),
start_date: Timestamp.now(),
end_date: Timestamp.now(),
uid: "jack sun"
}

const bookingDeletionItem: BookingHistoryEvent = {
event_type: "removed_user_from_booking",
timestamp: Timestamp.fromMillis(69),
start_date: Timestamp.now(),
end_date: Timestamp.now(),
uid: "stephen zhang"
}

const availabilityChangeItem: BookingHistoryEvent = {
event_type: "changed_date_availability",
timestamp: Timestamp.fromMillis(69),
start_date: Timestamp.now(),
end_date: Timestamp.now(),
change: -32
}

export const AdditionItem: Story = {
args: {
item: bookingAdditionItem,
name: "stephen zhang"
}
}

export const DeletionItem: Story = {
args: {
item: bookingDeletionItem,
name: "Jack sun"
}
}

export const AvailabilityChangeItem: Story = {
args: {
item: availabilityChangeItem
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,107 @@
import { DateUtils } from "@/components/utils/DateUtils"
import { BookingHistoryEvent } from "@/models/History"
import { useMemo } from "react"

interface IAdminBookingHistoryItem {
/**
* The event that is to be parsed and displayed in list view
*/
item: BookingHistoryEvent
/**
* The name of the user associated with the event (**NOT** the admin performing it)
*/
name?: string
/**
* The email of the user associated with the event (**NOT** the admin performing it)
*/
email?: string
}

const AdminBookingHistoryItem = ({
item,
name,
email
}: IAdminBookingHistoryItem) => {
/**
* Used for parsing the history event and presenting it
*/
const InnerContent = useMemo(() => {
const UserInformation = () => {
return (
<h5 className="border-dark-blue-100 w-fit border-2 px-3">
User: <strong>{name}</strong> | Email: <strong>{email}</strong>
</h5>
)
}
const SharedContent = () => {
return (
<>
<p>
At{" "}
<strong>
{new Date(
DateUtils.timestampMilliseconds(item.timestamp)
).toLocaleString()}
</strong>{" "}
for the date range{" "}
<strong>
{DateUtils.formattedNzDate(
new Date(DateUtils.timestampMilliseconds(item.start_date))
)}
</strong>{" "}
to{" "}
<strong>
{DateUtils.formattedNzDate(
new Date(DateUtils.timestampMilliseconds(item.end_date))
)}
</strong>
</p>
</>
)
}
switch (item.event_type) {
case "added_user_to_booking":
return (
<>
<h5 className="font-bold uppercase underline">Added to booking</h5>
<UserInformation />
<SharedContent />
</>
)
case "removed_user_from_booking":
return (
<>
<h5 className="font-bold uppercase underline">
Removed from booking
</h5>
<UserInformation />
<SharedContent />
</>
)
case "changed_date_availability":
return (
<>
<h5 className="font-bold uppercase underline">
Availability Changed
</h5>
<div className="flex gap-1">
<SharedContent />
<p>
for <strong>{item.change}</strong> slots
</p>
</div>
</>
)
}
}, [item, name, email])

return (
<>
<div className="border-gray-3 flex w-full flex-col gap-1 rounded-md border bg-white p-4">
{InnerContent}
</div>
</>
)
}

export default AdminBookingHistoryItem
Loading

0 comments on commit 4390812

Please sign in to comment.