@hanzo/commerce 7.7.0 → 7.7.2
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/dist/components/checkout/payment-step-form/methods/card.js +20 -2
- package/dist/components/checkout/payment-step-form/methods/card.js.map +1 -1
- package/package.json +38 -9
- package/billing.ts +0 -2
- package/client.ts +0 -783
- package/components/Icons.tsx +0 -35
- package/components/add-to-cart-widget.tsx +0 -195
- package/components/buy/buy-card.tsx +0 -269
- package/components/buy/carousel-buy-card.tsx +0 -243
- package/components/buy/multi-family/all-variants-carousel.tsx +0 -259
- package/components/buy/multi-family/family-carousel/index.tsx +0 -75
- package/components/buy/multi-family/family-carousel/slide.tsx +0 -82
- package/components/buy/multi-family/family-carousel/state.ts +0 -87
- package/components/buy/multi-family/index.ts +0 -2
- package/components/buy/single-family-selector.tsx +0 -91
- package/components/buy/title-and-byline.tsx +0 -26
- package/components/cart/cart-panel/cart-line-item.tsx +0 -77
- package/components/cart/cart-panel/index.tsx +0 -157
- package/components/cart/cart-panel/promo-code.tsx +0 -105
- package/components/cart/cart-panel/total-area.tsx +0 -61
- package/components/checkout/payment-step-form/card-icon-row.tsx +0 -26
- package/components/checkout/payment-step-form/card-icons/amex.tsx +0 -32
- package/components/checkout/payment-step-form/card-icons/diners-club.tsx +0 -13
- package/components/checkout/payment-step-form/card-icons/discover.tsx +0 -25
- package/components/checkout/payment-step-form/card-icons/jcb.tsx +0 -26
- package/components/checkout/payment-step-form/card-icons/mastercard.tsx +0 -27
- package/components/checkout/payment-step-form/card-icons/visa.tsx +0 -25
- package/components/checkout/payment-step-form/cc-button.tsx +0 -18
- package/components/checkout/payment-step-form/contact-form.tsx +0 -48
- package/components/checkout/payment-step-form/crypto-icons/btc.tsx +0 -11
- package/components/checkout/payment-step-form/crypto-icons/eth.tsx +0 -20
- package/components/checkout/payment-step-form/crypto-icons/usdt.tsx +0 -13
- package/components/checkout/payment-step-form/index.tsx +0 -113
- package/components/checkout/payment-step-form/methods/bank-transfer.tsx +0 -81
- package/components/checkout/payment-step-form/methods/card.tsx +0 -230
- package/components/checkout/payment-step-form/methods/crypto.tsx +0 -226
- package/components/checkout/payment-step-form/methods/index.ts +0 -23
- package/components/checkout/shipping-step-form.tsx +0 -171
- package/components/index.ts +0 -11
- package/components/item/product-card.tsx +0 -66
- package/components/item-selector/button.tsx +0 -213
- package/components/item-selector/carousel/index.tsx +0 -196
- package/components/item-selector/carousel/slider.tsx +0 -37
- package/components/item-selector/index.ts +0 -5
- package/components/item-selector/quantity-indicator.tsx +0 -50
- package/components/node-tabs/index.tsx +0 -90
- package/components/node-tabs/node-image.tsx +0 -31
- package/index.ts +0 -55
- package/metering.test.ts +0 -199
- package/metering.ts +0 -289
- package/product-card.test.tsx +0 -104
- package/service/context.tsx +0 -45
- package/service/debug.ts +0 -41
- package/service/impls/standalone/actual-line-item.ts +0 -136
- package/service/impls/standalone/get-instance.ts +0 -64
- package/service/impls/standalone/index.ts +0 -579
- package/service/impls/standalone/order/firebase.ts +0 -5
- package/service/impls/standalone/order/index.ts +0 -58
- package/service/impls/standalone/persistence.ts +0 -33
- package/service/path-utils.ts +0 -26
- package/service/sep.ts +0 -7
- package/tsconfig.json +0 -17
- package/types/README.md +0 -2
- package/types/category-node.ts +0 -50
- package/types/checkout.ts +0 -47
- package/types/commerce-config.ts +0 -13
- package/types/commerce-service.ts +0 -128
- package/types/family.ts +0 -26
- package/types/index.ts +0 -15
- package/types/item-selector.ts +0 -97
- package/types/line-item.ts +0 -29
- package/types/multi-family-selector-props.ts +0 -20
- package/types/product.ts +0 -21
- package/types/promo.ts +0 -10
- package/types/selection-ui-specifier.ts +0 -52
- package/types/string-mutator.ts +0 -14
- package/types/token-separators.ts +0 -7
- package/util/analytics.ts +0 -21
- package/util/countries.ts +0 -196
- package/util/error.ts +0 -34
- package/util/index.ts +0 -71
- package/util/item-selector-options-accessor.ts +0 -35
- package/util/line-item-ref.ts +0 -23
- package/util/multi-family-selector-options-accessor.ts +0 -15
- package/util/obs-string-mutator.ts +0 -22
- package/util/product-media-accessor.ts +0 -58
- package/util/promo-codes.ts +0 -106
- package/util/selection-ui-specifiers.ts +0 -30
- package/util/square-payment.ts +0 -50
- package/util/use-sync-sku-param-w-current-item.ts +0 -88
|
@@ -1,136 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
action,
|
|
3
|
-
computed,
|
|
4
|
-
makeObservable,
|
|
5
|
-
observable,
|
|
6
|
-
} from 'mobx'
|
|
7
|
-
|
|
8
|
-
import type { ImageDef, MediaTransform, VideoDef } from '@hanzo/ui/types'
|
|
9
|
-
|
|
10
|
-
import type { Product, LineItem, CommerceService } from '../../../types'
|
|
11
|
-
|
|
12
|
-
interface ActualLineItemSnapshot {
|
|
13
|
-
sku: string
|
|
14
|
-
familyId: string // helps impl of restoreFromSnapshot
|
|
15
|
-
title: string
|
|
16
|
-
price: number
|
|
17
|
-
quantity: number
|
|
18
|
-
timeAdded: number
|
|
19
|
-
timeModified: number
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
class ActualLineItem
|
|
23
|
-
implements LineItem
|
|
24
|
-
{
|
|
25
|
-
qu: number = 0
|
|
26
|
-
|
|
27
|
-
id: string
|
|
28
|
-
sku: string
|
|
29
|
-
fullTitle?: string
|
|
30
|
-
optionLabel: string
|
|
31
|
-
optionLabelShort?: string
|
|
32
|
-
familyTitle: string
|
|
33
|
-
familyId: string
|
|
34
|
-
byline?: string
|
|
35
|
-
desc?: string
|
|
36
|
-
price: number
|
|
37
|
-
img?: ImageDef
|
|
38
|
-
video?: VideoDef
|
|
39
|
-
animation?: string
|
|
40
|
-
mediaTransform?: MediaTransform
|
|
41
|
-
optionImg?: ImageDef
|
|
42
|
-
|
|
43
|
-
timeAdded: number = 0 // Timestamp when added
|
|
44
|
-
timeModified: number = 0 // Timestamp quantity last modified (0 if not in cart)
|
|
45
|
-
|
|
46
|
-
constructor(prod: Product, snap?: ActualLineItemSnapshot) {
|
|
47
|
-
this.id = prod.id
|
|
48
|
-
this.sku = prod.sku
|
|
49
|
-
this.fullTitle = prod.fullTitle
|
|
50
|
-
this.optionLabel = prod.optionLabel
|
|
51
|
-
this.optionLabelShort = prod.optionLabelShort
|
|
52
|
-
this.familyTitle = prod.familyTitle
|
|
53
|
-
this.familyId = prod.familyId
|
|
54
|
-
this.byline = prod.byline
|
|
55
|
-
this.desc = prod.desc
|
|
56
|
-
this.price = prod.price
|
|
57
|
-
this.img = prod.img
|
|
58
|
-
this.video = prod.video
|
|
59
|
-
this.animation = prod.animation
|
|
60
|
-
this.optionImg = prod.optionImg
|
|
61
|
-
this.mediaTransform = prod.mediaTransform
|
|
62
|
-
|
|
63
|
-
if (snap) {
|
|
64
|
-
this.qu = snap.quantity
|
|
65
|
-
this.timeAdded = snap.timeAdded
|
|
66
|
-
this.timeModified = snap.timeModified
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
makeObservable(this, {
|
|
70
|
-
qu: observable,
|
|
71
|
-
timeAdded: observable,
|
|
72
|
-
timeModified: observable,
|
|
73
|
-
canDecrement: computed,
|
|
74
|
-
isInCart: computed,
|
|
75
|
-
title: computed,
|
|
76
|
-
increment: action,
|
|
77
|
-
decrement: action,
|
|
78
|
-
})
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
// TODO: create a way to pass template strings to the ui conf per sku path!
|
|
82
|
-
get title(): string {
|
|
83
|
-
return this.fullTitle ? this.fullTitle : (this.familyTitle + ', ' + this.optionLabel)
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
takeSnapshot = (cmmc: CommerceService): ActualLineItemSnapshot => {
|
|
87
|
-
|
|
88
|
-
const title = this.fullTitle ?
|
|
89
|
-
this.fullTitle
|
|
90
|
-
:
|
|
91
|
-
((cmmc.getFamilyById(this.familyId)?.title ?? this.familyTitle) + ', ' + this.optionLabel)
|
|
92
|
-
|
|
93
|
-
return({
|
|
94
|
-
sku: this.sku,
|
|
95
|
-
familyId: this.familyId,
|
|
96
|
-
title,
|
|
97
|
-
price: this.price,
|
|
98
|
-
quantity: this.qu,
|
|
99
|
-
timeAdded: this.timeAdded,
|
|
100
|
-
timeModified: this.timeModified
|
|
101
|
-
} satisfies ActualLineItemSnapshot)
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
get canDecrement(): boolean { return this.qu > 0 }
|
|
105
|
-
get quantity(): number {return this.qu}
|
|
106
|
-
get isInCart(): boolean {return this.qu > 0}
|
|
107
|
-
|
|
108
|
-
increment(): void {
|
|
109
|
-
if (this.qu === 0) {
|
|
110
|
-
this.timeAdded = new Date().getTime()
|
|
111
|
-
this.timeModified = this.timeAdded
|
|
112
|
-
}
|
|
113
|
-
else {
|
|
114
|
-
this.timeModified = new Date().getTime()
|
|
115
|
-
}
|
|
116
|
-
this.qu++
|
|
117
|
-
}
|
|
118
|
-
|
|
119
|
-
decrement(): void {
|
|
120
|
-
if (this.canDecrement) {
|
|
121
|
-
this.qu--
|
|
122
|
-
if (this.qu === 0) {
|
|
123
|
-
this.timeAdded = 0
|
|
124
|
-
this.timeModified = 0
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
this.timeModified = new Date().getTime()
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export {
|
|
134
|
-
type ActualLineItemSnapshot,
|
|
135
|
-
ActualLineItem as default
|
|
136
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { enableStaticRendering } from 'mobx-react-lite'
|
|
2
|
-
|
|
3
|
-
import type { CommerceService, CommerceConfig } from '../../../types'
|
|
4
|
-
import { StandaloneService } from './index'
|
|
5
|
-
import { initSelectionUI } from '../../../util'
|
|
6
|
-
|
|
7
|
-
import { readSnapshot, writeSnapshotsOnChange } from './persistence'
|
|
8
|
-
|
|
9
|
-
enableStaticRendering(typeof window === "undefined")
|
|
10
|
-
|
|
11
|
-
const _LOG = false
|
|
12
|
-
const _log = (s: string) => {
|
|
13
|
-
if (!_LOG) return;
|
|
14
|
-
const d = new Date()
|
|
15
|
-
console.log(`TIMESTAMPED: ${d.getUTCMinutes()}:${d.getUTCSeconds()}:${d.getUTCMilliseconds()}`)
|
|
16
|
-
console.log(s)
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
// https://dev.to/ivandotv/mobx-server-side-rendering-with-next-js-4m18
|
|
20
|
-
|
|
21
|
-
let instance: StandaloneService | undefined = undefined
|
|
22
|
-
|
|
23
|
-
export const getInstance = ({
|
|
24
|
-
families,
|
|
25
|
-
rootNode,
|
|
26
|
-
options,
|
|
27
|
-
uiSpecifiers
|
|
28
|
-
}: CommerceConfig) : CommerceService => {
|
|
29
|
-
|
|
30
|
-
if (!options) {
|
|
31
|
-
throw new Error('cmmc getInstance(): Standalone Commerce Service requires config options!')
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
if (typeof window === "undefined") {
|
|
35
|
-
if (uiSpecifiers) {
|
|
36
|
-
initSelectionUI(uiSpecifiers)
|
|
37
|
-
}
|
|
38
|
-
_log("NEW INSTANCE: SERVER") //////////
|
|
39
|
-
return new StandaloneService(
|
|
40
|
-
families,
|
|
41
|
-
rootNode,
|
|
42
|
-
options
|
|
43
|
-
)
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Client side, create the store only once in the client
|
|
47
|
-
if (!instance) {
|
|
48
|
-
if (uiSpecifiers) {
|
|
49
|
-
initSelectionUI(uiSpecifiers)
|
|
50
|
-
}
|
|
51
|
-
_log("NEW INSTANCE: CLIENT") ///////////
|
|
52
|
-
const snapShot = readSnapshot(options.localStorageKey)
|
|
53
|
-
instance = new StandaloneService(
|
|
54
|
-
families,
|
|
55
|
-
rootNode,
|
|
56
|
-
options,
|
|
57
|
-
snapShot
|
|
58
|
-
)
|
|
59
|
-
writeSnapshotsOnChange(instance, options.localStorageKey)
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
return instance
|
|
63
|
-
}
|
|
64
|
-
|