@anker-in/campaign-ui 0.2.10-beta.28 → 0.2.10-beta.30
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/cjs/components/credits/context/const.d.ts +2 -1
- package/dist/cjs/components/credits/context/const.js +1 -1
- package/dist/cjs/components/credits/context/const.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemableList.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/CardValue.d.ts +6 -0
- package/dist/cjs/components/credits/creditsRedeemList/CardValue.js +2 -0
- package/dist/cjs/components/credits/creditsRedeemList/CardValue.js.map +7 -0
- package/dist/cjs/components/credits/creditsRedeemList/NonProductValue.d.ts +6 -0
- package/dist/cjs/components/credits/creditsRedeemList/NonProductValue.js +2 -0
- package/dist/cjs/components/credits/creditsRedeemList/NonProductValue.js.map +7 -0
- package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Init.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Init.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.d.ts +6 -0
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.js +2 -0
- package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.js.map +7 -0
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
- package/dist/cjs/components/credits/creditsRedeemList/index.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/index.js.map +2 -2
- package/dist/esm/components/credits/context/const.d.ts +2 -1
- package/dist/esm/components/credits/context/const.js +1 -1
- package/dist/esm/components/credits/context/const.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemableList.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/CardValue.d.ts +6 -0
- package/dist/esm/components/credits/creditsRedeemList/CardValue.js +2 -0
- package/dist/esm/components/credits/creditsRedeemList/CardValue.js.map +7 -0
- package/dist/esm/components/credits/creditsRedeemList/NonProductValue.d.ts +6 -0
- package/dist/esm/components/credits/creditsRedeemList/NonProductValue.js +2 -0
- package/dist/esm/components/credits/creditsRedeemList/NonProductValue.js.map +7 -0
- package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Init.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Init.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.d.ts +6 -0
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.js +2 -0
- package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.js.map +7 -0
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
- package/dist/esm/components/credits/creditsRedeemList/index.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/index.js.map +2 -2
- package/package.json +1 -1
- package/src/components/credits/context/const.ts +1 -0
- package/src/components/credits/context/hooks/useRedeemableList.ts +0 -14
- package/src/components/credits/creditsRedeemList/NonProductValue.tsx +38 -0
- package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +4 -6
- package/src/components/credits/creditsRedeemList/RedeemProductModal/Init.tsx +2 -10
- package/src/components/credits/creditsRedeemList/RedeemProductModal/NonProductValue.tsx +23 -0
- package/src/components/credits/creditsRedeemList/RedeemableItem.tsx +10 -23
- package/src/components/credits/creditsRedeemList/index.tsx +0 -2
|
@@ -35,20 +35,6 @@ function useRedeemableList() {
|
|
|
35
35
|
})
|
|
36
36
|
|
|
37
37
|
const getRedeemableList = useCallback(() => {
|
|
38
|
-
const cacheName = `consume_credit_rules-${locale}`
|
|
39
|
-
|
|
40
|
-
const cacheStr = localStorage?.getItem(cacheName)
|
|
41
|
-
if (cacheStr) {
|
|
42
|
-
try {
|
|
43
|
-
const cache = JSON.parse(cacheStr)
|
|
44
|
-
if (cache.expire > Date.now() && cache.consume_credit_rules.length) {
|
|
45
|
-
// 缓存未过期
|
|
46
|
-
setRedeemableList(cache.consume_credit_rules)
|
|
47
|
-
return
|
|
48
|
-
}
|
|
49
|
-
} catch (e) {}
|
|
50
|
-
localStorage?.removeItem(cacheName)
|
|
51
|
-
}
|
|
52
38
|
trigger(
|
|
53
39
|
{
|
|
54
40
|
user_id: profile?.user_id,
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Text } from '@anker-in/headless-ui'
|
|
2
|
+
import { RedeemableItem } from '../type'
|
|
3
|
+
import { ConsumeType } from '../context/const'
|
|
4
|
+
import { CreditsRedeemListCopy } from './type'
|
|
5
|
+
|
|
6
|
+
export const NoneProductValue = ({ item, copy }: { item: RedeemableItem; copy: CreditsRedeemListCopy }) => {
|
|
7
|
+
// shipping coupon 仅展示文案
|
|
8
|
+
if (item.config?.type === ConsumeType.ShippingCoupon) {
|
|
9
|
+
return (
|
|
10
|
+
<div className="absolute left-[16px] l-xxl:left-[12px] bottom-[8px] l:left-[8px] font-extrabold text-white md:bottom-[4px] md:left-[5px]">
|
|
11
|
+
<Text
|
|
12
|
+
className="text-[32px] font-bold leading-none md:text-[12px] l-xxl:text-[20px] w-[70%] md:w-full md-l:text-[14px]"
|
|
13
|
+
html={item.config?.value}
|
|
14
|
+
as="p"
|
|
15
|
+
/>
|
|
16
|
+
</div>
|
|
17
|
+
)
|
|
18
|
+
} else {
|
|
19
|
+
return (
|
|
20
|
+
<div className="absolute left-[16px] l-xxl:left-[12px] l:left-[8px] bottom-[8px] font-extrabold text-white md:bottom-[4px] md:left-[5px]">
|
|
21
|
+
{item.config?.value ? (
|
|
22
|
+
<div className="flex items-end">
|
|
23
|
+
<Text
|
|
24
|
+
className="text-[64px] font-extrabold leading-none md:text-[20px] l-xxl:text-[40px] md-l:text-[22px]"
|
|
25
|
+
html={item.config?.value.toString()}
|
|
26
|
+
/>
|
|
27
|
+
<Text
|
|
28
|
+
className="ml-[4px] text-[24px] font-bold leading-[2] md:ml-[2px] l:text-[12px] xxl:leading-[1.4] l-xxl:text-[20px]"
|
|
29
|
+
html={item.config?.type === ConsumeType.GiftCard ? copy?.giftCardLabel : copy?.off}
|
|
30
|
+
/>
|
|
31
|
+
</div>
|
|
32
|
+
) : (
|
|
33
|
+
<Text className="text-[24px] w-[70%] font-bold leading-none" html={item.config?.title} as="p" />
|
|
34
|
+
)}
|
|
35
|
+
</div>
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -11,6 +11,7 @@ import { numberFormat } from '../context/utils'
|
|
|
11
11
|
import type { RedeemableItem as RedeemableItemType } from '../type'
|
|
12
12
|
import { useHeadlessContext } from '@anker-in/lib'
|
|
13
13
|
import { CreditsRedeemListCopy } from './type'
|
|
14
|
+
import { NoneProductValue } from './RedeemProductModal/NonProductValue'
|
|
14
15
|
|
|
15
16
|
function RedeemCouponModal({
|
|
16
17
|
item,
|
|
@@ -95,15 +96,12 @@ function RedeemCouponModal({
|
|
|
95
96
|
)}
|
|
96
97
|
>
|
|
97
98
|
<div className="relative mx-auto h-[164px] w-[324px]">
|
|
98
|
-
{copy?.imageMapping?.
|
|
99
|
-
<Picture source={copy
|
|
99
|
+
{copy?.imageMapping[item.config?.type]?.url && (
|
|
100
|
+
<Picture source={copy.imageMapping[item.config.type].url} className="h-full [&_img]:h-full" />
|
|
100
101
|
)}
|
|
101
102
|
<div className="absolute bottom-[8px] left-[16px] font-extrabold text-white">
|
|
102
103
|
{item.config.value ? (
|
|
103
|
-
<
|
|
104
|
-
<Text className="text-[64px] font-bold leading-none" html={item.config.value.toString()} />
|
|
105
|
-
<Text className="text-[24px] font-bold leading-[2]" html={copy?.off} />
|
|
106
|
-
</div>
|
|
104
|
+
<NoneProductValue item={item} copy={copy} />
|
|
107
105
|
) : (
|
|
108
106
|
<Text size={3} html={item.alpc?.title} />
|
|
109
107
|
)}
|
|
@@ -5,6 +5,7 @@ import { numberFormat } from '../../context/utils'
|
|
|
5
5
|
import type { RedeemableItem as RedeemableItemType } from '../../type'
|
|
6
6
|
import { CreditsRedeemListCopy } from '../type'
|
|
7
7
|
import { ConsumeType } from '../../context/const'
|
|
8
|
+
import { NoneProductValue } from './NonProductValue'
|
|
8
9
|
|
|
9
10
|
type InitProps = {
|
|
10
11
|
copy: CreditsRedeemListCopy
|
|
@@ -23,7 +24,6 @@ export const Init = ({ copy, item, loading, disabled, setStatus }: InitProps) =>
|
|
|
23
24
|
return [...descriptions, ...(copy.redeemModal.product.rules || [])]
|
|
24
25
|
}, [item.config.rules, item.config.desc, copy.redeemModal.product.rules])
|
|
25
26
|
|
|
26
|
-
console.log('item', item)
|
|
27
27
|
return (
|
|
28
28
|
<div className="flex flex-col">
|
|
29
29
|
<div
|
|
@@ -43,15 +43,7 @@ export const Init = ({ copy, item, loading, disabled, setStatus }: InitProps) =>
|
|
|
43
43
|
></Picture>
|
|
44
44
|
{/* 礼品卡展示 */}
|
|
45
45
|
<div className="absolute bottom-[8px] left-[16px] font-extrabold text-white">
|
|
46
|
-
{item.config.value &&
|
|
47
|
-
<div className="flex items-end gap-[4px]">
|
|
48
|
-
<Text className="text-[64px] font-bold leading-none" html={item.config.value.toString()} />
|
|
49
|
-
<Text
|
|
50
|
-
className="text-[24px] font-bold leading-[2]"
|
|
51
|
-
html={item.config.type === ConsumeType.Coupon ? copy?.off : copy?.giftCardLabel}
|
|
52
|
-
/>
|
|
53
|
-
</div>
|
|
54
|
-
)}
|
|
46
|
+
{item.config.value && <NoneProductValue item={item} copy={copy} />}
|
|
55
47
|
</div>
|
|
56
48
|
</div>
|
|
57
49
|
<div className="mt-[30px] md:mt-[18px]">
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Text } from '@anker-in/headless-ui'
|
|
2
|
+
import { RedeemableItem } from '../../type'
|
|
3
|
+
import { CreditsRedeemListCopy } from '../type'
|
|
4
|
+
import { ConsumeType } from '../../context/const'
|
|
5
|
+
|
|
6
|
+
export const NoneProductValue = ({ item, copy }: { item: RedeemableItem; copy: CreditsRedeemListCopy }) => {
|
|
7
|
+
// shipping coupon 仅展示文案
|
|
8
|
+
if (item.config?.type === ConsumeType.ShippingCoupon) {
|
|
9
|
+
return <Text className="text-[24px] w-[70%] font-bold leading-none" html={item.config?.value} as="p" />
|
|
10
|
+
} else {
|
|
11
|
+
return item.config?.value ? (
|
|
12
|
+
<div className="flex items-end gap-[4px]">
|
|
13
|
+
<Text className="text-[64px] font-extrabold leading-none" html={item.config.value.toString()} />
|
|
14
|
+
<Text
|
|
15
|
+
className="text-[24px] font-bold leading-[2]"
|
|
16
|
+
html={item.config.type === ConsumeType.Coupon ? copy?.off : copy?.giftCardLabel}
|
|
17
|
+
/>
|
|
18
|
+
</div>
|
|
19
|
+
) : (
|
|
20
|
+
<Text className="text-[24px] w-[70%] font-bold leading-none" html={item.config?.title} as="p" />
|
|
21
|
+
)
|
|
22
|
+
}
|
|
23
|
+
}
|
|
@@ -9,6 +9,7 @@ import { AlpcConsumeType, ConsumeType } from '../context/const'
|
|
|
9
9
|
import { numberFormat } from '../context/utils'
|
|
10
10
|
import type { CreditsRedeemListCopy } from './type'
|
|
11
11
|
import { gaTrack } from '../../../helpers/track'
|
|
12
|
+
import { NoneProductValue } from './NonProductValue'
|
|
12
13
|
|
|
13
14
|
export function RedeemableItem({
|
|
14
15
|
copy,
|
|
@@ -82,35 +83,21 @@ export function RedeemableItem({
|
|
|
82
83
|
className
|
|
83
84
|
)}
|
|
84
85
|
>
|
|
85
|
-
{item.config?.type
|
|
86
|
-
<div className=
|
|
86
|
+
{item.config?.type === ConsumeType.Product ? (
|
|
87
|
+
<div className={classNames('relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]')}>
|
|
87
88
|
<Picture
|
|
88
|
-
|
|
89
|
-
|
|
89
|
+
className="h-full w-auto [&_img]:h-full [&_img]:object-contain"
|
|
90
|
+
source={item.config?.image?.url || item.product.images?.[0]?.url}
|
|
90
91
|
></Picture>
|
|
91
|
-
<div className="absolute bottom-[8px] left-[16px] font-extrabold text-white md:bottom-[2px] md:left-[5px]">
|
|
92
|
-
{item.config?.value ? (
|
|
93
|
-
<div className="flex items-end">
|
|
94
|
-
<Text
|
|
95
|
-
className="text-[64px] font-bold leading-none md:text-[20px] l-xxl:text-[40px] md-l:text-[22px]"
|
|
96
|
-
html={item.config?.value}
|
|
97
|
-
/>
|
|
98
|
-
<Text
|
|
99
|
-
className="ml-[4px] text-[24px] font-bold leading-[2] md:ml-[2px] l:text-[12px] xxl:leading-[1.4] l-xxl:text-[20px]"
|
|
100
|
-
html={item.config?.type === ConsumeType.GiftCard ? copy?.giftCardLabel : copy?.off}
|
|
101
|
-
/>
|
|
102
|
-
</div>
|
|
103
|
-
) : (
|
|
104
|
-
<Text size={3} html={item.config?.title || item.alpc?.title} />
|
|
105
|
-
)}
|
|
106
|
-
</div>
|
|
107
92
|
</div>
|
|
108
93
|
) : (
|
|
109
|
-
<div className=
|
|
94
|
+
<div className="relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]">
|
|
110
95
|
<Picture
|
|
111
|
-
|
|
112
|
-
|
|
96
|
+
source={copy?.imageMapping[item.config?.type]?.url}
|
|
97
|
+
className="h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain"
|
|
113
98
|
></Picture>
|
|
99
|
+
|
|
100
|
+
<NoneProductValue item={item} copy={copy} />
|
|
114
101
|
</div>
|
|
115
102
|
)}
|
|
116
103
|
<div className={classNames('mt-[22px] flex w-full flex-1 flex-col justify-between')}>
|
|
@@ -95,8 +95,6 @@ export function CreditsRedeemList({
|
|
|
95
95
|
[getRedeemableList]
|
|
96
96
|
)
|
|
97
97
|
|
|
98
|
-
console.log('popRedeemData', popRedeemData)
|
|
99
|
-
|
|
100
98
|
return (
|
|
101
99
|
<Container className={classNames('relative bg-[#F5F5F7]', className)}>
|
|
102
100
|
{!hideTitle && <Heading as="h2" size="4" html={copy.title} />}
|