Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmmc: hook takes category level as param #45

Merged
merged 1 commit into from
Mar 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/commerce/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hanzo/commerce",
"version": "1.1.2",
"version": "1.1.3",
"description": "Library with shopping cart components.",
"publishConfig": {
"registry": "https://registry.npmjs.org/",
Expand Down
11 changes: 7 additions & 4 deletions packages/commerce/util/use-sync-sku-param-w-current-item.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,12 @@ import {
} from 'next-usequerystate'

import { useCommerce } from '../service/context'
import type { FacetsValue } from '../types'

const PLEASE_SELECT_FACETS = 'Please select an option from each group above.'

const useSyncSkuParamWithCurrentItem = (
categoryLevel: number,
setMessage: (m: string | undefined) => void,
setLoading?: (l: boolean) => void
) => {
Expand Down Expand Up @@ -53,10 +55,11 @@ const useSyncSkuParamWithCurrentItem = (

const setCurrentCategoryFromSku = (sku: string) => {
const toks: string[] = sku.split('-')
cmmc.setFacets({
1: [toks[1]],
2: [toks[2]]
})
const fv: FacetsValue = {}
for (let i = 1; i < categoryLevel; i++) {
fv[i] = [toks[i]]
}
cmmc.setFacets(fv)
}

// setCI returns true if it's a recognized sku
Expand Down
Loading