-
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.
Brochures are now generated client-side on the fly and with an upgraded UI.
- Loading branch information
1 parent
a0371d2
commit cf334f0
Showing
12 changed files
with
714 additions
and
9 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import { YachtProvider } from "@/context/yacht"; | ||
import { | ||
fetchCharter, | ||
fetchNewConstruction, | ||
fetchSale, | ||
} from "@/actions/yachts"; | ||
import { getLocale } from "next-intl/server"; | ||
import { | ||
Hero, | ||
Details, | ||
About, | ||
KeyFeatures, | ||
Photo, | ||
Footer, | ||
} from "@/components/yachts/yacht/brochure"; | ||
import { IContext } from "@/context/view"; | ||
|
||
const Brochure = async ({ | ||
params, | ||
searchParams, | ||
}: { | ||
params: { | ||
id: string; | ||
}; | ||
searchParams: { | ||
type: "sale" | "charter" | "new-construction"; | ||
brochure: "hero" | "details" | "about" | "key-features" | "footer" | string; | ||
currency: IContext["currency"]; | ||
length: IContext["units"]["length"]; | ||
weight: IContext["units"]["weight"]; | ||
}; | ||
}) => { | ||
const yacht = await (async () => { | ||
switch (searchParams.type) { | ||
case "sale": | ||
return await fetchSale(params.id, (await getLocale()) as "en" | "fr"); | ||
case "charter": | ||
return await fetchCharter( | ||
params.id, | ||
(await getLocale()) as "en" | "fr", | ||
); | ||
case "new-construction": | ||
return await fetchNewConstruction( | ||
params.id, | ||
(await getLocale()) as "en" | "fr", | ||
); | ||
default: | ||
return await fetchSale(params.id, (await getLocale()) as "en" | "fr"); | ||
} | ||
})(), | ||
units: IContext["units"] = { | ||
length: searchParams.length, | ||
weight: searchParams.weight, | ||
}; | ||
|
||
const renderComponent = () => { | ||
switch (searchParams.brochure) { | ||
case "hero": | ||
return <Hero units={units} />; | ||
case "details": | ||
return <Details currency={searchParams.currency} units={units} />; | ||
case "about": | ||
return <About />; | ||
case "key-features": | ||
return <KeyFeatures />; | ||
case "footer": | ||
return <Footer />; | ||
default: | ||
if (parseInt(searchParams.brochure) >= 0) { | ||
return ( | ||
<Photo index={parseInt(searchParams.brochure)} units={units} /> | ||
); | ||
} | ||
return null; | ||
} | ||
}; | ||
|
||
return ( | ||
<YachtProvider data={yacht} type={searchParams.type}> | ||
<main className="w-full flex flex-col justify-start items-center"> | ||
{renderComponent()} | ||
</main> | ||
</YachtProvider> | ||
); | ||
}; | ||
|
||
export default Brochure; |
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
Oops, something went wrong.