@anker-in/campaign-ui 0.2.0-beta.1 → 0.2.0-beta.11

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.
Files changed (166) hide show
  1. package/dist/cjs/components/credits/context/provider.d.ts +2 -2
  2. package/dist/cjs/components/credits/context/provider.js +1 -1
  3. package/dist/cjs/components/credits/context/provider.js.map +3 -3
  4. package/dist/cjs/components/credits/creditsBenefits/benefitItem.js +1 -1
  5. package/dist/cjs/components/credits/creditsBenefits/benefitItem.js.map +3 -3
  6. package/dist/cjs/components/credits/creditsBenefits/index.js +3 -3
  7. package/dist/cjs/components/credits/creditsBenefits/index.js.map +3 -3
  8. package/dist/cjs/components/credits/creditsCash/CreditsCash.js +1 -1
  9. package/dist/cjs/components/credits/creditsCash/CreditsCash.js.map +3 -3
  10. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
  11. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +3 -3
  12. package/dist/cjs/components/credits/creditsCash/type.d.ts +0 -2
  13. package/dist/cjs/components/credits/creditsCash/type.js +1 -1
  14. package/dist/cjs/components/credits/creditsCash/type.js.map +1 -1
  15. package/dist/cjs/components/credits/creditsFaq/index.js +1 -1
  16. package/dist/cjs/components/credits/creditsFaq/index.js.map +3 -3
  17. package/dist/cjs/components/credits/creditsInfoCard/index.d.ts +0 -2
  18. package/dist/cjs/components/credits/creditsInfoCard/index.js +1 -1
  19. package/dist/cjs/components/credits/creditsInfoCard/index.js.map +3 -3
  20. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/CountrySelect.js +1 -1
  21. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/CountrySelect.js.map +3 -3
  22. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/StateSelect.js +1 -1
  23. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/StateSelect.js.map +3 -3
  24. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
  25. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js.map +2 -2
  26. package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
  27. package/dist/cjs/components/credits/creditsRedeemList/CreditsRedeemList.js.map +2 -2
  28. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
  29. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +3 -3
  30. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +1 -1
  31. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +2 -2
  32. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Success.js +1 -1
  33. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/Success.js.map +3 -3
  34. package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
  35. package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +2 -2
  36. package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
  37. package/dist/cjs/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
  38. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
  39. package/dist/cjs/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
  40. package/dist/cjs/components/credits/modal/MyRewardsModal.js +1 -1
  41. package/dist/cjs/components/credits/modal/MyRewardsModal.js.map +2 -2
  42. package/dist/cjs/components/credits/modal/activitiesModal.js +1 -1
  43. package/dist/cjs/components/credits/modal/activitiesModal.js.map +2 -2
  44. package/dist/cjs/components/credits/modal/creditsUploadReceiptModal.js +1 -1
  45. package/dist/cjs/components/credits/modal/creditsUploadReceiptModal.js.map +3 -3
  46. package/dist/cjs/components/credits/modal/modalContainer.js +1 -1
  47. package/dist/cjs/components/credits/modal/modalContainer.js.map +3 -3
  48. package/dist/cjs/components/credits/modal/subscribeModal.js +1 -1
  49. package/dist/cjs/components/credits/modal/subscribeModal.js.map +3 -3
  50. package/dist/cjs/components/credits/modal/tip.js +1 -1
  51. package/dist/cjs/components/credits/modal/tip.js.map +3 -3
  52. package/dist/cjs/components/credits/type.d.ts +4 -2
  53. package/dist/cjs/components/credits/type.js +1 -1
  54. package/dist/cjs/components/credits/type.js.map +1 -1
  55. package/dist/cjs/components/registration/authCodeActivate/Message.js +1 -1
  56. package/dist/cjs/components/registration/authCodeActivate/Message.js.map +2 -2
  57. package/dist/cjs/components/registration/authCodeActivate/index.js +1 -1
  58. package/dist/cjs/components/registration/authCodeActivate/index.js.map +3 -3
  59. package/dist/cjs/components/registration/authCodeActivate/type.d.ts +0 -1
  60. package/dist/cjs/components/registration/authCodeActivate/type.js.map +1 -1
  61. package/dist/cjs/components/registration/context/provider.d.ts +2 -0
  62. package/dist/cjs/components/registration/context/provider.js +1 -1
  63. package/dist/cjs/components/registration/context/provider.js.map +3 -3
  64. package/dist/cjs/components/registration/modalContainer.d.ts +1 -2
  65. package/dist/cjs/components/registration/modalContainer.js +1 -1
  66. package/dist/cjs/components/registration/modalContainer.js.map +3 -3
  67. package/dist/cjs/templates/credits.d.ts +9 -8
  68. package/dist/cjs/templates/credits.js +1 -1
  69. package/dist/cjs/templates/credits.js.map +3 -3
  70. package/dist/esm/components/credits/context/provider.d.ts +2 -2
  71. package/dist/esm/components/credits/context/provider.js +1 -1
  72. package/dist/esm/components/credits/context/provider.js.map +3 -3
  73. package/dist/esm/components/credits/creditsBenefits/benefitItem.js +1 -1
  74. package/dist/esm/components/credits/creditsBenefits/benefitItem.js.map +3 -3
  75. package/dist/esm/components/credits/creditsBenefits/index.js +3 -3
  76. package/dist/esm/components/credits/creditsBenefits/index.js.map +3 -3
  77. package/dist/esm/components/credits/creditsCash/CreditsCash.js +1 -1
  78. package/dist/esm/components/credits/creditsCash/CreditsCash.js.map +3 -3
  79. package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
  80. package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +3 -3
  81. package/dist/esm/components/credits/creditsCash/type.d.ts +0 -2
  82. package/dist/esm/components/credits/creditsFaq/index.js +1 -1
  83. package/dist/esm/components/credits/creditsFaq/index.js.map +3 -3
  84. package/dist/esm/components/credits/creditsInfoCard/index.d.ts +0 -2
  85. package/dist/esm/components/credits/creditsInfoCard/index.js +1 -1
  86. package/dist/esm/components/credits/creditsInfoCard/index.js.map +3 -3
  87. package/dist/esm/components/credits/creditsRedeemList/AddressForm/CountrySelect.js +1 -1
  88. package/dist/esm/components/credits/creditsRedeemList/AddressForm/CountrySelect.js.map +3 -3
  89. package/dist/esm/components/credits/creditsRedeemList/AddressForm/StateSelect.js +1 -1
  90. package/dist/esm/components/credits/creditsRedeemList/AddressForm/StateSelect.js.map +3 -3
  91. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
  92. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js.map +3 -3
  93. package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js +1 -1
  94. package/dist/esm/components/credits/creditsRedeemList/CreditsRedeemList.js.map +3 -3
  95. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js +1 -1
  96. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Address.js.map +3 -3
  97. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js +1 -1
  98. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.js.map +3 -3
  99. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Success.js +1 -1
  100. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/Success.js.map +3 -3
  101. package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
  102. package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +3 -3
  103. package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js +1 -1
  104. package/dist/esm/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.js.map +3 -3
  105. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js +1 -1
  106. package/dist/esm/components/credits/creditsWaysToGetCredits/useActions.js.map +2 -2
  107. package/dist/esm/components/credits/modal/MyRewardsModal.js +1 -1
  108. package/dist/esm/components/credits/modal/MyRewardsModal.js.map +3 -3
  109. package/dist/esm/components/credits/modal/activitiesModal.js +1 -1
  110. package/dist/esm/components/credits/modal/activitiesModal.js.map +3 -3
  111. package/dist/esm/components/credits/modal/creditsUploadReceiptModal.js +1 -1
  112. package/dist/esm/components/credits/modal/creditsUploadReceiptModal.js.map +3 -3
  113. package/dist/esm/components/credits/modal/modalContainer.js +1 -1
  114. package/dist/esm/components/credits/modal/modalContainer.js.map +3 -3
  115. package/dist/esm/components/credits/modal/subscribeModal.js +1 -1
  116. package/dist/esm/components/credits/modal/subscribeModal.js.map +3 -3
  117. package/dist/esm/components/credits/modal/tip.js +1 -1
  118. package/dist/esm/components/credits/modal/tip.js.map +3 -3
  119. package/dist/esm/components/credits/type.d.ts +4 -2
  120. package/dist/esm/components/registration/authCodeActivate/Message.js +1 -1
  121. package/dist/esm/components/registration/authCodeActivate/Message.js.map +2 -2
  122. package/dist/esm/components/registration/authCodeActivate/index.js +1 -1
  123. package/dist/esm/components/registration/authCodeActivate/index.js.map +3 -3
  124. package/dist/esm/components/registration/authCodeActivate/type.d.ts +0 -1
  125. package/dist/esm/components/registration/context/provider.d.ts +2 -0
  126. package/dist/esm/components/registration/context/provider.js +1 -1
  127. package/dist/esm/components/registration/context/provider.js.map +3 -3
  128. package/dist/esm/components/registration/modalContainer.d.ts +1 -2
  129. package/dist/esm/components/registration/modalContainer.js +1 -1
  130. package/dist/esm/components/registration/modalContainer.js.map +3 -3
  131. package/dist/esm/templates/credits.d.ts +9 -8
  132. package/dist/esm/templates/credits.js +1 -1
  133. package/dist/esm/templates/credits.js.map +3 -3
  134. package/package.json +3 -3
  135. package/src/components/credits/context/provider.tsx +1 -4
  136. package/src/components/credits/creditsBenefits/benefitItem.tsx +2 -5
  137. package/src/components/credits/creditsBenefits/index.tsx +1 -4
  138. package/src/components/credits/creditsCash/CreditsCash.tsx +4 -7
  139. package/src/components/credits/creditsCash/RedeemableItem.tsx +5 -4
  140. package/src/components/credits/creditsCash/type.ts +0 -2
  141. package/src/components/credits/creditsFaq/index.tsx +2 -3
  142. package/src/components/credits/creditsInfoCard/index.tsx +10 -12
  143. package/src/components/credits/creditsRedeemList/AddressForm/CountrySelect.tsx +3 -4
  144. package/src/components/credits/creditsRedeemList/AddressForm/StateSelect.tsx +2 -3
  145. package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +2 -3
  146. package/src/components/credits/creditsRedeemList/CreditsRedeemList.tsx +2 -4
  147. package/src/components/credits/creditsRedeemList/RedeemProductModal/Address.tsx +2 -3
  148. package/src/components/credits/creditsRedeemList/RedeemProductModal/ProductInfo.tsx +6 -4
  149. package/src/components/credits/creditsRedeemList/RedeemProductModal/Success.tsx +2 -3
  150. package/src/components/credits/creditsRedeemList/RedeemableItem.tsx +2 -3
  151. package/src/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.tsx +5 -3
  152. package/src/components/credits/creditsWaysToGetCredits/useActions.ts +4 -1
  153. package/src/components/credits/modal/MyRewardsModal.tsx +2 -3
  154. package/src/components/credits/modal/activitiesModal.tsx +2 -3
  155. package/src/components/credits/modal/creditsUploadReceiptModal.tsx +2 -3
  156. package/src/components/credits/modal/modalContainer.tsx +2 -3
  157. package/src/components/credits/modal/subscribeModal.tsx +9 -32
  158. package/src/components/credits/modal/tip.tsx +2 -3
  159. package/src/components/credits/type.ts +4 -2
  160. package/src/components/registration/authCodeActivate/Message.tsx +1 -1
  161. package/src/components/registration/authCodeActivate/index.tsx +141 -109
  162. package/src/components/registration/authCodeActivate/type.ts +0 -1
  163. package/src/components/registration/context/provider.tsx +9 -0
  164. package/src/components/registration/modalContainer.tsx +9 -7
  165. package/src/templates/credits.tsx +41 -31
  166. package/src/components/credits/const.ts +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/CreditsWaysToGetCredits.tsx"],
