forked from Kiranism/next-shadcn-dashboard-starter
-
Notifications
You must be signed in to change notification settings - Fork 0
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
142 additions
and
60 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 |
---|---|---|
@@ -1,9 +1,30 @@ | ||
import { Breadcrumbs } from '@/components/breadcrumbs'; | ||
import FormCardSkeleton from '@/components/form-card-skeleton'; | ||
import PageContainer from '@/components/layout/page-container'; | ||
import { ProductViewPage } from '@/sections/product/view'; | ||
import { Suspense } from 'react'; | ||
|
||
export const metadata = { | ||
title: 'Dashboard : Product View' | ||
}; | ||
|
||
export default function Page() { | ||
return <ProductViewPage />; | ||
const breadcrumbItems = [ | ||
{ title: 'Dashboard', link: '/dashboard' }, | ||
{ title: 'Product', link: '/dashboard/product' }, | ||
{ title: 'Create', link: '/dashboard/product/create' } | ||
]; | ||
|
||
type PageProps = { params: { productId: string } }; | ||
|
||
export default function Page({ params }: PageProps) { | ||
return ( | ||
<PageContainer scrollable> | ||
<div className="flex-1 space-y-4"> | ||
<Breadcrumbs items={breadcrumbItems} /> | ||
<Suspense fallback={<FormCardSkeleton />}> | ||
<ProductViewPage productId={params.productId} /> | ||
</Suspense> | ||
</div> | ||
</PageContainer> | ||
); | ||
} |
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,52 @@ | ||
import React from 'react'; | ||
import { Card, CardContent, CardHeader } from './ui/card'; | ||
import { Skeleton } from './ui/skeleton'; | ||
|
||
export default function FormCardSkeleton() { | ||
return ( | ||
<Card className="mx-auto w-full"> | ||
<CardHeader> | ||
<Skeleton className="h-8 w-48" /> {/* Title */} | ||
</CardHeader> | ||
<CardContent> | ||
<div className="space-y-8"> | ||
{/* Image upload area skeleton */} | ||
<div className="space-y-6"> | ||
<Skeleton className="h-4 w-16" /> {/* Label */} | ||
<Skeleton className="h-32 w-full rounded-lg" /> {/* Upload area */} | ||
</div> | ||
|
||
{/* Grid layout for form fields */} | ||
<div className="grid grid-cols-1 gap-6 md:grid-cols-2"> | ||
{/* Product Name field */} | ||
<div className="space-y-2"> | ||
<Skeleton className="h-4 w-24" /> {/* Label */} | ||
<Skeleton className="h-10 w-full" /> {/* Input */} | ||
</div> | ||
|
||
{/* Category field */} | ||
<div className="space-y-2"> | ||
<Skeleton className="h-4 w-20" /> {/* Label */} | ||
<Skeleton className="h-10 w-full" /> {/* Select */} | ||
</div> | ||
|
||
{/* Price field */} | ||
<div className="space-y-2"> | ||
<Skeleton className="h-4 w-16" /> {/* Label */} | ||
<Skeleton className="h-10 w-full" /> {/* Input */} | ||
</div> | ||
</div> | ||
|
||
{/* Description field */} | ||
<div className="space-y-2"> | ||
<Skeleton className="h-4 w-24" /> {/* Label */} | ||
<Skeleton className="h-32 w-full" /> {/* Textarea */} | ||
</div> | ||
|
||
{/* Submit button */} | ||
<Skeleton className="h-10 w-28" /> | ||
</div> | ||
</CardContent> | ||
</Card> | ||
); | ||
} |
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 was deleted.
Oops, something went wrong.
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,22 +1,20 @@ | ||
import { Breadcrumbs } from '@/components/breadcrumbs'; | ||
import { ScrollArea } from '@/components/ui/scroll-area'; | ||
import React from 'react'; | ||
import { fakeProducts, Product } from '@/constants/mock-api'; | ||
import ProductForm from '../product-form'; | ||
import PageContainer from '@/components/layout/page-container'; | ||
import { notFound } from 'next/navigation'; | ||
|
||
const breadcrumbItems = [ | ||
{ title: 'Dashboard', link: '/dashboard' }, | ||
{ title: 'Product', link: '/dashboard/product' }, | ||
{ title: 'Create', link: '/dashboard/product/create' } | ||
]; | ||
type TProductViewPageProps = { | ||
productId: string; | ||
}; | ||
|
||
export default function ProductViewPage() { | ||
return ( | ||
<PageContainer scrollable> | ||
<div className="flex-1 space-y-4"> | ||
<Breadcrumbs items={breadcrumbItems} /> | ||
<ProductForm /> | ||
</div> | ||
</PageContainer> | ||
); | ||
export default async function ProductViewPage({ | ||
productId | ||
}: TProductViewPageProps) { | ||
const data = await fakeProducts.getProductById(Number(productId)); | ||
const product = data.product as Product; | ||
|
||
if (!product) { | ||
return notFound(); | ||
} | ||
|
||
return <ProductForm initialData={product} />; | ||
} |