diff --git a/.vscode/settings.example.json b/.vscode/settings.example.json index 867356d2d..5af3f81ca 100644 --- a/.vscode/settings.example.json +++ b/.vscode/settings.example.json @@ -1,5 +1,6 @@ { "typescript.tsdk": "node_modules/typescript/lib", + "typescript.enablePromptUseWorkspaceTsdk": true, "eslint.workingDirectories": [ { "pattern": "apps/*/" }, { "pattern": "packages/*/" } diff --git a/apps/core/app/(default)/product/[slug]/_components/breadcrumbs.tsx b/apps/core/app/(default)/product/[slug]/_components/breadcrumbs.tsx index 79a0f5660..d18af5b74 100644 --- a/apps/core/app/(default)/product/[slug]/_components/breadcrumbs.tsx +++ b/apps/core/app/(default)/product/[slug]/_components/breadcrumbs.tsx @@ -1,23 +1,44 @@ -import { getProduct } from '~/client/queries/get-product'; +import { removeEdgesAndNodes } from '@bigcommerce/catalyst-client'; + import { Link } from '~/components/link'; import { cn } from '~/lib/utils'; +import { FragmentOf, graphql, readFragment } from '~/tada/graphql'; + +export const BreadcrumbsFragment = graphql(` + fragment BreadcrumbsFragment on CategoryConnection { + edges { + node { + breadcrumbs(depth: 5) { + edges { + node { + name + path + } + } + } + } + } + } +`); interface Props { - productId: number; + data: FragmentOf; } -export const BreadCrumbs = async ({ productId }: Props) => { - const product = await getProduct(productId); - const category = product?.categories?.[0]; +export const BreadCrumbs = ({ data }: Props) => { + const fragmentData = readFragment(BreadcrumbsFragment, data); + const [category] = removeEdgesAndNodes(fragmentData); if (!category) { return null; } + const breadcrumbs = removeEdgesAndNodes(category.breadcrumbs); + return (