4
- "sourcesContent": ["import { Button, Container, Heading, Picture, Text } from '@anker-in/headless-ui'\nimport { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'\nimport { motion } from 'framer-motion'\nimport { useMemo, useState } from 'react'\n\nimport { TaskType, type CreditsWaysToGetCreditsProps } from './type'\nimport { useActions } from './useActions'\nimport { useCreditsContext } from '../context/provider'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useRegistration } from '../../registration'\nimport { CreditsUploadReceiptModal } from '../modal/creditsUploadReceiptModal'\nimport { CreditsSubscribeModal } from '../modal/subscribeModal'\nimport { roundedBrands } from '../const'\n\nexport const CreditsWaysToGetCredits = ({ copy, classNames }: CreditsWaysToGetCreditsProps) => {\n const [showMore, setShowMore] = useState(false)\n const { profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const { brand } = useHeadlessContext()\n const rounded = roundedBrands.includes(brand)\n const isLogin = !!profile\n\n const [isUploadReceiptModalOpen, setIsUploadReceiptModalOpen] = useState(false)\n const [isSubscribeModalOpen, setIsSubscribeModalOpen] = useState(false)\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isUploadReceiptSuccess, setIsUploadReceiptSuccess] = useState(false)\n\n const { actions } = useActions({\n copy,\n subscribe: {\n openSubscribePopup: () => setIsSubscribeModalOpen(true),\n isSuccess: isSubscribeSuccess,\n },\n uploadReceipt: {\n openUploadReceiptPopup: () => setIsUploadReceiptModalOpen(true),\n isSuccess: isUploadReceiptSuccess,\n },\n })\n const list = useMemo(() => {\n const list = copy.list\n .map(item => {\n if (!actions[item.id as keyof typeof actions]) {\n return undefined\n }\n const { finished, notLogin, notFinished, completed } = actions[item.id as keyof typeof actions]\n let buttonLabel = ''\n let handleClick = undefined\n let link = undefined\n if (!isLogin) {\n buttonLabel = notLogin.buttonLabel\n handleClick = notLogin.handleClick\n } else if (finished) {\n buttonLabel = completed.buttonLabel\n handleClick = undefined\n } else {\n buttonLabel = notFinished.buttonLabel\n handleClick = notFinished.handleClick\n link = (notFinished as { link: string }).link\n }\n return {\n ...item,\n buttonLabel,\n handleClick,\n finished,\n link,\n }\n })\n .filter(Boolean) as {\n title: string\n credits: string\n id: TaskType\n buttonLabel: string\n finished: boolean\n link: string\n handleClick: (() => void) | undefined\n }[]\n\n // \u767B\u5F55\u540E\uFF0C\u4FDD\u7559\u539F\u987A\u5E8F\uFF0C\u5C06\u5DF2\u5B8C\u6210\u7684\u4EFB\u52A1\u653E\u5728\u6700\u540E\n if (isLogin) {\n return list.sort((a, b) => {\n if (a?.finished && !b?.finished) {\n return 1 // a\u5DF2\u5B8C\u6210\uFF0Cb\u672A\u5B8C\u6210\uFF0Ca\u6392\u5728\u540E\u9762\n }\n if (!a?.finished && b?.finished) {\n return -1 // a\u672A\u5B8C\u6210\uFF0Cb\u5DF2\u5B8C\u6210\uFF0Ca\u6392\u5728\u524D\u9762\n }\n return 0 // \u90FD\u5DF2\u5B8C\u6210\u6216\u90FD\u672A\u5B8C\u6210\uFF0C\u4FDD\u6301\u539F\u987A\u5E8F\n })\n } else {\n return list\n }\n }, [actions, copy.list, isLogin])\n\n return (\n <Container id=\"ways-to-get-credits\" className=\" bg-[#F5F5F7] [&>div]:l:!px-0\">\n <div\n className={cn(\n 'rounded-[16px] bg-[#1D1D1F] py-[64px] px-[140px] text-white md:px-[16px] l:rounded-none md-l:px-[32px] l-xl:px-[77px]',\n !rounded && 'rounded-none'\n )}\n >\n <Heading as=\"h2\" size={4} html={copy?.title} className=\"text-center l:pl-[16px] l:text-left\" />\n <div className=\"mt-[64px] flex items-center justify-between md:mt-[64px] l:mt-[24px] l:flex-col-reverse l:items-start md-l:mt-[32px]\">\n <div className=\"pl-[16px] l:mt-[40px] desktop:pl-[24px] lg-desktop:pl-[32px]\">\n <Heading size={3} as=\"h3\" html={copy.subtitle} className={classNames?.subtitle} />\n <div className=\"mt-[8px] flex items-center\">\n {copy.creditsIcon?.url && (\n <Picture\n className=\"size-[48px] mr-[8px] stroke-brand xl:size-[30px] [&_path]:stroke-brand\"\n source={copy.creditsIcon.url}\n alt={copy.creditsIcon.alt || 'credits'}\n />\n )}\n <Heading\n html={copy.equalCredits}\n size={4}\n as=\"h3\"\n className={cn('mt-2 text-white md:text-[24px]', classNames?.equalCreditsText)}\n />\n </div>\n </div>\n <Picture className=\"w-full laptop:w-[50%]\" source={copy.mainImage?.url} />\n </div>\n\n <div className=\"relative\">\n <motion.div\n className={cn(\n 'relative mt-[64px] grid grid-cols-3 gap-[16px] overflow-hidden md:mt-[16px] md:grid-cols-1 l:gap-[12px] min-md:!h-auto md-l:mt-[32px] md-l:grid-cols-2'\n )}\n initial={{ height: 512 }}\n animate={{ height: showMore ? 'auto' : 512 }}\n transition={{ duration: 0.3 }}\n onAnimationComplete={() => {\n if (!showMore && window.screen.width < 768) {\n const section = document.getElementById('ways-to-get-credits')\n if (section) {\n section.scrollIntoView({ behavior: 'smooth', block: 'end' })\n }\n }\n }}\n >\n {list.map(item => (\n <div\n key={item.id}\n className={cn(\n 'flex min-h-[160px] flex-col justify-between rounded-[16px] bg-white p-[16px] text-[#1D1D1F] desktop:min-h-[192px] desktop:p-[24px] lg-desktop:min-h-[240px] lg-desktop:p-[32px]',\n !rounded && 'rounded-none'\n )}\n >\n <div>\n <Heading as=\"h4\" html={item.title} size={2} className=\"text-pretty\" />\n <div className=\"mt-[4px] flex items-center\">\n <Picture\n className=\"size-[24px] xl:size-[18px] [&_path]:size-full\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450\"\n />\n <Text as=\"p\" html={item.credits} size={2} className=\"ml-[4px] mt-[6px] lg-desktop:text-[18px]\" />\n </div>\n </div>\n\n {item.handleClick &&\n !(item.id === TaskType.UploadReceipt && isUploadReceiptSuccess) &&\n !(item.id === TaskType.Activate && authCodeActivate.isActivateSuccess) &&\n !(item.id === TaskType.Subscribe && isSubscribeSuccess) ? (\n <Button\n as={item.link ? 'a' : 'button'}\n {...(item.link && { href: item.link })}\n {...(item.handleClick && { onClick: item.handleClick })}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[24px] w-fit\"\n >\n {item.buttonLabel}\n </Button>\n ) : (\n <Button variant=\"primary\" size=\"lg\" className=\"mt-[24px] w-fit\" disabled>\n {item.buttonLabel}\n </Button>\n )}\n </div>\n ))}\n {!showMore && (\n <div\n className=\"absolute inset-0 pointer-events-none min-md:hidden\"\n style={{ background: 'linear-gradient(180deg, rgba(29, 29, 31, 0) 66.37%, #1D1D1F 100%)' }}\n ></div>\n )}\n </motion.div>\n {showMore ? (\n <button\n className=\"mx-auto mt-[12px] block w-fit min-md:hidden\"\n onClick={() => {\n setShowMore(false)\n }}\n >\n <ChevronUpIcon className=\"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]\"></ChevronUpIcon>\n </button>\n ) : (\n <>\n <div className=\"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden\">\n <button className=\"w-fit\" onClick={() => setShowMore(!showMore)}>\n <ChevronDownIcon className=\"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]\"></ChevronDownIcon>\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n {copy.receipt && (\n <CreditsUploadReceiptModal\n isOpen={isUploadReceiptModalOpen}\n onClose={() => {\n setIsUploadReceiptModalOpen(false)\n }}\n copy={copy.receipt}\n onSuccess={() => {\n setIsUploadReceiptSuccess(true)\n }}\n />\n )}\n {copy.subscribe && (\n <CreditsSubscribeModal\n copy={copy.subscribe}\n onSuccess={() => {\n setIsSubscribeSuccess(true)\n }}\n isOpen={isSubscribeModalOpen}\n onClose={() => {\n setIsSubscribeModalOpen(false)\n }}\n />\n )}\n </Container>\n )\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GA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UAAU,kDAAkD,EAC/E,EACF,EACF,GAEJ,GACF,EACCF,EAAK,YACJ,OAAC,6BACC,OAAQS,EACR,QAAS,IAAM,CACbC,EAA4B,EAAK,CACnC,EACA,KAAMV,EAAK,QACX,UAAW,IAAM,CACfgB,EAA0B,EAAI,CAChC,EACF,EAEDhB,EAAK,cACJ,OAAC,yBACC,KAAMA,EAAK,UACX,UAAW,IAAM,CACfc,EAAsB,EAAI,CAC5B,EACA,OAAQH,EACR,QAAS,IAAM,CACbC,EAAwB,EAAK,CAC/B,EACF,GAEJ,CAEJ",
6
- "names": ["CreditsWaysToGetCredits_exports", "__export", "CreditsWaysToGetCredits", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_outline", "import_framer_motion", "import_react", "import_type", "import_useActions", "import_provider", "import_lib", "import_registration", "import_creditsUploadReceiptModal", "import_subscribeModal", "import_const", "copy", "classNames", "showMore", "setShowMore", "profile", "authCodeActivate", "brand", "rounded", "isLogin", "isUploadReceiptModalOpen", "setIsUploadReceiptModalOpen", "isSubscribeModalOpen", "setIsSubscribeModalOpen", "isSubscribeSuccess", "setIsSubscribeSuccess", "isUploadReceiptSuccess", "setIsUploadReceiptSuccess", "actions", "list", "item", "finished", "notLogin", "notFinished", "completed", "buttonLabel", "handleClick", "link", "a", "b", "cn", "section"]
4
+ "sourcesContent": ["import { Button, Container, Heading, Picture, Text } from '@anker-in/headless-ui'\nimport { ChevronDownIcon, ChevronUpIcon } from '@heroicons/react/24/outline'\nimport { motion } from 'framer-motion'\nimport { useMemo, useState } from 'react'\n\nimport { TaskType, type CreditsWaysToGetCreditsProps } from './type'\nimport { useActions } from './useActions'\nimport { useCreditsContext } from '../context/provider'\nimport { classNames as cn, useHeadlessContext, ROUNDED_BRANDS } from '@anker-in/lib'\nimport { useRegistration } from '../../registration'\nimport { CreditsUploadReceiptModal } from '../modal/creditsUploadReceiptModal'\nimport { CreditsSubscribeModal } from '../modal/subscribeModal'\n\nexport const CreditsWaysToGetCredits = ({ copy, classNames }: CreditsWaysToGetCreditsProps) => {\n const [showMore, setShowMore] = useState(false)\n const { profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n const isLogin = !!profile\n\n const [isUploadReceiptModalOpen, setIsUploadReceiptModalOpen] = useState(false)\n const [isSubscribeModalOpen, setIsSubscribeModalOpen] = useState(false)\n const [isSubscribeSuccess, setIsSubscribeSuccess] = useState(false)\n const [isUploadReceiptSuccess, setIsUploadReceiptSuccess] = useState(false)\n\n const { actions } = useActions({\n copy,\n subscribe: {\n openSubscribePopup: () => setIsSubscribeModalOpen(true),\n isSuccess: isSubscribeSuccess,\n },\n uploadReceipt: {\n openUploadReceiptPopup: () => setIsUploadReceiptModalOpen(true),\n isSuccess: isUploadReceiptSuccess,\n },\n })\n const list = useMemo(() => {\n const list = copy.list\n .map(item => {\n if (!actions[item.id as keyof typeof actions]) {\n return undefined\n }\n const { finished, notLogin, notFinished, completed } = actions[item.id as keyof typeof actions]\n let buttonLabel = ''\n let handleClick = undefined\n let link = undefined\n if (!isLogin) {\n buttonLabel = notLogin.buttonLabel\n handleClick = notLogin.handleClick\n } else if (finished) {\n buttonLabel = completed.buttonLabel\n handleClick = undefined\n } else {\n buttonLabel = notFinished.buttonLabel\n handleClick = notFinished.handleClick\n link = (notFinished as { link: string }).link\n }\n return {\n ...item,\n buttonLabel,\n handleClick,\n finished,\n link,\n }\n })\n .filter(Boolean) as {\n title: string\n credits: string\n id: TaskType\n buttonLabel: string\n finished: boolean\n link: string\n handleClick: (() => void) | undefined\n }[]\n\n // \u767B\u5F55\u540E\uFF0C\u4FDD\u7559\u539F\u987A\u5E8F\uFF0C\u5C06\u5DF2\u5B8C\u6210\u7684\u4EFB\u52A1\u653E\u5728\u6700\u540E\n if (isLogin) {\n return list.sort((a, b) => {\n if (a?.finished && !b?.finished) {\n return 1 // a\u5DF2\u5B8C\u6210\uFF0Cb\u672A\u5B8C\u6210\uFF0Ca\u6392\u5728\u540E\u9762\n }\n if (!a?.finished && b?.finished) {\n return -1 // a\u672A\u5B8C\u6210\uFF0Cb\u5DF2\u5B8C\u6210\uFF0Ca\u6392\u5728\u524D\u9762\n }\n return 0 // \u90FD\u5DF2\u5B8C\u6210\u6216\u90FD\u672A\u5B8C\u6210\uFF0C\u4FDD\u6301\u539F\u987A\u5E8F\n })\n } else {\n return list\n }\n }, [actions, copy.list, isLogin])\n\n return (\n <Container id=\"ways-to-get-credits\" className=\" bg-[#F5F5F7] [&>div]:l:!px-0\">\n <div\n className={cn(\n 'rounded-[16px] bg-[#1D1D1F] py-[64px] px-[140px] text-white md:px-[16px] l:rounded-none md-l:px-[32px] l-xl:px-[77px]',\n !rounded && 'rounded-none'\n )}\n >\n <Heading as=\"h2\" size={4} html={copy?.title} className=\"text-center l:pl-[16px] l:text-left\" />\n <div className=\"mt-[64px] flex items-center justify-between md:mt-[64px] l:mt-[24px] l:flex-col-reverse l:items-start md-l:mt-[32px]\">\n <div className=\"pl-[16px] l:mt-[40px] desktop:pl-[24px] lg-desktop:pl-[32px]\">\n <Heading size={3} as=\"h3\" html={copy.subtitle} className={classNames?.subtitle} />\n <div className=\"mt-[8px] flex items-center\">\n {copy.creditsIcon?.url && (\n <Picture\n className=\"size-[48px] mr-[8px] stroke-brand xl:size-[30px] [&_path]:stroke-brand\"\n source={copy.creditsIcon.url}\n alt={copy.creditsIcon.alt || 'credits'}\n />\n )}\n <Heading\n html={copy.equalCredits}\n size={4}\n as=\"h3\"\n className={cn('mt-2 text-white md:text-[24px]', classNames?.equalCreditsText)}\n />\n </div>\n </div>\n <Picture className=\"w-full laptop:w-[50%]\" source={copy.mainImage?.url} />\n </div>\n\n <div className=\"relative\">\n <motion.div\n className={cn(\n 'relative mt-[64px] grid grid-cols-3 gap-[16px] overflow-hidden md:mt-[16px] md:grid-cols-1 l:gap-[12px] min-md:!h-auto md-l:mt-[32px] md-l:grid-cols-2'\n )}\n initial={{ height: 512 }}\n animate={{ height: showMore ? 'auto' : 512 }}\n transition={{ duration: 0.3 }}\n onAnimationComplete={() => {\n if (!showMore && window.screen.width < 768) {\n const section = document.getElementById('ways-to-get-credits')\n if (section) {\n section.scrollIntoView({ behavior: 'smooth', block: 'end' })\n }\n }\n }}\n >\n {list.map(item => (\n <div\n key={item.id}\n className={cn(\n 'flex min-h-[160px] flex-col justify-between rounded-[16px] bg-white p-[16px] text-[#1D1D1F] desktop:min-h-[192px] desktop:p-[24px] lg-desktop:min-h-[240px] lg-desktop:p-[32px]',\n !rounded && 'rounded-none'\n )}\n >\n <div>\n <Heading as=\"h4\" html={item.title} size={2} className=\"text-pretty\" />\n <div className=\"mt-[4px] flex items-center\">\n <Picture\n className=\"size-[24px] xl:size-[18px] [&_path]:size-full\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450\"\n />\n <Text as=\"p\" html={item.credits} size={2} className=\"ml-[4px] mt-[6px] lg-desktop:text-[18px]\" />\n </div>\n </div>\n\n {item.handleClick &&\n !(item.id === TaskType.UploadReceipt && isUploadReceiptSuccess) &&\n !(item.id === TaskType.Activate && authCodeActivate.isActivateSuccess) &&\n !(item.id === TaskType.Subscribe && isSubscribeSuccess) ? (\n <Button\n as={item.link ? 'a' : 'button'}\n {...(item.link && { href: item.link })}\n {...(item.handleClick && { onClick: item.handleClick })}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[24px] w-fit\"\n >\n {item.buttonLabel}\n </Button>\n ) : (\n <Button variant=\"primary\" size=\"lg\" className=\"mt-[24px] w-fit\" disabled>\n {item.buttonLabel}\n </Button>\n )}\n </div>\n ))}\n {!showMore && (\n <div\n className=\"absolute inset-0 pointer-events-none min-md:hidden\"\n style={{ background: 'linear-gradient(180deg, rgba(29, 29, 31, 0) 66.37%, #1D1D1F 100%)' }}\n ></div>\n )}\n </motion.div>\n {showMore ? (\n <button\n className=\"mx-auto mt-[12px] block w-fit min-md:hidden\"\n onClick={() => {\n setShowMore(false)\n }}\n >\n <ChevronUpIcon className=\"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]\"></ChevronUpIcon>\n </button>\n ) : (\n <>\n <div className=\"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden\">\n <button className=\"w-fit\" onClick={() => setShowMore(!showMore)}>\n <ChevronDownIcon className=\"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]\"></ChevronDownIcon>\n </button>\n </div>\n </>\n )}\n </div>\n </div>\n {copy.receipt && (\n <CreditsUploadReceiptModal\n isOpen={isUploadReceiptModalOpen}\n onClose={() => {\n setIsUploadReceiptModalOpen(false)\n }}\n copy={copy.receipt}\n onSuccess={() => {\n setIsUploadReceiptSuccess(true)\n }}\n />\n )}\n {copy.subscribe && (\n <CreditsSubscribeModal\n copy={copy.subscribe}\n onSuccess={() => {\n setIsSubscribeSuccess(true)\n setTimeout(() => {\n setIsSubscribeModalOpen(false)\n }, 3000)\n }}\n isOpen={isSubscribeModalOpen}\n onClose={() => {\n setIsSubscribeModalOpen(false)\n }}\n />\n )}\n </Container>\n )\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAoGQ,IAAAI,EAAA,6BApGRC,EAA0D,iCAC1DC,EAA+C,uCAC/CC,EAAuB,yBACvBC,EAAkC,iBAElCC,EAA4D,kBAC5DC,EAA2B,wBAC3BC,EAAkC,+BAClCC,EAAqE,yBACrEC,EAAgC,8BAChCC,EAA0C,8CAC1CC,EAAsC,mCAE/B,MAAMb,EAA0B,CAAC,CAAE,KAAAc,EAAM,WAAAC,CAAW,IAAoC,CAC7F,KAAM,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EACxC,CAAE,QAAAC,CAAQ,KAAI,qBAAkB,EAChC,CAAE,iBAAAC,CAAiB,KAAI,mBAAgB,EACvC,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CA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ime", "import_headless_ui", "import_outline", "import_framer_motion", "import_react", "import_type", "import_useActions", "import_provider", "import_lib", "import_registration", "import_creditsUploadReceiptModal", "import_subscribeModal", "copy", "classNames", "showMore", "setShowMore", "profile", "authCodeActivate", "brand", "rounded", "isLogin", "isUploadReceiptModalOpen", "setIsUploadReceiptModalOpen", "isSubscribeModalOpen", "setIsSubscribeModalOpen", "isSubscribeSuccess", "setIsSubscribeSuccess", "isUploadReceiptSuccess", "setIsUploadReceiptSuccess", "actions", "list", "item", "finished", "notLogin", "notFinished", "completed", "buttonLabel", "handleClick", "link", "a", "b", "cn", "section"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var j=Object.create;var b=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var T=Object.getPrototypeOf,A=Object.prototype.hasOwnProperty;var x=(e,i)=>{for(var n in i)b(e,n,{get:i[n],enumerable:!0})},h=(e,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of U(i))!A.call(e,o)&&o!==n&&b(e,o,{get:()=>i[o],enumerable:!(s=_(i,o))||s.enumerable});return e};var G=(e,i,n)=>(n=e!=null?j(T(e)):{},h(i||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e)),W=e=>h(b({},"__esModule",{value:!0}),e);var E={};x(E,{useActions:()=>$});module.exports=W(E);var r=require("@anker-in/lib"),t=require("./type"),k=require("../context/provider"),d=require("react"),L=G(require("../context/hooks/useReceiptUploaded")),f=require("../context/hooks/useFirstPurchaseFinished"),N=require("../context/hooks/useSubscribed"),C=require("../../registration");const $=({copy:e,subscribe:i,uploadReceipt:n,gaParameters:s})=>{const{openSignUpPopup:o,gtm:P,profile:l}=(0,k.useCreditsContext)(),{authCodeActivate:g}=(0,C.useRegistration)(),u=(0,N.useSubscribed)(),c=(0,f.useFirstPurchaseFinished)(),m=(0,L.default)(),{appName:v,passportUrl:F}=(0,r.useHeadlessContext)(),p=(0,d.useMemo)(()=>(l?.first_name||l?.last_name)&&l?.phone_number&&l?.dob,[l]);return(0,d.useMemo)(()=>{const a=({buttonName:S,id:w,callback:R})=>{(0,r.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:P.pageGroup,position:s?.position||e.title,button_name:S,info:w}}),R()};return{actions:{[t.TaskType.Activate]:{finished:l?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>a({buttonName:e?.activate,callback:()=>g.open(),id:t.TaskType.Activate})},completed:{buttonLabel:e?.completed}},[t.TaskType.Subscribe]:{finished:u,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.Subscribe})},notFinished:{buttonLabel:e?.subscribeLabel,handleClick:()=>a({buttonName:e?.subscribeLabel,callback:()=>i.openSubscribePopup(),id:t.TaskType.Subscribe})},completed:{buttonLabel:e?.completed}},[t.TaskType.CompleteProfile]:{finished:p,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${F}/account/profile?app=${v}`,handleClick:()=>a({buttonName:e?.completeProfile,callback:()=>{},id:t.TaskType.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.TaskType.FirstPurchase]:{finished:c,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>a({buttonName:e?.makeFirstPurchase,callback:o,id:t.TaskType.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>a({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.TaskType.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.TaskType.UploadReceipt]:{finished:m,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>a({buttonName:e?.uploadReceipt,callback:()=>n.openUploadReceiptPopup(),id:t.TaskType.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.TaskType.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>a({buttonName:e?.shopNow,callback:()=>{},id:t.TaskType.Shop})},completed:{buttonLabel:e?.completed}}}}},[l?.activated,e?.joinNow,e?.activate,e?.completed,e?.subscribe,e?.completeProfile,e?.makeFirstPurchase,e?.uploadReceipt,e?.shopNow,e.title,e?.goShopLink,u,p,c,m,s?.position,o])};
1
+ "use strict";var j=Object.create;var b=Object.defineProperty;var _=Object.getOwnPropertyDescriptor;var U=Object.getOwnPropertyNames;var A=Object.getPrototypeOf,T=Object.prototype.hasOwnProperty;var x=(e,i)=>{for(var n in i)b(e,n,{get:i[n],enumerable:!0})},k=(e,i,n,s)=>{if(i&&typeof i=="object"||typeof i=="function")for(let o of U(i))!T.call(e,o)&&o!==n&&b(e,o,{get:()=>i[o],enumerable:!(s=_(i,o))||s.enumerable});return e};var G=(e,i,n)=>(n=e!=null?j(A(e)):{},k(i||!e||!e.__esModule?b(n,"default",{value:e,enumerable:!0}):n,e)),W=e=>k(b({},"__esModule",{value:!0}),e);var $={};x($,{useActions:()=>E});module.exports=W($);var r=require("@anker-in/lib"),t=require("./type"),L=require("../context/provider"),u=require("react"),f=G(require("../context/hooks/useReceiptUploaded")),N=require("../context/hooks/useFirstPurchaseFinished"),C=require("../context/hooks/useSubscribed"),P=require("../../registration");const E=({copy:e,subscribe:i,uploadReceipt:n,gaParameters:s})=>{const{openSignUpPopup:o,gtm:g,profile:l}=(0,L.useCreditsContext)(),{authCodeActivate:d}=(0,P.useRegistration)(),c=(0,C.useSubscribed)(),m=(0,N.useFirstPurchaseFinished)(),p=(0,f.default)(),{appName:v,passportUrl:F}=(0,r.useHeadlessContext)(),h=(0,u.useMemo)(()=>(l?.first_name||l?.last_name)&&l?.phone_number&&l?.dob,[l]);return(0,u.useMemo)(()=>{const a=({buttonName:S,id:w,callback:R})=>{(0,r.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:g.pageGroup,position:s?.position||e.title,button_name:S,info:w}}),R()};return{actions:{[t.TaskType.Activate]:{finished:l?.activated,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.Activate})},notFinished:{buttonLabel:e?.activate,handleClick:()=>a({buttonName:e?.activate,callback:()=>{d.setAutoSendEmail(!0),d.open()},id:t.TaskType.Activate})},completed:{buttonLabel:e?.completed}},[t.TaskType.Subscribe]:{finished:c,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.Subscribe})},notFinished:{buttonLabel:e?.subscribeLabel,handleClick:()=>a({buttonName:e?.subscribeLabel,callback:()=>i.openSubscribePopup(),id:t.TaskType.Subscribe})},completed:{buttonLabel:e?.completed}},[t.TaskType.CompleteProfile]:{finished:h,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.CompleteProfile})},notFinished:{buttonLabel:e?.completeProfile,link:`${F}/account/profile?app=${v}`,handleClick:()=>a({buttonName:e?.completeProfile,callback:()=>{},id:t.TaskType.CompleteProfile})},completed:{buttonLabel:e?.completed}},[t.TaskType.FirstPurchase]:{finished:m,notLogin:{buttonLabel:e?.makeFirstPurchase,handleClick:()=>a({buttonName:e?.makeFirstPurchase,callback:o,id:t.TaskType.FirstPurchase})},notFinished:{buttonLabel:e?.makeFirstPurchase,link:e?.goShopLink,handleClick:()=>a({buttonName:e?.makeFirstPurchase,callback:()=>{},id:t.TaskType.FirstPurchase})},completed:{buttonLabel:e?.completed}},[t.TaskType.UploadReceipt]:{finished:p,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.UploadReceipt})},notFinished:{buttonLabel:e?.uploadReceipt,handleClick:()=>a({buttonName:e?.uploadReceipt,callback:()=>n.openUploadReceiptPopup(),id:t.TaskType.UploadReceipt})},completed:{buttonLabel:e?.completed}},[t.TaskType.Shop]:{finished:!1,notLogin:{buttonLabel:e?.joinNow,handleClick:()=>a({buttonName:e?.joinNow,callback:o,id:t.TaskType.Shop})},notFinished:{buttonLabel:e?.shopNow,link:e?.goShopLink,handleClick:()=>a({buttonName:e?.shopNow,callback:()=>{},id:t.TaskType.Shop})},completed:{buttonLabel:e?.completed}}}}},[l?.activated,e?.joinNow,e?.activate,e?.completed,e?.subscribe,e?.completeProfile,e?.makeFirstPurchase,e?.uploadReceipt,e?.shopNow,e.title,e?.goShopLink,c,h,m,p,s?.position,o])};
2
2
  //# sourceMappingURL=useActions.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/useActions.ts"],
4
- "sourcesContent": ["import { useHeadlessContext, gaTrack } from '@anker-in/lib'\n\nimport { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useMemo } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsCopy } from './type'\n\nimport { useRegistration } from '../../registration'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n gaParameters,\n}: {\n copy: CreditsWaysToGetCreditsCopy\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => authCodeActivate.open(),\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribeLabel,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribeLabel,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link: `${passportUrl}/account/profile?app=${appName}`,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.completeProfile,\n callback: () => {},\n id: TaskType.CompleteProfile,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.FirstPurchase]: {\n finished: firstPurchaseFinished,\n notLogin: {\n buttonLabel: copy?.makeFirstPurchase,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: openSignUpPopup,\n id: TaskType.FirstPurchase,\n }),\n },\n notFinished: {\n buttonLabel: copy?.makeFirstPurchase,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: () => {},\n id: TaskType.FirstPurchase,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.UploadReceipt]: {\n finished: uploadedReceipt,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.UploadReceipt,\n }),\n },\n notFinished: {\n buttonLabel: copy?.uploadReceipt,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.uploadReceipt,\n callback: () => uploadReceipt.openUploadReceiptPopup(),\n id: TaskType.UploadReceipt,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Shop]: {\n finished: false,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.Shop,\n }),\n },\n notFinished: {\n buttonLabel: copy?.shopNow,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.shopNow,\n callback: () => {},\n id: TaskType.Shop,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n },\n }\n }, [\n profile?.activated,\n copy?.joinNow,\n copy?.activate,\n copy?.completed,\n copy?.subscribe,\n copy?.completeProfile,\n copy?.makeFirstPurchase,\n copy?.uploadReceipt,\n copy?.shopNow,\n copy.title,\n copy?.goShopLink,\n isSubscribed,\n profileCompleted,\n firstPurchaseFinished,\n uploadedReceipt,\n gaParameters?.position,\n openSignUpPopup,\n ])\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,yBAE5CC,EAAyB,kBACzBC,EAAkC,+BAClCC,EAAwB,iBACxBC,EAA+B,kDAC/BC,EAAyC,qDACzCC,EAA8B,0CAG9BC,EAAgC,8BAEzB,MAAMT,EAAa,CAAC,CACzB,KAAAU,EACA,UAAAC,EACA,cAAAC,EACA,aAAAC,CACF,IAaM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,KAAI,qBAAkB,EACtD,CAAE,iBAAAC,CAAiB,KAAI,mBAAgB,EACvCC,KAAe,iBAAc,EAC7BC,KAAwB,4BAAyB,EACjDC,KAAkB,EAAAC,SAAmB,EACrC,CAAE,QAAAC,EAAS,YAAAC,CAAY,KAAI,sBAAmB,EAE9CC,KAAmB,WAAQ,KACvBR,GAAS,YAAcA,GAAS,YAAcA,GAAS,cAAgBA,GAAS,IACvF,CAACA,CAAO,CAAC,EAEZ,SAAO,WAAQ,IAAM,CACnB,MAAMS,EAAuB,CAAC,CAC5B,WAAAC,EACA,GAAAC,EACA,SAAAC,CACF,IAIM,IACJ,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBZ,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYD,EAAI,UAChB,SAAUF,GAAc,UAAYH,EAAK,MACzC,YAAagB,EACb,KAAMC,CACR,CACF,CAAC,EACDC,EAAS,CACX,EACA,MAAO,CACL,QAAS,CACP,CAAC,WAAS,QAAQ,EAAG,CACnB,SAAUZ,GAAS,UACnB,SAAU,CACR,YAA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YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,kBAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,GAAM,SACrB,CACF,EACA,CAAC,WAAS,aAAa,EAAG,CACxB,SAAUU,EACV,SAAU,CACR,YAAaV,GAAM,QACnB,YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,QAClB,SAAUI,EACV,GAAI,WAAS,aACf,CAAC,CACL,EACA,YAAa,CACX,YAAaJ,GAAM,cACnB,YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,cAClB,SAAU,IAAME,EAAc,uBAAuB,EACrD,GAAI,WAAS,aACf,CAAC,CACL,EACA,UAAW,CACT,YAAaF,GAAM,SACrB,CACF,EACA,CAAC,WAAS,IAAI,EAAG,CACf,SAAU,GACV,SAAU,CACR,YAAaA,GAAM,QACnB,YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,QAClB,SAAUI,EACV,GAAI,WAAS,IACf,CAAC,CACL,EACA,YAAa,CACX,YAAaJ,GAAM,QACnB,KAAMA,GAAM,WACZ,YAAa,IACXe,EAAqB,CACnB,WAAYf,GAAM,QAClB,SAAU,IAAM,CAAC,EACjB,GAAI,WAAS,IACf,CAAC,CACL,EACA,UAAW,CACT,YAAaA,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDM,GAAS,UACTN,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAM,EACAL,EACAC,EACAP,GAAc,SACdC,CACF,CAAC,CACH",
4
+ "sourcesContent": ["import { useHeadlessContext, gaTrack } from '@anker-in/lib'\n\nimport { TaskType } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useMemo } from 'react'\nimport useReceiptUploaded from '../context/hooks/useReceiptUploaded'\nimport { useFirstPurchaseFinished } from '../context/hooks/useFirstPurchaseFinished'\nimport { useSubscribed } from '../context/hooks/useSubscribed'\nimport type { CreditsWaysToGetCreditsCopy } from './type'\n\nimport { useRegistration } from '../../registration'\n\nexport const useActions = ({\n copy,\n subscribe,\n uploadReceipt,\n gaParameters,\n}: {\n copy: CreditsWaysToGetCreditsCopy\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n gaParameters?: {\n position: string\n }\n}) => {\n const { openSignUpPopup, gtm, profile } = useCreditsContext()\n const { authCodeActivate } = useRegistration()\n const isSubscribed = useSubscribed()\n const firstPurchaseFinished = useFirstPurchaseFinished()\n const uploadedReceipt = useReceiptUploaded()\n const { appName, passportUrl } = useHeadlessContext()\n\n const profileCompleted = useMemo(() => {\n return (profile?.first_name || profile?.last_name) && profile?.phone_number && profile?.dob\n }, [profile])\n\n return useMemo(() => {\n const handleClickWithTrack = ({\n buttonName,\n id,\n callback,\n }: {\n buttonName: string\n id?: string\n callback: () => void\n }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: gaParameters?.position || copy.title,\n button_name: buttonName,\n info: id,\n },\n })\n callback()\n }\n return {\n actions: {\n [TaskType.Activate]: {\n finished: profile?.activated,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Activate }),\n },\n notFinished: {\n buttonLabel: copy?.activate,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.activate,\n callback: () => {\n authCodeActivate.setAutoSendEmail(true)\n authCodeActivate.open()\n },\n id: TaskType.Activate,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Subscribe]: {\n finished: isSubscribed,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({ buttonName: copy?.joinNow, callback: openSignUpPopup, id: TaskType.Subscribe }),\n },\n notFinished: {\n buttonLabel: copy?.subscribeLabel,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.subscribeLabel,\n callback: () => subscribe.openSubscribePopup(),\n id: TaskType.Subscribe,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.CompleteProfile]: {\n finished: profileCompleted,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.CompleteProfile,\n }),\n },\n notFinished: {\n buttonLabel: copy?.completeProfile,\n link: `${passportUrl}/account/profile?app=${appName}`,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.completeProfile,\n callback: () => {},\n id: TaskType.CompleteProfile,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.FirstPurchase]: {\n finished: firstPurchaseFinished,\n notLogin: {\n buttonLabel: copy?.makeFirstPurchase,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: openSignUpPopup,\n id: TaskType.FirstPurchase,\n }),\n },\n notFinished: {\n buttonLabel: copy?.makeFirstPurchase,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.makeFirstPurchase,\n callback: () => {},\n id: TaskType.FirstPurchase,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.UploadReceipt]: {\n finished: uploadedReceipt,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.UploadReceipt,\n }),\n },\n notFinished: {\n buttonLabel: copy?.uploadReceipt,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.uploadReceipt,\n callback: () => uploadReceipt.openUploadReceiptPopup(),\n id: TaskType.UploadReceipt,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n [TaskType.Shop]: {\n finished: false,\n notLogin: {\n buttonLabel: copy?.joinNow,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.joinNow,\n callback: openSignUpPopup,\n id: TaskType.Shop,\n }),\n },\n notFinished: {\n buttonLabel: copy?.shopNow,\n link: copy?.goShopLink,\n handleClick: () =>\n handleClickWithTrack({\n buttonName: copy?.shopNow,\n callback: () => {},\n id: TaskType.Shop,\n }),\n },\n completed: {\n buttonLabel: copy?.completed,\n },\n },\n },\n }\n }, [\n profile?.activated,\n copy?.joinNow,\n copy?.activate,\n copy?.completed,\n copy?.subscribe,\n copy?.completeProfile,\n copy?.makeFirstPurchase,\n copy?.uploadReceipt,\n copy?.shopNow,\n copy.title,\n copy?.goShopLink,\n isSubscribed,\n profileCompleted,\n firstPurchaseFinished,\n uploadedReceipt,\n gaParameters?.position,\n openSignUpPopup,\n ])\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,gBAAAE,IAAA,eAAAC,EAAAH,GAAA,IAAAI,EAA4C,yBAE5CC,EAAyB,kBACzBC,EAAkC,+BAClCC,EAAwB,iBACxBC,EAA+B,kDAC/BC,EAAyC,qDACzCC,EAA8B,0CAG9BC,EAAgC,8BAEzB,MAAMT,EAAa,CAAC,CACzB,KAAAU,EACA,UAAAC,EACA,cAAAC,EACA,aAAAC,CACF,IAaM,CACJ,KAAM,CAAE,gBAAAC,EAAiB,IAAAC,EAAK,QAAAC,CAAQ,KAAI,qBAAkB,EACtD,CAAE,iBAAAC,CAAiB,KAAI,mBAAgB,EACvCC,KAAe,iBAAc,EAC7BC,KAAwB,4BAAyB,EACjDC,KAAkB,EAAAC,SAAmB,EACrC,CAAE,QAAAC,EAAS,YAAAC,CAAY,KAAI,sBAAmB,EAE9CC,KAAmB,WAAQ,KACvBR,GAAS,YAAcA,GAAS,YAAcA,GAAS,cAAgBA,GAAS,IACvF,CAACA,CAAO,C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CACT,YAAaA,GAAM,SACrB,CACF,CACF,CACF,CACF,EAAG,CACDM,GAAS,UACTN,GAAM,QACNA,GAAM,SACNA,GAAM,UACNA,GAAM,UACNA,GAAM,gBACNA,GAAM,kBACNA,GAAM,cACNA,GAAM,QACNA,EAAK,MACLA,GAAM,WACNQ,EACAM,EACAL,EACAC,EACAP,GAAc,SACdC,CACF,CAAC,CACH",
6
6
  "names": ["useActions_exports", "__export", "useActions", "__toCommonJS", "import_lib", "import_type", "import_provider", "import_react", "import_useReceiptUploaded", "import_useFirstPurchaseFinished", "import_useSubscribed", "import_registration", "copy", "subscribe", "uploadReceipt", "gaParameters", "openSignUpPopup", "gtm", "profile", "authCodeActivate", "isSubscribed", "firstPurchaseFinished", "uploadedReceipt", "useReceiptUploaded", "appName", "passportUrl", "profileCompleted", "handleClickWithTrack", "buttonName", "id", "callback"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var G=Object.create;var m=Object.defineProperty;var J=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Z=(o,n)=>{for(var i in n)m(o,i,{get:n[i],enumerable:!0})},R=(o,n,i,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of Q(n))!X.call(o,a)&&a!==i&&m(o,a,{get:()=>n[a],enumerable:!(u=J(n,a))||u.enumerable});return o};var d=(o,n,i)=>(i=o!=null?G(W(o)):{},R(n||!o||!o.__esModule?m(i,"default",{value:o,enumerable:!0}):i,o)),ee=o=>R(m({},"__esModule",{value:!0}),o);var se={};Z(se,{default:()=>te});module.exports=ee(se);var s=require("react/jsx-runtime"),p=require("@anker-in/headless-ui"),g=d(require("classnames")),F=d(require("copy-to-clipboard")),h=d(require("dayjs")),r=require("react"),e=require("../context/const"),_=require("./modalContainer"),A=d(require("./tip")),D=d(require("./loadingDots")),v=d(require("../context/hooks/useMyRewards")),O=require("@anker-in/lib"),I=require("../const");function oe({data:o,...n}){const[i,u]=(0,r.useState)(e.AlpcConsumeType.Coupon),{brand:a}=(0,O.useHeadlessContext)(),x=I.roundedBrands.includes(a),[c,k]=(0,r.useState)(1),[f,U]=(0,r.useState)(1),[Y,y]=(0,r.useState)(-1),j=(0,r.useMemo)(()=>{const t=[];return o.couponTab&&t.push({title:o.couponTab,type:e.AlpcConsumeType.Coupon}),o.productTab&&t.push({title:o.productTab,type:e.AlpcConsumeType.Product}),t},[o.couponTab,o.productTab]),E=(0,r.useMemo)(()=>({page:n.isOpen?f:0,pageSize:1e3,consumeType:e.AlpcConsumeType.Product}),[n.isOpen,f]),H=(0,r.useMemo)(()=>({page:n.isOpen?c:0,pageSize:1e3,consumeType:e.AlpcConsumeType.Coupon}),[n.isOpen,c]),{myRewards:C=[],canNext:T,isLoading:$}=(0,v.default)(H),{myRewards:N=[],canNext:L,isLoading:z}=(0,v.default)(E),P=(0,r.useMemo)(()=>i===e.AlpcConsumeType.Coupon?C.map(t=>({title:t.goods_title,value:t.consume_credits,type:e.RewardType.Received,date:new Date(t.create_time*1e3),couponCode:t.coupon_code,orderNumber:""})):i===e.AlpcConsumeType.Product?N.map(t=>{let l=e.RewardType.Pending;return t.fulfillment_status&&t.fulfillment_status!=="null"?t.fulfillment_status==="fulfilled"?l=e.RewardType.Fulfilled:l=e.RewardType.Unfulfilled:t.approval_status===e.ApprovalStatus.Success||t.approval_status===e.ApprovalStatus.DoubleConfirm?l=e.RewardType.ApproveSuccess:t.approval_status===e.ApprovalStatus.Failed&&(l=e.RewardType.Failed),{title:t.goods_title,value:t.consume_credits,type:l,date:new Date(t.create_time*1e3),orderNumber:t.order_number,couponCode:""}}):[],[i,N,C]),M=(0,r.useMemo)(()=>i===e.AlpcConsumeType.Coupon?T:i===e.AlpcConsumeType.Product?L:!1,[i,T,L]),q=(0,r.useMemo)(()=>({[e.RewardType.Received]:o.receivedLabel,[e.RewardType.Pending]:o.pendingLabel,[e.RewardType.ApproveFail]:o.failedLabel,[e.RewardType.ApproveSuccess]:o.approveSuccessLabel,[e.RewardType.Unfulfilled]:o.unfulfilledLabel,[e.RewardType.Fulfilled]:o.fulfilledLabel,[e.RewardType.Failed]:o.failedLabel}),[o]),w=(0,r.useMemo)(()=>({[e.RewardType.Received]:"",[e.RewardType.Pending]:o.pendingTip,[e.RewardType.ApproveFail]:"",[e.RewardType.ApproveSuccess]:o.confirmedTip,[e.RewardType.Unfulfilled]:o.processingTip,[e.RewardType.Fulfilled]:o.ShippedTip,[e.RewardType.Failed]:""}),[o]),B=(0,r.useMemo)(()=>({[e.RewardType.Received]:"#52C41A",[e.RewardType.Pending]:"#999",[e.RewardType.ApproveFail]:"#F84D4F",[e.RewardType.ApproveSuccess]:"#999",[e.RewardType.Unfulfilled]:"#999",[e.RewardType.Fulfilled]:"#999",[e.RewardType.Failed]:"#F84D4F"}),[]),K=(0,r.useCallback)(()=>{M&&(i===e.AlpcConsumeType.Coupon?k(c+1):i===e.AlpcConsumeType.Product&&U(f+1))},[i,f,c,M]),V=(0,r.useCallback)((t,l)=>{y(l),(0,F.default)(t),setTimeout(()=>{y(-1)},2e3)},[]),S=i===e.AlpcConsumeType.Coupon?$:z;return(0,s.jsxs)(_.CreditsModalContainer,{title:o.title,className:(0,g.default)("h-[800px] w-[640px]"),useAnimation:!0,animationClassName:"md:translate-y-[100vh]",scrollClassName:"md:mb-0",...n,onScrollEnd:K,children:[(0,s.jsx)("div",{className:"",children:(0,s.jsx)(p.Tabs,{align:"left",shape:x?"rounded":"square",value:i.toString(),onValueChange:t=>{u(Number(t))},children:(0,s.jsx)(p.TabsList,{children:j.map(t=>(0,s.jsx)(p.TabsTrigger,{value:t.type.toString(),children:t.title},t.type))})})}),S&&(0,s.jsx)("div",{className:"flex h-full flex-col items-center justify-center",children:(0,s.jsx)(D.default,{})}),!S&&(0,s.jsx)("div",{className:"mt-[24px] overflow-auto overscroll-contain",children:P.length>0?(0,s.jsx)("div",{className:"grid gap-[18px] md:gap-[12px]",children:P.map((t,l)=>(0,s.jsxs)("div",{className:"grid gap-[8px]",children:[t?.orderNumber&&(0,s.jsxs)("div",{className:"text-[15px] font-semibold leading-[1.4] text-[#777]",children:[o.orderNumberLabel,": ",t.orderNumber]}),(0,s.jsxs)("div",{className:(0,g.default)("flex items-center justify-between rounded-[8px] bg-[#f7f8f9] px-[16px] py-[20px]",!x&&"rounded-none"),children:[(0,s.jsxs)("div",{className:"grid gap-[4px]",children:[(0,s.jsx)("div",{className:"text-[16px] font-bold leading-[1.4]",children:t.title}),(0,s.jsxs)("div",{className:"text-[14px] font-semibold text-[#999]",children:[o.valueLabel,": ",t.value," ",o?.pointUnit]}),(0,s.jsxs)("div",{className:"text-[14px] font-semibold text-[#999]",children:[t?.couponCode?`${o?.code||"Code"}: ${t.couponCode} `:"",t?.couponCode&&(0,s.jsx)("span",{className:"cursor-pointer text-[14px] font-semibold text-brand underline",onClick:()=>{V(t.couponCode,l)},role:"button",tabIndex:0,onKeyDown:b=>{(b.key==="Enter"||b.key===" ")&&b.preventDefault()},children:Y===l?o?.copied||"COPIED":o?.copy||"COPY"})]})]}),(0,s.jsxs)("div",{className:"grid gap-[4px] text-right",children:[(0,s.jsxs)("div",{className:(0,g.default)("flex items-center justify-end text-[16px] font-bold leading-[1.4]",`text-[${B[t.type]}]`),children:[(0,s.jsx)("span",{children:q[t.type]}),w[t.type]&&(0,s.jsx)(A.default,{info:w[t.type],index:l})]}),(0,s.jsx)("div",{className:"text-[14px] font-semibold text-[#999]",children:(0,h.default)(t.date).format("YYYY-MM-DD HH:mm").toString()})]})]})]},l))}):(0,s.jsxs)("div",{className:"flex h-full flex-col items-center justify-center",children:[(0,s.jsx)(p.Picture,{className:"mb-[12px] w-[160px]",source:o?.emptyListImage?.url,alt:o?.emptyListImage?.alt||"empty list image"}),(0,s.jsx)("div",{className:"text-[16px] font-semibold leading-[1.4]",children:o?.emptyListLabel})]})})]})}var te=oe;
1
+ "use strict";var V=Object.create;var m=Object.defineProperty;var G=Object.getOwnPropertyDescriptor;var J=Object.getOwnPropertyNames;var Q=Object.getPrototypeOf,W=Object.prototype.hasOwnProperty;var X=(o,n)=>{for(var i in n)m(o,i,{get:n[i],enumerable:!0})},F=(o,n,i,u)=>{if(n&&typeof n=="object"||typeof n=="function")for(let a of J(n))!W.call(o,a)&&a!==i&&m(o,a,{get:()=>n[a],enumerable:!(u=G(n,a))||u.enumerable});return o};var d=(o,n,i)=>(i=o!=null?V(Q(o)):{},F(n||!o||!o.__esModule?m(i,"default",{value:o,enumerable:!0}):i,o)),Z=o=>F(m({},"__esModule",{value:!0}),o);var te={};X(te,{default:()=>oe});module.exports=Z(te);var s=require("react/jsx-runtime"),p=require("@anker-in/headless-ui"),g=d(require("classnames")),_=d(require("copy-to-clipboard")),h=d(require("dayjs")),r=require("react"),e=require("../context/const"),D=require("./modalContainer"),A=d(require("./tip")),O=d(require("./loadingDots")),x=d(require("../context/hooks/useMyRewards")),b=require("@anker-in/lib");function ee({data:o,...n}){const[i,u]=(0,r.useState)(e.AlpcConsumeType.Coupon),{brand:a}=(0,b.useHeadlessContext)(),y=b.ROUNDED_BRANDS.includes(a),[c,I]=(0,r.useState)(1),[f,U]=(0,r.useState)(1),[k,C]=(0,r.useState)(-1),E=(0,r.useMemo)(()=>{const t=[];return o.couponTab&&t.push({title:o.couponTab,type:e.AlpcConsumeType.Coupon}),o.productTab&&t.push({title:o.productTab,type:e.AlpcConsumeType.Product}),t},[o.couponTab,o.productTab]),Y=(0,r.useMemo)(()=>({page:n.isOpen?f:0,pageSize:1e3,consumeType:e.AlpcConsumeType.Product}),[n.isOpen,f]),j=(0,r.useMemo)(()=>({page:n.isOpen?c:0,pageSize:1e3,consumeType:e.AlpcConsumeType.Coupon}),[n.isOpen,c]),{myRewards:N=[],canNext:T,isLoading:H}=(0,x.default)(j),{myRewards:L=[],canNext:P,isLoading:$}=(0,x.default)(Y),M=(0,r.useMemo)(()=>i===e.AlpcConsumeType.Coupon?N.map(t=>({title:t.goods_title,value:t.consume_credits,type:e.RewardType.Received,date:new Date(t.create_time*1e3),couponCode:t.coupon_code,orderNumber:""})):i===e.AlpcConsumeType.Product?L.map(t=>{let l=e.RewardType.Pending;return t.fulfillment_status&&t.fulfillment_status!=="null"?t.fulfillment_status==="fulfilled"?l=e.RewardType.Fulfilled:l=e.RewardType.Unfulfilled:t.approval_status===e.ApprovalStatus.Success||t.approval_status===e.ApprovalStatus.DoubleConfirm?l=e.RewardType.ApproveSuccess:t.approval_status===e.ApprovalStatus.Failed&&(l=e.RewardType.Failed),{title:t.goods_title,value:t.consume_credits,type:l,date:new Date(t.create_time*1e3),orderNumber:t.order_number,couponCode:""}}):[],[i,L,N]),w=(0,r.useMemo)(()=>i===e.AlpcConsumeType.Coupon?T:i===e.AlpcConsumeType.Product?P:!1,[i,T,P]),z=(0,r.useMemo)(()=>({[e.RewardType.Received]:o.receivedLabel,[e.RewardType.Pending]:o.pendingLabel,[e.RewardType.ApproveFail]:o.failedLabel,[e.RewardType.ApproveSuccess]:o.approveSuccessLabel,[e.RewardType.Unfulfilled]:o.unfulfilledLabel,[e.RewardType.Fulfilled]:o.fulfilledLabel,[e.RewardType.Failed]:o.failedLabel}),[o]),R=(0,r.useMemo)(()=>({[e.RewardType.Received]:"",[e.RewardType.Pending]:o.pendingTip,[e.RewardType.ApproveFail]:"",[e.RewardType.ApproveSuccess]:o.confirmedTip,[e.RewardType.Unfulfilled]:o.processingTip,[e.RewardType.Fulfilled]:o.ShippedTip,[e.RewardType.Failed]:""}),[o]),q=(0,r.useMemo)(()=>({[e.RewardType.Received]:"#52C41A",[e.RewardType.Pending]:"#999",[e.RewardType.ApproveFail]:"#F84D4F",[e.RewardType.ApproveSuccess]:"#999",[e.RewardType.Unfulfilled]:"#999",[e.RewardType.Fulfilled]:"#999",[e.RewardType.Failed]:"#F84D4F"}),[]),B=(0,r.useCallback)(()=>{w&&(i===e.AlpcConsumeType.Coupon?I(c+1):i===e.AlpcConsumeType.Product&&U(f+1))},[i,f,c,w]),K=(0,r.useCallback)((t,l)=>{C(l),(0,_.default)(t),setTimeout(()=>{C(-1)},2e3)},[]),S=i===e.AlpcConsumeType.Coupon?H:$;return(0,s.jsxs)(D.CreditsModalContainer,{title:o.title,className:(0,g.default)("h-[800px] w-[640px]"),useAnimation:!0,animationClassName:"md:translate-y-[100vh]",scrollClassName:"md:mb-0",...n,onScrollEnd:B,children:[(0,s.jsx)("div",{className:"",children:(0,s.jsx)(p.Tabs,{align:"left",shape:y?"rounded":"square",value:i.toString(),onValueChange:t=>{u(Number(t))},children:(0,s.jsx)(p.TabsList,{children:E.map(t=>(0,s.jsx)(p.TabsTrigger,{value:t.type.toString(),children:t.title},t.type))})})}),S&&(0,s.jsx)("div",{className:"flex h-full flex-col items-center justify-center",children:(0,s.jsx)(O.default,{})}),!S&&(0,s.jsx)("div",{className:"mt-[24px] overflow-auto overscroll-contain",children:M.length>0?(0,s.jsx)("div",{className:"grid gap-[18px] md:gap-[12px]",children:M.map((t,l)=>(0,s.jsxs)("div",{className:"grid gap-[8px]",children:[t?.orderNumber&&(0,s.jsxs)("div",{className:"text-[15px] font-semibold leading-[1.4] text-[#777]",children:[o.orderNumberLabel,": ",t.orderNumber]}),(0,s.jsxs)("div",{className:(0,g.default)("flex items-center justify-between rounded-[8px] bg-[#f7f8f9] px-[16px] py-[20px]",!y&&"rounded-none"),children:[(0,s.jsxs)("div",{className:"grid gap-[4px]",children:[(0,s.jsx)("div",{className:"text-[16px] font-bold leading-[1.4]",children:t.title}),(0,s.jsxs)("div",{className:"text-[14px] font-semibold text-[#999]",children:[o.valueLabel,": ",t.value," ",o?.pointUnit]}),(0,s.jsxs)("div",{className:"text-[14px] font-semibold text-[#999]",children:[t?.couponCode?`${o?.code||"Code"}: ${t.couponCode} `:"",t?.couponCode&&(0,s.jsx)("span",{className:"cursor-pointer text-[14px] font-semibold text-brand underline",onClick:()=>{K(t.couponCode,l)},role:"button",tabIndex:0,onKeyDown:v=>{(v.key==="Enter"||v.key===" ")&&v.preventDefault()},children:k===l?o?.copied||"COPIED":o?.copy||"COPY"})]})]}),(0,s.jsxs)("div",{className:"grid gap-[4px] text-right",children:[(0,s.jsxs)("div",{className:(0,g.default)("flex items-center justify-end text-[16px] font-bold leading-[1.4]",`text-[${q[t.type]}]`),children:[(0,s.jsx)("span",{children:z[t.type]}),R[t.type]&&(0,s.jsx)(A.default,{info:R[t.type],index:l})]}),(0,s.jsx)("div",{className:"text-[14px] font-semibold text-[#999]",children:(0,h.default)(t.date).format("YYYY-MM-DD HH:mm").toString()})]})]})]},l))}):(0,s.jsxs)("div",{className:"flex h-full flex-col items-center justify-center",children:[(0,s.jsx)(p.Picture,{className:"mb-[12px] w-[160px]",source:o?.emptyListImage?.url,alt:o?.emptyListImage?.alt||"empty list image"}),(0,s.jsx)("div",{className:"text-[16px] font-semibold leading-[1.4]",children:o?.emptyListLabel})]})})]})}var oe=ee;
2
2
  //# sourceMappingURL=MyRewardsModal.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/modal/MyRewardsModal.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, 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 { roundedBrands } from '../const'\n\nexport interface MyRewardsMetafields {\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 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 emptyListImage: {\n url: string\n alt?: string\n }\n}\ninterface MyRewardsModalProps extends ModalContainerProps {\n data: MyRewardsMetafields\n}\n\nfunction MyRewardsModal({ data, ...props }: MyRewardsModalProps) {\n const [activeTab, setActiveTab] = useState(AlpcConsumeType.Coupon)\n const { brand } = useHeadlessContext()\n const rounded = roundedBrands.includes(brand)\n\n const [couponPage, setCouponPage] = useState(1)\n const [productPage, setProductPage] = useState(1)\n const [copied, setCopied] = useState(-1)\n\n const tabs = useMemo(() => {\n const availableTabs: { title: string; type: number }[] = []\n\n if (data.couponTab) {\n availableTabs.push({\n title: data.couponTab,\n type: AlpcConsumeType.Coupon,\n })\n }\n\n if (data.productTab) {\n availableTabs.push({\n title: data.productTab,\n type: AlpcConsumeType.Product,\n })\n }\n\n return availableTabs\n }, [data.couponTab, data.productTab])\n\n const myProductRewardsOptions = useMemo(() => {\n return {\n page: props.isOpen ? productPage : 0,\n pageSize: 1000,\n consumeType: AlpcConsumeType.Product,\n }\n }, [props.isOpen, productPage])\n const myCouponRewardsOptions = useMemo(() => {\n return {\n page: props.isOpen ? couponPage : 0,\n pageSize: 1000,\n consumeType: AlpcConsumeType.Coupon,\n }\n }, [props.isOpen, couponPage])\n\n const {\n myRewards: myCouponRewards = [],\n canNext: couponCanNext,\n isLoading: couponIsLoading,\n } = useMyRewards(myCouponRewardsOptions)\n const {\n myRewards: myProductRewards = [],\n canNext: productCanNext,\n isLoading: productIsLoading,\n } = useMyRewards(myProductRewardsOptions)\n\n const list = useMemo(() => {\n if (activeTab === AlpcConsumeType.Coupon) {\n return myCouponRewards.map(item => ({\n title: item.goods_title,\n value: item.consume_credits,\n type: RewardType.Received,\n date: new Date(item.create_time * 1000),\n couponCode: item.coupon_code,\n orderNumber: '',\n }))\n }\n\n if (activeTab === AlpcConsumeType.Product) {\n return myProductRewards.map(item => {\n let type = RewardType.Pending\n\n if (item.fulfillment_status && item.fulfillment_status !== 'null') {\n // \u7269\u6D41\u72B6\u6001\n if (item.fulfillment_status === 'fulfilled') {\n type = RewardType.Fulfilled\n } else {\n type = RewardType.Unfulfilled\n }\n } else {\n if (\n item.approval_status === ApprovalStatus.Success ||\n item.approval_status === ApprovalStatus.DoubleConfirm\n ) {\n type = RewardType.ApproveSuccess\n } else if (item.approval_status === ApprovalStatus.Failed) {\n type = RewardType.Failed\n }\n }\n\n return {\n title: item.goods_title,\n value: item.consume_credits,\n type,\n date: new Date(item.create_time * 1000),\n orderNumber: item.order_number,\n couponCode: '',\n }\n })\n }\n\n return []\n }, [activeTab, myProductRewards, myCouponRewards])\n\n const canNext = useMemo(() => {\n if (activeTab === AlpcConsumeType.Coupon) {\n return couponCanNext\n }\n\n if (activeTab === AlpcConsumeType.Product) {\n return productCanNext\n }\n\n return false\n }, [activeTab, couponCanNext, productCanNext])\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 }\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 }\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 }\n }, [])\n\n const handleScrollEnd = useCallback(() => {\n if (!canNext) {\n return\n }\n\n if (activeTab === AlpcConsumeType.Coupon) {\n setCouponPage(couponPage + 1)\n } else if (activeTab === AlpcConsumeType.Product) {\n setProductPage(productPage + 1)\n }\n }, [activeTab, productPage, couponPage, 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 const isLoading = activeTab === AlpcConsumeType.Coupon ? couponIsLoading : productIsLoading\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 </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 MyRewardsModal\n"],
5
- "mappings": "2jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,GAAAH,IA8Oc,IAAAI,EAAA,6BA9OdC,EAAqD,iCACrDC,EAAuB,yBACvBC,EAAsB,gCACtBC,EAAkB,oBAClBC,EAA+C,iBAE/CC,EAA4D,4BAC5DC,EAAgE,4BAChEC,EAAgB,oBAChBC,EAAwB,4BACxBC,EAAyB,4CACzBC,EAAmC,yBACnCL,EAA8B,oBAgC9B,SAASM,GAAe,CAAE,KAAAC,EAAM,GAAGC,CAAM,EAAwB,CAC/D,KAAM,CAACC,EAAWC,CAAY,KAAI,YAAS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,OAAQxC,GAAM,gBAAgB,IAC9B,IAAKA,GAAM,gBAAgB,KAAO,mBACnC,KACD,OAAC,OAAI,UAAU,0CAA2C,SAAAA,GAAM,eAAe,GACjF,EAEJ,GAEJ,CAEJ,CAEA,IAAOf,GAAQc",
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, 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, ROUNDED_BRANDS } from '@anker-in/lib'\n\nexport interface MyRewardsMetafields {\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 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 emptyListImage: {\n url: string\n alt?: string\n }\n}\ninterface MyRewardsModalProps extends ModalContainerProps {\n data: MyRewardsMetafields\n}\n\nfunction MyRewardsModal({ data, ...props }: MyRewardsModalProps) {\n const [activeTab, setActiveTab] = useState(AlpcConsumeType.Coupon)\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const [couponPage, setCouponPage] = useState(1)\n const [productPage, setProductPage] = useState(1)\n const [copied, setCopied] = useState(-1)\n\n const tabs = useMemo(() => {\n const availableTabs: { title: string; type: number }[] = []\n\n if (data.couponTab) {\n availableTabs.push({\n title: data.couponTab,\n type: AlpcConsumeType.Coupon,\n })\n }\n\n if (data.productTab) {\n availableTabs.push({\n title: data.productTab,\n type: AlpcConsumeType.Product,\n })\n }\n\n return availableTabs\n }, [data.couponTab, data.productTab])\n\n const myProductRewardsOptions = useMemo(() => {\n return {\n page: props.isOpen ? productPage : 0,\n pageSize: 1000,\n consumeType: AlpcConsumeType.Product,\n }\n }, [props.isOpen, productPage])\n const myCouponRewardsOptions = useMemo(() => {\n return {\n page: props.isOpen ? couponPage : 0,\n pageSize: 1000,\n consumeType: AlpcConsumeType.Coupon,\n }\n }, [props.isOpen, couponPage])\n\n const {\n myRewards: myCouponRewards = [],\n canNext: couponCanNext,\n isLoading: couponIsLoading,\n } = useMyRewards(myCouponRewardsOptions)\n const {\n myRewards: myProductRewards = [],\n canNext: productCanNext,\n isLoading: productIsLoading,\n } = useMyRewards(myProductRewardsOptions)\n\n const list = useMemo(() => {\n if (activeTab === AlpcConsumeType.Coupon) {\n return myCouponRewards.map(item => ({\n title: item.goods_title,\n value: item.consume_credits,\n type: RewardType.Received,\n date: new Date(item.create_time * 1000),\n couponCode: item.coupon_code,\n orderNumber: '',\n }))\n }\n\n if (activeTab === AlpcConsumeType.Product) {\n return myProductRewards.map(item => {\n let type = RewardType.Pending\n\n if (item.fulfillment_status && item.fulfillment_status !== 'null') {\n // \u7269\u6D41\u72B6\u6001\n if (item.fulfillment_status === 'fulfilled') {\n type = RewardType.Fulfilled\n } else {\n type = RewardType.Unfulfilled\n }\n } else {\n if (\n item.approval_status === ApprovalStatus.Success ||\n item.approval_status === ApprovalStatus.DoubleConfirm\n ) {\n type = RewardType.ApproveSuccess\n } else if (item.approval_status === ApprovalStatus.Failed) {\n type = RewardType.Failed\n }\n }\n\n return {\n title: item.goods_title,\n value: item.consume_credits,\n type,\n date: new Date(item.create_time * 1000),\n orderNumber: item.order_number,\n couponCode: '',\n }\n })\n }\n\n return []\n }, [activeTab, myProductRewards, myCouponRewards])\n\n const canNext = useMemo(() => {\n if (activeTab === AlpcConsumeType.Coupon) {\n return couponCanNext\n }\n\n if (activeTab === AlpcConsumeType.Product) {\n return productCanNext\n }\n\n return false\n }, [activeTab, couponCanNext, productCanNext])\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 }\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 }\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 }\n }, [])\n\n const handleScrollEnd = useCallback(() => {\n if (!canNext) {\n return\n }\n\n if (activeTab === AlpcConsumeType.Coupon) {\n setCouponPage(couponPage + 1)\n } else if (activeTab === AlpcConsumeType.Product) {\n setProductPage(productPage + 1)\n }\n }, [activeTab, productPage, couponPage, 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 const isLoading = activeTab === AlpcConsumeType.Coupon ? couponIsLoading : productIsLoading\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 </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 MyRewardsModal\n"],
5
+ "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IA6Oc,IAAAI,EAAA,6BA7OdC,EAAqD,iCACrDC,EAAuB,yBACvBC,EAAsB,gCACtBC,EAAkB,oBAClBC,EAA+C,iBAE/CC,EAA4D,4BAC5DC,EAAgE,4BAChEC,EAAgB,oBAChBC,EAAwB,4BACxBC,EAAyB,4CACzBC,EAAmD,yBAgCnD,SAASC,GAAe,CAAE,KAAAC,EAAM,GAAGC,CAAM,EAAwB,CAC/D,KAAM,CAACC,EAAWC,CAAY,KAAI,YAAS,kBAAgB,MAAM,EAC3D,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvC,CAACE,EAAYC,CAAa,KAAI,YAAS,CAAC,EACxC,CAACC,EAAaC,CAAc,KAAI,YAAS,CAAC,EAC1C,CAACC,EAAQC,CAAS,KAAI,YAAS,EAAE,EAEjCC,KAAO,WAAQ,IAAM,CACzB,MAAMC,EAAmD,CAAC,EAE1D,OAAIb,EAAK,WACPa,EAAc,KAAK,CACjB,MAAOb,EAAK,UACZ,KAAM,kBAAgB,MACxB,CAAC,EAGCA,EAAK,YACPa,EAAc,KAAK,CACjB,MAAOb,EAAK,WACZ,KAAM,kBAAgB,OACxB,CAAC,EAGIa,CACT,EAAG,CAACb,EAAK,UAAWA,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AAU,IAAM,GACpEA,GAAM,eACL,OAAC,QACC,UAAU,gEACV,QAAS,IAAM,CACbO,EAAWP,EAAK,WAAYgB,CAAK,CACnC,EACA,KAAK,SACL,SAAU,EACV,UAAWC,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,MACjCA,EAAE,eAAe,CAErB,EAEC,SAAA/B,IAAW8B,EAAQxC,GAAM,QAAU,SAAWA,GAAM,MAAQ,OAC/D,GAEJ,GACF,KACA,QAAC,OAAI,UAAU,4BACb,qBAAC,OACC,aAAW,EAAAoC,SACT,oEACA,SAASP,EAASL,EAAK,IAAI,CAAC,GAC9B,EAEA,oBAAC,QAAM,SAAAG,EAAQH,EAAK,IAAI,EAAE,EACzBI,EAAOJ,EAAK,IAAI,MAAK,OAAC,EAAAkB,QAAA,CAAI,KAAMd,EAAOJ,EAAK,IAAI,EAAG,MAAOgB,EAAO,GACpE,KACA,OAAC,OAAI,UAAU,wCACZ,cAAAG,SAAMnB,EAAK,IAAI,EAAE,OAAO,kBAAkB,EAAE,SAAS,EACxD,GACF,GACF,IApDQgB,CAqDV,CACD,EACH,KAEA,QAAC,OAAI,UAAU,mDACb,oBAAC,WACC,UAAU,sBACV,OAAQxC,GAAM,gBAAgB,IAC9B,IAAKA,GAAM,gBAAgB,KAAO,mBACnC,KACD,OAAC,OAAI,UAAU,0CAA2C,SAAAA,GAAM,eAAe,GACjF,EAEJ,GAEJ,CAEJ,CAEA,IAAOf,GAAQc",
6
6
  "names": ["MyRewardsModal_exports", "__export", "MyRewardsModal_default", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_copy_to_clipboard", "import_dayjs", "import_react", "import_const", "import_modalContainer", "import_tip", "import_loadingDots", "import_useMyRewards", "import_lib", "MyRewardsModal", "data", "props", "activeTab", "setActiveTab", "brand", "rounded", "couponPage", "setCouponPage", "productPage", "setProductPage", "copied", "setCopied", "tabs", "availableTabs", "myProductRewardsOptions", "myCouponRewardsOptions", "myCouponRewards", "couponCanNext", "couponIsLoading", "useMyRewards", "myProductRewards", "productCanNext", "productIsLoading", "list", "item", "type", "canNext", "TypeMap", "TipMap", "ColorMap", "handleScrollEnd", "handleCopy", "code", "idx", "clipboard", "isLoading", "classNames", "value", "tab", "LoadingDots", "index", "e", "Tip", "dayjs"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var I=Object.create;var f=Object.defineProperty;var j=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var H=Object.getPrototypeOf,O=Object.prototype.hasOwnProperty;var z=(e,r)=>{for(var a in r)f(e,a,{get:r[a],enumerable:!0})},_=(e,r,a,m)=>{if(r&&typeof r=="object"||typeof r=="function")for(let n of F(r))!O.call(e,n)&&n!==a&&f(e,n,{get:()=>r[n],enumerable:!(m=j(r,n))||m.enumerable});return e};var x=(e,r,a)=>(a=e!=null?I(H(e)):{},_(r||!e||!e.__esModule?f(a,"default",{value:e,enumerable:!0}):a,e)),q=e=>_(f({},"__esModule",{value:!0}),e);var $={};z($,{default:()=>V});module.exports=q($);var i=require("react/jsx-runtime"),o=require("react"),M=require("../context/provider"),t=require("../context/const"),P=x(require("../context/hooks/useActivities")),C=require("./modalContainer"),d=require("@anker-in/lib"),c=require("@anker-in/headless-ui"),S=x(require("./loadingDots")),T=require("@anker-in/headless-ui"),y=x(require("dayjs")),U=require("../const");function K({data:e,...r}){const[a,m]=(0,o.useState)(1),{taskIdToTypeMapping:n}=(0,M.useCreditsContext)(),{brand:D}=(0,d.useHeadlessContext)(),b=U.roundedBrands.includes(D),L=(0,o.useMemo)(()=>({page:r.isOpen?a:0,pageSize:1e3}),[r.isOpen,a]),[u,Y]=(0,o.useState)(t.CreditType.All),w=(0,o.useMemo)(()=>{const p=[{title:e.allTab,type:t.CreditType.All},{title:e.earnedTab,type:t.CreditType.Earned},{title:e.deductedTab,type:t.CreditType.Deducted}];return e.expiredTab&&p.push({title:e.expiredTab,type:t.CreditType.Expired}),p},[e]),{activities:h=[],canNext:N,isLoading:A}=(0,P.default)(L),v=(0,o.useMemo)(()=>{const p={[t.TaskSubType.Activation]:e.activationTask,[t.TaskSubType.UpdateName]:e.updateNameTask,[t.TaskSubType.UpdatePhone]:e.updatePhoneTask,[t.TaskSubType.UpdateBirthday]:e.updateBirthdayTask,[t.TaskSubType.Subscription]:e.subscriptionTask,[t.TaskSubType.UpadteAppName]:e.updateAppNameTask,[t.TaskSubType.Refund]:e.refundTask,[t.TaskSubType.ProductUnApproved]:e.productUnApprovedTask},k={[t.DTC_TASK_TYPE.FirstPurchase]:e.firstPurchaseTask,[t.DTC_TASK_TYPE.UploadReceipt]:e.uploadReceiptTask,[t.DTC_TASK_TYPE.Shopping]:e.shoppingTask};function R(s){return s.task_type===t.TaskType.Redeem&&s.task_sub_type===t.TaskSubType.ProductUnApproved&&e.productUnApprovedTask?s.task_name.replace("Refund",e.productUnApprovedTask):n?.[String(s.task_rule_id)]?k[n?.[String(s.task_rule_id)]]:p[s.task_sub_type]||s.task_name}let l=h.map(s=>({title:R(s),date:new Date(s.create_time*1e3),value:s.credit,type:s.credit_type,pending_time:s.pending_time,credit_type:s.credit_type,status:s.status}))||[];return u===t.CreditType.Earned?l=l?.filter(s=>s.type===1):u===t.CreditType.Deducted?l=l?.filter(s=>s.type===2&&s.status!==3):u===t.CreditType.Expired&&(l=l?.filter(s=>s.type===2&&s.status===3)),l.map(s=>{let{value:g,...B}=s;return s.type===t.CreditType.Deducted&&g>0&&(g=-g),{value:g,...B}})},[e.activationTask,e.updateNameTask,e.updatePhoneTask,e.updateBirthdayTask,e.subscriptionTask,e.updateAppNameTask,e.refundTask,e.productUnApprovedTask,e.firstPurchaseTask,e.uploadReceiptTask,e.shoppingTask,h,u,n]),E=(0,o.useCallback)(()=>{N&&m(a+1)},[a,N]);return(0,i.jsxs)(C.CreditsModalContainer,{title:e.title,className:(0,d.classNames)("h-[800px] w-[640px]"),useAnimation:!0,animationClassName:"md:translate-y-[100vh]",scrollClassName:"",...r,onScrollEnd:E,children:[(0,i.jsx)("div",{className:"w-full sticky top-0 bg-white z-10 pb-[24px] overflow-x-auto",children:(0,i.jsx)(c.Tabs,{align:"left",shape:b?"rounded":"square",value:u.toString(),onValueChange:p=>{Y(Number(p))},className:"",children:(0,i.jsx)(c.TabsList,{children:w.map(p=>(0,i.jsx)(c.TabsTrigger,{value:p.type.toString(),children:p.title},p.type))})})}),(0,i.jsxs)("div",{className:"grid gap-[18px] overflow-auto overscroll-contain md:gap-[12px]",children:[A&&(0,i.jsx)("div",{className:"flex h-full flex-col items-center justify-center",children:(0,i.jsx)(S.default,{})}),!A&&(0,i.jsx)(i.Fragment,{children:v.length>0?v.map((p,k)=>(0,i.jsxs)("div",{className:(0,d.classNames)("flex h-fit items-center justify-between rounded-[8px] bg-[#f2f0f1] px-[16px] py-[20px] text-[16px]",!b&&"rounded-none"),children:[(0,i.jsxs)("div",{className:"grid gap-[6px]",children:[(0,i.jsx)("div",{className:"font-bold",children:p.title}),(0,i.jsx)("div",{className:"text-[14px] font-semibold text-[#999]",children:(0,y.default)(p.date).format("YYYY-MM-DD HH:mm").toString()}),!e.pendingTips&&(0,i.jsxs)("div",{className:`hidden text-[14px] font-semibold text-[#777] ${p.status===2&&p.credit_type===1?"!flex":""}`,children:[(0,i.jsx)(T.Text,{html:e.pendingTips}),(0,i.jsx)("span",{children:y.default.unix(p.pending_time).add(1,"day").format("YYYY-MM-DD")}),e.pendingTips2&&(0,i.jsx)(T.Text,{html:e.pendingTips2})]})]}),(0,i.jsxs)("div",{className:(0,d.classNames)("font-bold",p.value>=0||p.credit_type===t.CreditType.Expired?"text-[#52C41A]":"text-[#F84D4F]"),children:[p.value>=0&&"+",p.value]})]},k)):(0,i.jsxs)("div",{className:"flex h-full flex-col items-center justify-center",children:[(0,i.jsx)(T.Picture,{className:"mb-[16px] h-[120px] w-[160px]",source:e?.emptyListImage?.url,alt:e?.emptyListImage?.alt||"empty list image"}),(0,i.jsx)("div",{className:"leading-1.4 text-[16px] font-semibold",children:e?.emptyListLabel})]})})]}),v.length>0&&(0,i.jsx)("div",{className:"mt-[12px] pb-[24px] text-[14px] font-semibold text-[#999]",children:e.tips})]})}var V=K;
1
+ "use strict";var B=Object.create;var f=Object.defineProperty;var I=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var j=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var H=(e,a)=>{for(var r in a)f(e,r,{get:a[r],enumerable:!0})},_=(e,a,r,m)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of O(a))!F.call(e,n)&&n!==r&&f(e,n,{get:()=>a[n],enumerable:!(m=I(a,n))||m.enumerable});return e};var x=(e,a,r)=>(r=e!=null?B(j(e)):{},_(a||!e||!e.__esModule?f(r,"default",{value:e,enumerable:!0}):r,e)),z=e=>_(f({},"__esModule",{value:!0}),e);var V={};H(V,{default:()=>K});module.exports=z(V);var i=require("react/jsx-runtime"),o=require("react"),M=require("../context/provider"),t=require("../context/const"),P=x(require("../context/hooks/useActivities")),C=require("./modalContainer"),l=require("@anker-in/lib"),c=require("@anker-in/headless-ui"),D=x(require("./loadingDots")),T=require("@anker-in/headless-ui"),y=x(require("dayjs"));function q({data:e,...a}){const[r,m]=(0,o.useState)(1),{taskIdToTypeMapping:n}=(0,M.useCreditsContext)(),{brand:S}=(0,l.useHeadlessContext)(),b=l.ROUNDED_BRANDS.includes(S),U=(0,o.useMemo)(()=>({page:a.isOpen?r:0,pageSize:1e3}),[a.isOpen,r]),[u,L]=(0,o.useState)(t.CreditType.All),E=(0,o.useMemo)(()=>{const p=[{title:e.allTab,type:t.CreditType.All},{title:e.earnedTab,type:t.CreditType.Earned},{title:e.deductedTab,type:t.CreditType.Deducted}];return e.expiredTab&&p.push({title:e.expiredTab,type:t.CreditType.Expired}),p},[e]),{activities:h=[],canNext:N,isLoading:A}=(0,P.default)(U),v=(0,o.useMemo)(()=>{const p={[t.TaskSubType.Activation]:e.activationTask,[t.TaskSubType.UpdateName]:e.updateNameTask,[t.TaskSubType.UpdatePhone]:e.updatePhoneTask,[t.TaskSubType.UpdateBirthday]:e.updateBirthdayTask,[t.TaskSubType.Subscription]:e.subscriptionTask,[t.TaskSubType.UpadteAppName]:e.updateAppNameTask,[t.TaskSubType.Refund]:e.refundTask,[t.TaskSubType.ProductUnApproved]:e.productUnApprovedTask},k={[t.DTC_TASK_TYPE.FirstPurchase]:e.firstPurchaseTask,[t.DTC_TASK_TYPE.UploadReceipt]:e.uploadReceiptTask,[t.DTC_TASK_TYPE.Shopping]:e.shoppingTask};function Y(s){return s.task_type===t.TaskType.Redeem&&s.task_sub_type===t.TaskSubType.ProductUnApproved&&e.productUnApprovedTask?s.task_name.replace("Refund",e.productUnApprovedTask):n?.[String(s.task_rule_id)]?k[n?.[String(s.task_rule_id)]]:p[s.task_sub_type]||s.task_name}let d=h.map(s=>({title:Y(s),date:new Date(s.create_time*1e3),value:s.credit,type:s.credit_type,pending_time:s.pending_time,credit_type:s.credit_type,status:s.status}))||[];return u===t.CreditType.Earned?d=d?.filter(s=>s.type===1):u===t.CreditType.Deducted?d=d?.filter(s=>s.type===2&&s.status!==3):u===t.CreditType.Expired&&(d=d?.filter(s=>s.type===2&&s.status===3)),d.map(s=>{let{value:g,...w}=s;return s.type===t.CreditType.Deducted&&g>0&&(g=-g),{value:g,...w}})},[e.activationTask,e.updateNameTask,e.updatePhoneTask,e.updateBirthdayTask,e.subscriptionTask,e.updateAppNameTask,e.refundTask,e.productUnApprovedTask,e.firstPurchaseTask,e.uploadReceiptTask,e.shoppingTask,h,u,n]),R=(0,o.useCallback)(()=>{N&&m(r+1)},[r,N]);return(0,i.jsxs)(C.CreditsModalContainer,{title:e.title,className:(0,l.classNames)("h-[800px] w-[640px]"),useAnimation:!0,animationClassName:"md:translate-y-[100vh]",scrollClassName:"",...a,onScrollEnd:R,children:[(0,i.jsx)("div",{className:"w-full sticky top-0 bg-white z-10 pb-[24px] overflow-x-auto",children:(0,i.jsx)(c.Tabs,{align:"left",shape:b?"rounded":"square",value:u.toString(),onValueChange:p=>{L(Number(p))},className:"",children:(0,i.jsx)(c.TabsList,{children:E.map(p=>(0,i.jsx)(c.TabsTrigger,{value:p.type.toString(),children:p.title},p.type))})})}),(0,i.jsxs)("div",{className:"grid gap-[18px] overflow-auto overscroll-contain md:gap-[12px]",children:[A&&(0,i.jsx)("div",{className:"flex h-full flex-col items-center justify-center",children:(0,i.jsx)(D.default,{})}),!A&&(0,i.jsx)(i.Fragment,{children:v.length>0?v.map((p,k)=>(0,i.jsxs)("div",{className:(0,l.classNames)("flex h-fit items-center justify-between rounded-[8px] bg-[#f2f0f1] px-[16px] py-[20px] text-[16px]",!b&&"rounded-none"),children:[(0,i.jsxs)("div",{className:"grid gap-[6px]",children:[(0,i.jsx)("div",{className:"font-bold",children:p.title}),(0,i.jsx)("div",{className:"text-[14px] font-semibold text-[#999]",children:(0,y.default)(p.date).format("YYYY-MM-DD HH:mm").toString()}),!e.pendingTips&&(0,i.jsxs)("div",{className:`hidden text-[14px] font-semibold text-[#777] ${p.status===2&&p.credit_type===1?"!flex":""}`,children:[(0,i.jsx)(T.Text,{html:e.pendingTips}),(0,i.jsx)("span",{children:y.default.unix(p.pending_time).add(1,"day").format("YYYY-MM-DD")}),e.pendingTips2&&(0,i.jsx)(T.Text,{html:e.pendingTips2})]})]}),(0,i.jsxs)("div",{className:(0,l.classNames)("font-bold",p.value>=0||p.credit_type===t.CreditType.Expired?"text-[#52C41A]":"text-[#F84D4F]"),children:[p.value>=0&&"+",p.value]})]},k)):(0,i.jsxs)("div",{className:"flex h-full flex-col items-center justify-center",children:[(0,i.jsx)(T.Picture,{className:"mb-[16px] h-[120px] w-[160px]",source:e?.emptyListImage?.url,alt:e?.emptyListImage?.alt||"empty list image"}),(0,i.jsx)("div",{className:"leading-1.4 text-[16px] font-semibold",children:e?.emptyListLabel})]})})]}),v.length>0&&(0,i.jsx)("div",{className:"mt-[12px] pb-[24px] text-[14px] font-semibold text-[#999]",children:e.tips})]})}var K=q;
2
2
  //# sourceMappingURL=activitiesModal.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/modal/activitiesModal.tsx"],
4
- "sourcesContent": ["import { useCallback, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../context/provider'\nimport { CreditType, DTC_TASK_TYPE, TaskSubType, TaskType } from '../context/const'\nimport useActivities from '../context/hooks/useActivities'\nimport type { Task } from '../context/response'\nimport { CreditsModalContainer, type ModalContainerProps } from './modalContainer'\nimport { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport LoadingDots from './loadingDots'\nimport { Picture, Text } from '@anker-in/headless-ui'\nimport dayjs from 'dayjs'\nimport { roundedBrands } from '../const'\n\nexport interface MyActivitiesMetafields {\n title: string\n tips: string\n allTab: string\n earnedTab: string\n deductedTab: string\n expiredTab: string\n activationTask: string\n updateNameTask: string\n updatePhoneTask: string\n updateBirthdayTask: string\n updateAppNameTask: string\n subscriptionTask: string\n refundTask: string\n productUnApprovedTask: string\n pendingTips?: string\n pendingTips2?: string\n firstPurchaseTask: string\n uploadReceiptTask: string\n shoppingTask: string\n emptyListImage: {\n url: string\n alt?: string\n }\n emptyListLabel: string\n}\n\ninterface ActivitiesModalProps extends ModalContainerProps {\n data: MyActivitiesMetafields\n}\n\nfunction ActivitiesModal({ data, ...props }: ActivitiesModalProps) {\n const [page, setPage] = useState(1)\n const { taskIdToTypeMapping } = useCreditsContext()\n const { brand } = useHeadlessContext()\n const rounded = roundedBrands.includes(brand)\n\n const myActivitiesOptions = useMemo(() => {\n return {\n page: props.isOpen ? page : 0,\n pageSize: 1000,\n }\n }, [props.isOpen, page])\n\n const [activeTab, setActiveTab] = useState(CreditType.All)\n const tabs = useMemo(() => {\n const tabs = [\n {\n title: data.allTab,\n type: CreditType.All,\n },\n {\n title: data.earnedTab,\n type: CreditType.Earned,\n },\n {\n title: data.deductedTab,\n type: CreditType.Deducted,\n },\n ]\n if (data.expiredTab) {\n tabs.push({\n title: data.expiredTab,\n type: CreditType.Expired,\n })\n }\n return tabs\n }, [data])\n\n const { activities = [], canNext, isLoading } = useActivities(myActivitiesOptions)\n\n const list = useMemo(() => {\n const taskNameMap = {\n [TaskSubType.Activation]: data.activationTask,\n [TaskSubType.UpdateName]: data.updateNameTask,\n [TaskSubType.UpdatePhone]: data.updatePhoneTask,\n [TaskSubType.UpdateBirthday]: data.updateBirthdayTask,\n [TaskSubType.Subscription]: data.subscriptionTask,\n [TaskSubType.UpadteAppName]: data.updateAppNameTask,\n [TaskSubType.Refund]: data.refundTask,\n [TaskSubType.ProductUnApproved]: data.productUnApprovedTask,\n }\n const dtcTaskTypeToNameMap = {\n [DTC_TASK_TYPE.FirstPurchase]: data.firstPurchaseTask,\n [DTC_TASK_TYPE.UploadReceipt]: data.uploadReceiptTask,\n [DTC_TASK_TYPE.Shopping]: data.shoppingTask,\n }\n\n function getTitle(item: Task) {\n if (\n item.task_type === TaskType.Redeem &&\n item.task_sub_type === TaskSubType.ProductUnApproved &&\n data.productUnApprovedTask\n ) {\n // \u65B0\u589E\u7684\u90E8\u5206\u4EFB\u52A1\u90FD\u4F7F\u7528\u4E86 alpc \u540C\u4E00\u4E2A\u4EFB\u52A1\u7C7B\u578B\uFF0C\u9700\u8981\u7528\u4EFB\u52A1 id \u6765\u533A\u5206\n return item.task_name.replace('Refund', data.productUnApprovedTask)\n } else if (taskIdToTypeMapping?.[String(item.task_rule_id)]) {\n return dtcTaskTypeToNameMap[taskIdToTypeMapping?.[String(item.task_rule_id)]]\n } else {\n return taskNameMap[item.task_sub_type] || item.task_name\n }\n }\n\n const all = activities.map(item => ({\n title: getTitle(item),\n date: new Date(item.create_time * 1000),\n value: item.credit,\n type: item.credit_type,\n pending_time: item.pending_time,\n credit_type: item.credit_type,\n status: item.status,\n }))\n\n let filtered = all || []\n if (activeTab === CreditType.Earned) {\n filtered = filtered?.filter(item => item.type === 1)\n } else if (activeTab === CreditType.Deducted) {\n filtered = filtered?.filter(item => item.type === 2 && item.status !== 3)\n } else if (activeTab === CreditType.Expired) {\n filtered = filtered?.filter(item => item.type === 2 && item.status === 3)\n }\n\n return filtered.map(item => {\n let { value, ...otherItem } = item\n if (item.type === CreditType.Deducted && value > 0) {\n value = -value\n }\n\n return {\n value,\n ...otherItem,\n }\n })\n }, [\n data.activationTask,\n data.updateNameTask,\n data.updatePhoneTask,\n data.updateBirthdayTask,\n data.subscriptionTask,\n data.updateAppNameTask,\n data.refundTask,\n data.productUnApprovedTask,\n data.firstPurchaseTask,\n data.uploadReceiptTask,\n data.shoppingTask,\n activities,\n activeTab,\n taskIdToTypeMapping,\n ])\n\n const handleScrollEnd = useCallback(() => {\n if (!canNext) {\n return\n }\n setPage(page + 1)\n }, [page, canNext])\n\n return (\n <CreditsModalContainer\n title={data.title}\n className={cn('h-[800px] w-[640px]')}\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n scrollClassName=\"\"\n {...props}\n onScrollEnd={handleScrollEnd}\n >\n <div className=\"w-full sticky top-0 bg-white z-10 pb-[24px] overflow-x-auto\">\n <Tabs\n align=\"left\"\n shape={rounded ? 'rounded' : 'square'}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(Number(value))\n }}\n className=\"\"\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 <div className=\"grid gap-[18px] overflow-auto overscroll-contain md:gap-[12px]\">\n {isLoading && (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <LoadingDots />\n </div>\n )}\n\n {!isLoading && (\n <>\n {list.length > 0 ? (\n list.map((item, index) => (\n <div\n key={index}\n className={cn(\n 'flex h-fit items-center justify-between rounded-[8px] bg-[#f2f0f1] px-[16px] py-[20px] text-[16px]',\n !rounded && 'rounded-none'\n )}\n >\n <div className=\"grid gap-[6px]\">\n <div className=\"font-bold\">{item.title}</div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {dayjs(item.date).format('YYYY-MM-DD HH:mm').toString()}\n </div>\n {!data.pendingTips && (\n <div\n className={`hidden text-[14px] font-semibold text-[#777] ${item.status === 2 && item.credit_type === 1 ? '!flex' : ''}`}\n >\n <Text html={data.pendingTips} />\n <span>{dayjs.unix(item.pending_time).add(1, 'day').format('YYYY-MM-DD')}</span>\n {data.pendingTips2 && <Text html={data.pendingTips2} />}\n </div>\n )}\n </div>\n <div\n className={cn(\n 'font-bold',\n item.value >= 0 || item.credit_type === CreditType.Expired ? 'text-[#52C41A]' : 'text-[#F84D4F]'\n )}\n >\n {item.value >= 0 && '+'}\n {item.value}\n </div>\n </div>\n ))\n ) : (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <Picture\n className=\"mb-[16px] h-[120px] w-[160px]\"\n source={data?.emptyListImage?.url}\n alt={data?.emptyListImage?.alt || 'empty list image'}\n ></Picture>\n <div className=\"leading-1.4 text-[16px] font-semibold\">{data?.emptyListLabel}</div>\n </div>\n )}\n </>\n )}\n </div>\n {/* \u79EF\u5206\u5230\u8D26\u65F6\u95F4\u63D0\u9192 */}\n {list.length > 0 && <div className=\"mt-[12px] pb-[24px] text-[14px] font-semibold text-[#999]\">{data.tips}</div>}\n </CreditsModalContainer>\n )\n}\n\nexport default ActivitiesModal\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GAgMc,IAAAI,EAAA,6BAhMdC,EAA+C,iBAC/CC,EAAkC,+BAClCC,EAAiE,4BACjEC,EAA0B,6CAE1BC,EAAgE,4BAChEC,EAAqD,yBACrDC,EAA4C,iCAC5CC,EAAwB,4BACxBD,EAA8B,iCAC9BE,EAAkB,oBAClBN,EAA8B,oBAiC9B,SAASO,EAAgB,CAAE,KAAAC,EAAM,GAAGC,CAAM,EAAyB,CACjE,KAAM,CAACC,EAAMC,CAAO,KAAI,YAAS,CAAC,EAC5B,C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W,QAAU,iBAAmB,gBAClF,EAEC,UAAAA,EAAK,OAAS,GAAK,IACnBA,EAAK,OACR,IA7BKQ,CA8BP,CACD,KAED,QAAC,OAAI,UAAU,mDACb,oBAAC,WACC,UAAU,gCACV,OAAQ3B,GAAM,gBAAgB,IAC9B,IAAKA,GAAM,gBAAgB,KAAO,mBACnC,KACD,OAAC,OAAI,UAAU,wCAAyC,SAAAA,GAAM,eAAe,GAC/E,EAEJ,GAEJ,EAECe,EAAK,OAAS,MAAK,OAAC,OAAI,UAAU,4DAA6D,SAAAf,EAAK,KAAK,GAC5G,CAEJ,CAEA,IAAOb,EAAQY",
4
+ "sourcesContent": ["import { useCallback, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../context/provider'\nimport { CreditType, DTC_TASK_TYPE, TaskSubType, TaskType } from '../context/const'\nimport useActivities from '../context/hooks/useActivities'\nimport type { Task } from '../context/response'\nimport { CreditsModalContainer, type ModalContainerProps } from './modalContainer'\nimport { classNames as cn, useHeadlessContext, ROUNDED_BRANDS } from '@anker-in/lib'\nimport { Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport LoadingDots from './loadingDots'\nimport { Picture, Text } from '@anker-in/headless-ui'\nimport dayjs from 'dayjs'\n\nexport interface MyActivitiesMetafields {\n title: string\n tips: string\n allTab: string\n earnedTab: string\n deductedTab: string\n expiredTab: string\n activationTask: string\n updateNameTask: string\n updatePhoneTask: string\n updateBirthdayTask: string\n updateAppNameTask: string\n subscriptionTask: string\n refundTask: string\n productUnApprovedTask: string\n pendingTips?: string\n pendingTips2?: string\n firstPurchaseTask: string\n uploadReceiptTask: string\n shoppingTask: string\n emptyListImage: {\n url: string\n alt?: string\n }\n emptyListLabel: string\n}\n\ninterface ActivitiesModalProps extends ModalContainerProps {\n data: MyActivitiesMetafields\n}\n\nfunction ActivitiesModal({ data, ...props }: ActivitiesModalProps) {\n const [page, setPage] = useState(1)\n const { taskIdToTypeMapping } = useCreditsContext()\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const myActivitiesOptions = useMemo(() => {\n return {\n page: props.isOpen ? page : 0,\n pageSize: 1000,\n }\n }, [props.isOpen, page])\n\n const [activeTab, setActiveTab] = useState(CreditType.All)\n const tabs = useMemo(() => {\n const tabs = [\n {\n title: data.allTab,\n type: CreditType.All,\n },\n {\n title: data.earnedTab,\n type: CreditType.Earned,\n },\n {\n title: data.deductedTab,\n type: CreditType.Deducted,\n },\n ]\n if (data.expiredTab) {\n tabs.push({\n title: data.expiredTab,\n type: CreditType.Expired,\n })\n }\n return tabs\n }, [data])\n\n const { activities = [], canNext, isLoading } = useActivities(myActivitiesOptions)\n\n const list = useMemo(() => {\n const taskNameMap = {\n [TaskSubType.Activation]: data.activationTask,\n [TaskSubType.UpdateName]: data.updateNameTask,\n [TaskSubType.UpdatePhone]: data.updatePhoneTask,\n [TaskSubType.UpdateBirthday]: data.updateBirthdayTask,\n [TaskSubType.Subscription]: data.subscriptionTask,\n [TaskSubType.UpadteAppName]: data.updateAppNameTask,\n [TaskSubType.Refund]: data.refundTask,\n [TaskSubType.ProductUnApproved]: data.productUnApprovedTask,\n }\n const dtcTaskTypeToNameMap = {\n [DTC_TASK_TYPE.FirstPurchase]: data.firstPurchaseTask,\n [DTC_TASK_TYPE.UploadReceipt]: data.uploadReceiptTask,\n [DTC_TASK_TYPE.Shopping]: data.shoppingTask,\n }\n\n function getTitle(item: Task) {\n if (\n item.task_type === TaskType.Redeem &&\n item.task_sub_type === TaskSubType.ProductUnApproved &&\n data.productUnApprovedTask\n ) {\n // \u65B0\u589E\u7684\u90E8\u5206\u4EFB\u52A1\u90FD\u4F7F\u7528\u4E86 alpc \u540C\u4E00\u4E2A\u4EFB\u52A1\u7C7B\u578B\uFF0C\u9700\u8981\u7528\u4EFB\u52A1 id \u6765\u533A\u5206\n return item.task_name.replace('Refund', data.productUnApprovedTask)\n } else if (taskIdToTypeMapping?.[String(item.task_rule_id)]) {\n return dtcTaskTypeToNameMap[taskIdToTypeMapping?.[String(item.task_rule_id)]]\n } else {\n return taskNameMap[item.task_sub_type] || item.task_name\n }\n }\n\n const all = activities.map(item => ({\n title: getTitle(item),\n date: new Date(item.create_time * 1000),\n value: item.credit,\n type: item.credit_type,\n pending_time: item.pending_time,\n credit_type: item.credit_type,\n status: item.status,\n }))\n\n let filtered = all || []\n if (activeTab === CreditType.Earned) {\n filtered = filtered?.filter(item => item.type === 1)\n } else if (activeTab === CreditType.Deducted) {\n filtered = filtered?.filter(item => item.type === 2 && item.status !== 3)\n } else if (activeTab === CreditType.Expired) {\n filtered = filtered?.filter(item => item.type === 2 && item.status === 3)\n }\n\n return filtered.map(item => {\n let { value, ...otherItem } = item\n if (item.type === CreditType.Deducted && value > 0) {\n value = -value\n }\n\n return {\n value,\n ...otherItem,\n }\n })\n }, [\n data.activationTask,\n data.updateNameTask,\n data.updatePhoneTask,\n data.updateBirthdayTask,\n data.subscriptionTask,\n data.updateAppNameTask,\n data.refundTask,\n data.productUnApprovedTask,\n data.firstPurchaseTask,\n data.uploadReceiptTask,\n data.shoppingTask,\n activities,\n activeTab,\n taskIdToTypeMapping,\n ])\n\n const handleScrollEnd = useCallback(() => {\n if (!canNext) {\n return\n }\n setPage(page + 1)\n }, [page, canNext])\n\n return (\n <CreditsModalContainer\n title={data.title}\n className={cn('h-[800px] w-[640px]')}\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n scrollClassName=\"\"\n {...props}\n onScrollEnd={handleScrollEnd}\n >\n <div className=\"w-full sticky top-0 bg-white z-10 pb-[24px] overflow-x-auto\">\n <Tabs\n align=\"left\"\n shape={rounded ? 'rounded' : 'square'}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(Number(value))\n }}\n className=\"\"\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 <div className=\"grid gap-[18px] overflow-auto overscroll-contain md:gap-[12px]\">\n {isLoading && (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <LoadingDots />\n </div>\n )}\n\n {!isLoading && (\n <>\n {list.length > 0 ? (\n list.map((item, index) => (\n <div\n key={index}\n className={cn(\n 'flex h-fit items-center justify-between rounded-[8px] bg-[#f2f0f1] px-[16px] py-[20px] text-[16px]',\n !rounded && 'rounded-none'\n )}\n >\n <div className=\"grid gap-[6px]\">\n <div className=\"font-bold\">{item.title}</div>\n <div className=\"text-[14px] font-semibold text-[#999]\">\n {dayjs(item.date).format('YYYY-MM-DD HH:mm').toString()}\n </div>\n {!data.pendingTips && (\n <div\n className={`hidden text-[14px] font-semibold text-[#777] ${item.status === 2 && item.credit_type === 1 ? '!flex' : ''}`}\n >\n <Text html={data.pendingTips} />\n <span>{dayjs.unix(item.pending_time).add(1, 'day').format('YYYY-MM-DD')}</span>\n {data.pendingTips2 && <Text html={data.pendingTips2} />}\n </div>\n )}\n </div>\n <div\n className={cn(\n 'font-bold',\n item.value >= 0 || item.credit_type === CreditType.Expired ? 'text-[#52C41A]' : 'text-[#F84D4F]'\n )}\n >\n {item.value >= 0 && '+'}\n {item.value}\n </div>\n </div>\n ))\n ) : (\n <div className=\"flex h-full flex-col items-center justify-center\">\n <Picture\n className=\"mb-[16px] h-[120px] w-[160px]\"\n source={data?.emptyListImage?.url}\n alt={data?.emptyListImage?.alt || 'empty list image'}\n ></Picture>\n <div className=\"leading-1.4 text-[16px] font-semibold\">{data?.emptyListLabel}</div>\n </div>\n )}\n </>\n )}\n </div>\n {/* \u79EF\u5206\u5230\u8D26\u65F6\u95F4\u63D0\u9192 */}\n {list.length > 0 && <div className=\"mt-[12px] pb-[24px] text-[14px] font-semibold text-[#999]\">{data.tips}</div>}\n </CreditsModalContainer>\n )\n}\n\nexport default ActivitiesModal\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,aAAAE,IAAA,eAAAC,EAAAH,GA+Lc,IAAAI,EAAA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ErH,oBAAC,QAAK,KAAMnB,EAAK,YAAa,KAC9B,OAAC,QAAM,WAAA4B,QAAM,KAAKT,EAAK,YAAY,EAAE,IAAI,EAAG,KAAK,EAAE,OAAO,YAAY,EAAE,EACvEnB,EAAK,iBAAgB,OAAC,QAAK,KAAMA,EAAK,aAAc,GACvD,GAEJ,KACA,QAAC,OACC,aAAW,EAAAwB,YACT,YACAL,EAAK,OAAS,GAAKA,EAAK,cAAgB,aAAW,QAAU,iBAAmB,gBAClF,EAEC,UAAAA,EAAK,OAAS,GAAK,IACnBA,EAAK,OACR,IA7BKQ,CA8BP,CACD,KAED,QAAC,OAAI,UAAU,mDACb,oBAAC,WACC,UAAU,gCACV,OAAQ3B,GAAM,gBAAgB,IAC9B,IAAKA,GAAM,gBAAgB,KAAO,mBACnC,KACD,OAAC,OAAI,UAAU,wCAAyC,SAAAA,GAAM,eAAe,GAC/E,EAEJ,GAEJ,EAECe,EAAK,OAAS,MAAK,OAAC,OAAI,UAAU,4DAA6D,SAAAf,EAAK,KAAK,GAC5G,CAEJ,CAEA,IAAOb,EAAQY",
6
6
  "names": ["activitiesModal_exports", "__export", "activitiesModal_default", "__toCommonJS", "import_jsx_runtime", "import_react", "import_provider", "import_const", "import_useActivities", "import_modalContainer", "import_lib", "import_headless_ui", "import_loadingDots", "import_dayjs", "ActivitiesModal", "data", "props", "page", "setPage", "taskIdToTypeMapping", "brand", "rounded", "myActivitiesOptions", "activeTab", "setActiveTab", "tabs", "activities", "canNext", "isLoading", "useActivities", "list", "taskNameMap", "dtcTaskTypeToNameMap", "getTitle", "item", "filtered", "value", "otherItem", "handleScrollEnd", "cn", "tab", "LoadingDots", "index", "dayjs"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var P=Object.create;var c=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var w=Object.getOwnPropertyNames;var B=Object.getPrototypeOf,F=Object.prototype.hasOwnProperty;var H=(s,t)=>{for(var e in t)c(s,e,{get:t[e],enumerable:!0})},h=(s,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of w(t))!F.call(s,o)&&o!==e&&c(s,o,{get:()=>t[o],enumerable:!(a=k(t,o))||a.enumerable});return s};var O=(s,t,e)=>(e=s!=null?P(B(s)):{},h(t||!s||!s.__esModule?c(e,"default",{value:s,enumerable:!0}):e,s)),U=s=>h(c({},"__esModule",{value:!0}),s);var Y={};H(Y,{CreditsUploadReceiptModal:()=>A});module.exports=U(Y);var i=require("react/jsx-runtime"),n=require("@anker-in/headless-ui"),l=require("react"),m=require("./modalContainer"),N=require("../context/hooks/useUploadReceipt"),b=require("@anker-in/lib"),R=require("../const"),T=O(require("classnames"));function A({isOpen:s,onClose:t,copy:e,onSuccess:a}){const{trigger:o,isMutating:D}=(0,N.useUploadReceipt)(),[p,u]=(0,l.useState)(""),[x,f]=(0,l.useState)(!1),[r,g]=(0,l.useState)({icon:"",title:"",description:"",isSuccess:!1}),{brand:S}=(0,b.useHeadlessContext)(),v=R.roundedBrands.includes(S),I=(0,l.useCallback)(()=>{o({orderName:p},{onSuccess:d=>{if(f(!0),d?.ok)a(),g({icon:e.successIcon,title:e.successTitle||"Success",description:e.successDescription||"Your receipt has been uploaded successfully",isSuccess:!0});else{const z=e.failedReasons.find(M=>M.code===d.code?.toString());g({icon:e.failedIcon,title:e.failedTitle||"Failed",description:z?.description||"Please try again",isSuccess:!1})}}})},[o,p,a,e.successIcon,e.successTitle,e.successDescription,e.failedReasons,e.failedIcon,e.failedTitle]),C=()=>{f(!1),u(""),r.isSuccess&&t()};return(0,i.jsxs)(m.CreditsModalContainer,{isOpen:s,onClose:t,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px]",titleClassName:"h-[56px]",useAnimation:!0,animationClassName:"md:translate-y-[100vh]",children:[(0,i.jsx)(n.Heading,{size:"3",children:e.title}),(0,i.jsx)(n.Text,{size:"3",className:"mt-[8px] md:mt-[4px]",children:e.description}),(0,i.jsx)("input",{placeholder:e.placeholder,className:(0,T.default)("mt-[24px] h-[50px] w-full rounded-[2px] border border-[#6D6D6F] pl-[14px] text-[16px] font-bold placeholder:text-[16px] placeholder:font-bold placeholder:text-[#6D6D6F] focus:outline-none focus:ring-0 md:rounded-[4px] md:placeholder:text-[14px]",!v&&"rounded-none"),value:p,onChange:d=>u(d.target.value)}),(0,i.jsx)(n.Text,{size:"1",as:"p",className:"mt-[8px] text-[#6D6D6F]",children:e.note}),(0,i.jsx)(n.Button,{variant:"primary",className:"mt-[24px] w-full",loading:D,onClick:I,children:e.submit}),x&&(0,i.jsxs)(m.CreditsModalContainer,{isOpen:x,onClose:C,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px] flex flex-col items-center text-center",titleClassName:"h-[56px]",children:[(0,i.jsx)(n.Text,{size:"3",className:"size-[64px]",as:"div",html:r.icon}),(0,i.jsx)(n.Heading,{size:"3",className:"mt-[16px]",children:r.title}),(0,i.jsx)(n.Text,{size:"3",className:"mt-[8px] md:mt-[4px]",children:r.description}),(0,i.jsx)(n.Button,{variant:"primary",className:"mt-[24px]",onClick:C,children:e.gotIt})]})]})}
1
+ "use strict";var M=Object.create;var d=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var P=Object.getOwnPropertyNames;var k=Object.getPrototypeOf,w=Object.prototype.hasOwnProperty;var B=(s,t)=>{for(var e in t)d(s,e,{get:t[e],enumerable:!0})},h=(s,t,e,a)=>{if(t&&typeof t=="object"||typeof t=="function")for(let o of P(t))!w.call(s,o)&&o!==e&&d(s,o,{get:()=>t[o],enumerable:!(a=O(t,o))||a.enumerable});return s};var F=(s,t,e)=>(e=s!=null?M(k(s)):{},h(t||!s||!s.__esModule?d(e,"default",{value:s,enumerable:!0}):e,s)),H=s=>h(d({},"__esModule",{value:!0}),s);var A={};B(A,{CreditsUploadReceiptModal:()=>U});module.exports=H(A);var i=require("react/jsx-runtime"),n=require("@anker-in/headless-ui"),l=require("react"),u=require("./modalContainer"),b=require("../context/hooks/useUploadReceipt"),p=require("@anker-in/lib"),D=F(require("classnames"));function U({isOpen:s,onClose:t,copy:e,onSuccess:a}){const{trigger:o,isMutating:R}=(0,b.useUploadReceipt)(),[m,x]=(0,l.useState)(""),[f,g]=(0,l.useState)(!1),[r,C]=(0,l.useState)({icon:"",title:"",description:"",isSuccess:!1}),{brand:S}=(0,p.useHeadlessContext)(),T=p.ROUNDED_BRANDS.includes(S),v=(0,l.useCallback)(()=>{o({orderName:m},{onSuccess:c=>{if(g(!0),c?.ok)a(),C({icon:e.successIcon,title:e.successTitle||"Success",description:e.successDescription||"Your receipt has been uploaded successfully",isSuccess:!0});else{const I=e.failedReasons.find(z=>z.code===c.code?.toString());C({icon:e.failedIcon,title:e.failedTitle||"Failed",description:I?.description||"Please try again",isSuccess:!1})}}})},[o,m,a,e.successIcon,e.successTitle,e.successDescription,e.failedReasons,e.failedIcon,e.failedTitle]),N=()=>{g(!1),x(""),r.isSuccess&&t()};return(0,i.jsxs)(u.CreditsModalContainer,{isOpen:s,onClose:t,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px]",titleClassName:"h-[56px]",useAnimation:!0,animationClassName:"md:translate-y-[100vh]",children:[(0,i.jsx)(n.Heading,{size:"3",children:e.title}),(0,i.jsx)(n.Text,{size:"3",className:"mt-[8px] md:mt-[4px]",children:e.description}),(0,i.jsx)("input",{placeholder:e.placeholder,className:(0,D.default)("mt-[24px] h-[50px] w-full rounded-[2px] border border-[#6D6D6F] pl-[14px] text-[16px] font-bold placeholder:text-[16px] placeholder:font-bold placeholder:text-[#6D6D6F] focus:outline-none focus:ring-0 md:rounded-[4px] md:placeholder:text-[14px]",!T&&"rounded-none"),value:m,onChange:c=>x(c.target.value)}),(0,i.jsx)(n.Text,{size:"1",as:"p",className:"mt-[8px] text-[#6D6D6F]",children:e.note}),(0,i.jsx)(n.Button,{variant:"primary",className:"mt-[24px] w-full",loading:R,onClick:v,children:e.submit}),f&&(0,i.jsxs)(u.CreditsModalContainer,{isOpen:f,onClose:N,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px] flex flex-col items-center text-center",titleClassName:"h-[56px]",children:[(0,i.jsx)(n.Text,{size:"3",className:"size-[64px]",as:"div",html:r.icon}),(0,i.jsx)(n.Heading,{size:"3",className:"mt-[16px]",children:r.title}),(0,i.jsx)(n.Text,{size:"3",className:"mt-[8px] md:mt-[4px]",children:r.description}),(0,i.jsx)(n.Button,{variant:"primary",className:"mt-[24px]",onClick:N,children:e.gotIt})]})]})}
2
2
  //# sourceMappingURL=creditsUploadReceiptModal.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/modal/creditsUploadReceiptModal.tsx"],
4
- "sourcesContent": ["import { Button, Heading, Text } from '@anker-in/headless-ui'\nimport { useCallback, useState } from 'react'\nimport { CreditsModalContainer } from './modalContainer'\nimport { useUploadReceipt } from '../context/hooks/useUploadReceipt'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { roundedBrands } from '../const'\nimport classNames from 'classnames'\n\nexport type ReceiptCopy = {\n title: string\n description: string\n placeholder: string\n note: string\n submit: string\n successTitle: string\n successDescription: string\n gotIt: string\n failedTitle: string\n successIcon: string\n failedIcon: string\n failedReasons: {\n code: string\n id: string\n description: string\n }[]\n}\n\nexport function CreditsUploadReceiptModal({\n isOpen,\n onClose,\n copy,\n onSuccess,\n}: {\n isOpen: boolean\n onClose: () => void\n copy: ReceiptCopy\n onSuccess: () => void\n}) {\n const { trigger, isMutating } = useUploadReceipt()\n const [orderName, setOrderName] = useState('')\n const [resultPopup, setResultPopup] = useState(false)\n const [resultPopupContent, setResultPopupContent] = useState({\n icon: '',\n title: '',\n description: '',\n isSuccess: false,\n })\n\n const { brand } = useHeadlessContext()\n const rounded = roundedBrands.includes(brand)\n\n const handleSubmit = useCallback(() => {\n trigger(\n { orderName },\n {\n onSuccess: result => {\n setResultPopup(true)\n if (result?.ok) {\n onSuccess()\n setResultPopupContent({\n icon: copy.successIcon,\n title: copy.successTitle || 'Success',\n description: copy.successDescription || 'Your receipt has been uploaded successfully',\n isSuccess: true,\n })\n } else {\n const error = copy.failedReasons.find(reason => reason.code === result.code?.toString())\n setResultPopupContent({\n icon: copy.failedIcon,\n title: copy.failedTitle || 'Failed',\n description: error?.description || 'Please try again',\n isSuccess: false,\n })\n }\n },\n }\n )\n }, [\n trigger,\n orderName,\n onSuccess,\n copy.successIcon,\n copy.successTitle,\n copy.successDescription,\n copy.failedReasons,\n copy.failedIcon,\n copy.failedTitle,\n ])\n\n const handleResultClose = () => {\n setResultPopup(false)\n setOrderName('')\n // \u5982\u679C\u4E0A\u4F20\u6210\u529F\uFF0C\u5168\u90E8\u5F39\u7A97\u5173\u95ED\n if (resultPopupContent.isSuccess) {\n onClose()\n }\n }\n\n return (\n <CreditsModalContainer\n isOpen={isOpen}\n onClose={onClose}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px]\"\n titleClassName=\"h-[56px]\"\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n >\n <Heading size=\"3\">{copy.title}</Heading>\n <Text size=\"3\" className=\"mt-[8px] md:mt-[4px]\">\n {copy.description}\n </Text>\n <input\n placeholder={copy.placeholder}\n className={classNames(\n 'mt-[24px] h-[50px] w-full rounded-[2px] border border-[#6D6D6F] pl-[14px] text-[16px] font-bold placeholder:text-[16px] placeholder:font-bold placeholder:text-[#6D6D6F] focus:outline-none focus:ring-0 md:rounded-[4px] md:placeholder:text-[14px]',\n !rounded && 'rounded-none'\n )}\n value={orderName}\n onChange={e => setOrderName(e.target.value)}\n />\n <Text size=\"1\" as=\"p\" className=\"mt-[8px] text-[#6D6D6F]\">\n {copy.note}\n </Text>\n <Button variant=\"primary\" className=\"mt-[24px] w-full\" loading={isMutating} onClick={handleSubmit}>\n {copy.submit}\n </Button>\n {resultPopup && (\n <CreditsModalContainer\n isOpen={resultPopup}\n onClose={handleResultClose}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px] flex flex-col items-center text-center\"\n titleClassName=\"h-[56px]\"\n >\n <Text size=\"3\" className=\"size-[64px]\" as=\"div\" html={resultPopupContent.icon} />\n <Heading size=\"3\" className=\"mt-[16px]\">\n {resultPopupContent.title}\n </Heading>\n <Text size=\"3\" className=\"mt-[8px] md:mt-[4px]\">\n {resultPopupContent.description}\n </Text>\n <Button variant=\"primary\" className=\"mt-[24px]\" onClick={handleResultClose}>\n {copy.gotIt}\n </Button>\n </CreditsModalContainer>\n )}\n </CreditsModalContainer>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GA4GM,IAAAI,EAAA,6BA5GNC,EAAsC,iCACtCC,EAAsC,iBACtCC,EAAsC,4BACtCC,EAAiC,6CACjCC,EAAmC,yBACnCC,EAA8B,oBAC9BC,EAAuB,yBAqBhB,SAAST,EAA0B,CACxC,OAAAU,EACA,QAAAC,EACA,KAAAC,EACA,UAAAC,CACF,EAKG,CACD,KAAM,CAAE,QAAAC,EAAS,WAAAC,CAAW,KAAI,oBAAiB,EAC3C,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAE,EACvC,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAK,EAC9C,CAACC,EAAoBC,CAAqB,KAAI,YAAS,CAC3D,KAAM,GACN,MAAO,GACP,YAAa,GACb,UAAW,EACb,CAAC,EAEK,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,gBAAc,SAASD,CAAK,EAEtCE,KAAe,eAAY,IAAM,CACrCV,EACE,CAAE,UAAAE,CAAU,EACZ,CACE,UA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AI,UAAU,cAAc,GAAG,MAAM,KAAMR,EAAmB,KAAM,KAC/E,OAAC,WAAQ,KAAK,IAAI,UAAU,YACzB,SAAAA,EAAmB,MACtB,KACA,OAAC,QAAK,KAAK,IAAI,UAAU,uBACtB,SAAAA,EAAmB,YACtB,KACA,OAAC,UAAO,QAAQ,UAAU,UAAU,YAAY,QAASQ,EACtD,SAAAhB,EAAK,MACR,GACF,GAEJ,CAEJ",
6
- "names": ["creditsUploadReceiptModal_exports", "__export", "CreditsUploadReceiptModal", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_react", "import_modalContainer", "import_useUploadReceipt", "import_lib", "import_const", "import_classnames", "isOpen", "onClose", "copy", "onSuccess", "trigger", "isMutating", "orderName", "setOrderName", "resultPopup", "setResultPopup", "resultPopupContent", "setResultPopupContent", "brand", "rounded", "handleSubmit", "result", "error", "reason", "handleResultClose", "classNames", "e"]
4
+ "sourcesContent": ["import { Button, Heading, Text } from '@anker-in/headless-ui'\nimport { useCallback, useState } from 'react'\nimport { CreditsModalContainer } from './modalContainer'\nimport { useUploadReceipt } from '../context/hooks/useUploadReceipt'\nimport { useHeadlessContext, ROUNDED_BRANDS } from '@anker-in/lib'\nimport classNames from 'classnames'\n\nexport type ReceiptCopy = {\n title: string\n description: string\n placeholder: string\n note: string\n submit: string\n successTitle: string\n successDescription: string\n gotIt: string\n failedTitle: string\n successIcon: string\n failedIcon: string\n failedReasons: {\n code: string\n id: string\n description: string\n }[]\n}\n\nexport function CreditsUploadReceiptModal({\n isOpen,\n onClose,\n copy,\n onSuccess,\n}: {\n isOpen: boolean\n onClose: () => void\n copy: ReceiptCopy\n onSuccess: () => void\n}) {\n const { trigger, isMutating } = useUploadReceipt()\n const [orderName, setOrderName] = useState('')\n const [resultPopup, setResultPopup] = useState(false)\n const [resultPopupContent, setResultPopupContent] = useState({\n icon: '',\n title: '',\n description: '',\n isSuccess: false,\n })\n\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n const handleSubmit = useCallback(() => {\n trigger(\n { orderName },\n {\n onSuccess: result => {\n setResultPopup(true)\n if (result?.ok) {\n onSuccess()\n setResultPopupContent({\n icon: copy.successIcon,\n title: copy.successTitle || 'Success',\n description: copy.successDescription || 'Your receipt has been uploaded successfully',\n isSuccess: true,\n })\n } else {\n const error = copy.failedReasons.find(reason => reason.code === result.code?.toString())\n setResultPopupContent({\n icon: copy.failedIcon,\n title: copy.failedTitle || 'Failed',\n description: error?.description || 'Please try again',\n isSuccess: false,\n })\n }\n },\n }\n )\n }, [\n trigger,\n orderName,\n onSuccess,\n copy.successIcon,\n copy.successTitle,\n copy.successDescription,\n copy.failedReasons,\n copy.failedIcon,\n copy.failedTitle,\n ])\n\n const handleResultClose = () => {\n setResultPopup(false)\n setOrderName('')\n // \u5982\u679C\u4E0A\u4F20\u6210\u529F\uFF0C\u5168\u90E8\u5F39\u7A97\u5173\u95ED\n if (resultPopupContent.isSuccess) {\n onClose()\n }\n }\n\n return (\n <CreditsModalContainer\n isOpen={isOpen}\n onClose={onClose}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px]\"\n titleClassName=\"h-[56px]\"\n useAnimation\n animationClassName=\"md:translate-y-[100vh]\"\n >\n <Heading size=\"3\">{copy.title}</Heading>\n <Text size=\"3\" className=\"mt-[8px] md:mt-[4px]\">\n {copy.description}\n </Text>\n <input\n placeholder={copy.placeholder}\n className={classNames(\n 'mt-[24px] h-[50px] w-full rounded-[2px] border border-[#6D6D6F] pl-[14px] text-[16px] font-bold placeholder:text-[16px] placeholder:font-bold placeholder:text-[#6D6D6F] focus:outline-none focus:ring-0 md:rounded-[4px] md:placeholder:text-[14px]',\n !rounded && 'rounded-none'\n )}\n value={orderName}\n onChange={e => setOrderName(e.target.value)}\n />\n <Text size=\"1\" as=\"p\" className=\"mt-[8px] text-[#6D6D6F]\">\n {copy.note}\n </Text>\n <Button variant=\"primary\" className=\"mt-[24px] w-full\" loading={isMutating} onClick={handleSubmit}>\n {copy.submit}\n </Button>\n {resultPopup && (\n <CreditsModalContainer\n isOpen={resultPopup}\n onClose={handleResultClose}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-[48px] md:mb-0 md:pb-[24px] md:px-[16px] flex flex-col items-center text-center\"\n titleClassName=\"h-[56px]\"\n >\n <Text size=\"3\" className=\"size-[64px]\" as=\"div\" html={resultPopupContent.icon} />\n <Heading size=\"3\" className=\"mt-[16px]\">\n {resultPopupContent.title}\n </Heading>\n <Text size=\"3\" className=\"mt-[8px] md:mt-[4px]\">\n {resultPopupContent.description}\n </Text>\n <Button variant=\"primary\" className=\"mt-[24px]\" onClick={handleResultClose}>\n {copy.gotIt}\n </Button>\n </CreditsModalContainer>\n )}\n </CreditsModalContainer>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,+BAAAE,IAAA,eAAAC,EAAAH,GA2GM,IAAAI,EAAA,6BA3GNC,EAAsC,iCACtCC,EAAsC,iBACtCC,EAAsC,4BACtCC,EAAiC,6CACjCC,EAAmD,yBACnDC,EAAuB,yBAqBhB,SAASR,EAA0B,CACxC,OAAAS,EACA,QAAAC,EACA,KAAAC,EACA,UAAAC,CACF,EAKG,CACD,KAAM,CAAE,QAAAC,EAAS,WAAAC,CAAW,KAAI,oBAAiB,EAC3C,CAACC,EAAWC,CAAY,KAAI,YAAS,EAAE,EACvC,CAACC,EAAaC,CAAc,KAAI,YAAS,EAAK,EAC9C,CAACC,EAAoBC,CAAqB,KAAI,YAAS,CAC3D,KAAM,GACN,MAAO,GACP,YAAa,GACb,UAAW,EACb,CAAC,EAEK,CAAE,MAAAC,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,iBAAe,SAASD,CAAK,EAEvCE,KAAe,eAAY,IAAM,CACrCV,EACE,CAAE,UAAAE,CAAU,EACZ,CACE,UAAWS,GAAU,CAEnB,GADAN,E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M,KAAMR,EAAmB,KAAM,KAC/E,OAAC,WAAQ,KAAK,IAAI,UAAU,YACzB,SAAAA,EAAmB,MACtB,KACA,OAAC,QAAK,KAAK,IAAI,UAAU,uBACtB,SAAAA,EAAmB,YACtB,KACA,OAAC,UAAO,QAAQ,UAAU,UAAU,YAAY,QAASQ,EACtD,SAAAhB,EAAK,MACR,GACF,GAEJ,CAEJ",
6
+ "names": ["creditsUploadReceiptModal_exports", "__export", "CreditsUploadReceiptModal", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_react", "import_modalContainer", "import_useUploadReceipt", "import_lib", "import_classnames", "isOpen", "onClose", "copy", "onSuccess", "trigger", "isMutating", "orderName", "setOrderName", "resultPopup", "setResultPopup", "resultPopupContent", "setResultPopupContent", "brand", "rounded", "handleSubmit", "result", "error", "reason", "handleResultClose", "classNames", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var M=Object.create;var d=Object.defineProperty;var E=Object.getOwnPropertyDescriptor;var H=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var D=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let l of H(t))!k.call(e,l)&&l!==n&&d(e,l,{get:()=>t[l],enumerable:!(r=E(t,l))||r.enumerable});return e};var S=(e,t,n)=>(n=e!=null?M(R(e)):{},C(t||!e||!e.__esModule?d(n,"default",{value:e,enumerable:!0}):n,e)),Z=e=>C(d({},"__esModule",{value:!0}),e);var T={};D(T,{CreditsModalContainer:()=>I});module.exports=Z(T);var o=require("react/jsx-runtime"),i=require("@anker-in/lib"),m=require("react"),f=S(require("react-modal")),v=require("../const");const I=({isOpen:e,title:t,className:n="",overlayClassName:r="",scrollClassName:l="",onClose:c,onScrollEnd:p,children:u,useAnimation:x,animationClassName:h,titleClassName:L="",...g})=>{const[b,w]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x&&requestAnimationFrame(()=>{w(e??!1)})},[e,x]);const{brand:N}=(0,i.useHeadlessContext)(),y=v.roundedBrands.includes(N);return(0,o.jsxs)(f.default,{isOpen:e??!1,overlayClassName:(0,i.classNames)("fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end",r),className:(0,i.classNames)("min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none",!y&&"rounded-none",b?"":h,n),onRequestClose:c,...g,children:[(0,o.jsxs)("div",{className:(0,i.classNames)("flex w-full shrink-0 items-center justify-between",t?"min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]":"h-[48px] px-[16px]",L),children:[(0,o.jsx)("div",{className:"text-[18px] font-bold",children:t}),(0,o.jsx)("div",{className:"size-[22px] cursor-pointer",onClick:c,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),c?.())},role:"button",tabIndex:0,children:(0,o.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:(0,o.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z",fill:"#333333"})})})]}),(0,o.jsx)("div",{className:(0,i.classNames)("my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]",!t&&"mt-0","min-l:px-[32px]",l),onScroll:s=>{const a=s.target;a.scrollHeight<=a.clientHeight||a.scrollTop+a.clientHeight>=a.scrollHeight-50&&p&&p(s)},children:u})]})};
1
+ "use strict";var y=Object.create;var d=Object.defineProperty;var M=Object.getOwnPropertyDescriptor;var E=Object.getOwnPropertyNames;var R=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty;var H=(e,t)=>{for(var n in t)d(e,n,{get:t[n],enumerable:!0})},C=(e,t,n,r)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of E(t))!D.call(e,i)&&i!==n&&d(e,i,{get:()=>t[i],enumerable:!(r=M(t,i))||r.enumerable});return e};var k=(e,t,n)=>(n=e!=null?y(R(e)):{},C(t||!e||!e.__esModule?d(n,"default",{value:e,enumerable:!0}):n,e)),S=e=>C(d({},"__esModule",{value:!0}),e);var A={};H(A,{CreditsModalContainer:()=>Z});module.exports=S(A);var l=require("react/jsx-runtime"),o=require("@anker-in/lib"),m=require("react"),f=k(require("react-modal"));const Z=({isOpen:e,title:t,className:n="",overlayClassName:r="",scrollClassName:i="",onClose:c,onScrollEnd:p,children:v,useAnimation:x,animationClassName:u,titleClassName:h="",...L})=>{const[g,b]=(0,m.useState)(!1);(0,m.useEffect)(()=>{x&&requestAnimationFrame(()=>{b(e??!1)})},[e,x]);const{brand:w}=(0,o.useHeadlessContext)(),N=o.ROUNDED_BRANDS.includes(w);return(0,l.jsxs)(f.default,{isOpen:e??!1,overlayClassName:(0,o.classNames)("fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end",r),className:(0,o.classNames)("min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none",!N&&"rounded-none",g?"":u,n),onRequestClose:c,...L,children:[(0,l.jsxs)("div",{className:(0,o.classNames)("flex w-full shrink-0 items-center justify-between",t?"min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]":"h-[48px] px-[16px]",h),children:[(0,l.jsx)("div",{className:"text-[18px] font-bold",children:t}),(0,l.jsx)("div",{className:"size-[22px] cursor-pointer",onClick:c,onKeyDown:s=>{(s.key==="Enter"||s.key===" ")&&(s.preventDefault(),c?.())},role:"button",tabIndex:0,children:(0,l.jsx)("svg",{xmlns:"http://www.w3.org/2000/svg",width:"22",height:"22",viewBox:"0 0 22 22",fill:"none",children:(0,l.jsx)("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z",fill:"#333333"})})})]}),(0,l.jsx)("div",{className:(0,o.classNames)("my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]",!t&&"mt-0","min-l:px-[32px]",i),onScroll:s=>{const a=s.target;a.scrollHeight<=a.clientHeight||a.scrollTop+a.clientHeight>=a.scrollHeight-50&&p&&p(s)},children:v})]})};
2
2
  //# sourceMappingURL=modalContainer.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/modal/modalContainer.tsx"],
