@luxfi/core 5.1.2 → 5.1.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/commerce/AUTO-GEN-bullion-by-family.json +33 -33
- package/commerce/EDIT-ME-bullion-market-prices.ts +11 -11
- package/commerce/assign-prices.ts +49 -49
- package/commerce/assign-videos-by-family-group.ts +14 -14
- package/commerce/bullion-price-1oz.ts +5 -5
- package/commerce/index.ts +18 -18
- package/commerce/lux-service-options.ts +6 -6
- package/components/access-code-input.tsx +71 -71
- package/components/auth/auth-listener.tsx +29 -29
- package/components/auth/auth-token/clear-auth-token.tsx +12 -12
- package/components/auth/auth-token/set-auth-token.tsx +16 -16
- package/components/auth/common-auth-domains.ts +16 -16
- package/components/auth/login-panel.tsx +104 -104
- package/components/chat-widget.tsx +80 -80
- package/components/commerce/bag-button.tsx +98 -98
- package/components/commerce/buy-drawer/drawer.tsx +44 -44
- package/components/commerce/buy-drawer/index.tsx +46 -46
- package/components/commerce/checkout-button.tsx +116 -116
- package/components/commerce/checkout-panel/close-button.tsx +26 -26
- package/components/commerce/checkout-panel/dt-bag-carousel.tsx +36 -36
- package/components/commerce/checkout-panel/dt-checkout-panel.tsx +66 -66
- package/components/commerce/checkout-panel/index.tsx +123 -123
- package/components/commerce/checkout-panel/links-row.tsx +21 -21
- package/components/commerce/checkout-panel/mb-checkout-panel.tsx +54 -54
- package/components/commerce/checkout-panel/steps-indicator.tsx +39 -39
- package/components/commerce/checkout-panel/thank-you.tsx +18 -18
- package/components/commerce/checkout-widget/const.ts +13 -13
- package/components/commerce/checkout-widget/index.tsx +86 -86
- package/components/commerce/checkout-widget/obs-string-set.ts +48 -48
- package/components/commerce/checkout-widget/use-anim-clx-set.ts +56 -56
- package/components/commerce/checkout-widget/use-lagging-item-ref.ts +29 -29
- package/components/commerce/desktop-bag-popup.tsx +78 -78
- package/components/commerce/mobile-bag-drawer.tsx +51 -51
- package/components/commerce/mobile-login-button.tsx +101 -0
- package/components/commerce/mobile-menu-toggle-button.tsx +35 -35
- package/components/commerce/mobile-nav-menu-ai.tsx +98 -0
- package/components/commerce/mobile-nav-menu-item.tsx +46 -0
- package/components/commerce/mobile-nav-menu.tsx +79 -64
- package/components/contact-dialog/contact-form.tsx +112 -112
- package/components/contact-dialog/disclaimer.tsx +13 -13
- package/components/contact-dialog/index.tsx +64 -64
- package/components/copyright.tsx +21 -21
- package/components/footer.tsx +77 -77
- package/components/header/desktop.tsx +54 -54
- package/components/header/guts.tsx +27 -0
- package/components/header/index.tsx +47 -26
- package/components/header/mobile.tsx +165 -161
- package/components/header/theme-toggle.tsx +26 -26
- package/components/icons/avatar.tsx +11 -0
- package/components/icons/bag-icon.tsx +10 -10
- package/components/icons/github.tsx +14 -14
- package/components/icons/index.tsx +43 -35
- package/components/icons/left-arrow.tsx +11 -0
- package/components/icons/lux-logo.tsx +10 -10
- package/components/icons/right-arrow.tsx +10 -0
- package/components/icons/search.tsx +12 -0
- package/components/icons/secure-delivery.tsx +13 -13
- package/components/icons/social-icon.tsx +35 -35
- package/components/icons/social-svg.css +3 -3
- package/components/icons/youtube-logo.tsx +59 -59
- package/components/index.ts +27 -27
- package/components/logo.tsx +81 -81
- package/components/mini-chart/index.tsx +7 -7
- package/components/mini-chart/mini-chart-props.ts +43 -43
- package/components/mini-chart/mini-chart.tsx +85 -85
- package/components/mini-chart/wrapper.tsx +23 -23
- package/components/not-found/index.tsx +27 -27
- package/components/not-found/not-found-content.mdx +5 -5
- package/components/scripts.tsx +24 -24
- package/conf/index.ts +50 -50
- package/environment.d.ts +5 -5
- package/next/analytics/fpixel.ts +15 -15
- package/next/analytics/google-analytics.ts +13 -13
- package/next/analytics/index.ts +3 -3
- package/next/analytics/pixel-analytics.tsx +54 -54
- package/next/font/get-app-router-font-classes.ts +12 -12
- package/next/font/load-and-return-lux-next-fonts-on-import.ts +68 -68
- package/next/font/next-font-desc.ts +27 -27
- package/next/font/pages-router-font-vars.tsx +18 -18
- package/next/head-metadata/from-next/metadata-types.ts +158 -158
- package/next/head-metadata/from-next/opengraph-types.ts +267 -267
- package/next/head-metadata/from-next/twitter-types.ts +92 -92
- package/next/head-metadata/index.tsx +208 -208
- package/next/middleware/determine-device-mw.ts +16 -16
- package/package.json +73 -72
- package/root-layout/WHY_THIS_IS_SEPARATE.txt +1 -1
- package/root-layout/index.tsx +121 -120
- package/server-actions/firebase-app.ts +14 -14
- package/server-actions/index.ts +5 -5
- package/server-actions/store-contact.ts +51 -51
- package/site-def/footer/community.tsx +67 -67
- package/site-def/footer/company.ts +37 -37
- package/site-def/footer/ecosystem.ts +37 -37
- package/site-def/footer/index.tsx +26 -26
- package/site-def/footer/legal.ts +28 -28
- package/site-def/footer/network.ts +45 -45
- package/site-def/footer/svg/warpcast-logo.svg +11 -11
- package/site-def/index.ts +2 -2
- package/site-def/main-nav.tsx +292 -0
- package/style/cart-animation.css +29 -29
- package/style/checkout-animation.css +23 -23
- package/style/lux-colors.css +85 -85
- package/style/lux-global.css +30 -30
- package/tailwind/fontFamily.tailwind.lux.ts +18 -18
- package/tailwind/index.ts +2 -2
- package/tailwind/lux-tw-fonts.ts +39 -39
- package/tailwind/tailwind.config.lux-preset.ts +10 -10
- package/tsconfig.json +10 -10
- package/types/chatbot-config.ts +6 -6
- package/types/chatbot-suggested-question.ts +7 -7
- package/types/commerce-config.ts +10 -10
- package/types/contact-info.ts +10 -10
- package/types/index.ts +5 -5
- package/types/site-def.ts +45 -45
- package/site-def/main-nav.ts +0 -35
|
@@ -1,34 +1,34 @@
|
|
|
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
|
-
}
|
|
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
34
|
]
|
|
@@ -1,12 +1,12 @@
|
|
|
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
|
-
},
|
|
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
12
|
}
|
|
@@ -1,50 +1,50 @@
|
|
|
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
|
|
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
50
|
}
|
|
@@ -1,14 +1,14 @@
|
|
|
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
|
+
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 +1,5 @@
|
|
|
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
|
+
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
|
+
)
|
package/commerce/index.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
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 './lux-service-options'
|
|
17
|
-
export { default as bullionPrice1oz } from './bullion-price-1oz'
|
|
18
|
-
|
|
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 './lux-service-options'
|
|
17
|
+
export { default as bullionPrice1oz } from './bullion-price-1oz'
|
|
18
|
+
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import type { ServiceOptions } from '@hanzo/commerce'
|
|
2
|
-
|
|
3
|
-
export default {
|
|
4
|
-
dbName: 'lux-commerce',
|
|
5
|
-
ordersTable: 'orders'
|
|
6
|
-
} satisfies ServiceOptions
|
|
1
|
+
import type { ServiceOptions } from '@hanzo/commerce'
|
|
2
|
+
|
|
3
|
+
export default {
|
|
4
|
+
dbName: 'lux-commerce',
|
|
5
|
+
ordersTable: 'orders'
|
|
6
|
+
} satisfies ServiceOptions
|
|
@@ -1,71 +1,71 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useState } from 'react'
|
|
4
|
-
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from '@hanzo/ui/primitives'
|
|
5
|
-
import { cn } from '@hanzo/ui/util'
|
|
6
|
-
|
|
7
|
-
const AccessCodeInput: React.FC<{
|
|
8
|
-
onSuccess?: () => void
|
|
9
|
-
onFail?: () => void
|
|
10
|
-
validCodes?: string[]
|
|
11
|
-
className?: string
|
|
12
|
-
}> = ({
|
|
13
|
-
onSuccess,
|
|
14
|
-
onFail,
|
|
15
|
-
validCodes,
|
|
16
|
-
className
|
|
17
|
-
}) => {
|
|
18
|
-
const [status, setStatus] = useState<'valid' | 'invalid' | 'checking' | undefined>()
|
|
19
|
-
|
|
20
|
-
const checkAccessCode = (code: string) => {
|
|
21
|
-
setStatus(undefined)
|
|
22
|
-
if (code.length === 6) {
|
|
23
|
-
setStatus('checking')
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
if (validCodes?.includes(code) && onSuccess) {
|
|
26
|
-
setStatus('valid')
|
|
27
|
-
onSuccess()
|
|
28
|
-
}
|
|
29
|
-
else {
|
|
30
|
-
setStatus('invalid')
|
|
31
|
-
onFail && onFail()
|
|
32
|
-
}
|
|
33
|
-
}, 1000)
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
return (
|
|
38
|
-
<div className={cn('flex flex-col gap-2 mx-auto w-full text-center items-center', className)}>
|
|
39
|
-
<InputOTP
|
|
40
|
-
className='mx-auto'
|
|
41
|
-
maxLength={6}
|
|
42
|
-
onInput={(event) => checkAccessCode((event.target as HTMLInputElement).value)}
|
|
43
|
-
render={({ slots }) => (
|
|
44
|
-
<>
|
|
45
|
-
<InputOTPGroup>
|
|
46
|
-
{slots.slice(0, 3).map((slot, index) => (
|
|
47
|
-
<InputOTPSlot key={index} {...slot} />
|
|
48
|
-
))}{" "}
|
|
49
|
-
</InputOTPGroup>
|
|
50
|
-
<InputOTPSeparator />
|
|
51
|
-
<InputOTPGroup>
|
|
52
|
-
{slots.slice(3).map((slot, index) => (
|
|
53
|
-
<InputOTPSlot key={index + 3} {...slot} />
|
|
54
|
-
))}
|
|
55
|
-
</InputOTPGroup>
|
|
56
|
-
</>
|
|
57
|
-
)}
|
|
58
|
-
/>
|
|
59
|
-
<p className='h-[3rem]'>
|
|
60
|
-
{
|
|
61
|
-
status === 'checking' ? 'Checking access code...' :
|
|
62
|
-
status === 'invalid' ? <span className='text-destructive'>Invalid access code!</span> :
|
|
63
|
-
status === 'valid' ? <span>Access code is valid! Redirecting...</span> :
|
|
64
|
-
null
|
|
65
|
-
}
|
|
66
|
-
</p>
|
|
67
|
-
</div>
|
|
68
|
-
)
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
export default AccessCodeInput
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useState } from 'react'
|
|
4
|
+
import { InputOTP, InputOTPGroup, InputOTPSeparator, InputOTPSlot } from '@hanzo/ui/primitives'
|
|
5
|
+
import { cn } from '@hanzo/ui/util'
|
|
6
|
+
|
|
7
|
+
const AccessCodeInput: React.FC<{
|
|
8
|
+
onSuccess?: () => void
|
|
9
|
+
onFail?: () => void
|
|
10
|
+
validCodes?: string[]
|
|
11
|
+
className?: string
|
|
12
|
+
}> = ({
|
|
13
|
+
onSuccess,
|
|
14
|
+
onFail,
|
|
15
|
+
validCodes,
|
|
16
|
+
className
|
|
17
|
+
}) => {
|
|
18
|
+
const [status, setStatus] = useState<'valid' | 'invalid' | 'checking' | undefined>()
|
|
19
|
+
|
|
20
|
+
const checkAccessCode = (code: string) => {
|
|
21
|
+
setStatus(undefined)
|
|
22
|
+
if (code.length === 6) {
|
|
23
|
+
setStatus('checking')
|
|
24
|
+
setTimeout(() => {
|
|
25
|
+
if (validCodes?.includes(code) && onSuccess) {
|
|
26
|
+
setStatus('valid')
|
|
27
|
+
onSuccess()
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
setStatus('invalid')
|
|
31
|
+
onFail && onFail()
|
|
32
|
+
}
|
|
33
|
+
}, 1000)
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return (
|
|
38
|
+
<div className={cn('flex flex-col gap-2 mx-auto w-full text-center items-center', className)}>
|
|
39
|
+
<InputOTP
|
|
40
|
+
className='mx-auto'
|
|
41
|
+
maxLength={6}
|
|
42
|
+
onInput={(event) => checkAccessCode((event.target as HTMLInputElement).value)}
|
|
43
|
+
render={({ slots }) => (
|
|
44
|
+
<>
|
|
45
|
+
<InputOTPGroup>
|
|
46
|
+
{slots.slice(0, 3).map((slot, index) => (
|
|
47
|
+
<InputOTPSlot key={index} {...slot} />
|
|
48
|
+
))}{" "}
|
|
49
|
+
</InputOTPGroup>
|
|
50
|
+
<InputOTPSeparator />
|
|
51
|
+
<InputOTPGroup>
|
|
52
|
+
{slots.slice(3).map((slot, index) => (
|
|
53
|
+
<InputOTPSlot key={index + 3} {...slot} />
|
|
54
|
+
))}
|
|
55
|
+
</InputOTPGroup>
|
|
56
|
+
</>
|
|
57
|
+
)}
|
|
58
|
+
/>
|
|
59
|
+
<p className='h-[3rem]'>
|
|
60
|
+
{
|
|
61
|
+
status === 'checking' ? 'Checking access code...' :
|
|
62
|
+
status === 'invalid' ? <span className='text-destructive'>Invalid access code!</span> :
|
|
63
|
+
status === 'valid' ? <span>Access code is valid! Redirecting...</span> :
|
|
64
|
+
null
|
|
65
|
+
}
|
|
66
|
+
</p>
|
|
67
|
+
</div>
|
|
68
|
+
)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export default AccessCodeInput
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
'use client'
|
|
2
|
-
|
|
3
|
-
import { useEffect } from 'react'
|
|
4
|
-
import { useAuth } from '@hanzo/auth/service'
|
|
5
|
-
import { getCookie } from 'cookies-next'
|
|
6
|
-
|
|
7
|
-
const AuthListener = () => {
|
|
8
|
-
const auth = useAuth()
|
|
9
|
-
|
|
10
|
-
useEffect(() => {
|
|
11
|
-
fetch(`${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/api/auth/get-auth-token`, {
|
|
12
|
-
method: 'GET',
|
|
13
|
-
credentials: 'include',
|
|
14
|
-
})
|
|
15
|
-
.then(response => response.json())
|
|
16
|
-
.then((data: any) => {
|
|
17
|
-
const token = getCookie('auth-token')
|
|
18
|
-
console.log(data)
|
|
19
|
-
console.log(token)
|
|
20
|
-
if (!!token) {
|
|
21
|
-
auth.loginWithCustomToken(token)
|
|
22
|
-
}
|
|
23
|
-
})
|
|
24
|
-
}, [auth])
|
|
25
|
-
|
|
26
|
-
return ( <></> )
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
export default AuthListener
|
|
1
|
+
'use client'
|
|
2
|
+
|
|
3
|
+
import { useEffect } from 'react'
|
|
4
|
+
import { useAuth } from '@hanzo/auth/service'
|
|
5
|
+
import { getCookie } from 'cookies-next'
|
|
6
|
+
|
|
7
|
+
const AuthListener = () => {
|
|
8
|
+
const auth = useAuth()
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
fetch(`${process.env.NEXT_PUBLIC_LOGIN_SITE_URL}/api/auth/get-auth-token`, {
|
|
12
|
+
method: 'GET',
|
|
13
|
+
credentials: 'include',
|
|
14
|
+
})
|
|
15
|
+
.then(response => response.json())
|
|
16
|
+
.then((data: any) => {
|
|
17
|
+
const token = getCookie('auth-token')
|
|
18
|
+
console.log(data)
|
|
19
|
+
console.log(token)
|
|
20
|
+
if (!!token) {
|
|
21
|
+
auth.loginWithCustomToken(token)
|
|
22
|
+
}
|
|
23
|
+
})
|
|
24
|
+
}, [auth])
|
|
25
|
+
|
|
26
|
+
return ( <></> )
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export default AuthListener
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import domains from '../common-auth-domains'
|
|
2
|
-
|
|
3
|
-
const ClearAuthToken = () => {
|
|
4
|
-
return (<>
|
|
5
|
-
{domains.map(({url}) => (
|
|
6
|
-
/* Clear auth-token cookie across all Lux domains */
|
|
7
|
-
<img src={`${url}/api/auth/clear-auth-token`} className='absolute hidden'/>
|
|
8
|
-
))}
|
|
9
|
-
</>)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export default ClearAuthToken
|
|
1
|
+
import domains from '../common-auth-domains'
|
|
2
|
+
|
|
3
|
+
const ClearAuthToken = () => {
|
|
4
|
+
return (<>
|
|
5
|
+
{domains.map(({url}) => (
|
|
6
|
+
/* Clear auth-token cookie across all Lux domains */
|
|
7
|
+
<img src={`${url}/api/auth/clear-auth-token`} className='absolute hidden'/>
|
|
8
|
+
))}
|
|
9
|
+
</>)
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default ClearAuthToken
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
import domains from '../common-auth-domains'
|
|
2
|
-
|
|
3
|
-
const SetAuthToken: React.FC<{
|
|
4
|
-
authToken: string
|
|
5
|
-
}> = ({
|
|
6
|
-
authToken,
|
|
7
|
-
}) => {
|
|
8
|
-
return (<>
|
|
9
|
-
{!!authToken && domains.map(({url}) => (
|
|
10
|
-
/* Set auth-token cookie across all Lux domains */
|
|
11
|
-
<img src={`${url}/api/auth/set-auth-token?token=${authToken}`} className='absolute hidden'/>
|
|
12
|
-
))}
|
|
13
|
-
</>)
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
export default SetAuthToken
|
|
1
|
+
import domains from '../common-auth-domains'
|
|
2
|
+
|
|
3
|
+
const SetAuthToken: React.FC<{
|
|
4
|
+
authToken: string
|
|
5
|
+
}> = ({
|
|
6
|
+
authToken,
|
|
7
|
+
}) => {
|
|
8
|
+
return (<>
|
|
9
|
+
{!!authToken && domains.map(({url}) => (
|
|
10
|
+
/* Set auth-token cookie across all Lux domains */
|
|
11
|
+
<img src={`${url}/api/auth/set-auth-token?token=${authToken}`} className='absolute hidden'/>
|
|
12
|
+
))}
|
|
13
|
+
</>)
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export default SetAuthToken
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
const domains = [
|
|
2
|
-
{ id: 'lux.market', url: 'https://lux.market' },
|
|
3
|
-
{ id: 'lux.shop', url: 'https://lux.shop' },
|
|
4
|
-
{ id: 'lux.credit', url: 'https://lux.credit' },
|
|
5
|
-
{ id: 'lux.network', url: 'https://lux.network' },
|
|
6
|
-
{ id: 'wallet.lux.network', url: 'https://wallet.lux.network' },
|
|
7
|
-
{ id: 'safe.lux.network', url: 'https://safe.lux.network' },
|
|
8
|
-
{ id: 'lux.finance', url: 'https://lux.finance' },
|
|
9
|
-
{ id: 'lux.exchange', url: 'https://lux.exchange' },
|
|
10
|
-
{ id: 'lux.quest', url: 'https://lux.quest' },
|
|
11
|
-
{ id: 'lux.services', url: 'https://lux.services' },
|
|
12
|
-
]
|
|
13
|
-
|
|
14
|
-
export {
|
|
15
|
-
domains as default
|
|
16
|
-
}
|
|
1
|
+
const domains = [
|
|
2
|
+
{ id: 'lux.market', url: 'https://lux.market' },
|
|
3
|
+
{ id: 'lux.shop', url: 'https://lux.shop' },
|
|
4
|
+
{ id: 'lux.credit', url: 'https://lux.credit' },
|
|
5
|
+
{ id: 'lux.network', url: 'https://lux.network' },
|
|
6
|
+
{ id: 'wallet.lux.network', url: 'https://wallet.lux.network' },
|
|
7
|
+
{ id: 'safe.lux.network', url: 'https://safe.lux.network' },
|
|
8
|
+
{ id: 'lux.finance', url: 'https://lux.finance' },
|
|
9
|
+
{ id: 'lux.exchange', url: 'https://lux.exchange' },
|
|
10
|
+
{ id: 'lux.quest', url: 'https://lux.quest' },
|
|
11
|
+
{ id: 'lux.services', url: 'https://lux.services' },
|
|
12
|
+
]
|
|
13
|
+
|
|
14
|
+
export {
|
|
15
|
+
domains as default
|
|
16
|
+
}
|