Skip to content

Commit

Permalink
Set default functions for breadcrumbs to make it usable outside
Browse files Browse the repository at this point in the history
  • Loading branch information
pozylon committed Jan 1, 2025
1 parent 8d2ba15 commit 2166b3d
Showing 1 changed file with 20 additions and 4 deletions.
24 changes: 20 additions & 4 deletions packages/core-assortments/src/module/configureAssortmentsModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -357,11 +357,27 @@ export const configureAssortmentsModule = async ({
productId?: string;
},
{
resolveAssortmentLinks,
resolveAssortmentProducts,
resolveAssortmentLinks = async (id: string) => {
return AssortmentLinks.find(
{ childAssortmentId: id },
{
projection: { _id: 1, childAssortmentId: 1, parentAssortmentId: 1 },
sort: { sortKey: 1, parentAssortmentId: 1 },
},
).toArray();
},
resolveAssortmentProducts = async (id: string) => {
return AssortmentProducts.find(
{ productId: id },
{
projection: { _id: true, assortmentId: true, productId: true },
sort: { sortKey: 1, productId: 1 },
},
).toArray();
},
}: {
resolveAssortmentLinks: BreadcrumbAssortmentLinkFunction;
resolveAssortmentProducts: BreacrumbAssortmentProductFunction;
resolveAssortmentLinks?: BreadcrumbAssortmentLinkFunction;
resolveAssortmentProducts?: BreacrumbAssortmentProductFunction;
},
): Promise<Array<{ links: Array<AssortmentPathLink> }>> => {
const buildBreadcrumbs = makeAssortmentBreadcrumbsBuilder({
Expand Down

0 comments on commit 2166b3d

Please sign in to comment.