@hanzo/commerce 7.1.3 → 7.1.5
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 +181 -181
- package/components/buy/buy-card.tsx +259 -259
- package/components/buy/carousel-buy-card.tsx +245 -243
- package/components/buy/multi-family/all-variants-carousel.tsx +261 -259
- 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-accordian.tsx +59 -59
- package/components/cart/cart-panel/cart-line-item.tsx +76 -76
- package/components/cart/cart-panel/index.tsx +159 -159
- package/components/cart/cart-panel/promo-code.tsx +98 -98
- 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 +12 -12
- 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/context/index.tsx +45 -45
- package/index.ts +12 -12
- package/package.json +60 -60
- package/service/debug.ts +41 -41
- package/service/get-instance.ts +2 -2
- package/service/impls/standalone/actual-line-item.ts +121 -121
- package/service/impls/standalone/index.ts +62 -62
- package/service/impls/standalone/localStorage.ts +34 -34
- package/service/impls/standalone/orders/firebase-app.ts +14 -14
- package/service/impls/standalone/orders/index.ts +128 -128
- package/service/impls/standalone/standalone-service.ts +550 -550
- 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 +121 -121
- 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,129 +1,129 @@
|
|
|
1
|
-
import firebaseApp from './firebase-app'
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
getFirestore,
|
|
5
|
-
collection,
|
|
6
|
-
setDoc,
|
|
7
|
-
doc,
|
|
8
|
-
serverTimestamp,
|
|
9
|
-
type Firestore,
|
|
10
|
-
type FieldValue,
|
|
11
|
-
} from 'firebase/firestore'
|
|
12
|
-
|
|
13
|
-
import type { ActualLineItemSnapshot } from '../actual-line-item'
|
|
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 firebaseApp from './firebase-app'
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
getFirestore,
|
|
5
|
+
collection,
|
|
6
|
+
setDoc,
|
|
7
|
+
doc,
|
|
8
|
+
serverTimestamp,
|
|
9
|
+
type Firestore,
|
|
10
|
+
type FieldValue,
|
|
11
|
+
} from 'firebase/firestore'
|
|
12
|
+
|
|
13
|
+
import type { ActualLineItemSnapshot } from '../actual-line-item'
|
|
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 }
|