-
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.
660 frontend put lodge schemas on bookings page (#763)
* create basic story and implement component on page * fetch data from sanity * update docs
- Loading branch information
1 parent
cafd4e8
commit ea8b816
Showing
11 changed files
with
182 additions
and
13 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
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
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
28 changes: 28 additions & 0 deletions
28
...s/composite/Booking/BookingInformationAndCreation/BookingInformationAndCreation.story.tsx
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,28 @@ | ||
import type { Meta, StoryObj } from "@storybook/react" | ||
import BookingInformationAndCreation from "./BookingInformationAndCreation" | ||
|
||
const meta: Meta<typeof BookingInformationAndCreation> = { | ||
component: BookingInformationAndCreation | ||
} | ||
|
||
export default meta | ||
|
||
type Story = StoryObj<typeof meta> | ||
|
||
export const DefaultBookingInformationAndCreation: Story = { | ||
args: { | ||
lodgeInfoProps: { | ||
children: ( | ||
<> | ||
<h2 className="italic">About our lodge</h2> | ||
<p> | ||
Lorem ipsum dolor sit amet consectetur, adipisicing elit. Sit | ||
molestiae repellendus nulla voluptatibus iure! Quasi earum quis | ||
velit facilis mollitia minus a consequuntur blanditiis, excepturi | ||
omnis harum laudantium ad dolores. | ||
</p> | ||
</> | ||
) | ||
} | ||
} | ||
} |
76 changes: 76 additions & 0 deletions
76
...ponents/composite/Booking/BookingInformationAndCreation/BookingInformationAndCreation.tsx
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,76 @@ | ||
"use client" | ||
|
||
import { useState } from "react" | ||
import LodgeInfo, { ILodgeInfo } from "../../LodgeInfo/LodgeInfo" | ||
import { | ||
CreateBookingSection, | ||
ICreateBookingSection | ||
} from "../BookingCreation/BookingCreation" | ||
import { ProtectedCreateBookingSection } from "../BookingCreation/ProtectedCreateBookingSection" | ||
import { useSearchParams } from "next/navigation" | ||
|
||
/** | ||
* Utility type determining what should be displayed to the user in {@link BookingInformationAndCreation} | ||
*/ | ||
type BookingStages = "booking-information" | "booking-creation" | ||
|
||
interface IBookingInformationAndCreation { | ||
/** | ||
* The required props for {@link CreateBookingSection} | ||
* | ||
* Optional if {@link enableNetworkRequests} is set to `false` | ||
*/ | ||
bookingCreationProps?: ICreateBookingSection | ||
|
||
/** | ||
* The required props for {@link LodgeInfo} | ||
*/ | ||
lodgeInfoProps?: Omit<ILodgeInfo, "handleBookLodgeClick"> | ||
|
||
/** | ||
* Only set to `true` if embedding on page, for storybook purposes keep as false. | ||
* | ||
* Uses the {@link ProtectedCreateBookingSection} component if set to `true` otherwise | ||
* uses the implementation of{@link CreateBookingSection} | ||
*/ | ||
enableNetworkRequests?: boolean | ||
} | ||
|
||
/** | ||
* Wrapper component that handles presentation for the booking creation page, | ||
* with the information screen to allow users to know more about the lodge | ||
*/ | ||
const BookingInformationAndCreation = ({ | ||
bookingCreationProps, | ||
lodgeInfoProps, | ||
enableNetworkRequests | ||
}: IBookingInformationAndCreation) => { | ||
const params = useSearchParams() | ||
|
||
const defaultStage: BookingStages = | ||
params.get("skip-info") === "true" | ||
? "booking-creation" | ||
: "booking-information" | ||
|
||
const [currentStage, setCurrentStage] = useState<BookingStages>(defaultStage) | ||
|
||
switch (currentStage) { | ||
case "booking-information": | ||
return ( | ||
<LodgeInfo | ||
{...lodgeInfoProps} | ||
handleBookLodgeClick={() => { | ||
setCurrentStage("booking-creation") | ||
}} | ||
/> | ||
) | ||
case "booking-creation": | ||
if (enableNetworkRequests) { | ||
return <ProtectedCreateBookingSection /> | ||
} else { | ||
return <CreateBookingSection {...bookingCreationProps} /> | ||
} | ||
} | ||
} | ||
|
||
export default BookingInformationAndCreation |
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,2 +1,13 @@ | ||
import { PortableTextBlock } from "@portabletext/types" | ||
|
||
export const LODGE_INFORMATION_GROQ_QUERY = | ||
`[_type == "lodge-information"]` as const | ||
`*[_type == "lodge-information"]{"imageUrls": images[]{"url": asset->url}, ...}` as const | ||
|
||
type LodgeInformationImage = { | ||
url?: string | ||
} | ||
|
||
export type LodgeInformation = { | ||
imageUrls?: LodgeInformationImage[] | ||
information?: PortableTextBlock[] | ||
} |
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