Skip to content

Commit

Permalink
refactor: add link in home to go to product test page
Browse files Browse the repository at this point in the history
  • Loading branch information
Yokaito committed Nov 21, 2023
1 parent 82af2f4 commit c72fdbc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
11 changes: 5 additions & 6 deletions apps/commerce/src/app/page.tsx
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { api } from '@/sdk/lib/trpc/server';
import Link from 'next/link';

export default async function HomePage() {
const product = await api.product.getProductByHandle({
handle: 'camiseta-de-manga-longa'
});

return (
<div className="flex min-h-screen flex-col items-center p-24">
<span>{product?.title} Server Component</span>
<span>Home</span>
<Link href="/product/camiseta-de-manga-longa" prefetch>
Produto Teste
</Link>
</div>
);
}
10 changes: 7 additions & 3 deletions apps/commerce/src/app/product/[handle]/page.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HIDDEN_PRODUCT_TAG } from '@/sdk/lib/constants';
import { getProduct } from '@/sdk/lib/shopify';
import { api } from '@/sdk/lib/trpc/server';
import { Metadata } from 'next';
import { notFound } from 'next/navigation';

Expand All @@ -14,7 +14,9 @@ export async function generateMetadata({
}: {
params: { handle: string };
}): Promise<Metadata> {
const product = await getProduct(params.handle);
const product = await api.product.getProductByHandle({
handle: params.handle
});

if (!product) return notFound();

Expand Down Expand Up @@ -49,7 +51,9 @@ export async function generateMetadata({
}

export default async function ProductPage({ params }: Props) {
const product = await getProduct(params.handle);
const product = await api.product.getProductByHandle({
handle: params.handle
});

if (!product) return notFound();

Expand Down

0 comments on commit c72fdbc

Please sign in to comment.