@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.
Files changed (84) hide show
  1. package/components/Icons.tsx +34 -34
  2. package/components/add-to-cart-widget.tsx +181 -181
  3. package/components/buy/buy-card.tsx +259 -259
  4. package/components/buy/carousel-buy-card.tsx +245 -243
  5. package/components/buy/multi-family/all-variants-carousel.tsx +261 -259
  6. package/components/buy/multi-family/family-carousel/index.tsx +77 -77
  7. package/components/buy/multi-family/family-carousel/slide.tsx +83 -83
  8. package/components/buy/multi-family/family-carousel/state.ts +87 -87
  9. package/components/buy/multi-family/index.ts +2 -2
  10. package/components/buy/single-family-selector.tsx +90 -90
  11. package/components/buy/title-and-byline.tsx +25 -25
  12. package/components/cart/cart-accordian.tsx +59 -59
  13. package/components/cart/cart-panel/cart-line-item.tsx +76 -76
  14. package/components/cart/cart-panel/index.tsx +159 -159
  15. package/components/cart/cart-panel/promo-code.tsx +98 -98
  16. package/components/checkout/payment-step-form/card-icon-row.tsx +26 -26
  17. package/components/checkout/payment-step-form/card-icons/amex.tsx +32 -32
  18. package/components/checkout/payment-step-form/card-icons/diners-club.tsx +13 -13
  19. package/components/checkout/payment-step-form/card-icons/discover.tsx +25 -25
  20. package/components/checkout/payment-step-form/card-icons/jcb.tsx +26 -26
  21. package/components/checkout/payment-step-form/card-icons/mastercard.tsx +27 -27
  22. package/components/checkout/payment-step-form/card-icons/visa.tsx +25 -25
  23. package/components/checkout/payment-step-form/cc-button.tsx +17 -17
  24. package/components/checkout/payment-step-form/contact-form.tsx +49 -49
  25. package/components/checkout/payment-step-form/crypto-icons/btc.tsx +11 -11
  26. package/components/checkout/payment-step-form/crypto-icons/eth.tsx +20 -20
  27. package/components/checkout/payment-step-form/crypto-icons/usdt.tsx +13 -13
  28. package/components/checkout/payment-step-form/index.tsx +122 -122
  29. package/components/checkout/payment-step-form/methods/bank-transfer.tsx +79 -79
  30. package/components/checkout/payment-step-form/methods/card.tsx +232 -232
  31. package/components/checkout/payment-step-form/methods/crypto.tsx +227 -227
  32. package/components/checkout/payment-step-form/methods/index.ts +22 -22
  33. package/components/checkout/shipping-step-form.tsx +172 -172
  34. package/components/index.ts +12 -12
  35. package/components/item/product-card.tsx +48 -48
  36. package/components/item-selector/button.tsx +188 -188
  37. package/components/item-selector/carousel/index.tsx +197 -197
  38. package/components/item-selector/carousel/slider.tsx +40 -40
  39. package/components/item-selector/index.ts +5 -5
  40. package/components/item-selector/quantity-indicator.tsx +48 -48
  41. package/components/node-tabs/index.tsx +91 -91
  42. package/components/node-tabs/node-image.tsx +31 -31
  43. package/context/index.tsx +45 -45
  44. package/index.ts +12 -12
  45. package/package.json +60 -60
  46. package/service/debug.ts +41 -41
  47. package/service/get-instance.ts +2 -2
  48. package/service/impls/standalone/actual-line-item.ts +121 -121
  49. package/service/impls/standalone/index.ts +62 -62
  50. package/service/impls/standalone/localStorage.ts +34 -34
  51. package/service/impls/standalone/orders/firebase-app.ts +14 -14
  52. package/service/impls/standalone/orders/index.ts +128 -128
  53. package/service/impls/standalone/standalone-service.ts +550 -550
  54. package/service/path-utils.ts +25 -25
  55. package/service/sep.ts +6 -6
  56. package/tsconfig.json +10 -10
  57. package/types/README.md +1 -1
  58. package/types/category-node.ts +49 -49
  59. package/types/checkout.ts +46 -46
  60. package/types/commerce-config.ts +13 -13
  61. package/types/commerce-service.ts +121 -121
  62. package/types/family.ts +25 -25
  63. package/types/index.ts +15 -15
  64. package/types/item-selector.ts +96 -96
  65. package/types/line-item.ts +29 -29
  66. package/types/multi-family-selector-props.ts +19 -19
  67. package/types/product.ts +20 -20
  68. package/types/promo.ts +9 -9
  69. package/types/selection-ui-specifier.ts +51 -51
  70. package/types/string-mutator.ts +13 -13
  71. package/types/token-separators.ts +7 -7
  72. package/util/analytics.ts +20 -20
  73. package/util/countries.ts +195 -195
  74. package/util/error.ts +34 -34
  75. package/util/index.ts +70 -70
  76. package/util/item-selector-options-accessor.ts +34 -34
  77. package/util/line-item-ref.ts +23 -23
  78. package/util/multi-family-selector-options-accessor.ts +14 -14
  79. package/util/obs-string-mutator.ts +22 -22
  80. package/util/product-media-accessor.ts +58 -58
  81. package/util/promo-codes.ts +108 -108
  82. package/util/selection-ui-specifiers.ts +29 -29
  83. package/util/square-payment.ts +42 -42
  84. 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 }