@hanzo/commerce 1.1.3 → 1.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/facet-toggles-widget/index.tsx +5 -3
- package/components/facets-widget.tsx +3 -0
- package/components/product-selection-radio-group.tsx +4 -2
- package/package.json +2 -2
- package/service/impls/standalone/orders/index.ts +6 -1
- package/service/impls/standalone/standalone-service.ts +3 -2
- package/types/commerce-service.ts +2 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use client'
|
|
2
2
|
import React, { useState } from 'react'
|
|
3
3
|
|
|
4
|
-
import { ToggleGroup, ToggleGroupItem,} from "@hanzo/ui/primitives"
|
|
4
|
+
import { ToggleGroup, ToggleGroupItem, type toggleVariants} from "@hanzo/ui/primitives"
|
|
5
5
|
import { cn } from '@hanzo/ui/util'
|
|
6
6
|
|
|
7
7
|
import type { FacetValueDesc, StringMutator, StringArrayMutator } from '../../types'
|
|
@@ -13,12 +13,14 @@ const FacetTogglesWidget: React.FC<{
|
|
|
13
13
|
multiple?: boolean
|
|
14
14
|
className?: string
|
|
15
15
|
isMobile?: boolean
|
|
16
|
+
tabSize?: string
|
|
16
17
|
}> = ({
|
|
17
18
|
facetValues,
|
|
18
19
|
mutator,
|
|
19
20
|
multiple='',
|
|
20
21
|
className='',
|
|
21
|
-
isMobile=false
|
|
22
|
+
isMobile=false,
|
|
23
|
+
tabSize
|
|
22
24
|
}) => {
|
|
23
25
|
|
|
24
26
|
const [last, setLast] = useState<string | undefined>(undefined)
|
|
@@ -48,7 +50,7 @@ const FacetTogglesWidget: React.FC<{
|
|
|
48
50
|
type={multiple ? 'multiple' : 'single'}
|
|
49
51
|
value={val}
|
|
50
52
|
variant='default'
|
|
51
|
-
size={isMobile ? 'sm' : 'default'}
|
|
53
|
+
size={isMobile ? 'sm' : tabSize ? tabSize : 'default'}
|
|
52
54
|
onValueChange={multiple ? handleChangeMultiple : handleChangeSingle}
|
|
53
55
|
className={className}
|
|
54
56
|
{...roundedToSpread}
|
|
@@ -15,6 +15,7 @@ const FacetsWidget: React.FC<PropsWithChildren & {
|
|
|
15
15
|
isMobile?: boolean
|
|
16
16
|
id?: string
|
|
17
17
|
className?: string
|
|
18
|
+
tabSize?: string
|
|
18
19
|
}> = ({
|
|
19
20
|
children,
|
|
20
21
|
facets,
|
|
@@ -23,6 +24,7 @@ const FacetsWidget: React.FC<PropsWithChildren & {
|
|
|
23
24
|
facetClassNames,
|
|
24
25
|
isMobile=false,
|
|
25
26
|
className='',
|
|
27
|
+
tabSize,
|
|
26
28
|
id='FacetsWidget'
|
|
27
29
|
}) => {
|
|
28
30
|
const horiz = className.includes('flex-row')
|
|
@@ -36,6 +38,7 @@ const FacetsWidget: React.FC<PropsWithChildren & {
|
|
|
36
38
|
isMobile={isMobile}
|
|
37
39
|
facetValues={facets[parseInt(key)]}
|
|
38
40
|
className={cn((horiz ? '' : 'mb-2'), (i !== 0 && !horiz) ? 'mt-2' : '', (facetClassNames?.[i]) ?? '')}
|
|
41
|
+
tabSize={tabSize}
|
|
39
42
|
/>
|
|
40
43
|
))}
|
|
41
44
|
{children}
|
|
@@ -10,12 +10,14 @@ const ProductSelectionRadioGroup: React.FC<{
|
|
|
10
10
|
onValueChange: (v: string) => void
|
|
11
11
|
groupClx?: string
|
|
12
12
|
itemClx?: string
|
|
13
|
+
showPrice?: boolean
|
|
13
14
|
}> = ({
|
|
14
15
|
products,
|
|
15
16
|
selectedSku,
|
|
16
17
|
onValueChange,
|
|
17
18
|
groupClx='',
|
|
18
|
-
itemClx=''
|
|
19
|
+
itemClx='',
|
|
20
|
+
showPrice=true
|
|
19
21
|
}) => (
|
|
20
22
|
<RadioGroup
|
|
21
23
|
className={groupClx}
|
|
@@ -25,7 +27,7 @@ const ProductSelectionRadioGroup: React.FC<{
|
|
|
25
27
|
{products.map((prod) => (
|
|
26
28
|
<div className={itemClx} key={prod.sku}>
|
|
27
29
|
<RadioGroupItem value={prod.sku} id={prod.sku} />
|
|
28
|
-
<Label htmlFor={prod.sku}>{prod.titleAsOption + ', ' + formatPrice(prod.price)}</Label>
|
|
30
|
+
<Label htmlFor={prod.sku}>{prod.titleAsOption + (showPrice ? (', ' + formatPrice(prod.price)) : '')}</Label>
|
|
29
31
|
</div>
|
|
30
32
|
))}
|
|
31
33
|
</RadioGroup>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hanzo/commerce",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"description": "Library with shopping cart components.",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -34,7 +34,7 @@
|
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
36
|
"@hanzo/auth": "^1.0.12",
|
|
37
|
-
"@hanzo/ui": "^1.0.
|
|
37
|
+
"@hanzo/ui": "^1.0.12",
|
|
38
38
|
"firebase": "^10.8.0",
|
|
39
39
|
"mobx": "^6.12.0",
|
|
40
40
|
"mobx-react-lite": "^4.0.5",
|
|
@@ -24,6 +24,8 @@ const getDBInstance = (name: string): Firestore => {
|
|
|
24
24
|
interface SavedOrder {
|
|
25
25
|
email: string
|
|
26
26
|
paymentMethod: string
|
|
27
|
+
// TODO: add shippingInfo type
|
|
28
|
+
shippingInfo?: any
|
|
27
29
|
status: string
|
|
28
30
|
timestamp: FieldValue
|
|
29
31
|
items: ActualLineItemSnapshot[]
|
|
@@ -69,11 +71,13 @@ const updateOrder = async (
|
|
|
69
71
|
orderId: string,
|
|
70
72
|
email: string,
|
|
71
73
|
paymentMethod: string,
|
|
74
|
+
// TODO: add shippingInfo type
|
|
72
75
|
items: ActualLineItemSnapshot[],
|
|
73
76
|
options: {
|
|
74
77
|
dbName: string
|
|
75
78
|
ordersTable: string
|
|
76
|
-
}
|
|
79
|
+
},
|
|
80
|
+
shippingInfo?: any
|
|
77
81
|
): Promise<{
|
|
78
82
|
success: boolean,
|
|
79
83
|
error: any
|
|
@@ -86,6 +90,7 @@ const updateOrder = async (
|
|
|
86
90
|
await setDoc(doc(ordersRef, orderId), {
|
|
87
91
|
email,
|
|
88
92
|
paymentMethod,
|
|
93
|
+
shippingInfo,
|
|
89
94
|
status: 'open',
|
|
90
95
|
timestamp: serverTimestamp(),
|
|
91
96
|
items,
|
|
@@ -93,9 +93,10 @@ class StandaloneService
|
|
|
93
93
|
return order.id
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
// TODO: add shippingInfo type
|
|
97
|
+
async updateOrder(orderId: string, email: string, paymentMethod: string, shippingInfo?: any): Promise<void> {
|
|
97
98
|
const snapshot = this.takeSnapshot()
|
|
98
|
-
updateOrderHelper(orderId, email, paymentMethod, snapshot.items, this._options) // didn't want to have two levels of 'items'
|
|
99
|
+
updateOrderHelper(orderId, email, paymentMethod, snapshot.items, this._options, shippingInfo) // didn't want to have two levels of 'items'
|
|
99
100
|
}
|
|
100
101
|
|
|
101
102
|
takeSnapshot = (): StandaloneServiceSnapshot => ({
|
|
@@ -9,7 +9,8 @@ interface CommerceService extends ObsLineItemRef {
|
|
|
9
9
|
getCartCategorySubtotal(categoryId: string): number
|
|
10
10
|
|
|
11
11
|
createOrder(email: string, paymentMethod: string): Promise<string | undefined>
|
|
12
|
-
|
|
12
|
+
// TODO: add shippingInfo type
|
|
13
|
+
updateOrder(orderId: string, email: string, paymentMethod: string, shippingInfo?: any): Promise<void>
|
|
13
14
|
|
|
14
15
|
/**
|
|
15
16
|
* Sets the tokens at each level supplied.
|