-
Notifications
You must be signed in to change notification settings - Fork 764
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
181 additions
and
80 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import { AlertDialog, AlertDialogContent } from "@/components/ui/alert-dialog" | ||
|
||
export default function ModalLayout({ children }: React.PropsWithChildren) { | ||
return ( | ||
<AlertDialog defaultOpen> | ||
<AlertDialogContent className="max-w-3xl overflow-hidden p-0"> | ||
{children} | ||
</AlertDialogContent> | ||
</AlertDialog> | ||
) | ||
} |
15 changes: 15 additions & 0 deletions
15
src/app/(lobby)/@modal/(.)preview/product/[productId]/not-found.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,15 @@ | ||
import { ErrorCard } from "@/components/cards/error-card" | ||
import { Shell } from "@/components/shells/shell" | ||
|
||
export default function ProductNotFound() { | ||
return ( | ||
<Shell variant="centered" className="max-w-md"> | ||
<ErrorCard | ||
title="Product not found" | ||
description="The product may have expired or you may have already updated your product" | ||
retryLink="/" | ||
retryLinkText="Go to Home" | ||
/> | ||
</Shell> | ||
) | ||
} |
100 changes: 100 additions & 0 deletions
100
src/app/(lobby)/@modal/(.)preview/product/[productId]/page.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,100 @@ | ||
import Image from "next/image" | ||
import Link from "next/link" | ||
import { notFound } from "next/navigation" | ||
import { db } from "@/db" | ||
import type { StoredFile } from "@/types" | ||
import { EnterFullScreenIcon } from "@radix-ui/react-icons" | ||
import { eq, sql } from "drizzle-orm" | ||
import { products } from "drizzle/schema" | ||
|
||
import { cn, formatPrice } from "@/lib/utils" | ||
import { AlertDialogAction } from "@/components/ui/alert-dialog" | ||
import { AspectRatio } from "@/components/ui/aspect-ratio" | ||
import { buttonVariants } from "@/components/ui/button" | ||
import { AddToCartForm } from "@/components/forms/add-to-cart-form" | ||
import { PlaceholderImage } from "@/components/placeholder-image" | ||
import { Rating } from "@/components/rating" | ||
import { DialogShell } from "@/components/shells/dialog-shell" | ||
|
||
interface ProductModalPageProps { | ||
params: { | ||
productId: string | ||
} | ||
} | ||
|
||
export default async function ProductModalPage({ | ||
params, | ||
}: ProductModalPageProps) { | ||
const productId = Number(params.productId) | ||
|
||
const product = await db | ||
.select({ | ||
id: products.id, | ||
name: products.name, | ||
description: products.description, | ||
images: sql<StoredFile[] | null>`${products.images}`, | ||
category: products.category, | ||
price: products.price, | ||
inventory: products.inventory, | ||
rating: products.rating, | ||
}) | ||
.from(products) | ||
.where(eq(products.id, productId)) | ||
.execute() | ||
.then((rows) => rows[0]) | ||
|
||
if (!product) { | ||
notFound() | ||
} | ||
|
||
return ( | ||
<DialogShell className="flex flex-col gap-2 overflow-visible sm:flex-row"> | ||
<AlertDialogAction | ||
className={cn( | ||
buttonVariants({ | ||
variant: "ghost", | ||
size: "icon", | ||
className: | ||
"absolute right-10 top-4 h-auto w-auto shrink-0 rounded-sm bg-transparent p-0 text-foreground opacity-70 ring-offset-background transition-opacity hover:bg-transparent hover:opacity-100 focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:pointer-events-none data-[state=open]:bg-accent data-[state=open]:text-muted-foreground", | ||
}) | ||
)} | ||
asChild | ||
> | ||
<Link href={`/product/${product.id}`}> | ||
<EnterFullScreenIcon className="h-4 w-4" aria-hidden="true" /> | ||
</Link> | ||
</AlertDialogAction> | ||
<AspectRatio ratio={16 / 9} className="w-full"> | ||
{product.images?.length ? ( | ||
<Image | ||
src={product.images[0]?.url ?? "/images/product-placeholder.webp"} | ||
alt={product.images[0]?.name ?? product.name} | ||
className="object-cover" | ||
sizes="(min-width: 1024px) 20vw, (min-width: 768px) 25vw, (min-width: 640px) 33vw, (min-width: 475px) 50vw, 100vw" | ||
fill | ||
loading="lazy" | ||
/> | ||
) : ( | ||
<PlaceholderImage className="rounded-none" asChild /> | ||
)} | ||
</AspectRatio> | ||
<div className="w-full space-y-8 p-6 sm:p-10"> | ||
<div className="space-y-2"> | ||
<h1 className="line-clamp-2 text-2xl font-bold">{product.name}</h1> | ||
<p className="text-base text-muted-foreground"> | ||
{formatPrice(product.price)} | ||
</p> | ||
<Rating rating={Math.round(product.rating / 5)} /> | ||
<p className="text-base text-muted-foreground"> | ||
{product.inventory} in stock | ||
</p> | ||
</div> | ||
<AddToCartForm productId={product.id} /> | ||
|
||
<p className="line-clamp-2 text-base text-muted-foreground"> | ||
{product.description} | ||
</p> | ||
</div> | ||
</DialogShell> | ||
) | ||
} |
11 changes: 0 additions & 11 deletions
11
src/app/(lobby)/@modal/(.)product-preview/[productId]/layout.tsx
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
src/app/(lobby)/@modal/(.)product-preview/[productId]/page.tsx
This file was deleted.
Oops, something went wrong.
File renamed without changes.
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
d4efb80
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
skateshop – ./
skateshop13.vercel.app
skateshop-sadmann7.vercel.app
skateshop-git-main-sadmann7.vercel.app
skateshop.sadmn.com