@hanzo/commerce 2.0.0 → 3.0.0
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/add-to-cart-widget.tsx +3 -3
- package/components/buy-item/buy-item-button.tsx +28 -0
- package/components/buy-item/buy-item-card.tsx +82 -0
- package/components/buy-item/buy-item-popup.tsx +38 -0
- package/components/{select-category-and-item-widget.tsx → buy-item/select-category-and-item-widget.tsx} +4 -4
- package/components/buy-item/select-category-item-card.tsx +111 -0
- package/components/{cart-line-item.tsx → cart-panel/cart-line-item.tsx} +4 -3
- package/components/{cart.tsx → cart-panel/index.tsx} +24 -17
- package/components/category-item-ios-wheel-selector.tsx +60 -0
- package/components/category-item-radio-selector.tsx +55 -0
- package/components/{checkout → checkout-panel}/confirm-order.tsx +3 -2
- package/components/{checkout → checkout-panel}/index.tsx +26 -69
- package/components/checkout-panel/payment/contact-info.tsx +59 -0
- package/components/checkout-panel/payment/index.tsx +118 -0
- package/components/checkout-panel/payment/pay-with-bank-transfer.tsx +106 -0
- package/components/checkout-panel/payment/pay-with-card.tsx +198 -0
- package/components/{checkout → checkout-panel/payment}/pay-with-crypto.tsx +52 -30
- package/components/checkout-panel/payment/payment-methods/amex.tsx +32 -0
- package/components/checkout-panel/payment/payment-methods/diners-club.tsx +13 -0
- package/components/checkout-panel/payment/payment-methods/discover.tsx +25 -0
- package/components/checkout-panel/payment/payment-methods/index.tsx +24 -0
- package/components/checkout-panel/payment/payment-methods/jcb.tsx +26 -0
- package/components/checkout-panel/payment/payment-methods/mastercard.tsx +27 -0
- package/components/checkout-panel/payment/payment-methods/visa.tsx +25 -0
- package/components/{checkout → checkout-panel}/shipping-info.tsx +4 -10
- package/components/{facet-toggles-widget → facet-values-widget}/facet-image.tsx +7 -3
- package/components/{facet-toggles-widget → facet-values-widget}/index.tsx +7 -5
- package/components/index.ts +11 -9
- package/components/{select-item-in-category-view.tsx → select-category-item-panel.tsx} +72 -76
- package/index.ts +2 -2
- package/package.json +11 -4
- package/service/context.tsx +4 -4
- package/service/impls/standalone/index.ts +4 -4
- package/service/impls/standalone/orders/index.ts +42 -20
- package/service/impls/standalone/standalone-service.ts +128 -44
- package/types/category.ts +3 -2
- package/types/checkout.ts +6 -0
- package/types/commerce-service.ts +20 -7
- package/types/facet.ts +1 -3
- package/types/index.ts +4 -4
- package/types/item-selector.ts +14 -0
- package/util/index.ts +31 -1
- package/util/square-payment.ts +43 -0
- package/util/use-sync-sku-param-w-current-item.ts +4 -1
- package/blocks/components/commerce-cat-and-item-block.tsx +0 -13
- package/blocks/def/commerce-cat-and-item-block.ts +0 -9
- package/components/checkout/contact-info.tsx +0 -83
- package/components/checkout/pay-by-bank-transfer.tsx +0 -76
- package/components/facets-widget.tsx +0 -55
- package/components/product-selection-mobile-picker.tsx +0 -78
- package/components/product-selection-radio-group.tsx +0 -38
- /package/components/{checkout → checkout-panel}/countries.ts +0 -0
- /package/components/{checkout → checkout-panel}/icons/btc.tsx +0 -0
- /package/components/{checkout → checkout-panel}/icons/eth.tsx +0 -0
- /package/components/{checkout → checkout-panel}/icons/usdt.tsx +0 -0
- /package/components/{checkout → checkout-panel}/thank-you.tsx +0 -0
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import type { ReactNode } from 'react'
|
|
4
|
-
import { Copy } from 'lucide-react'
|
|
5
|
-
|
|
6
|
-
import { Button, Tabs, TabsContent, TabsList, TabsTrigger, toast } from '@hanzo/ui/primitives'
|
|
7
|
-
import { EnhHeadingBlockComponent, type EnhHeadingBlock, type Block } from '@hanzo/ui/blocks'
|
|
8
|
-
|
|
9
|
-
const InfoField: React.FC<{label: string, value: ReactNode, copyValue: string}> = ({label, value, copyValue}) => {
|
|
10
|
-
const copyToClipboard = (label: string, text: string) => {
|
|
11
|
-
navigator.clipboard.writeText(text)
|
|
12
|
-
toast({title: `${label} copied to clipboard`})
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
return (
|
|
16
|
-
<div className='flex flex-col gap-1'>
|
|
17
|
-
<p className='text-xs'>{label}</p>
|
|
18
|
-
<div className='flex items-center justify-between text-lg border rounded-lg py-2 px-4'>
|
|
19
|
-
{value}
|
|
20
|
-
<Button variant='ghost' size='icon' onClick={() => copyToClipboard(label, copyValue)}>
|
|
21
|
-
<Copy className='h-4 w-4'/>
|
|
22
|
-
</Button>
|
|
23
|
-
</div>
|
|
24
|
-
</div>
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const PayByBankTransfer: React.FC<{setCurrentStep: (step: number) => void}> = ({setCurrentStep}) => {
|
|
29
|
-
return (<>
|
|
30
|
-
<Tabs defaultValue="usd" className='w-full mx-auto max-w-[50rem]'>
|
|
31
|
-
<TabsList className="grid w-full grid-cols-2 max-w-[15rem] mx-auto bg-level-2">
|
|
32
|
-
<TabsTrigger value="usd">USD</TabsTrigger>
|
|
33
|
-
<TabsTrigger value="eur">EUR/GBP</TabsTrigger>
|
|
34
|
-
</TabsList>
|
|
35
|
-
<TabsContent value="usd">
|
|
36
|
-
<div className='flex flex-col gap-4 w-full'>
|
|
37
|
-
<InfoField
|
|
38
|
-
label='Beneficiary Bank'
|
|
39
|
-
value={<div>Bank of America<br/>NA 222 Broadway<br/>New York, New York. 10038</div>}
|
|
40
|
-
copyValue='Bank of America, NA 222 Broadway, New York, New York. 10038'
|
|
41
|
-
/>
|
|
42
|
-
<InfoField
|
|
43
|
-
label='Beneficiary'
|
|
44
|
-
value={<div>Hanzo, Inc<br/>4811 Mastin Street<br/>Merriam, KS 66203</div>}
|
|
45
|
-
copyValue='Hanzo, Inc, 4811 Mastin Street, Merriam, KS 66203'
|
|
46
|
-
/>
|
|
47
|
-
<InfoField label='Routing Number - ACH' value='113000023 / 111000025' copyValue='113000023 / 111000025'/>
|
|
48
|
-
<InfoField label='Routing Number - Wire' value='026009593' copyValue='026009593'/>
|
|
49
|
-
<InfoField label='Routing Number - SWIFT' value='BOFAUS3N' copyValue='BOFAUS3N'/>
|
|
50
|
-
<InfoField label='Reference' value='Lux' copyValue='Lux'/>
|
|
51
|
-
</div>
|
|
52
|
-
</TabsContent>
|
|
53
|
-
<TabsContent value="eur">
|
|
54
|
-
<div className='flex flex-col gap-4 w-full'>
|
|
55
|
-
<InfoField
|
|
56
|
-
label='Beneficiary Bank'
|
|
57
|
-
value={<div>Clear Junction Limited<br/>4th floor<br/>Imperial House</div>}
|
|
58
|
-
copyValue='Clear Junction Limited, 4th floor, Imperial House'
|
|
59
|
-
/>
|
|
60
|
-
<InfoField label='Account Number (GBP)' value='33781813' copyValue='33781813'/>
|
|
61
|
-
<InfoField label='Account Name' value='AiDLT Global Ltd.' copyValue='AiDLT Global Ltd.'/>
|
|
62
|
-
<InfoField label='SWIFT/BIC' value='CLJUGB21' copyValue='CLJUGB21'/>
|
|
63
|
-
<InfoField label='Sort Code (GBP)' value='041307' copyValue='041307'/>
|
|
64
|
-
<InfoField label='IBAN' value='GB75 CLJU 0413 0733 78181 3' copyValue='GB75 CLJU 0413 0733 78181 3'/>
|
|
65
|
-
<InfoField label='Reference' value='Lux' copyValue='Lux'/>
|
|
66
|
-
</div>
|
|
67
|
-
</TabsContent>
|
|
68
|
-
</Tabs>
|
|
69
|
-
<div className='flex gap-4 items-center mt-6'>
|
|
70
|
-
<Button variant='outline' onClick={() => setCurrentStep(1)} className='mx-auto w-full'>Back</Button>
|
|
71
|
-
<Button onClick={() => setCurrentStep(3)} className='mx-auto w-full'>Continue</Button>
|
|
72
|
-
</div>
|
|
73
|
-
</>)
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
export default PayByBankTransfer
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
import React, { type PropsWithChildren } from 'react'
|
|
3
|
-
|
|
4
|
-
import { cn } from '@hanzo/ui/util'
|
|
5
|
-
|
|
6
|
-
import type { FacetsDesc, StringMutator, StringArrayMutator } from '../types'
|
|
7
|
-
|
|
8
|
-
import FacetTogglesWidget from './facet-toggles-widget'
|
|
9
|
-
|
|
10
|
-
const FacetsWidget: React.FC<PropsWithChildren & {
|
|
11
|
-
facets: FacetsDesc
|
|
12
|
-
mutators: StringMutator[] | StringArrayMutator[]
|
|
13
|
-
facetClx?: string[]
|
|
14
|
-
facetItemClx?: string
|
|
15
|
-
multiple?: boolean
|
|
16
|
-
isMobile?: boolean
|
|
17
|
-
id?: string
|
|
18
|
-
className?: string
|
|
19
|
-
tabSize?: string
|
|
20
|
-
childrenAfter?: boolean
|
|
21
|
-
}> = ({
|
|
22
|
-
children,
|
|
23
|
-
facets,
|
|
24
|
-
mutators,
|
|
25
|
-
multiple=false,
|
|
26
|
-
facetClx,
|
|
27
|
-
facetItemClx='',
|
|
28
|
-
isMobile=false,
|
|
29
|
-
className='',
|
|
30
|
-
tabSize,
|
|
31
|
-
id='FacetsWidget',
|
|
32
|
-
childrenAfter=true
|
|
33
|
-
}) => {
|
|
34
|
-
const horiz = className.includes('flex-row')
|
|
35
|
-
return (
|
|
36
|
-
<div id={id} className={className} >
|
|
37
|
-
{!childrenAfter && children}
|
|
38
|
-
{Object.keys(facets).map((key, i) => (
|
|
39
|
-
<FacetTogglesWidget
|
|
40
|
-
key={i}
|
|
41
|
-
multiple={multiple}
|
|
42
|
-
mutator={mutators[i]}
|
|
43
|
-
isMobile={isMobile}
|
|
44
|
-
facetValues={facets[parseInt(key)]}
|
|
45
|
-
className={cn((horiz ? '' : 'mb-2'), (i !== 0 && !horiz) ? 'mt-2' : '', (facetClx?.[i]) ?? '')}
|
|
46
|
-
buttonClx={facetItemClx}
|
|
47
|
-
tabSize={tabSize}
|
|
48
|
-
/>
|
|
49
|
-
))}
|
|
50
|
-
{childrenAfter && children}
|
|
51
|
-
</div>
|
|
52
|
-
)
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export default FacetsWidget
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import React, { useState } from 'react'
|
|
2
|
-
import Picker from 'react-mobile-picker'
|
|
3
|
-
|
|
4
|
-
import type { Product } from '../types'
|
|
5
|
-
import { formatPrice } from '../util'
|
|
6
|
-
import { cn } from '@hanzo/ui/util'
|
|
7
|
-
|
|
8
|
-
// from source code
|
|
9
|
-
interface PickerItemRenderProps {
|
|
10
|
-
selected: boolean;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
function renderOptions(options: string[], selectedColor: string) {
|
|
14
|
-
return options.map((option) => (
|
|
15
|
-
<Picker.Item key={option} value={option}>
|
|
16
|
-
{({ selected }: PickerItemRenderProps) => (
|
|
17
|
-
<div className={selected ? `font-semibold ${selectedColor}` : 'text-neutral-400'}>{option}</div>
|
|
18
|
-
)}
|
|
19
|
-
</Picker.Item>
|
|
20
|
-
))
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// const DEFAULT_HEIGHT = 216
|
|
24
|
-
// const DEFAULT_ITEM_HEIGHT = 36
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const ProductSelectionMobilePicker: React.FC<{
|
|
28
|
-
products: Product[]
|
|
29
|
-
selectedSku: string | undefined
|
|
30
|
-
onValueChange: (v: string) => void
|
|
31
|
-
height?: number
|
|
32
|
-
itemHeight?: number
|
|
33
|
-
outerClx?: string
|
|
34
|
-
itemClx?: string
|
|
35
|
-
}> = ({
|
|
36
|
-
products,
|
|
37
|
-
selectedSku,
|
|
38
|
-
onValueChange,
|
|
39
|
-
height,
|
|
40
|
-
itemHeight,
|
|
41
|
-
outerClx='',
|
|
42
|
-
itemClx=''
|
|
43
|
-
}) => {
|
|
44
|
-
|
|
45
|
-
// @ts-ignore
|
|
46
|
-
const onChange = (val, ignore) => {
|
|
47
|
-
console.log("VAL", val)
|
|
48
|
-
console.log("key")
|
|
49
|
-
onValueChange(val.item)
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
return (
|
|
53
|
-
<div className={cn('border border-muted-4 rounded-lg px-2', outerClx)}>
|
|
54
|
-
<Picker
|
|
55
|
-
className=''
|
|
56
|
-
value={selectedSku ? {item: selectedSku} : {item: undefined}}
|
|
57
|
-
onChange={onChange}
|
|
58
|
-
wheelMode="natural"
|
|
59
|
-
height={height}
|
|
60
|
-
itemHeight={itemHeight}
|
|
61
|
-
>
|
|
62
|
-
<Picker.Column name="item">
|
|
63
|
-
{products.map((prod) => (
|
|
64
|
-
<Picker.Item key={prod.sku} value={prod.sku}>
|
|
65
|
-
{({ selected }: PickerItemRenderProps) => (
|
|
66
|
-
<div className={cn(selected ? 'font-semibold text-accent' : 'text-muted', itemClx)}>
|
|
67
|
-
{prod.titleAsOption + ', ' + formatPrice(prod.price)}
|
|
68
|
-
</div>
|
|
69
|
-
)}
|
|
70
|
-
</Picker.Item>
|
|
71
|
-
))}
|
|
72
|
-
</Picker.Column>
|
|
73
|
-
</Picker>
|
|
74
|
-
</div>
|
|
75
|
-
)
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
export default ProductSelectionMobilePicker
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { Label, RadioGroup, RadioGroupItem } from '@hanzo/ui/primitives'
|
|
4
|
-
import type { Product } from '../types'
|
|
5
|
-
import { formatPrice } from '../util'
|
|
6
|
-
|
|
7
|
-
const ProductSelectionRadioGroup: React.FC<{
|
|
8
|
-
products: Product[]
|
|
9
|
-
selectedSku: string | undefined
|
|
10
|
-
onValueChange: (v: string) => void
|
|
11
|
-
groupClx?: string
|
|
12
|
-
itemClx?: string
|
|
13
|
-
showPrice?: boolean
|
|
14
|
-
}> = ({
|
|
15
|
-
products,
|
|
16
|
-
selectedSku,
|
|
17
|
-
onValueChange,
|
|
18
|
-
groupClx='',
|
|
19
|
-
itemClx='',
|
|
20
|
-
showPrice=true
|
|
21
|
-
}) => (
|
|
22
|
-
products.length > 1 && (
|
|
23
|
-
<RadioGroup
|
|
24
|
-
className={groupClx}
|
|
25
|
-
onValueChange={onValueChange}
|
|
26
|
-
value={selectedSku}
|
|
27
|
-
>
|
|
28
|
-
{products.map((prod) => (
|
|
29
|
-
<div className={itemClx} key={prod.sku}>
|
|
30
|
-
<RadioGroupItem value={prod.sku} id={prod.sku} />
|
|
31
|
-
<Label htmlFor={prod.sku}>{prod.titleAsOption + (showPrice ? (', ' + formatPrice(prod.price)) : '')}</Label>
|
|
32
|
-
</div>
|
|
33
|
-
))}
|
|
34
|
-
</RadioGroup>
|
|
35
|
-
)
|
|
36
|
-
)
|
|
37
|
-
|
|
38
|
-
export default ProductSelectionRadioGroup
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|