4
- "sourcesContent": ["import { classNames as cn, useHeadlessContext } from '@anker-in/lib'\nimport { useEffect, useState, type UIEvent } from 'react'\nimport ReactModal from 'react-modal'\nimport { roundedBrands } from '../const'\n\nexport type ModalContainerProps = {\n overlayClassName?: string\n className?: string\n scrollClassName?: string\n title?: string\n titleClassName?: string\n useAnimation?: boolean // \u4F7F\u7528\u52A8\u753B\u5C55\u793A\n animationClassName?: string // \u52A8\u753B\u5C55\u793A\u63A7\u5236\u7684classname\n isOpen: boolean\n children?: any\n onClose: () => void\n onScrollEnd?: (event: UIEvent<HTMLDivElement>) => void\n}\n\nexport const CreditsModalContainer = ({\n isOpen,\n title,\n className = '',\n overlayClassName = '',\n scrollClassName = '',\n onClose,\n onScrollEnd,\n children,\n useAnimation,\n animationClassName,\n titleClassName = '',\n ...props\n}: ModalContainerProps): React.ReactElement => {\n const [animationShow, setAnimationShow] = useState(false)\n\n useEffect(() => {\n if (!useAnimation) {\n return\n }\n requestAnimationFrame(() => {\n setAnimationShow(isOpen ?? false)\n })\n }, [isOpen, useAnimation])\n\n const { brand } = useHeadlessContext()\n const rounded = roundedBrands.includes(brand)\n\n return (\n <ReactModal\n isOpen={isOpen ?? false}\n overlayClassName={cn(\n 'fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end',\n overlayClassName\n )}\n className={cn(\n 'min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none',\n !rounded && 'rounded-none',\n animationShow ? '' : animationClassName,\n className\n )}\n onRequestClose={onClose}\n {...props}\n >\n <div\n className={cn(\n 'flex w-full shrink-0 items-center justify-between',\n title ? 'min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]' : 'h-[48px] px-[16px]',\n titleClassName\n )}\n >\n <div className=\"text-[18px] font-bold\">{title}</div>\n <div\n className=\"size-[22px] cursor-pointer\"\n onClick={onClose}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClose?.()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z\"\n fill=\"#333333\"\n />\n </svg>\n </div>\n </div>\n <div\n className={cn(\n 'my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]',\n !title && 'mt-0',\n 'min-l:px-[32px]',\n scrollClassName\n )}\n onScroll={event => {\n const targetElement = event.target as HTMLDivElement\n\n if (targetElement.scrollHeight <= targetElement.clientHeight) {\n return\n }\n\n if (targetElement.scrollTop + targetElement.clientHeight >= targetElement.scrollHeight - 50) {\n onScrollEnd && onScrollEnd(event)\n }\n }}\n >\n {children}\n </div>\n </ReactModal>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GA+DM,IAAAI,EAAA,6BA/DNC,EAAqD,yBACrDC,EAAkD,iBAClDC,EAAuB,0BACvBC,EAA8B,oBAgBvB,MAAMN,EAAwB,CAAC,CACpC,OAAAO,EACA,MAAAC,EACA,UAAAC,EAAY,GACZ,iBAAAC,EAAmB,GACnB,gBAAAC,EAAkB,GAClB,QAAAC,EACA,YAAAC,EACA,SAAAC,EACA,aAAAC,EACA,mBAAAC,EACA,eAAAC,EAAiB,GACjB,GAAGC,CACL,IAA+C,CAC7C,KAAM,CAACC,EAAeC,CAAgB,KAAI,YAAS,EAAK,KAExD,aAAU,IAAM,CACTL,GAGL,sBAAsB,IAAM,CAC1BK,EAAiBb,GAAU,EAAK,CAClC,CAAC,CACH,EAAG,CAACA,EAAQQ,CAAY,CAAC,EAEzB,KAAM,CAAE,MAAAM,CAAM,KAAI,sBAAmB,EAC/BC,EAAU,gBAAc,SAASD,CAAK,EAE5C,SACE,QAAC,EAAAE,QAAA,CACC,OAAQhB,GAAU,GAClB,oBAAkB,EAAAiB,YAChB,gGACAd,CACF,EACA,aAAW,EAAAc,YACT,mMACA,CAACF,GAAW,eACZH,EAAgB,GAAKH,EACrBP,CACF,EACA,eAAgBG,EACf,GAAGM,EAEJ,qBAAC,OACC,aAAW,EAAAM,YACT,oDACAhB,EAAQ,+DAAiE,qBACzES,CACF,EAEA,oBAAC,OAAI,UAAU,wBAAyB,SAAAT,EAAM,KAC9C,OAAC,OACC,UAAU,6BACV,QAASI,EACT,UAAWa,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,OACjCA,EAAE,eAAe,EACjBb,IAAU,EAEd,EACA,KAAK,SACL,SAAU,EAEV,mBAAC,OAAI,MAAM,6BAA6B,MAAM,KAAK,OAAO,KAAK,QAAQ,YAAY,KAAK,OACtF,mBAAC,QACC,SAAS,UACT,SAAS,UACT,EAAE,syCACF,KAAK,UACP,EACF,EACF,GACF,KACA,OAAC,OACC,aAAW,EAAAY,YACT,2EACA,CAAChB,GAAS,OACV,kBACAG,CACF,EACA,SAAUe,GAAS,CACjB,MAAMC,EAAgBD,EAAM,OAExBC,EAAc,cAAgBA,EAAc,cAI5CA,EAAc,UAAYA,EAAc,cAAgBA,EAAc,aAAe,IACvFd,GAAeA,EAAYa,CAAK,CAEpC,EAEC,SAAAZ,EACH,GACF,CAEJ",
6
- "names": ["modalContainer_exports", "__export", "CreditsModalContainer", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_react", "import_react_modal", "import_const", "isOpen", "title", "className", "overlayClassName", "scrollClassName", "onClose", "onScrollEnd", "children", "useAnimation", "animationClassName", "titleClassName", "props", "animationShow", "setAnimationShow", "brand", "rounded", "ReactModal", "cn", "e", "event", "targetElement"]
4
+ "sourcesContent": ["import { classNames as cn, useHeadlessContext, ROUNDED_BRANDS } from '@anker-in/lib'\nimport { useEffect, useState, type UIEvent } from 'react'\nimport ReactModal from 'react-modal'\n\nexport type ModalContainerProps = {\n overlayClassName?: string\n className?: string\n scrollClassName?: string\n title?: string\n titleClassName?: string\n useAnimation?: boolean // \u4F7F\u7528\u52A8\u753B\u5C55\u793A\n animationClassName?: string // \u52A8\u753B\u5C55\u793A\u63A7\u5236\u7684classname\n isOpen: boolean\n children?: any\n onClose: () => void\n onScrollEnd?: (event: UIEvent<HTMLDivElement>) => void\n}\n\nexport const CreditsModalContainer = ({\n isOpen,\n title,\n className = '',\n overlayClassName = '',\n scrollClassName = '',\n onClose,\n onScrollEnd,\n children,\n useAnimation,\n animationClassName,\n titleClassName = '',\n ...props\n}: ModalContainerProps): React.ReactElement => {\n const [animationShow, setAnimationShow] = useState(false)\n\n useEffect(() => {\n if (!useAnimation) {\n return\n }\n requestAnimationFrame(() => {\n setAnimationShow(isOpen ?? false)\n })\n }, [isOpen, useAnimation])\n\n const { brand } = useHeadlessContext()\n const rounded = ROUNDED_BRANDS.includes(brand)\n\n return (\n <ReactModal\n isOpen={isOpen ?? false}\n overlayClassName={cn(\n 'fixed inset-0 z-[999] flex items-center justify-center bg-black/70 leading-[1.2] md:items-end',\n overlayClassName\n )}\n className={cn(\n 'min-md:max-h-[calc(100vh-96px)] relative flex min-h-[200px] flex-col overflow-hidden rounded-[16px] bg-white outline-none transition-all duration-300 md:h-[88.27vh] md:w-full md:rounded-b-none',\n !rounded && 'rounded-none',\n animationShow ? '' : animationClassName,\n className\n )}\n onRequestClose={onClose}\n {...props}\n >\n <div\n className={cn(\n 'flex w-full shrink-0 items-center justify-between',\n title ? 'min-l:px-[32px] h-[70px] border-b border-[#e2e2e2] px-[24px]' : 'h-[48px] px-[16px]',\n titleClassName\n )}\n >\n <div className=\"text-[18px] font-bold\">{title}</div>\n <div\n className=\"size-[22px] cursor-pointer\"\n onClick={onClose}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n onClose?.()\n }\n }}\n role=\"button\"\n tabIndex={0}\n >\n <svg xmlns=\"http://www.w3.org/2000/svg\" width=\"22\" height=\"22\" viewBox=\"0 0 22 22\" fill=\"none\">\n <path\n fillRule=\"evenodd\"\n clipRule=\"evenodd\"\n d=\"M16.8525 5.31015C16.4558 4.91337 15.8125 4.91338 15.4157 5.31015L11.1268 9.5991L6.83815 5.31049C6.44138 4.91372 5.79808 4.91372 5.40131 5.31049C5.00454 5.70726 5.00455 6.35055 5.40131 6.74732L9.68993 11.0359L5.40105 15.3248C5.00428 15.7216 5.00428 16.3649 5.40105 16.7616C5.79782 17.1584 6.44111 17.1584 6.83788 16.7616L11.1268 12.4728L15.416 16.762C15.8128 17.1588 16.456 17.1588 16.8528 16.762C17.2496 16.3652 17.2496 15.7219 16.8528 15.3252L12.5636 11.0359L16.8525 6.74698C17.2493 6.35021 17.2493 5.70692 16.8525 5.31015ZM16.921 6.02856C16.921 6.22992 16.8441 6.43127 16.6905 6.5849L14.465 8.8104L12.2395 11.0359L12.2395 11.0359L16.6905 6.58493C16.8441 6.43129 16.921 6.22993 16.921 6.02856ZM5.34966 6.19087C5.37992 6.3354 5.45115 6.47307 5.56336 6.58528L10.014 11.0359L10.014 11.0359L5.56336 6.58524C5.45116 6.47304 5.37992 6.33539 5.34966 6.19087ZM5.35087 16.2121C5.38193 16.3541 5.45267 16.4891 5.56309 16.5996C5.87037 16.9068 6.36856 16.9068 6.67583 16.5996L11.1268 12.1486L15.578 16.5999C15.8853 16.9072 16.3835 16.9072 16.6908 16.5999C16.8498 16.4409 16.9265 16.2307 16.9209 16.0223C16.9265 16.2307 16.8498 16.4409 16.6908 16.5999C16.3835 16.9072 15.8853 16.9072 15.578 16.5999L11.1268 12.1487L6.67583 16.5996C6.36856 16.9069 5.87037 16.9069 5.56309 16.5996C5.45267 16.4892 5.38192 16.3541 5.35087 16.2121Z\"\n fill=\"#333333\"\n />\n </svg>\n </div>\n </div>\n <div\n className={cn(\n 'my-[32px] flex-1 overflow-auto overscroll-contain px-[24px] md:mb-[48px]',\n !title && 'mt-0',\n 'min-l:px-[32px]',\n scrollClassName\n )}\n onScroll={event => {\n const targetElement = event.target as HTMLDivElement\n\n if (targetElement.scrollHeight <= targetElement.clientHeight) {\n return\n }\n\n if (targetElement.scrollTop + targetElement.clientHeight >= targetElement.scrollHeight - 50) {\n onScrollEnd && onScrollEnd(event)\n }\n }}\n >\n {children}\n </div>\n </ReactModal>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,2BAAAE,IAAA,eAAAC,EAAAH,GA8DM,IAAAI,EAAA,6BA9DNC,EAAqE,yBACrEC,EAAkD,iBAClDC,EAAuB,0BAgBhB,MAAML,EAAwB,CAAC,CACpC,OAAAM,EACA,MAAAC,EACA,UAA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GAAeA,EAAYa,CAAK,CAEpC,EAEC,SAAAZ,EACH,GACF,CAEJ",
6
+ "names": ["modalContainer_exports", "__export", "CreditsModalContainer", "__toCommonJS", "import_jsx_runtime", "import_lib", "import_react", "import_react_modal", "isOpen", "title", "className", "overlayClassName", "scrollClassName", "onClose", "onScrollEnd", "children", "useAnimation", "animationClassName", "titleClassName", "props", "animationShow", "setAnimationShow", "brand", "rounded", "ReactModal", "cn", "e", "event", "targetElement"]
7
7
  }