heyitsmass / BayView

The next generation reservation tracking and notification system
https://bayview.dev
MIT License
1 stars 2 forks source link

Lodging Card #86

Closed cpilande closed 10 months ago

cpilande commented 10 months ago

Description

This PR implements the lodging card with the agreed-upon wireframe styles. This card receives the following inputs:

Motivation and Context

This PR is necessary to allow the user to search for and book hotel reservations. Lodging is one of the three necessary aspects of the itinerary that are necessary to plan for the trip.

How Has This Been Tested?

Screenshots (if appropriate):

Screenshot 2023-11-20 at 10 19 21 PM

Note: May have to add negative value checks to other card components

Types of changes

Checklist:

vercel[bot] commented 10 months ago

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
bay-view ❌ Failed (Inspect) Nov 26, 2023 11:46pm
cpilande commented 10 months ago

Looks good to me. I wonder if there might be a way to make the code easier to read if we set the input/inputpair components into their own function.

Yeah, that's true. We're going to have to refactor the date inputs for the customizable calendar also since it uses different Calendar and Dialog components

heyitsmass commented 10 months ago

Looks good to me. I wonder if there might be a way to make the code easier to read if we set the input/inputpair components into their own function.

There is, using an array

//handleSearch.ts

'use server'
export const handleSearch = async () => { 
 /* perform search */ 
 /* return results */ 
} 
export default function LodgingCard() {
  const form = {
    header: {
      label: "Location",
      name: "lodging-location",
      icon: faLocationArrow,
      placeholder: "Going to...",
      required: true,
    },
    pair: [
      {
        label: "Check-In Date",
      },
      {
        label: "Check-Out Date",
      },
    ],
    extra: [
      {
        label: "Number of Guests",
        placeholder: "Adults",
      },
      {
        label: "Number of Guests",
        placeholder: "Children",
      },
      {
        label: "Number of Guests",
        placeholder: "Rooms",
      },
    ],
  };

  return (
    <Card title="Lodging" subtitle="search for lodging reservations">
      <form action={handleSearch}>
        <Input {...form.header} icon={{ icon: form.header.icon }} />

        <InputPair icon={faArrowRight}>
          {
            form.pair.map((item, i) => (
              <Input
                key={i}
                {...item}
                icon={{ icon: faCalendarDays }}
                name={item.label.replaceAll(" ", "-").toLowerCase()}
                placeholder={item.label}
                required
              />
            )) as [ReactNode, ReactNode]
          }
        </InputPair>
        <div className="display: flex gap-3">
          {form.extra.map((item, i) => (
            <Input
              key={i}
              {...item}
              type="number"
              min="0"
              icon={{ icon: faUser }}
              name={item.label.replaceAll(" ", "-").toLowerCase()}
              required
            />
          ))}
        </div>
        <Button type="submit" variant="secondary" className="mt-4">
          Find Hotels
        </Button>
      </form>
    </Card>
  );
}