Skip to content

Commit

Permalink
Prevent crashing when no description is available
Browse files Browse the repository at this point in the history
  • Loading branch information
timuric committed Oct 10, 2023
1 parent 8adfa38 commit a59e5b3
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/app/products/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ export default async function Page(props: { params: { slug: string }; searchPara
}

const firstImage = product.thumbnail;
const description = parser.parse(JSON.parse((product?.description as string) || "{}"));
const description = product?.description ? parser.parse(JSON.parse(product?.description)) : null;

const variants = product.variants;
const selectedVariantID = searchParams.variant;
Expand Down Expand Up @@ -131,9 +131,9 @@ export default async function Page(props: { params: { slug: string }; searchPara
</p>

{variants && <VariantSelector variants={variants} />}
<div className="mt-4 space-y-6 mt-8">
{description && <div className="mt-4 space-y-6 mt-8">
<div dangerouslySetInnerHTML={{ __html: description }}></div>
</div>
</div>}
<div className="mt-6 flex items-center">
<CheckIcon className="h-5 w-5 flex-shrink-0 text-blue-500" aria-hidden="true" />
<p className="ml-1 text-sm font-semibold text-slate-500">In stock</p>
Expand Down

0 comments on commit a59e5b3

Please sign in to comment.