@hanzo/commerce 7.3.2 → 7.3.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/Icons.tsx +34 -34
- package/components/add-to-cart-widget.tsx +183 -183
- package/components/buy/buy-card.tsx +259 -259
- package/components/buy/carousel-buy-card.tsx +242 -242
- package/components/buy/multi-family/all-variants-carousel.tsx +261 -261
- package/components/buy/multi-family/family-carousel/index.tsx +77 -77
- package/components/buy/multi-family/family-carousel/slide.tsx +83 -83
- package/components/buy/multi-family/family-carousel/state.ts +87 -87
- package/components/buy/multi-family/index.ts +2 -2
- package/components/buy/single-family-selector.tsx +90 -90
- package/components/buy/title-and-byline.tsx +25 -25
- package/components/cart/cart-panel/cart-line-item.tsx +76 -76
- package/components/cart/cart-panel/index.tsx +154 -154
- package/components/cart/cart-panel/promo-code.tsx +106 -106
- package/components/cart/cart-panel/total-area.tsx +60 -60
- package/components/checkout/payment-step-form/card-icon-row.tsx +26 -26
- package/components/checkout/payment-step-form/card-icons/amex.tsx +32 -32
- package/components/checkout/payment-step-form/card-icons/diners-club.tsx +13 -13
- package/components/checkout/payment-step-form/card-icons/discover.tsx +25 -25
- package/components/checkout/payment-step-form/card-icons/jcb.tsx +26 -26
- package/components/checkout/payment-step-form/card-icons/mastercard.tsx +27 -27
- package/components/checkout/payment-step-form/card-icons/visa.tsx +25 -25
- package/components/checkout/payment-step-form/cc-button.tsx +17 -17
- package/components/checkout/payment-step-form/contact-form.tsx +49 -49
- package/components/checkout/payment-step-form/crypto-icons/btc.tsx +11 -11
- package/components/checkout/payment-step-form/crypto-icons/eth.tsx +20 -20
- package/components/checkout/payment-step-form/crypto-icons/usdt.tsx +13 -13
- package/components/checkout/payment-step-form/index.tsx +122 -122
- package/components/checkout/payment-step-form/methods/bank-transfer.tsx +79 -79
- package/components/checkout/payment-step-form/methods/card.tsx +232 -232
- package/components/checkout/payment-step-form/methods/crypto.tsx +227 -227
- package/components/checkout/payment-step-form/methods/index.ts +22 -22
- package/components/checkout/shipping-step-form.tsx +172 -172
- package/components/index.ts +11 -11
- package/components/item/product-card.tsx +48 -48
- package/components/item-selector/button.tsx +188 -188
- package/components/item-selector/carousel/index.tsx +197 -197
- package/components/item-selector/carousel/slider.tsx +40 -40
- package/components/item-selector/index.ts +5 -5
- package/components/item-selector/quantity-indicator.tsx +48 -48
- package/components/node-tabs/index.tsx +91 -91
- package/components/node-tabs/node-image.tsx +31 -31
- package/index.ts +12 -12
- package/package.json +60 -60
- package/service/context.tsx +45 -45
- package/service/debug.ts +41 -41
- package/service/impls/standalone/actual-line-item.ts +135 -135
- package/service/impls/standalone/get-instance.ts +64 -64
- package/service/impls/standalone/index.ts +579 -579
- package/service/impls/standalone/order/firebase.ts +14 -14
- package/service/impls/standalone/order/index.ts +128 -128
- package/service/impls/standalone/persistence.ts +33 -33
- package/service/path-utils.ts +25 -25
- package/service/sep.ts +6 -6
- package/tsconfig.json +10 -10
- package/types/README.md +1 -1
- package/types/category-node.ts +49 -49
- package/types/checkout.ts +46 -46
- package/types/commerce-config.ts +13 -13
- package/types/commerce-service.ts +127 -127
- package/types/family.ts +25 -25
- package/types/index.ts +15 -15
- package/types/item-selector.ts +96 -96
- package/types/line-item.ts +29 -29
- package/types/multi-family-selector-props.ts +19 -19
- package/types/product.ts +20 -20
- package/types/promo.ts +9 -9
- package/types/selection-ui-specifier.ts +51 -51
- package/types/string-mutator.ts +13 -13
- package/types/token-separators.ts +7 -7
- package/util/analytics.ts +20 -20
- package/util/countries.ts +195 -195
- package/util/error.ts +34 -34
- package/util/index.ts +70 -70
- package/util/item-selector-options-accessor.ts +34 -34
- package/util/line-item-ref.ts +23 -23
- package/util/multi-family-selector-options-accessor.ts +14 -14
- package/util/obs-string-mutator.ts +22 -22
- package/util/product-media-accessor.ts +58 -58
- package/util/promo-codes.ts +108 -108
- package/util/selection-ui-specifiers.ts +29 -29
- package/util/square-payment.ts +42 -42
- package/util/use-sync-sku-param-w-current-item.ts +88 -88
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { initializeApp, getApps } from 'firebase/app'
|
|
2
|
-
|
|
3
|
-
const firebaseConfig = {
|
|
4
|
-
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
5
|
-
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
6
|
-
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
7
|
-
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
8
|
-
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
9
|
-
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
10
|
-
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
// Initialize Firebase instance if there isn't one already
|
|
14
|
-
export default getApps().length === 0 ? initializeApp(firebaseConfig) : getApps()[0]
|
|
1
|
+
import { initializeApp, getApps } from 'firebase/app'
|
|
2
|
+
|
|
3
|
+
const firebaseConfig = {
|
|
4
|
+
apiKey: process.env.NEXT_PUBLIC_FIREBASE_API_KEY,
|
|
5
|
+
authDomain: process.env.NEXT_PUBLIC_FIREBASE_AUTH_DOMAIN,
|
|
6
|
+
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
|
7
|
+
storageBucket: process.env.NEXT_PUBLIC_FIREBASE_STORAGE_BUCKET,
|
|
8
|
+
messagingSenderId: process.env.NEXT_PUBLIC_FIREBASE_MESSAGING_SENDER_ID,
|
|
9
|
+
appId: process.env.NEXT_PUBLIC_FIREBASE_APP_ID,
|
|
10
|
+
measurementId: process.env.NEXT_PUBLIC_FIREBASE_MEASUREMENT_ID,
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// Initialize Firebase instance if there isn't one already
|
|
14
|
+
export default getApps().length === 0 ? initializeApp(firebaseConfig) : getApps()[0]
|
|
@@ -1,129 +1,129 @@
|
|
|
1
|
-
import {
|
|
2
|
-
getFirestore,
|
|
3
|
-
collection,
|
|
4
|
-
setDoc,
|
|
5
|
-
doc,
|
|
6
|
-
serverTimestamp,
|
|
7
|
-
type Firestore,
|
|
8
|
-
type FieldValue,
|
|
9
|
-
} from 'firebase/firestore'
|
|
10
|
-
|
|
11
|
-
import type { ActualLineItemSnapshot } from '../actual-line-item'
|
|
12
|
-
|
|
13
|
-
import firebaseApp from './firebase'
|
|
14
|
-
|
|
15
|
-
let dbInstance: Firestore | undefined = undefined
|
|
16
|
-
|
|
17
|
-
const getDBInstance = (name: string): Firestore => {
|
|
18
|
-
if (!dbInstance) {
|
|
19
|
-
dbInstance = getFirestore(firebaseApp, name)
|
|
20
|
-
}
|
|
21
|
-
return dbInstance
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
interface SavedOrder {
|
|
25
|
-
email: string
|
|
26
|
-
name: string
|
|
27
|
-
// TODO: add shippingInfo type
|
|
28
|
-
shippingInfo?: any
|
|
29
|
-
paymentInfo?: any
|
|
30
|
-
status: string
|
|
31
|
-
timestamp: FieldValue
|
|
32
|
-
items: ActualLineItemSnapshot[]
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const createOrder = async (
|
|
36
|
-
email: string,
|
|
37
|
-
items: ActualLineItemSnapshot[],
|
|
38
|
-
options: {
|
|
39
|
-
dbName: string
|
|
40
|
-
ordersTable: string
|
|
41
|
-
},
|
|
42
|
-
name?: string
|
|
43
|
-
): Promise<{
|
|
44
|
-
success: boolean,
|
|
45
|
-
error: any,
|
|
46
|
-
id?: string,
|
|
47
|
-
}> => {
|
|
48
|
-
|
|
49
|
-
let error: any | null = null
|
|
50
|
-
const ordersRef = collection(getDBInstance(options.dbName), options.ordersTable)
|
|
51
|
-
const orderId = `${email}-${new Date().toISOString()}`
|
|
52
|
-
|
|
53
|
-
try {
|
|
54
|
-
await setDoc(doc(ordersRef, orderId), {
|
|
55
|
-
email,
|
|
56
|
-
name: name ?? '',
|
|
57
|
-
status: 'open',
|
|
58
|
-
timestamp: serverTimestamp(),
|
|
59
|
-
items,
|
|
60
|
-
} satisfies SavedOrder)
|
|
61
|
-
return { success: !error, error, id: orderId }
|
|
62
|
-
}
|
|
63
|
-
catch (e) {
|
|
64
|
-
console.error('Error writing item document: ', e)
|
|
65
|
-
error = e
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
return { success: !error, error }
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
const updateOrderShippingInfo = async (
|
|
72
|
-
orderId: string,
|
|
73
|
-
shippingInfo: any,
|
|
74
|
-
options: {
|
|
75
|
-
dbName: string
|
|
76
|
-
ordersTable: string
|
|
77
|
-
}
|
|
78
|
-
): Promise<{
|
|
79
|
-
success: boolean,
|
|
80
|
-
error: any
|
|
81
|
-
}> => {
|
|
82
|
-
|
|
83
|
-
let error: any | null = null
|
|
84
|
-
const ordersRef = collection(getDBInstance(options.dbName), options.ordersTable)
|
|
85
|
-
|
|
86
|
-
try {
|
|
87
|
-
await setDoc(doc(ordersRef, orderId), {
|
|
88
|
-
shippingInfo,
|
|
89
|
-
timestamp: serverTimestamp(),
|
|
90
|
-
}, { merge: true })
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
console.error('Error writing item document: ', e)
|
|
94
|
-
error = e
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
return { success: !error, error }
|
|
98
|
-
}
|
|
99
|
-
|
|
100
|
-
const updateOrderPaymentInfo = async (
|
|
101
|
-
orderId: string,
|
|
102
|
-
paymentInfo: any,
|
|
103
|
-
options: {
|
|
104
|
-
dbName: string
|
|
105
|
-
ordersTable: string
|
|
106
|
-
}
|
|
107
|
-
): Promise<{
|
|
108
|
-
success: boolean,
|
|
109
|
-
error: any
|
|
110
|
-
}> => {
|
|
111
|
-
|
|
112
|
-
let error: any | null = null
|
|
113
|
-
const ordersRef = collection(getDBInstance(options.dbName), options.ordersTable)
|
|
114
|
-
|
|
115
|
-
try {
|
|
116
|
-
await setDoc(doc(ordersRef, orderId), {
|
|
117
|
-
paymentInfo,
|
|
118
|
-
timestamp: serverTimestamp(),
|
|
119
|
-
}, { merge: true })
|
|
120
|
-
}
|
|
121
|
-
catch (e) {
|
|
122
|
-
console.error('Error writing item document: ', e)
|
|
123
|
-
error = e
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
return { success: !error, error }
|
|
127
|
-
}
|
|
128
|
-
|
|
1
|
+
import {
|
|
2
|
+
getFirestore,
|
|
3
|
+
collection,
|
|
4
|
+
setDoc,
|
|
5
|
+
doc,
|
|
6
|
+
serverTimestamp,
|
|
7
|
+
type Firestore,
|
|
8
|
+
type FieldValue,
|
|
9
|
+
} from 'firebase/firestore'
|
|
10
|
+
|
|
11
|
+
import type { ActualLineItemSnapshot } from '../actual-line-item'
|
|
12
|
+
|
|
13
|
+
import firebaseApp from './firebase'
|
|
14
|
+
|
|
15
|
+
let dbInstance: Firestore | undefined = undefined
|
|
16
|
+
|
|
17
|
+
const getDBInstance = (name: string): Firestore => {
|
|
18
|
+
if (!dbInstance) {
|
|
19
|
+
dbInstance = getFirestore(firebaseApp, name)
|
|
20
|
+
}
|
|
21
|
+
return dbInstance
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
interface SavedOrder {
|
|
25
|
+
email: string
|
|
26
|
+
name: string
|
|
27
|
+
// TODO: add shippingInfo type
|
|
28
|
+
shippingInfo?: any
|
|
29
|
+
paymentInfo?: any
|
|
30
|
+
status: string
|
|
31
|
+
timestamp: FieldValue
|
|
32
|
+
items: ActualLineItemSnapshot[]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const createOrder = async (
|
|
36
|
+
email: string,
|
|
37
|
+
items: ActualLineItemSnapshot[],
|
|
38
|
+
options: {
|
|
39
|
+
dbName: string
|
|
40
|
+
ordersTable: string
|
|
41
|
+
},
|
|
42
|
+
name?: string
|
|
43
|
+
): Promise<{
|
|
44
|
+
success: boolean,
|
|
45
|
+
error: any,
|
|
46
|
+
id?: string,
|
|
47
|
+
}> => {
|
|
48
|
+
|
|
49
|
+
let error: any | null = null
|
|
50
|
+
const ordersRef = collection(getDBInstance(options.dbName), options.ordersTable)
|
|
51
|
+
const orderId = `${email}-${new Date().toISOString()}`
|
|
52
|
+
|
|
53
|
+
try {
|
|
54
|
+
await setDoc(doc(ordersRef, orderId), {
|
|
55
|
+
email,
|
|
56
|
+
name: name ?? '',
|
|
57
|
+
status: 'open',
|
|
58
|
+
timestamp: serverTimestamp(),
|
|
59
|
+
items,
|
|
60
|
+
} satisfies SavedOrder)
|
|
61
|
+
return { success: !error, error, id: orderId }
|
|
62
|
+
}
|
|
63
|
+
catch (e) {
|
|
64
|
+
console.error('Error writing item document: ', e)
|
|
65
|
+
error = e
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return { success: !error, error }
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
const updateOrderShippingInfo = async (
|
|
72
|
+
orderId: string,
|
|
73
|
+
shippingInfo: any,
|
|
74
|
+
options: {
|
|
75
|
+
dbName: string
|
|
76
|
+
ordersTable: string
|
|
77
|
+
}
|
|
78
|
+
): Promise<{
|
|
79
|
+
success: boolean,
|
|
80
|
+
error: any
|
|
81
|
+
}> => {
|
|
82
|
+
|
|
83
|
+
let error: any | null = null
|
|
84
|
+
const ordersRef = collection(getDBInstance(options.dbName), options.ordersTable)
|
|
85
|
+
|
|
86
|
+
try {
|
|
87
|
+
await setDoc(doc(ordersRef, orderId), {
|
|
88
|
+
shippingInfo,
|
|
89
|
+
timestamp: serverTimestamp(),
|
|
90
|
+
}, { merge: true })
|
|
91
|
+
}
|
|
92
|
+
catch (e) {
|
|
93
|
+
console.error('Error writing item document: ', e)
|
|
94
|
+
error = e
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
return { success: !error, error }
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
const updateOrderPaymentInfo = async (
|
|
101
|
+
orderId: string,
|
|
102
|
+
paymentInfo: any,
|
|
103
|
+
options: {
|
|
104
|
+
dbName: string
|
|
105
|
+
ordersTable: string
|
|
106
|
+
}
|
|
107
|
+
): Promise<{
|
|
108
|
+
success: boolean,
|
|
109
|
+
error: any
|
|
110
|
+
}> => {
|
|
111
|
+
|
|
112
|
+
let error: any | null = null
|
|
113
|
+
const ordersRef = collection(getDBInstance(options.dbName), options.ordersTable)
|
|
114
|
+
|
|
115
|
+
try {
|
|
116
|
+
await setDoc(doc(ordersRef, orderId), {
|
|
117
|
+
paymentInfo,
|
|
118
|
+
timestamp: serverTimestamp(),
|
|
119
|
+
}, { merge: true })
|
|
120
|
+
}
|
|
121
|
+
catch (e) {
|
|
122
|
+
console.error('Error writing item document: ', e)
|
|
123
|
+
error = e
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return { success: !error, error }
|
|
127
|
+
}
|
|
128
|
+
|
|
129
129
|
export { createOrder, updateOrderShippingInfo, updateOrderPaymentInfo }
|
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
import { reaction } from 'mobx'
|
|
2
|
-
import { StandaloneService, type StandaloneServiceSnapshot } from './index'
|
|
3
|
-
|
|
4
|
-
const LS_KEY = 'lux-cart'
|
|
5
|
-
|
|
6
|
-
const readSnapshot = (key: string): StandaloneServiceSnapshot | undefined => {
|
|
7
|
-
const snapshotAsStr = localStorage.getItem(key)
|
|
8
|
-
return snapshotAsStr ? JSON.parse(snapshotAsStr) as StandaloneServiceSnapshot : undefined
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
const writeSnapshotsOnChange = (cmmc: StandaloneService, key: string): void => {
|
|
12
|
-
|
|
13
|
-
if (typeof window !== 'undefined') {
|
|
14
|
-
reaction(
|
|
15
|
-
() => (cmmc.cartTotal),
|
|
16
|
-
(total) => {
|
|
17
|
-
if (total > 0) {
|
|
18
|
-
const snapshot = cmmc.takeSnapshot()
|
|
19
|
-
localStorage.setItem(key, JSON.stringify(snapshot) )
|
|
20
|
-
}
|
|
21
|
-
else {
|
|
22
|
-
localStorage.removeItem(key)
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
|
-
)
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export {
|
|
30
|
-
readSnapshot,
|
|
31
|
-
writeSnapshotsOnChange
|
|
32
|
-
}
|
|
33
|
-
|
|
1
|
+
import { reaction } from 'mobx'
|
|
2
|
+
import { StandaloneService, type StandaloneServiceSnapshot } from './index'
|
|
3
|
+
|
|
4
|
+
const LS_KEY = 'lux-cart'
|
|
5
|
+
|
|
6
|
+
const readSnapshot = (key: string): StandaloneServiceSnapshot | undefined => {
|
|
7
|
+
const snapshotAsStr = localStorage.getItem(key)
|
|
8
|
+
return snapshotAsStr ? JSON.parse(snapshotAsStr) as StandaloneServiceSnapshot : undefined
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const writeSnapshotsOnChange = (cmmc: StandaloneService, key: string): void => {
|
|
12
|
+
|
|
13
|
+
if (typeof window !== 'undefined') {
|
|
14
|
+
reaction(
|
|
15
|
+
() => (cmmc.cartTotal),
|
|
16
|
+
(total) => {
|
|
17
|
+
if (total > 0) {
|
|
18
|
+
const snapshot = cmmc.takeSnapshot()
|
|
19
|
+
localStorage.setItem(key, JSON.stringify(snapshot) )
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
localStorage.removeItem(key)
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export {
|
|
30
|
+
readSnapshot,
|
|
31
|
+
writeSnapshotsOnChange
|
|
32
|
+
}
|
|
33
|
+
|
package/service/path-utils.ts
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
1
|
-
import type { SelectedPaths } from '../types'
|
|
2
|
-
import sep from './sep'
|
|
3
|
-
|
|
4
|
-
export const getSelectedPaths = (
|
|
5
|
-
skuPath: string
|
|
6
|
-
): { paths: SelectedPaths; level: number } => {
|
|
7
|
-
|
|
8
|
-
const toks = skuPath.split(sep.tok)
|
|
9
|
-
const level = toks.length - 1
|
|
10
|
-
const paths: SelectedPaths = {}
|
|
11
|
-
for (let l = 1; l <= level; l++ ) {
|
|
12
|
-
paths[l] = [toks[l]]
|
|
13
|
-
}
|
|
14
|
-
return {
|
|
15
|
-
paths,
|
|
16
|
-
level
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export const getParentPath = (skuPath: string): string => (
|
|
21
|
-
skuPath.split(sep.tok).slice(0, -1).join(sep.tok)
|
|
22
|
-
)
|
|
23
|
-
|
|
24
|
-
export const lastToken = (skuPath: string): string => (
|
|
25
|
-
skuPath.split(sep.tok).pop()!
|
|
1
|
+
import type { SelectedPaths } from '../types'
|
|
2
|
+
import sep from './sep'
|
|
3
|
+
|
|
4
|
+
export const getSelectedPaths = (
|
|
5
|
+
skuPath: string
|
|
6
|
+
): { paths: SelectedPaths; level: number } => {
|
|
7
|
+
|
|
8
|
+
const toks = skuPath.split(sep.tok)
|
|
9
|
+
const level = toks.length - 1
|
|
10
|
+
const paths: SelectedPaths = {}
|
|
11
|
+
for (let l = 1; l <= level; l++ ) {
|
|
12
|
+
paths[l] = [toks[l]]
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
paths,
|
|
16
|
+
level
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export const getParentPath = (skuPath: string): string => (
|
|
21
|
+
skuPath.split(sep.tok).slice(0, -1).join(sep.tok)
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
export const lastToken = (skuPath: string): string => (
|
|
25
|
+
skuPath.split(sep.tok).pop()!
|
|
26
26
|
)
|
package/service/sep.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { TokenSeparators } from '../types'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
tok: '-',
|
|
5
|
-
subTok: '_',
|
|
6
|
-
decimal: '.'
|
|
1
|
+
import type { TokenSeparators } from '../types'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
tok: '-',
|
|
5
|
+
subTok: '_',
|
|
6
|
+
decimal: '.'
|
|
7
7
|
} satisfies TokenSeparators
|
package/tsconfig.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
{
|
|
2
|
-
"extends": "../tsconfig.hanzo.base.json",
|
|
3
|
-
"include": [
|
|
4
|
-
"**/*.ts",
|
|
5
|
-
"**/*.tsx",
|
|
6
|
-
],
|
|
7
|
-
"exclude": [
|
|
8
|
-
"node_modules",
|
|
9
|
-
]
|
|
10
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"extends": "../tsconfig.hanzo.base.json",
|
|
3
|
+
"include": [
|
|
4
|
+
"**/*.ts",
|
|
5
|
+
"**/*.tsx",
|
|
6
|
+
],
|
|
7
|
+
"exclude": [
|
|
8
|
+
"node_modules",
|
|
9
|
+
]
|
|
10
|
+
}
|
package/types/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
These are the types that the card ui expects and understands.
|
|
1
|
+
These are the types that the card ui expects and understands.
|
|
2
2
|
There should always be adaptors both ways from Hanzo commerceJs types.
|
package/types/category-node.ts
CHANGED
|
@@ -1,50 +1,50 @@
|
|
|
1
|
-
import type { ReactNode } from 'react'
|
|
2
|
-
|
|
3
|
-
interface CategoryNode {
|
|
4
|
-
skuToken: string // a token in the sku
|
|
5
|
-
label: string;
|
|
6
|
-
/**
|
|
7
|
-
* Explicitly marks this node as a "last user-visible" / "outermost" Category.
|
|
8
|
-
* Normally, a node is "outermost" when it has no subnodes
|
|
9
|
-
* (and thus is a family with products -- "single-family")
|
|
10
|
-
* But if it *has* subnodes, and its subNodes are actually sibling families
|
|
11
|
-
* of a Category, it must be marked as "outermost" ("multi-family")
|
|
12
|
-
* */
|
|
13
|
-
outermost?: boolean;
|
|
14
|
-
img? : string | ReactNode // icon is required
|
|
15
|
-
imgAR? : number // helps with svgs
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* One word prompt that describes the 'meaning' of
|
|
19
|
-
* the subnodes.
|
|
20
|
-
* For example, if a node is 'Lux Credit',
|
|
21
|
-
* it's subNodesLabel might be 'Level', so some UI's
|
|
22
|
-
* might be configured to render 'Level: Black'
|
|
23
|
-
*
|
|
24
|
-
* or something like...
|
|
25
|
-
*
|
|
26
|
-
* <Tabs title={parentNode.label + ': ' + parentNode.subNodesLabel} values={families.map((f) => (f.shortName))} />
|
|
27
|
-
*
|
|
28
|
-
* ...which renders
|
|
29
|
-
*
|
|
30
|
-
* Lux Credit Levels:
|
|
31
|
-
* Black Elite Founder Sovereign
|
|
32
|
-
*/
|
|
33
|
-
subNodesLabel?: string
|
|
34
|
-
subNodes?: CategoryNode[]
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
type CategoryNodeRole =
|
|
38
|
-
'single-family' |
|
|
39
|
-
'family-in-multi-family' |
|
|
40
|
-
'multi-family' |
|
|
41
|
-
'non-outermost'
|
|
42
|
-
|
|
43
|
-
// Which facets tokens are 'on' at each level
|
|
44
|
-
type SelectedPaths = Record<number, string[]>
|
|
45
|
-
|
|
46
|
-
export type {
|
|
47
|
-
CategoryNodeRole,
|
|
48
|
-
CategoryNode,
|
|
49
|
-
SelectedPaths
|
|
1
|
+
import type { ReactNode } from 'react'
|
|
2
|
+
|
|
3
|
+
interface CategoryNode {
|
|
4
|
+
skuToken: string // a token in the sku
|
|
5
|
+
label: string;
|
|
6
|
+
/**
|
|
7
|
+
* Explicitly marks this node as a "last user-visible" / "outermost" Category.
|
|
8
|
+
* Normally, a node is "outermost" when it has no subnodes
|
|
9
|
+
* (and thus is a family with products -- "single-family")
|
|
10
|
+
* But if it *has* subnodes, and its subNodes are actually sibling families
|
|
11
|
+
* of a Category, it must be marked as "outermost" ("multi-family")
|
|
12
|
+
* */
|
|
13
|
+
outermost?: boolean;
|
|
14
|
+
img? : string | ReactNode // icon is required
|
|
15
|
+
imgAR? : number // helps with svgs
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* One word prompt that describes the 'meaning' of
|
|
19
|
+
* the subnodes.
|
|
20
|
+
* For example, if a node is 'Lux Credit',
|
|
21
|
+
* it's subNodesLabel might be 'Level', so some UI's
|
|
22
|
+
* might be configured to render 'Level: Black'
|
|
23
|
+
*
|
|
24
|
+
* or something like...
|
|
25
|
+
*
|
|
26
|
+
* <Tabs title={parentNode.label + ': ' + parentNode.subNodesLabel} values={families.map((f) => (f.shortName))} />
|
|
27
|
+
*
|
|
28
|
+
* ...which renders
|
|
29
|
+
*
|
|
30
|
+
* Lux Credit Levels:
|
|
31
|
+
* Black Elite Founder Sovereign
|
|
32
|
+
*/
|
|
33
|
+
subNodesLabel?: string
|
|
34
|
+
subNodes?: CategoryNode[]
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
type CategoryNodeRole =
|
|
38
|
+
'single-family' |
|
|
39
|
+
'family-in-multi-family' |
|
|
40
|
+
'multi-family' |
|
|
41
|
+
'non-outermost'
|
|
42
|
+
|
|
43
|
+
// Which facets tokens are 'on' at each level
|
|
44
|
+
type SelectedPaths = Record<number, string[]>
|
|
45
|
+
|
|
46
|
+
export type {
|
|
47
|
+
CategoryNodeRole,
|
|
48
|
+
CategoryNode,
|
|
49
|
+
SelectedPaths
|
|
50
50
|
}
|
package/types/checkout.ts
CHANGED
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import type { ComponentType } from 'react'
|
|
2
|
-
import type { UseFormReturn } from 'react-hook-form'
|
|
3
|
-
|
|
4
|
-
type TransactionStatus = 'unpaid' | 'paid' | 'confirmed' | 'error'
|
|
5
|
-
|
|
6
|
-
interface CheckoutStepComponentProps {
|
|
7
|
-
onDone: () => void
|
|
8
|
-
orderId: string | undefined
|
|
9
|
-
setOrderId: (orderId: string | undefined) => void
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
interface CheckoutStep {
|
|
13
|
-
name: string
|
|
14
|
-
label?: string
|
|
15
|
-
Comp: ComponentType<CheckoutStepComponentProps>
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
type ContactFormType = UseFormReturn<{
|
|
19
|
-
name: string
|
|
20
|
-
email: string
|
|
21
|
-
}, any, {
|
|
22
|
-
name: string
|
|
23
|
-
email: string
|
|
24
|
-
}>
|
|
25
|
-
|
|
26
|
-
interface PaymentMethodComponentProps {
|
|
27
|
-
onDone: () => void
|
|
28
|
-
transactionStatus: TransactionStatus
|
|
29
|
-
setTransactionStatus: (status: TransactionStatus) => void
|
|
30
|
-
storePaymentInfo: (paymentInfo: any) => Promise<void>
|
|
31
|
-
contactForm: ContactFormType
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
interface PaymentMethodDesc {
|
|
35
|
-
value: string
|
|
36
|
-
label: string
|
|
37
|
-
Comp: ComponentType<PaymentMethodComponentProps>
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export {
|
|
41
|
-
type TransactionStatus,
|
|
42
|
-
type CheckoutStepComponentProps,
|
|
43
|
-
type CheckoutStep,
|
|
44
|
-
type PaymentMethodComponentProps,
|
|
45
|
-
type PaymentMethodDesc,
|
|
46
|
-
type ContactFormType,
|
|
1
|
+
import type { ComponentType } from 'react'
|
|
2
|
+
import type { UseFormReturn } from 'react-hook-form'
|
|
3
|
+
|
|
4
|
+
type TransactionStatus = 'unpaid' | 'paid' | 'confirmed' | 'error'
|
|
5
|
+
|
|
6
|
+
interface CheckoutStepComponentProps {
|
|
7
|
+
onDone: () => void
|
|
8
|
+
orderId: string | undefined
|
|
9
|
+
setOrderId: (orderId: string | undefined) => void
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface CheckoutStep {
|
|
13
|
+
name: string
|
|
14
|
+
label?: string
|
|
15
|
+
Comp: ComponentType<CheckoutStepComponentProps>
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type ContactFormType = UseFormReturn<{
|
|
19
|
+
name: string
|
|
20
|
+
email: string
|
|
21
|
+
}, any, {
|
|
22
|
+
name: string
|
|
23
|
+
email: string
|
|
24
|
+
}>
|
|
25
|
+
|
|
26
|
+
interface PaymentMethodComponentProps {
|
|
27
|
+
onDone: () => void
|
|
28
|
+
transactionStatus: TransactionStatus
|
|
29
|
+
setTransactionStatus: (status: TransactionStatus) => void
|
|
30
|
+
storePaymentInfo: (paymentInfo: any) => Promise<void>
|
|
31
|
+
contactForm: ContactFormType
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface PaymentMethodDesc {
|
|
35
|
+
value: string
|
|
36
|
+
label: string
|
|
37
|
+
Comp: ComponentType<PaymentMethodComponentProps>
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export {
|
|
41
|
+
type TransactionStatus,
|
|
42
|
+
type CheckoutStepComponentProps,
|
|
43
|
+
type CheckoutStep,
|
|
44
|
+
type PaymentMethodComponentProps,
|
|
45
|
+
type PaymentMethodDesc,
|
|
46
|
+
type ContactFormType,
|
|
47
47
|
}
|
package/types/commerce-config.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import type { ServiceOptions } from '..'
|
|
2
|
-
import type { CategoryNode } from './category-node'
|
|
3
|
-
import type { Family } from './family'
|
|
4
|
-
import type { SelectionUISpecifier } from './selection-ui-specifier'
|
|
5
|
-
|
|
6
|
-
interface CommerceConfig {
|
|
7
|
-
families: Family[]
|
|
8
|
-
rootNode: CategoryNode
|
|
9
|
-
options?: ServiceOptions
|
|
10
|
-
uiSpecifiers?: Record<string, SelectionUISpecifier>
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export { type CommerceConfig as default }
|
|
1
|
+
import type { ServiceOptions } from '..'
|
|
2
|
+
import type { CategoryNode } from './category-node'
|
|
3
|
+
import type { Family } from './family'
|
|
4
|
+
import type { SelectionUISpecifier } from './selection-ui-specifier'
|
|
5
|
+
|
|
6
|
+
interface CommerceConfig {
|
|
7
|
+
families: Family[]
|
|
8
|
+
rootNode: CategoryNode
|
|
9
|
+
options?: ServiceOptions
|
|
10
|
+
uiSpecifiers?: Record<string, SelectionUISpecifier>
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export { type CommerceConfig as default }
|