@anker-in/campaign-ui 0.4.5-beta.9 → 0.4.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.
- package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useAlpcFetch.js.map +2 -2
- package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
- package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js.map +3 -3
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/cjs/components/credits/creditsCash/CreditsCash.js.map +3 -3
- 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/RedeemVirtualProductModal.js +1 -1
- package/dist/cjs/components/credits/creditsRedeemList/RedeemVirtualProductModal.js.map +2 -2
- package/dist/cjs/components/credits/modal/ActivitiesModal.js +1 -1
- package/dist/cjs/components/credits/modal/ActivitiesModal.js.map +2 -2
- package/dist/cjs/components/credits/modal/RewardsModal.js +1 -1
- package/dist/cjs/components/credits/modal/RewardsModal.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js +1 -1
- package/dist/esm/components/credits/context/hooks/useAlpcFetch.js.map +2 -2
- package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
- package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js.map +3 -3
- package/dist/esm/components/credits/creditsCash/CreditsCash.js +1 -1
- package/dist/esm/components/credits/creditsCash/CreditsCash.js.map +3 -3
- 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/RedeemVirtualProductModal.js +1 -1
- package/dist/esm/components/credits/creditsRedeemList/RedeemVirtualProductModal.js.map +2 -2
- package/dist/esm/components/credits/modal/ActivitiesModal.js +1 -1
- package/dist/esm/components/credits/modal/ActivitiesModal.js.map +2 -2
- package/dist/esm/components/credits/modal/RewardsModal.js +1 -1
- package/dist/esm/components/credits/modal/RewardsModal.js.map +2 -2
- package/package.json +1 -1
- package/src/components/credits/context/hooks/useAlpcFetch.ts +12 -5
- package/src/components/credits/context/hooks/useRedeemAndBuy.ts +2 -3
- package/src/components/credits/creditsCash/CreditsCash.tsx +12 -5
- package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +2 -3
- package/src/components/credits/creditsRedeemList/RedeemVirtualProductModal.tsx +3 -3
- package/src/components/credits/modal/ActivitiesModal.tsx +53 -51
- package/src/components/credits/modal/RewardsModal.tsx +5 -5
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../../src/components/credits/modal/RewardsModal.tsx"],
|
|
4
|
-
"sourcesContent": ["import { Tabs, TabsList, TabsTrigger, Picture } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport clipboard from 'copy-to-clipboard'\nimport dayjs from 'dayjs'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { ApprovalStatus, AlpcConsumeType, RewardType } from '../context/const'\nimport { CreditsModalContainer, type ModalContainerProps } from './ModalContainer'\nimport Tip from './Tip'\nimport LoadingDots from './LoadingDots'\nimport useMyRewards from '../context/hooks/useMyRewards'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport interface RewardsCopy {\n title: string\n orderNumberLabel: string\n valueLabel: string\n receivedLabel: string\n failedLabel: string\n approveSuccessLabel: string\n couponTab: string\n productTab: string\n externalProductTab?: string\n pendingLabel: string\n unfulfilledLabel: string\n fulfilledLabel: string\n confirmedTip: string\n pendingTip: string\n processingTip: string\n ShippedTip: string\n emptyListLabel: string\n pointUnit: string\n code: string\n copied: string\n copy: string\n redeemLinkLabel?: string\n goGiftStatus?: {\n pending?: {\n label: string\n tip: string\n }\n approved?: {\n label: string\n tip: string\n }\n secondConfirm?: {\n label: string\n tip: string\n }\n rejected?: {\n label: string\n tip: string\n }\n callbackPending?: {\n label: string\n tip: string\n }\n callbackSuccess?: {\n label: string\n tip: string\n }\n callbackTimeout?: {\n label: string\n tip: string\n }\n }\n emptyListImage: {\n url: string\n alt?: string\n }\n}\ninterface RewardsModalProps extends ModalContainerProps {\n data: RewardsCopy\n}\n\nfunction RewardsModal({ data, ...props }: RewardsModalProps) {\n const [activeTab, setActiveTab] = useState(AlpcConsumeType.Coupon)\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [page, setPage] = useState(1)\n const [copied, setCopied] = useState(-1)\n\n const tabs = useMemo(() => {\n return [\n { title: data.couponTab, type: AlpcConsumeType.Coupon },\n { title: data.productTab, type: AlpcConsumeType.Product },\n { title: data.externalProductTab, type: AlpcConsumeType.ExternalProduct },\n ].filter((tab): tab is { title: string; type: number } => !!tab.title)\n }, [data.couponTab, data.productTab, data.externalProductTab])\n\n // Reset page when switching tabs\n useEffect(() => {\n setPage(1)\n }, [activeTab])\n\n const { myRewards = [], canNext, isLoading } = useMyRewards({\n page,\n pageSize: 1000,\n consumeType: activeTab,\n })\n\n const getProductType = useCallback((item: any) => {\n if (item.fulfillment_status && item.fulfillment_status !== 'null') {\n return item.fulfillment_status === 'fulfilled' ? RewardType.Fulfilled : RewardType.Unfulfilled\n }\n\n if (item.approval_status === ApprovalStatus.Success || item.approval_status === ApprovalStatus.DoubleConfirm) {\n return RewardType.ApproveSuccess\n }\n\n if (item.approval_status === ApprovalStatus.Failed) {\n return RewardType.Failed\n }\n\n return RewardType.Pending\n }, [])\n\n const getGoGiftType = useCallback((status?: number) => {\n const statusMap: Record<number, RewardType> = {\n 0: RewardType.GogiftPending,\n 1: RewardType.GogiftApproved,\n 2: RewardType.GogiftSecondConfirm,\n 3: RewardType.GogiftRejected,\n 4: RewardType.GogiftCallbackPending,\n 5: RewardType.GogiftCallbackSuccess,\n 6: RewardType.GogiftCallbackTimeout,\n }\n return status !== undefined ? (statusMap[status] ?? RewardType.GogiftPending) : RewardType.GogiftPending\n }, [])\n\n const list = useMemo(() => {\n return myRewards.map(item => {\n const base = {\n title: item.goods_title,\n value: item.consume_credits,\n date: new Date(item.create_time * 1000),\n }\n\n if (activeTab === AlpcConsumeType.Coupon) {\n return {\n ...base,\n type: RewardType.Received,\n couponCode: item.coupon_code,\n orderNumber: '',\n link: '',\n }\n }\n\n if (activeTab === AlpcConsumeType.Product) {\n return {\n ...base,\n type: getProductType(item),\n orderNumber: item.order_number,\n couponCode: '',\n link: '',\n }\n }\n\n if (activeTab === AlpcConsumeType.ExternalProduct) {\n return {\n ...base,\n type: getGoGiftType(item.approval_status),\n orderNumber: '',\n couponCode: '',\n link: item.link || '',\n }\n }\n\n return { ...base, type: RewardType.Received, couponCode: '', orderNumber: '', link: '' }\n })\n }, [activeTab, myRewards, getProductType, getGoGiftType])\n\n\n const TypeMap = useMemo(() => {\n return {\n [RewardType.Received]: data.receivedLabel,\n [RewardType.Pending]: data.pendingLabel,\n [RewardType.ApproveFail]: data.failedLabel,\n [RewardType.ApproveSuccess]: data.approveSuccessLabel,\n [RewardType.Unfulfilled]: data.unfulfilledLabel,\n [RewardType.Fulfilled]: data.fulfilledLabel,\n [RewardType.Failed]: data.failedLabel,\n [RewardType.GogiftPending]: data.goGiftStatus?.pending?.label || data.pendingLabel,\n [RewardType.GogiftApproved]: data.goGiftStatus?.approved?.label || data.approveSuccessLabel,\n [RewardType.GogiftSecondConfirm]: data.goGiftStatus?.secondConfirm?.label || data.approveSuccessLabel,\n [RewardType.GogiftRejected]: data.goGiftStatus?.rejected?.label || data.failedLabel,\n [RewardType.GogiftCallbackPending]: data.goGiftStatus?.callbackPending?.label || data.pendingLabel,\n [RewardType.GogiftCallbackSuccess]: data.goGiftStatus?.callbackSuccess?.label || data.receivedLabel,\n [RewardType.GogiftCallbackTimeout]: data.goGiftStatus?.callbackTimeout?.label || data.failedLabel,\n }\n }, [data])\n\n const TipMap = useMemo(() => {\n return {\n [RewardType.Received]: '',\n [RewardType.Pending]: data.pendingTip,\n [RewardType.ApproveFail]: '',\n [RewardType.ApproveSuccess]: data.confirmedTip,\n [RewardType.Unfulfilled]: data.processingTip,\n [RewardType.Fulfilled]: data.ShippedTip,\n [RewardType.Failed]: '',\n [RewardType.GogiftPending]: data.goGiftStatus?.pending?.tip || '',\n [RewardType.GogiftApproved]: data.goGiftStatus?.approved?.tip || '',\n [RewardType.GogiftSecondConfirm]: data.goGiftStatus?.secondConfirm?.tip || '',\n [RewardType.GogiftRejected]: data.goGiftStatus?.rejected?.tip || '',\n [RewardType.GogiftCallbackPending]: data.goGiftStatus?.callbackPending?.tip || '',\n [RewardType.GogiftCallbackSuccess]: data.goGiftStatus?.callbackSuccess?.tip || '',\n [RewardType.GogiftCallbackTimeout]: data.goGiftStatus?.callbackTimeout?.tip || '',\n }\n }, [data])\n\n const ColorMap = useMemo(() => {\n return {\n [RewardType.Received]: '#52C41A',\n [RewardType.Pending]: '#999',\n [RewardType.ApproveFail]: '#F84D4F',\n [RewardType.ApproveSuccess]: '#999',\n [RewardType.Unfulfilled]: '#999',\n [RewardType.Fulfilled]: '#999',\n [RewardType.Failed]: '#F84D4F',\n [RewardType.GogiftPending]: '#999',\n [RewardType.GogiftApproved]: '#999',\n [RewardType.GogiftSecondConfirm]: '#999',\n [RewardType.GogiftRejected]: '#F84D4F',\n [RewardType.GogiftCallbackPending]: '#999',\n [RewardType.GogiftCallbackSuccess]: '#52C41A',\n [RewardType.GogiftCallbackTimeout]: '#F84D4F',\n }\n }, [])\n\n const handleScrollEnd = useCallback(() => {\n if (canNext) {\n setPage(prev => prev + 1)\n }\n }, [canNext])\n\n const handleCopy = useCallback((code: string, idx: number) => {\n setCopied(idx)\n clipboard(code)\n setTimeout(() => {\n setCopied(-1)\n }, 2000)\n }, [])\n\n\n return (\n <CreditsModalContainer\n title={data.title}\n className={classNames('h-[800px] w-[640px]')}\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n scrollClassName=\"md:mb-0\"\n {...props}\n onScrollEnd={handleScrollEnd}\n >\n <div className=\"\">\n <Tabs\n align=\"left\"\n shape={rounded ? 'rounded' : 'square'}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(Number(value))\n }}\n >\n <TabsList>\n {tabs.map(tab => (\n <TabsTrigger key={tab.type} value={tab.type.toString()}>\n {tab.title}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n </div>\n\n {isLoading && (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <LoadingDots />\n </div>\n )}\n\n {!isLoading && (\n <div className=\"mt-[24px] overflow-auto overscroll-contain\">\n {list.length > 0 ? (\n <div className=\"grid gap-[18px] md:gap-[12px]\">\n {list.map((item, index) => (\n <div key={index} className=\"grid gap-[8px]\">\n {item?.orderNumber && (\n <div className=\"text-[15px] font-semibold leading-[1.4] text-[#777]\">\n {data.orderNumberLabel}: {item.orderNumber}\n </div>\n )}\n <div\n className={classNames(\n 'flex items-center justify-between rounded-[8px] bg-[#f7f8f9] px-[16px] py-[20px]',\n !rounded && 'rounded-none'\n )}\n >\n <div className=\"grid gap-[4px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{item.title}</div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {data.valueLabel}: {item.value} {data?.pointUnit}\n </div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {item?.couponCode ? `${data?.code || 'Code'}: ${item.couponCode} ` : ''}\n {item?.couponCode && (\n <span\n className=\"cursor-pointer text-[14px] font-semibold text-brand underline\"\n onClick={() => {\n handleCopy(item.couponCode, index)\n }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copied === index ? data?.copied || 'COPIED' : data?.copy || 'COPY'}\n </span>\n )}\n </div>\n {item?.link && (\n <div className=\"text-[14px] font-semibold text-[#999]\">\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-brand underline\"\n >\n {data?.redeemLinkLabel || 'Redeem Link'}\n </a>\n </div>\n )}\n </div>\n <div className=\"grid gap-[4px] text-right\">\n <div\n className={classNames(\n 'flex items-center justify-end text-[16px] font-bold leading-[1.4]',\n `text-[${ColorMap[item.type]}]`\n )}\n >\n <span>{TypeMap[item.type]}</span>\n {TipMap[item.type] && <Tip info={TipMap[item.type]} index={index} />}\n </div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {dayjs(item.date).format('YYYY-MM-DD HH:mm').toString()}\n </div>\n </div>\n </div>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <Picture\n className=\"mb-[12px] w-[160px]\"\n source={data?.emptyListImage?.url}\n alt={data?.emptyListImage?.alt || 'empty list image'}\n ></Picture>\n <div className=\"text-[16px] font-semibold leading-[1.4]\">{data?.emptyListLabel}</div>\n </div>\n )}\n </div>\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RewardsModal\n"],
|
|
5
|
-
"mappings": "AA4Qc,cAAAA,EAqBM,QAAAC,MArBN,oBA5Qd,OAAS,QAAAC,EAAM,YAAAC,EAAU,eAAAC,EAAa,WAAAC,MAAe,wBACrD,OAAOC,MAAgB,aACvB,OAAOC,MAAe,oBACtB,OAAOC,MAAW,QAClB,OAAS,eAAAC,EAAa,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAE1D,OAAS,kBAAAC,EAAgB,mBAAAC,EAAiB,cAAAC,MAAkB,mBAC5D,OAAS,yBAAAC,MAAuD,mBAChE,OAAOC,MAAS,QAChB,OAAOC,MAAiB,gBACxB,OAAOC,MAAkB,gCACzB,OAAS,sBAAAC,MAA0B,gBACnC,OAAS,kBAAAC,MAAsB,qBAgE/B,SAASC,EAAa,CAAE,KAAAC,EAAM,GAAGC,CAAM,EAAsB,CAC3D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G,UACrB,CAACA,EAAW,aAAa,EAAG,OAC5B,CAACA,EAAW,cAAc,EAAG,OAC7B,CAACA,EAAW,mBAAmB,EAAG,OAClC,CAACA,EAAW,cAAc,EAAG,UAC7B,CAACA,EAAW,qBAAqB,EAAG,OACpC,CAACA,EAAW,qBAAqB,EAAG,UACpC,CAACA,EAAW,qBAAqB,EAAG,SACtC,GACC,CAAC,CAAC,EAECiC,EAAkBvC,EAAY,IAAM,CACpC2B,GACFN,EAAQmB,GAAQA,EAAO,CAAC,CAE5B,EAAG,CAACb,CAAO,CAAC,EAENc,EAAazC,EAAY,CAAC0C,EAAcC,IAAgB,CAC5DpB,EAAUoB,CAAG,EACb7C,EAAU4C,CAAI,EACd,WAAW,IAAM,CACfnB,EAAU,EAAE,CACd,EAAG,GAAI,CACT,EAAG,CAAC,CAAC,EAGL,OACE/B,EAACe,EAAA,CACC,MAAOO,EAAK,MACZ,UAAWjB,EAAW,qBAAqB,EAC3C,aAAY,GACZ,mBAAmB,yBACnB,gBAAgB,
|
|
4
|
+
"sourcesContent": ["import { Tabs, TabsList, TabsTrigger, Picture } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport clipboard from 'copy-to-clipboard'\nimport dayjs from 'dayjs'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\n\nimport { ApprovalStatus, AlpcConsumeType, RewardType } from '../context/const'\nimport { CreditsModalContainer, type ModalContainerProps } from './ModalContainer'\nimport Tip from './Tip'\nimport LoadingDots from './LoadingDots'\nimport useMyRewards from '../context/hooks/useMyRewards'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { ROUNDED_BRANDS } from '../../../constants'\n\nexport interface RewardsCopy {\n title: string\n orderNumberLabel: string\n valueLabel: string\n receivedLabel: string\n failedLabel: string\n approveSuccessLabel: string\n couponTab: string\n productTab: string\n externalProductTab?: string\n pendingLabel: string\n unfulfilledLabel: string\n fulfilledLabel: string\n confirmedTip: string\n pendingTip: string\n processingTip: string\n ShippedTip: string\n emptyListLabel: string\n pointUnit: string\n code: string\n copied: string\n copy: string\n redeemLinkLabel?: string\n goGiftStatus?: {\n pending?: {\n label: string\n tip: string\n }\n approved?: {\n label: string\n tip: string\n }\n secondConfirm?: {\n label: string\n tip: string\n }\n rejected?: {\n label: string\n tip: string\n }\n callbackPending?: {\n label: string\n tip: string\n }\n callbackSuccess?: {\n label: string\n tip: string\n }\n callbackTimeout?: {\n label: string\n tip: string\n }\n }\n emptyListImage: {\n url: string\n alt?: string\n }\n}\ninterface RewardsModalProps extends ModalContainerProps {\n data: RewardsCopy\n}\n\nfunction RewardsModal({ data, ...props }: RewardsModalProps) {\n const [activeTab, setActiveTab] = useState(AlpcConsumeType.Coupon)\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [page, setPage] = useState(1)\n const [copied, setCopied] = useState(-1)\n\n const tabs = useMemo(() => {\n return [\n { title: data.couponTab, type: AlpcConsumeType.Coupon },\n { title: data.productTab, type: AlpcConsumeType.Product },\n { title: data.externalProductTab, type: AlpcConsumeType.ExternalProduct },\n ].filter((tab): tab is { title: string; type: number } => !!tab.title)\n }, [data.couponTab, data.productTab, data.externalProductTab])\n\n // Reset page when switching tabs\n useEffect(() => {\n setPage(1)\n }, [activeTab])\n\n const { myRewards = [], canNext, isLoading } = useMyRewards({\n page,\n pageSize: 1000,\n consumeType: activeTab,\n })\n\n const getProductType = useCallback((item: any) => {\n if (item.fulfillment_status && item.fulfillment_status !== 'null') {\n return item.fulfillment_status === 'fulfilled' ? RewardType.Fulfilled : RewardType.Unfulfilled\n }\n\n if (item.approval_status === ApprovalStatus.Success || item.approval_status === ApprovalStatus.DoubleConfirm) {\n return RewardType.ApproveSuccess\n }\n\n if (item.approval_status === ApprovalStatus.Failed) {\n return RewardType.Failed\n }\n\n return RewardType.Pending\n }, [])\n\n const getGoGiftType = useCallback((status?: number) => {\n const statusMap: Record<number, RewardType> = {\n 0: RewardType.GogiftPending,\n 1: RewardType.GogiftApproved,\n 2: RewardType.GogiftSecondConfirm,\n 3: RewardType.GogiftRejected,\n 4: RewardType.GogiftCallbackPending,\n 5: RewardType.GogiftCallbackSuccess,\n 6: RewardType.GogiftCallbackTimeout,\n }\n return status !== undefined ? (statusMap[status] ?? RewardType.GogiftPending) : RewardType.GogiftPending\n }, [])\n\n const list = useMemo(() => {\n return myRewards.map(item => {\n const base = {\n title: item.goods_title,\n value: item.consume_credits,\n date: new Date(item.create_time * 1000),\n }\n\n if (activeTab === AlpcConsumeType.Coupon) {\n return {\n ...base,\n type: RewardType.Received,\n couponCode: item.coupon_code,\n orderNumber: '',\n link: '',\n }\n }\n\n if (activeTab === AlpcConsumeType.Product) {\n return {\n ...base,\n type: getProductType(item),\n orderNumber: item.order_number,\n couponCode: '',\n link: '',\n }\n }\n\n if (activeTab === AlpcConsumeType.ExternalProduct) {\n return {\n ...base,\n type: getGoGiftType(item.approval_status),\n orderNumber: '',\n couponCode: '',\n link: item.link || '',\n }\n }\n\n return { ...base, type: RewardType.Received, couponCode: '', orderNumber: '', link: '' }\n })\n }, [activeTab, myRewards, getProductType, getGoGiftType])\n\n\n const TypeMap = useMemo(() => {\n return {\n [RewardType.Received]: data.receivedLabel,\n [RewardType.Pending]: data.pendingLabel,\n [RewardType.ApproveFail]: data.failedLabel,\n [RewardType.ApproveSuccess]: data.approveSuccessLabel,\n [RewardType.Unfulfilled]: data.unfulfilledLabel,\n [RewardType.Fulfilled]: data.fulfilledLabel,\n [RewardType.Failed]: data.failedLabel,\n [RewardType.GogiftPending]: data.goGiftStatus?.pending?.label || data.pendingLabel,\n [RewardType.GogiftApproved]: data.goGiftStatus?.approved?.label || data.approveSuccessLabel,\n [RewardType.GogiftSecondConfirm]: data.goGiftStatus?.secondConfirm?.label || data.approveSuccessLabel,\n [RewardType.GogiftRejected]: data.goGiftStatus?.rejected?.label || data.failedLabel,\n [RewardType.GogiftCallbackPending]: data.goGiftStatus?.callbackPending?.label || data.pendingLabel,\n [RewardType.GogiftCallbackSuccess]: data.goGiftStatus?.callbackSuccess?.label || data.receivedLabel,\n [RewardType.GogiftCallbackTimeout]: data.goGiftStatus?.callbackTimeout?.label || data.failedLabel,\n }\n }, [data])\n\n const TipMap = useMemo(() => {\n return {\n [RewardType.Received]: '',\n [RewardType.Pending]: data.pendingTip,\n [RewardType.ApproveFail]: '',\n [RewardType.ApproveSuccess]: data.confirmedTip,\n [RewardType.Unfulfilled]: data.processingTip,\n [RewardType.Fulfilled]: data.ShippedTip,\n [RewardType.Failed]: '',\n [RewardType.GogiftPending]: data.goGiftStatus?.pending?.tip || '',\n [RewardType.GogiftApproved]: data.goGiftStatus?.approved?.tip || '',\n [RewardType.GogiftSecondConfirm]: data.goGiftStatus?.secondConfirm?.tip || '',\n [RewardType.GogiftRejected]: data.goGiftStatus?.rejected?.tip || '',\n [RewardType.GogiftCallbackPending]: data.goGiftStatus?.callbackPending?.tip || '',\n [RewardType.GogiftCallbackSuccess]: data.goGiftStatus?.callbackSuccess?.tip || '',\n [RewardType.GogiftCallbackTimeout]: data.goGiftStatus?.callbackTimeout?.tip || '',\n }\n }, [data])\n\n const ColorMap = useMemo(() => {\n return {\n [RewardType.Received]: '#52C41A',\n [RewardType.Pending]: '#999',\n [RewardType.ApproveFail]: '#F84D4F',\n [RewardType.ApproveSuccess]: '#999',\n [RewardType.Unfulfilled]: '#999',\n [RewardType.Fulfilled]: '#999',\n [RewardType.Failed]: '#F84D4F',\n [RewardType.GogiftPending]: '#999',\n [RewardType.GogiftApproved]: '#999',\n [RewardType.GogiftSecondConfirm]: '#999',\n [RewardType.GogiftRejected]: '#F84D4F',\n [RewardType.GogiftCallbackPending]: '#999',\n [RewardType.GogiftCallbackSuccess]: '#52C41A',\n [RewardType.GogiftCallbackTimeout]: '#F84D4F',\n }\n }, [])\n\n const handleScrollEnd = useCallback(() => {\n if (canNext) {\n setPage(prev => prev + 1)\n }\n }, [canNext])\n\n const handleCopy = useCallback((code: string, idx: number) => {\n setCopied(idx)\n clipboard(code)\n setTimeout(() => {\n setCopied(-1)\n }, 2000)\n }, [])\n\n\n return (\n <CreditsModalContainer\n title={data.title}\n className={classNames('h-[800px] w-[640px]')}\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n scrollClassName=\"md:mb-0 flex flex-col\"\n {...props}\n onScrollEnd={handleScrollEnd}\n >\n <div className=\"shrink-0\">\n <Tabs\n align=\"left\"\n shape={rounded ? 'rounded' : 'square'}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(Number(value))\n }}\n >\n <TabsList>\n {tabs.map(tab => (\n <TabsTrigger key={tab.type} value={tab.type.toString()}>\n {tab.title}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n </div>\n\n {isLoading && (\n <div className=\"flex flex-1 flex-col items-center justify-center\">\n <LoadingDots />\n </div>\n )}\n\n {!isLoading && (\n <div className=\"mt-[24px] flex-1 overflow-auto overscroll-contain pb-[24px] md:pb-[48px]\">\n {list.length > 0 ? (\n <div className=\"grid gap-[18px] md:gap-[12px]\">\n {list.map((item, index) => (\n <div key={index} className=\"grid gap-[8px]\">\n {item?.orderNumber && (\n <div className=\"text-[15px] font-semibold leading-[1.4] text-[#777]\">\n {data.orderNumberLabel}: {item.orderNumber}\n </div>\n )}\n <div\n className={classNames(\n 'flex items-center justify-between rounded-[8px] bg-[#f7f8f9] px-[16px] py-[20px]',\n !rounded && 'rounded-none'\n )}\n >\n <div className=\"grid gap-[4px]\">\n <div className=\"text-[16px] font-bold leading-[1.4]\">{item.title}</div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {data.valueLabel}: {item.value} {data?.pointUnit}\n </div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {item?.couponCode ? `${data?.code || 'Code'}: ${item.couponCode} ` : ''}\n {item?.couponCode && (\n <span\n className=\"cursor-pointer text-[14px] font-semibold text-brand underline\"\n onClick={() => {\n handleCopy(item.couponCode, index)\n }}\n role=\"button\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copied === index ? data?.copied || 'COPIED' : data?.copy || 'COPY'}\n </span>\n )}\n </div>\n {item?.link && (\n <div className=\"text-[14px] font-semibold text-[#999]\">\n <a\n href={item.link}\n target=\"_blank\"\n rel=\"noopener noreferrer\"\n className=\"text-brand underline\"\n >\n {data?.redeemLinkLabel || 'Redeem Link'}\n </a>\n </div>\n )}\n </div>\n <div className=\"grid gap-[4px] text-right\">\n <div\n className={classNames(\n 'flex items-center justify-end text-[16px] font-bold leading-[1.4]',\n `text-[${ColorMap[item.type]}]`\n )}\n >\n <span>{TypeMap[item.type]}</span>\n {TipMap[item.type] && <Tip info={TipMap[item.type]} index={index} />}\n </div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {dayjs(item.date).format('YYYY-MM-DD HH:mm').toString()}\n </div>\n </div>\n </div>\n </div>\n ))}\n </div>\n ) : (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <Picture\n className=\"mb-[12px] w-[160px]\"\n source={data?.emptyListImage?.url}\n alt={data?.emptyListImage?.alt || 'empty list image'}\n ></Picture>\n <div className=\"text-[16px] font-semibold leading-[1.4]\">{data?.emptyListLabel}</div>\n </div>\n )}\n </div>\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RewardsModal\n"],
|
|
5
|
+
"mappings": "AA4Qc,cAAAA,EAqBM,QAAAC,MArBN,oBA5Qd,OAAS,QAAAC,EAAM,YAAAC,EAAU,eAAAC,EAAa,WAAAC,MAAe,wBACrD,OAAOC,MAAgB,aACvB,OAAOC,MAAe,oBACtB,OAAOC,MAAW,QAClB,OAAS,eAAAC,EAAa,aAAAC,EAAW,WAAAC,EAAS,YAAAC,MAAgB,QAE1D,OAAS,kBAAAC,EAAgB,mBAAAC,EAAiB,cAAAC,MAAkB,mBAC5D,OAAS,yBAAAC,MAAuD,mBAChE,OAAOC,MAAS,QAChB,OAAOC,MAAiB,gBACxB,OAAOC,MAAkB,gCACzB,OAAS,sBAAAC,MAA0B,gBAC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AAOe,EAAO,GACpE,EACAtD,EAAC,OAAI,UAAU,wCACZ,SAAAQ,EAAM+B,EAAK,IAAI,EAAE,OAAO,kBAAkB,EAAE,SAAS,EACxD,GACF,GACF,IAhEQe,CAiEV,CACD,EACH,EAEArD,EAAC,OAAI,UAAU,mDACb,UAAAD,EAACK,EAAA,CACC,UAAU,sBACV,OAAQkB,GAAM,gBAAgB,IAC9B,IAAKA,GAAM,gBAAgB,KAAO,mBACnC,EACDvB,EAAC,OAAI,UAAU,0CAA2C,SAAAuB,GAAM,eAAe,GACjF,EAEJ,GAEJ,CAEJ,CAEA,IAAOiC,GAAQlC",
|
|
6
6
|
"names": ["jsx", "jsxs", "Tabs", "TabsList", "TabsTrigger", "Picture", "classNames", "clipboard", "dayjs", "useCallback", "useEffect", "useMemo", "useState", "ApprovalStatus", "AlpcConsumeType", "RewardType", "CreditsModalContainer", "Tip", "LoadingDots", "useMyRewards", "useHeadlessContext", "ROUNDED_BRANDS", "RewardsModal", "data", "props", "activeTab", "setActiveTab", "brand", "rounded", "page", "setPage", "copied", "setCopied", "tabs", "tab", "myRewards", "canNext", "isLoading", "getProductType", "item", "getGoGiftType", "status", "statusMap", "list", "base", "TypeMap", "TipMap", "ColorMap", "handleScrollEnd", "prev", "handleCopy", "code", "idx", "value", "index", "e", "RewardsModal_default"]
|
|
7
7
|
}
|
package/package.json
CHANGED
|
@@ -36,18 +36,25 @@ type Fetcher<TData, TBody> = (url: string, data: { arg: TBody }) => Promise<TDat
|
|
|
36
36
|
/**
|
|
37
37
|
* 统一处理 ALPC 接口返回的数据结构
|
|
38
38
|
* 兼容一层 data 和两层 data 的场景:
|
|
39
|
-
* - 两层 data: {data: {data: ..., code: 27004}}
|
|
40
|
-
* - 一层 data: {data: ..., code: 27004}
|
|
39
|
+
* - 两层 data: {data: {data: ..., code: 27004}} → 剥掉外层,返回内层 {data: ..., code: 27004}
|
|
40
|
+
* - 一层 data: {data: ..., code: 27004} → 直接返回,不做处理
|
|
41
|
+
*
|
|
42
|
+
* 判断两层的依据:responseData.data.data 存在(外层 data 内部还有一层 data)
|
|
41
43
|
*/
|
|
42
44
|
const normalizeResponseData = (responseData: any) => {
|
|
43
45
|
if (!responseData) return responseData
|
|
44
46
|
|
|
45
|
-
//
|
|
46
|
-
if (
|
|
47
|
+
// 两层结构:responseData.data 是对象,且其内部还有 data 字段
|
|
48
|
+
if (
|
|
49
|
+
responseData.data &&
|
|
50
|
+
typeof responseData.data === 'object' &&
|
|
51
|
+
!Array.isArray(responseData.data) &&
|
|
52
|
+
'data' in responseData.data
|
|
53
|
+
) {
|
|
47
54
|
return responseData.data
|
|
48
55
|
}
|
|
49
56
|
|
|
50
|
-
//
|
|
57
|
+
// 一层结构,直接返回
|
|
51
58
|
return responseData
|
|
52
59
|
}
|
|
53
60
|
|
|
@@ -38,10 +38,9 @@ export const useRedeemAndBuy = (
|
|
|
38
38
|
user_id: profile?.user_id,
|
|
39
39
|
rule_id: arg.redeemId,
|
|
40
40
|
})
|
|
41
|
-
|
|
42
|
-
if (res && data?.coupon_code) {
|
|
41
|
+
if (res && res.data?.coupon_code) {
|
|
43
42
|
buyNow({
|
|
44
|
-
discountCodes: [data.coupon_code],
|
|
43
|
+
discountCodes: [res.data.coupon_code],
|
|
45
44
|
lineItems: [
|
|
46
45
|
{
|
|
47
46
|
variant: arg.productVariant,
|
|
@@ -28,13 +28,20 @@ export const CreditsCash = ({ copy, id }: { copy: CreditsCashCopy; id?: string }
|
|
|
28
28
|
})
|
|
29
29
|
|
|
30
30
|
const list = useMemo(() => {
|
|
31
|
-
return
|
|
32
|
-
|
|
33
|
-
const
|
|
31
|
+
return (copy?.list || [])
|
|
32
|
+
.map(config => {
|
|
33
|
+
const handle = config?.products?.[0]?.handle
|
|
34
|
+
const sku = config?.products?.[0]?.sku
|
|
34
35
|
const alpcData = redeemableList.find(item => item.id?.toString() === config?.redeemId?.toString())
|
|
35
|
-
|
|
36
|
-
|
|
36
|
+
|
|
37
|
+
// 从 productByHandles 中找到对应 handle 的 product
|
|
38
|
+
const product = productByHandles?.find((p: Product) => p.handle === handle)
|
|
39
|
+
if (!product) return null
|
|
40
|
+
|
|
41
|
+
// 在 product 的 variants 中找到对应 sku 的 variant
|
|
42
|
+
const productVariant = product.variants?.find((variant: any) => variant.sku === sku) || product.variants?.[0]
|
|
37
43
|
if (!alpcData || !productVariant) return null
|
|
44
|
+
|
|
38
45
|
return {
|
|
39
46
|
product,
|
|
40
47
|
productVariant,
|
|
@@ -32,9 +32,8 @@ function RedeemCouponModal({
|
|
|
32
32
|
return
|
|
33
33
|
}
|
|
34
34
|
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
setCouponCode(data.coupon_code)
|
|
35
|
+
if (responseData.data?.success) {
|
|
36
|
+
setCouponCode(responseData.data.coupon_code)
|
|
38
37
|
fetchCreditInfo(profile?.user_id)
|
|
39
38
|
} else {
|
|
40
39
|
let errorMsg
|
|
@@ -40,7 +40,7 @@ function RedeemVirtualProductModal({
|
|
|
40
40
|
return
|
|
41
41
|
}
|
|
42
42
|
|
|
43
|
-
const data = responseData
|
|
43
|
+
const data = responseData.data
|
|
44
44
|
if (data?.id) {
|
|
45
45
|
setGiftCardId(data.id)
|
|
46
46
|
fetchCreditInfo(profile?.user_id)
|
|
@@ -121,8 +121,8 @@ function RedeemVirtualProductModal({
|
|
|
121
121
|
// GiftCard 类型使用 Product 接口,传递默认地址
|
|
122
122
|
const defaultAddress = {
|
|
123
123
|
email: profile?.email || '',
|
|
124
|
-
first_name: profile?.firstName || '',
|
|
125
|
-
last_name: profile?.lastName || '',
|
|
124
|
+
first_name: profile?.firstName || 'Anker',
|
|
125
|
+
last_name: profile?.lastName || 'Direct',
|
|
126
126
|
address1: 'Default Address',
|
|
127
127
|
city: 'Default City',
|
|
128
128
|
province: 'Default Province',
|
|
@@ -108,7 +108,7 @@ function ActivitiesModal({ data, ...props }: ActivitiesModalProps) {
|
|
|
108
108
|
// 新增的部分任务都使用了 alpc 同一个任务类型,需要用任务 id 来区分
|
|
109
109
|
return item.task_name.replace('Refund', data.productUnApprovedTask)
|
|
110
110
|
} else if (taskIdToTypeMapping?.[String(item.task_rule_id)]) {
|
|
111
|
-
return dtcTaskTypeToNameMap[taskIdToTypeMapping?.[String(item.task_rule_id)]]
|
|
111
|
+
return dtcTaskTypeToNameMap[taskIdToTypeMapping?.[String(item.task_rule_id)]] || item.task_name
|
|
112
112
|
} else {
|
|
113
113
|
return taskNameMap[item.task_sub_type] || item.task_name
|
|
114
114
|
}
|
|
@@ -174,7 +174,7 @@ function ActivitiesModal({ data, ...props }: ActivitiesModalProps) {
|
|
|
174
174
|
className={cn('h-[800px] w-[640px]')}
|
|
175
175
|
useAnimation
|
|
176
176
|
animationClassName="md:translate-y-[100vh]"
|
|
177
|
-
scrollClassName=""
|
|
177
|
+
scrollClassName="flex flex-col"
|
|
178
178
|
{...props}
|
|
179
179
|
onScrollEnd={handleScrollEnd}
|
|
180
180
|
>
|
|
@@ -198,62 +198,64 @@ function ActivitiesModal({ data, ...props }: ActivitiesModalProps) {
|
|
|
198
198
|
</Tabs>
|
|
199
199
|
</div>
|
|
200
200
|
|
|
201
|
-
<div className="
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
<
|
|
205
|
-
|
|
206
|
-
|
|
201
|
+
<div className="flex-1 overflow-auto overscroll-contain">
|
|
202
|
+
<div className="grid gap-[18px] md:gap-[12px]">
|
|
203
|
+
{isLoading && (
|
|
204
|
+
<div className="flex flex-1 flex-col items-center justify-center">
|
|
205
|
+
<LoadingDots />
|
|
206
|
+
</div>
|
|
207
|
+
)}
|
|
207
208
|
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
<div
|
|
213
|
-
key={index}
|
|
214
|
-
className={cn(
|
|
215
|
-
'flex h-fit items-center justify-between rounded-[8px] bg-[#f2f0f1] px-[16px] py-[20px] text-[16px]',
|
|
216
|
-
!rounded && 'rounded-none'
|
|
217
|
-
)}
|
|
218
|
-
>
|
|
219
|
-
<div className="grid gap-[6px]">
|
|
220
|
-
<div className="font-bold">{item.title}</div>
|
|
221
|
-
<div className="text-[14px] font-semibold text-[#999]">
|
|
222
|
-
{dayjs(item.date).format('YYYY-MM-DD HH:mm').toString()}
|
|
223
|
-
</div>
|
|
224
|
-
{!data.pendingTips && (
|
|
225
|
-
<div
|
|
226
|
-
className={`hidden text-[14px] font-semibold text-[#777] ${item.status === 2 && item.credit_type === 1 ? '!flex' : ''}`}
|
|
227
|
-
>
|
|
228
|
-
<Text html={data.pendingTips} />
|
|
229
|
-
<span>{dayjs.unix(item.pending_time).add(1, 'day').format('YYYY-MM-DD')}</span>
|
|
230
|
-
{data.pendingTips2 && <Text html={data.pendingTips2} />}
|
|
231
|
-
</div>
|
|
232
|
-
)}
|
|
233
|
-
</div>
|
|
209
|
+
{!isLoading && (
|
|
210
|
+
<>
|
|
211
|
+
{list.length > 0 ? (
|
|
212
|
+
list.map((item, index) => (
|
|
234
213
|
<div
|
|
214
|
+
key={index}
|
|
235
215
|
className={cn(
|
|
236
|
-
'
|
|
237
|
-
|
|
216
|
+
'flex h-fit items-center justify-between rounded-[8px] bg-[#f2f0f1] px-[16px] py-[20px] text-[16px]',
|
|
217
|
+
!rounded && 'rounded-none'
|
|
238
218
|
)}
|
|
239
219
|
>
|
|
240
|
-
|
|
241
|
-
|
|
220
|
+
<div className="grid gap-[6px]">
|
|
221
|
+
<div className="font-bold">{item.title}</div>
|
|
222
|
+
<div className="text-[14px] font-semibold text-[#999]">
|
|
223
|
+
{dayjs(item.date).format('YYYY-MM-DD HH:mm').toString()}
|
|
224
|
+
</div>
|
|
225
|
+
{!data.pendingTips && (
|
|
226
|
+
<div
|
|
227
|
+
className={`hidden text-[14px] font-semibold text-[#777] ${item.status === 2 && item.credit_type === 1 ? '!flex' : ''}`}
|
|
228
|
+
>
|
|
229
|
+
<Text html={data.pendingTips} />
|
|
230
|
+
<span>{dayjs.unix(item.pending_time).add(1, 'day').format('YYYY-MM-DD')}</span>
|
|
231
|
+
{data.pendingTips2 && <Text html={data.pendingTips2} />}
|
|
232
|
+
</div>
|
|
233
|
+
)}
|
|
234
|
+
</div>
|
|
235
|
+
<div
|
|
236
|
+
className={cn(
|
|
237
|
+
'font-bold',
|
|
238
|
+
item.value >= 0 || item.credit_type === CreditType.Expired ? 'text-[#52C41A]' : 'text-[#F84D4F]'
|
|
239
|
+
)}
|
|
240
|
+
>
|
|
241
|
+
{item.value >= 0 && '+'}
|
|
242
|
+
{item.value}
|
|
243
|
+
</div>
|
|
242
244
|
</div>
|
|
245
|
+
))
|
|
246
|
+
) : (
|
|
247
|
+
<div className="flex flex-col items-center justify-center py-[40px]">
|
|
248
|
+
<Picture
|
|
249
|
+
className="mb-[16px] h-[120px] w-[160px]"
|
|
250
|
+
source={data?.emptyListImage?.url}
|
|
251
|
+
alt={data?.emptyListImage?.alt || 'empty list image'}
|
|
252
|
+
></Picture>
|
|
253
|
+
<div className="leading-1.4 text-[16px] font-semibold">{data?.emptyListLabel}</div>
|
|
243
254
|
</div>
|
|
244
|
-
)
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
className="mb-[16px] h-[120px] w-[160px]"
|
|
249
|
-
source={data?.emptyListImage?.url}
|
|
250
|
-
alt={data?.emptyListImage?.alt || 'empty list image'}
|
|
251
|
-
></Picture>
|
|
252
|
-
<div className="leading-1.4 text-[16px] font-semibold">{data?.emptyListLabel}</div>
|
|
253
|
-
</div>
|
|
254
|
-
)}
|
|
255
|
-
</>
|
|
256
|
-
)}
|
|
255
|
+
)}
|
|
256
|
+
</>
|
|
257
|
+
)}
|
|
258
|
+
</div>
|
|
257
259
|
</div>
|
|
258
260
|
{/* 积分到账时间提醒 */}
|
|
259
261
|
{list.length > 0 && <div className="mt-[12px] pb-[24px] text-[14px] font-semibold text-[#999]">{data.tips}</div>}
|
|
@@ -251,11 +251,11 @@ function RewardsModal({ data, ...props }: RewardsModalProps) {
|
|
|
251
251
|
className={classNames('h-[800px] w-[640px]')}
|
|
252
252
|
useAnimation
|
|
253
253
|
animationClassName="md:translate-y-[100vh]"
|
|
254
|
-
scrollClassName="md:mb-0"
|
|
255
|
-
|
|
254
|
+
scrollClassName="md:mb-0 flex flex-col"
|
|
255
|
+
{...props}
|
|
256
256
|
onScrollEnd={handleScrollEnd}
|
|
257
257
|
>
|
|
258
|
-
<div className="">
|
|
258
|
+
<div className="shrink-0">
|
|
259
259
|
<Tabs
|
|
260
260
|
align="left"
|
|
261
261
|
shape={rounded ? 'rounded' : 'square'}
|
|
@@ -275,13 +275,13 @@ function RewardsModal({ data, ...props }: RewardsModalProps) {
|
|
|
275
275
|
</div>
|
|
276
276
|
|
|
277
277
|
{isLoading && (
|
|
278
|
-
<div className="flex
|
|
278
|
+
<div className="flex flex-1 flex-col items-center justify-center">
|
|
279
279
|
<LoadingDots />
|
|
280
280
|
</div>
|
|
281
281
|
)}
|
|
282
282
|
|
|
283
283
|
{!isLoading && (
|
|
284
|
-
<div className="mt-[24px] overflow-auto overscroll-contain">
|
|
284
|
+
<div className="mt-[24px] flex-1 overflow-auto overscroll-contain pb-[24px] md:pb-[48px]">
|
|
285
285
|
{list.length > 0 ? (
|
|
286
286
|
<div className="grid gap-[18px] md:gap-[12px]">
|
|
287
287
|
{list.map((item, index) => (
|