Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New booking table release #758

Merged
merged 4 commits into from
Aug 12, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions .github/workflows/deploy-client-production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Deploy Production Build of Client for UASC

on:
workflow_dispatch:
# schedules this to run 30 minutes
# schedules this to run every 30 minutes
schedule:
- cron: "30 * * * *"

Expand Down Expand Up @@ -36,10 +36,11 @@ jobs:

- run: yarn workspaces focus client && yarn workspace client build

- uses: FirebaseExtended/action-hosting-deploy@v0
- name: Publish to cloudflare
uses: cloudflare/pages-action@v1
with:
repoToken: "${{ secrets.GITHUB_TOKEN }}"
firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_UASC_PROD }}"
channelId: live
projectId: uasc-prod
entryPoint: client
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: uasc
directory: client/out
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
Binary file added client/public/videos/hero-background.mp4
Binary file not shown.
11 changes: 7 additions & 4 deletions client/src/app/sections/LandingSection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,16 +11,19 @@ const LandingSection = () => (
flex-col items-center
justify-center overflow-hidden"
>
<div className="pointer-events-none absolute -z-10 h-full w-full brightness-[0.6]">
<div className="absolute inset-0 backdrop-blur-sm" />
<div className="pointer-events-none absolute -z-10 h-full w-full brightness-[0.5]">
<div className="absolute inset-0" />
<video
src="/videos/hero-background.webm"
autoPlay
muted
playsInline
loop
poster="/images/landing-video-placeholder.webp"
className="h-full w-full object-cover"
/>
>
<source src="/videos/hero-background.mp4" type="video/mp4" />
<source src="/videos/hero-background.webm" type="video/webm" />
</video>
</div>

<div className="flex w-full max-w-96 flex-1 flex-col justify-center gap-y-12 px-6 text-center lg:gap-16">
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import type { Meta, StoryObj } from "@storybook/react"
import AdminBookingDate, { BookingInfo } from "./AdminBookingDate"
import { Timestamp } from "firebase/firestore"

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

export default meta
type Story = StoryObj<typeof meta>

const mockData: BookingInfo = {
bookingId: "djs",
uid: "1",
first_name: "Straight",
last_name: "Zhao",
date_of_birth: Timestamp.fromMillis(0),
phone_number: 69696969,
dietary_requirements: "nothing",
email: "[email protected]",
membership: "guest"
}

const mockDataArray: BookingInfo[] = []

for (let i = 0; i < 100; ++i) {
mockDataArray.push(mockData)
}

export const DefaultAdminBookingDate: Story = {
args: {
dateString: "20/10/2024",
users: mockDataArray
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { CombinedUserData } from "@/models/User"
import BookingUserCard from "./BookingUserCard"

export type BookingInfo = CombinedUserData & { bookingId: string }

export interface IAdminBookingDate {
/**
* The `unique` string representing the date the users are booked for
*/
dateString: string

/**
* For more detailed explaination of the date
*
* @example "Friday"
*/
dayName?: string

/**
* All of the user information associated with the date
*/
users: Readonly<BookingInfo>[]

/**
* Callback for when an attempt is made to delete a booking
*/
handleUserDelete: (id: string) => void
}

/**
* Component to display the available users for each date in a booking
*/
const AdminBookingDate = ({
dateString,
dayName,
users,
handleUserDelete
}: IAdminBookingDate) => {
return (
<div className="border-gray-3 flex h-fit w-full flex-col gap-2 border bg-white p-2">
{dayName && <h5 className="font-bold uppercase underline">{dayName}</h5>}
<h2 className="text-dark-blue-100 italic">{dateString}</h2>
<h5 className="font-bold uppercase">{users.length} Bookings</h5>
<h5 className="uppercase opacity-75">
Tap on user to toggle information
</h5>
{users.map((user, index) => {
return (
<BookingUserCard
user={user}
index={index}
key={user.uid}
handleDelete={handleUserDelete}
/>
)
})}
</div>
)
}

export default AdminBookingDate
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import type { Meta, StoryObj } from "@storybook/react"
import { Timestamp } from "firebase/firestore"
import BookingUserCard from "./BookingUserCard"
import { BookingInfo } from "./AdminBookingDate"

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

export default meta
type Story = StoryObj<typeof meta>

const mockUser: BookingInfo = {
bookingId: "asd",
uid: "1",
first_name: "Straight",
last_name: "Zhao",
date_of_birth: Timestamp.fromMillis(0),
phone_number: 69696969,
dietary_requirements:
"Lorem ipsum dolor sit amet consectetur adipisicing elit. Soluta enim voluptatum id placeat quod exercitationem vero non amet, minima totam voluptas illo ad ipsa autem odio reiciendis optio vel libero quia, consectetur ipsum molestias repellat distinctio a? Non error minima est beatae nostrum, nam, alias officiis, amet dolorem corrupti doloremque!",
email: "[email protected]",
membership: "guest"
}

export const DefaultAdminBookingDateDisplay: Story = {
args: {
user: mockUser
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import { useState } from "react"
import { BookingInfo } from "./AdminBookingDate"

interface IBookingUserCard {
index: number
user: Readonly<BookingInfo>
handleDelete?: (id: string) => void
}

const BookingUserCard = ({ index, user, handleDelete }: IBookingUserCard) => {
const [isOpen, setIsOpen] = useState<boolean>(false)
const hasDietaryRequirements = user.dietary_requirements.trim().length > 0
return (
<div
key={user.uid}
className="border-gray-3 w-full border bg-white px-4 py-2"
>
<div
className="flex w-full cursor-pointer items-center gap-5"
onClick={() => setIsOpen(!isOpen)}
>
<div className="flex flex-col gap-2">
<span className="flex flex-col">
<p className="underline">
<strong>{`#${index}`}</strong> {user.first_name} {user.last_name}
</p>
<h5>{user.membership}</h5>
</span>
{hasDietaryRequirements && (
<div className="border-dark-blue-100 flex w-full flex-col rounded-sm border px-2">
<h5 className="font-bold uppercase">Dietary Reqs</h5>
<p>{user.dietary_requirements}</p>
</div>
)}
</div>
<h5
className="text-red ml-auto cursor-pointer font-bold"
onClick={() => handleDelete?.(user.bookingId)}
>
X
</h5>
</div>
{isOpen && (
<div className="flex flex-col">
<div className="mb-2 mt-4 w-full border" />
<h5>
<strong>Email:</strong> {user.email}
</h5>
<h5>
<strong>Phone Number:</strong> {user.phone_number}
</h5>
<h5>
<strong>Emergency Contact:</strong> {user.emergency_contact}
</h5>
</div>
)}
</div>
)
}

export default BookingUserCard
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import type { Meta, StoryObj } from "@storybook/react"
import AdminBookingDateDisplay from "./AdminBookingDateDisplay"
import { Timestamp } from "firebase/firestore"
import {
BookingInfo,
IAdminBookingDate
} from "./AdminBookingDate/AdminBookingDate"

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

export default meta
type Story = StoryObj<typeof meta>

const mockUser: BookingInfo = {
bookingId: "2323",
uid: "1",
first_name: "Straight",
last_name: "Zhao",
date_of_birth: Timestamp.fromMillis(0),
phone_number: 69696969,
dietary_requirements: "nothing",
email: "[email protected]",
membership: "guest"
}

const mockUsersArray: BookingInfo[] = []

for (let i = 0; i < 32; ++i) {
mockUsersArray.push(mockUser)
}

const mockDatesArray: IAdminBookingDate[] = []

for (let i = 1; i < 30; ++i) {
mockDatesArray.push({
dateString: `${i}/10/2002`,
users: mockUsersArray,
handleUserDelete: () => {}
})
}

export const DefaultAdminBookingDateDisplay: Story = {
args: {
dates: mockDatesArray
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import AdminBookingDate, {
IAdminBookingDate
} from "./AdminBookingDate/AdminBookingDate"

export interface IAdminBookingDateDisplay {
/**
* The list of dates to be displayed to user
*/
dates: IAdminBookingDate[]

/**
* Callback to remove the booking with specified `id` from a booking date
*/
handleDelete?: (id: string) => void
}

const AdminBookingDateDisplay = ({ dates }: IAdminBookingDateDisplay) => {
return (
<div className="flex gap-2">
{dates.map((date) => {
return (
<span key={date.dateString} className="min-w-[340px]">
<AdminBookingDate
dateString={date.dateString}
dayName={date.dayName}
handleUserDelete={date.handleUserDelete}
users={date.users}
/>
</span>
)
})}
</div>
)
}

export default AdminBookingDateDisplay
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import type { Meta, StoryObj } from "@storybook/react"
import AdminBookingView, { BookingMemberColumnFormat } from "./AdminBookingView"
import AdminBookingView from "./AdminBookingView"
import {
BookingInfo,
IAdminBookingDate
} from "./AdminBookingDateDisplay/AdminBookingDate/AdminBookingDate"
import { Timestamp } from "firebase/firestore"

const meta: Meta<typeof AdminBookingView> = {
component: AdminBookingView
Expand All @@ -8,24 +13,37 @@ const meta: Meta<typeof AdminBookingView> = {
export default meta
type Story = StoryObj<typeof meta>

const mockData: BookingMemberColumnFormat = {
const mockUser: BookingInfo = {
bookingId: "23132al",
uid: "1",
Date: "04/06/2004",
Name: "Ray",
Number: "12345678",
Email: "[email protected]",
"Dietary Requirement": "none"
first_name: "Straight",
last_name: "Zhao",
date_of_birth: Timestamp.fromMillis(0),
phone_number: 69696969,
dietary_requirements: "nothing",
email: "[email protected]",
membership: "guest"
}

const mockDataArray: BookingMemberColumnFormat[] = []
const mockUsersArray: BookingInfo[] = []

for (let i = 0; i < 100; ++i) {
mockDataArray.push(mockData)
for (let i = 0; i < 32; ++i) {
mockUsersArray.push(mockUser)
}

const mockDatesArray: IAdminBookingDate[] = []

for (let i = 1; i < 30; ++i) {
mockDatesArray.push({
dateString: `${i}/10/2002`,
users: mockUsersArray,
handleUserDelete: () => {}
})
}

export const DefaultAdminBookingView: Story = {
args: {
data: mockDataArray,
data: mockDatesArray,
dateRange: {
startDate: new Date("6969-10-10"),
endDate: new Date("9696-10-01")
Expand Down
Loading
Loading