@luxfi/core 5.1.7 → 5.2.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@luxfi/core",
3
- "version": "5.1.7",
3
+ "version": "5.2.0",
4
4
  "description": "Library that contains shared UI primitives, support for a common design system, and other boilerplate support.",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/",
@@ -15,7 +15,6 @@ import { AuthListener, ChatWidget, Header, Scripts } from '../components'
15
15
 
16
16
  import CommerceDrawer from '../components/commerce/drawer'
17
17
 
18
- import { selectionUISpecifiers } from '../conf'
19
18
  import type SiteDef from '../types/site-def'
20
19
 
21
20
  import '../style/lux-global.css'
@@ -90,12 +89,7 @@ async function RootLayout({
90
89
  <Scripts/>
91
90
  <AuthServiceProvider user={currentUser} conf={{} as AuthServiceConf}>
92
91
  {siteDef?.commerce ? (
93
- <CommerceProvider
94
- rootNode={siteDef.commerce!.rootNode}
95
- families={siteDef.commerce!.families}
96
- options={siteDef.commerce!.options}
97
- uiSpecs={selectionUISpecifiers}
98
- >
92
+ <CommerceProvider config={siteDef.commerce!} >
99
93
  <CommerceUIProvider >
100
94
  <Guts />
101
95
  <CommerceDrawer />
package/types/index.ts CHANGED
@@ -2,4 +2,3 @@ export type { ContactInfo, ContactInfoFields } from './contact-info'
2
2
  export type { default as SiteDef } from './site-def'
3
3
  export type { default as ChatbotSuggestedQuestion } from './chatbot-suggested-question'
4
4
  export type { default as ChatbotConfig } from './chatbot-config'
5
- export type { default as CommerceConfig } from './commerce-config'
package/types/site-def.ts CHANGED
@@ -1,8 +1,8 @@
1
1
  import React from 'react'
2
2
 
3
3
  import type { LinkDef } from '@hanzo/ui/types'
4
+ import type { CommerceConfig } from '@hanzo/commerce/types'
4
5
 
5
- import type CommerceConfig from './commerce-config'
6
6
  import type ChatbotConfig from './chatbot-config'
7
7
 
8
8
  interface SiteDef {
@@ -1,34 +0,0 @@
1
- [
2
- {
3
- "id": "LXM-AG-B",
4
- "title": "Minted Bar",
5
- "parentTitle": "Lux Silver",
6
- "desc": "Get unprecedented access to silver with 1:1 asset-backed Lux Silver NFTs, sovereign ownership of physical silver without management fees, and mine-direct discount pricing.",
7
- "img": {
8
- "src": "/assets/commerce/silver/product/silver-bar-pt-800x800.png",
9
- "dim": {
10
- "w": 800,
11
- "h": 800
12
- }
13
- },
14
- "products": [
15
- {
16
- "id": "fce17569-a86c-4f69-bc61-ab435ed0c46f",
17
- "sku": "LXM-AG-B-1_OZ",
18
- "fullTitle": "Lux Silver, 1oz Minted Bar",
19
- "optionLabel": "1oz",
20
- "familyTitle": "Minted Bar",
21
- "familyId": "LXM-AG-B",
22
- "desc": "Get unprecedented access to silver with 1:1 asset-backed Lux Silver NFTs, sovereign ownership of physical silver without management fees, and mine-direct discount pricing.",
23
- "price": 0,
24
- "img": {
25
- "src": "/assets/commerce/silver/product/silver-bar-pt-800x800.png",
26
- "dim": {
27
- "w": 800,
28
- "h": 800
29
- }
30
- }
31
- }
32
- ]
33
- }
34
- ]
@@ -1,12 +0,0 @@
1
- // updated manually apr 29, 2024
2
-
3
- export default {
4
- au: {
5
- market1oz: 2336.50,
6
- discount: 0.01
7
- },
8
- ag: {
9
- market1oz: 27.143,
10
- discount: 0.10
11
- },
12
- }
@@ -1,50 +0,0 @@
1
- import type { Family } from '@hanzo/commerce/types'
2
-
3
- import prices from './EDIT-ME-bullion-market-prices'
4
-
5
- const sep = {
6
- tok: '-',
7
- subTok: '_',
8
- decimal: '.'
9
- }
10
-
11
- const GRAMS_PER_OZ = 28.3495
12
-
13
- const tree: any = {}
14
- for (let key in prices) {
15
- const values = prices[key as keyof typeof prices]
16
- tree[key] = {
17
- oz: values.market1oz * (1 - values.discount),
18
- g: values.market1oz * (1 - values.discount) / GRAMS_PER_OZ
19
- }
20
- }
21
-
22
- // LXB-AU-B-1_OZ, LXB-AU-B-2.5_g
23
- const priceFromSKU = (
24
- sku: string
25
- ) => {
26
- const tokens = sku.split(sep.tok)
27
- const type_ = tokens[1].toLowerCase()
28
-
29
- const quanAndUnit = tokens[tokens.length - 1]
30
- const quanAndUnitToks = quanAndUnit.split(sep.subTok)
31
- let quantity = quanAndUnitToks[0].includes(sep.decimal) ? parseFloat(quanAndUnitToks[0].split(sep.decimal).join('.')) : parseInt(quanAndUnitToks[0])
32
- let unit = quanAndUnitToks[1].toLowerCase()
33
- if (unit === 'kg') {
34
- quantity *= 1000
35
- unit = 'g'
36
- }
37
- else if (unit === 'lb') {
38
- quantity *= 16
39
- unit = 'oz'
40
- }
41
-
42
- return tree[type_][unit] * quantity
43
- }
44
-
45
- export default (c: Family): Family => {
46
- for (let prod of c.products) {
47
- prod.price = priceFromSKU(prod.sku)
48
- }
49
- return c
50
- }
@@ -1,14 +0,0 @@
1
- import type { VideoDef } from '@hanzo/ui/types'
2
- import type { Family } from '@hanzo/commerce/types'
3
-
4
- export default (fam: Family, map: Map<string, VideoDef>): Family => {
5
- if (fam.parentTitle) {
6
- for (let prod of fam.products) {
7
- const video = map.get(fam.parentTitle)
8
- if (video) {
9
- prod.video = video
10
- }
11
- }
12
- }
13
- return fam
14
- }
@@ -1,5 +0,0 @@
1
- import PRICES from './EDIT-ME-bullion-market-prices'
2
-
3
- export default (type_: keyof typeof PRICES): number => (
4
- PRICES[type_].market1oz * (1 - PRICES[type_].discount)
5
- )
@@ -1,18 +0,0 @@
1
- import type { VideoDef } from '@hanzo/ui/types'
2
-
3
- import bullionByFamily from './AUTO-GEN-bullion-by-family.json'
4
-
5
- import assignPrices from './assign-prices'
6
- import assignVideosByFamilyGroup from './assign-videos-by-family-group'
7
-
8
- export const getBullionFamilies = (videoMap: Map<string, VideoDef>) => (
9
- bullionByFamily.map(
10
- (fam) => (assignPrices(fam))).map(
11
- (fam) => (assignVideosByFamilyGroup(fam, videoMap)
12
- )
13
- )
14
- )
15
-
16
- export { default as serviceOptions } from '../../conf/lux-commerce-options'
17
- export { default as bullionPrice1oz } from './bullion-price-1oz'
18
-
package/conf/index.ts DELETED
@@ -1,52 +0,0 @@
1
- import type { SelectionUISpecifier } from '@hanzo/commerce/types'
2
-
3
- export { default as commerceServiceOptions } from './lux-commerce-options'
4
-
5
- export const selectionUISpecifiers = {
6
-
7
- 'LXM-CN': {
8
- singleFamily: {
9
- type: 'carousel',
10
- options: {
11
- familyTitle: 'long',
12
- showByline: false,
13
- showPrice: true,
14
- }
15
- }
16
- },
17
- 'LXM-FC': {
18
- singleFamily: {
19
- type: 'carousel',
20
- options: {
21
- //showQuantity: true
22
- }
23
- }
24
- },
25
- 'LXM-CR': {
26
- multiFamily: {
27
- type: 'all-variants-carousel',
28
- selectorOptions: {
29
- showParentTitle: false,
30
- showItemSwatches: true
31
- },
32
- itemOptions: {
33
- familyTitle: 'long',
34
- showFamilyByline: true,
35
- showPrice: false,
36
- }
37
- }
38
- },
39
- 'LXM-AG': {
40
- multiFamily: {
41
- type: 'all-variants-carousel',
42
- selectorOptions: {
43
- showParentTitle: true,
44
- showItemSwatches: false
45
- },
46
- itemOptions: {
47
- familyTitle: 'long',
48
- }
49
- }
50
- },
51
-
52
- } satisfies Record<string, SelectionUISpecifier>
@@ -1,6 +0,0 @@
1
- import type { ServiceOptions } from '@hanzo/commerce'
2
-
3
- export default {
4
- dbName: 'lux-commerce',
5
- ordersTable: 'orders'
6
- } satisfies ServiceOptions
@@ -1,10 +0,0 @@
1
- import type { ServiceOptions } from '@hanzo/commerce'
2
- import type { CategoryNode, Family } from '@hanzo/commerce/types'
3
-
4
- interface CommerceConfig {
5
- families: Family[]
6
- rootNode: CategoryNode
7
- options?: ServiceOptions
8
- }
9
-
10
- export { type CommerceConfig as default }