@anker-in/campaign-ui 0.2.10-beta.34 → 0.2.10-beta.35

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 (76) hide show
  1. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
  2. package/dist/cjs/components/credits/context/hooks/useRedeemAndBuy.js.map +2 -2
  3. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.d.ts +2 -1
  4. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js +1 -1
  5. package/dist/cjs/components/credits/context/hooks/useRedeemCoupon.js.map +2 -2
  6. package/dist/cjs/components/credits/context/hooks/useUploadReceipt.js +1 -1
  7. package/dist/cjs/components/credits/context/hooks/useUploadReceipt.js.map +2 -2
  8. package/dist/cjs/components/credits/creditsCash/RedeemableItem.d.ts +0 -2
  9. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js +1 -1
  10. package/dist/cjs/components/credits/creditsCash/RedeemableItem.js.map +3 -3
  11. package/dist/cjs/components/credits/creditsCash/index.d.ts +0 -2
  12. package/dist/cjs/components/credits/creditsCash/index.js +1 -1
  13. package/dist/cjs/components/credits/creditsCash/index.js.map +3 -3
  14. package/dist/cjs/components/credits/creditsFaq/index.js +1 -1
  15. package/dist/cjs/components/credits/creditsFaq/index.js.map +1 -1
  16. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
  17. package/dist/cjs/components/credits/creditsRedeemList/AddressForm/index.js.map +2 -2
  18. package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js +1 -1
  19. package/dist/cjs/components/credits/creditsRedeemList/RedeemCouponModal.js.map +2 -2
  20. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js +1 -1
  21. package/dist/cjs/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +2 -2
  22. package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
  23. package/dist/cjs/components/credits/creditsRedeemList/RedeemableItem.js.map +2 -2
  24. package/dist/cjs/components/credits/creditsRedeemList/index.d.ts +0 -1
  25. package/dist/cjs/components/credits/creditsRedeemList/index.js +1 -1
  26. package/dist/cjs/components/credits/creditsRedeemList/index.js.map +2 -2
  27. package/dist/cjs/components/credits/creditsWaysToGetCredits/index.js +1 -1
  28. package/dist/cjs/components/credits/creditsWaysToGetCredits/index.js.map +3 -3
  29. package/dist/cjs/components/credits/creditsWaysToGetCredits/type.d.ts +0 -1
  30. package/dist/cjs/components/credits/creditsWaysToGetCredits/type.js +1 -1
  31. package/dist/cjs/components/credits/creditsWaysToGetCredits/type.js.map +1 -1
  32. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js +1 -1
  33. package/dist/esm/components/credits/context/hooks/useRedeemAndBuy.js.map +2 -2
  34. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.d.ts +2 -1
  35. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js +1 -1
  36. package/dist/esm/components/credits/context/hooks/useRedeemCoupon.js.map +2 -2
  37. package/dist/esm/components/credits/context/hooks/useUploadReceipt.js +1 -1
  38. package/dist/esm/components/credits/context/hooks/useUploadReceipt.js.map +2 -2
  39. package/dist/esm/components/credits/creditsCash/RedeemableItem.d.ts +0 -2
  40. package/dist/esm/components/credits/creditsCash/RedeemableItem.js +1 -1
  41. package/dist/esm/components/credits/creditsCash/RedeemableItem.js.map +3 -3
  42. package/dist/esm/components/credits/creditsCash/index.d.ts +0 -2
  43. package/dist/esm/components/credits/creditsCash/index.js +1 -1
  44. package/dist/esm/components/credits/creditsCash/index.js.map +3 -3
  45. package/dist/esm/components/credits/creditsFaq/index.js +1 -1
  46. package/dist/esm/components/credits/creditsFaq/index.js.map +1 -1
  47. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js +1 -1
  48. package/dist/esm/components/credits/creditsRedeemList/AddressForm/index.js.map +2 -2
  49. package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js +1 -1
  50. package/dist/esm/components/credits/creditsRedeemList/RedeemCouponModal.js.map +2 -2
  51. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js +1 -1
  52. package/dist/esm/components/credits/creditsRedeemList/RedeemProductModal/index.js.map +2 -2
  53. package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js +1 -1
  54. package/dist/esm/components/credits/creditsRedeemList/RedeemableItem.js.map +2 -2
  55. package/dist/esm/components/credits/creditsRedeemList/index.d.ts +0 -1
  56. package/dist/esm/components/credits/creditsRedeemList/index.js +1 -1
  57. package/dist/esm/components/credits/creditsRedeemList/index.js.map +2 -2
  58. package/dist/esm/components/credits/creditsWaysToGetCredits/index.js +1 -1
  59. package/dist/esm/components/credits/creditsWaysToGetCredits/index.js.map +2 -2
  60. package/dist/esm/components/credits/creditsWaysToGetCredits/type.d.ts +0 -1
  61. package/dist/esm/components/credits/creditsWaysToGetCredits/type.js +1 -1
  62. package/dist/esm/components/credits/creditsWaysToGetCredits/type.js.map +1 -1
  63. package/package.json +1 -1
  64. package/src/components/credits/context/hooks/useRedeemAndBuy.ts +3 -1
  65. package/src/components/credits/context/hooks/useRedeemCoupon.ts +2 -1
  66. package/src/components/credits/context/hooks/useUploadReceipt.tsx +0 -1
  67. package/src/components/credits/creditsCash/RedeemableItem.tsx +15 -15
  68. package/src/components/credits/creditsCash/index.tsx +25 -27
  69. package/src/components/credits/creditsFaq/index.tsx +1 -1
  70. package/src/components/credits/creditsRedeemList/AddressForm/index.tsx +0 -1
  71. package/src/components/credits/creditsRedeemList/RedeemCouponModal.tsx +1 -1
  72. package/src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx +0 -1
  73. package/src/components/credits/creditsRedeemList/RedeemableItem.tsx +4 -4
  74. package/src/components/credits/creditsRedeemList/index.tsx +0 -4
  75. package/src/components/credits/creditsWaysToGetCredits/index.tsx +1 -2
  76. package/src/components/credits/creditsWaysToGetCredits/type.ts +0 -1
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/creditsRedeemList/RedeemProductModal/index.tsx"],
4
- "sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../../context/provider'\nimport useCountries from '../../context/hooks/useCountries'\nimport { AlpcErrorCode } from '../../context/const'\nimport { useAddressValidate } from '../../context/hooks/useAddressValidate'\nimport { useRedeemProduct } from '../../context/hooks/useRedeemProduct'\nimport type { ModalContainerProps } from '../../modal/modalContainer'\nimport { CreditsModalContainer } from '../../modal/modalContainer'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { CreditsRedeemListCopy } from '../type'\nimport { Error } from './Error'\nimport { Success } from './Success'\nimport { Address } from './Address'\nimport { Init } from './Init'\n\ntype RedeemProductModalProps = ModalContainerProps & {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n onError: (code: AlpcErrorCode) => void\n}\n\nfunction RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {\n const { fetchCreditInfo, profile } = useCreditsContext()\n const { storeDomain, locale } = useHeadlessContext()\n\n const { validatorInfo } = copy\n const { shippingAddress, shippingProduct } = copy.redeemModal.product\n\n const [status, setStatus] = useState<'init' | 'address' | 'success' | 'error'>('init')\n const [address, setAddress] = useState<any>()\n const [errorInfo, setErrorInfo] = useState({\n code: 0,\n message: '',\n imageUrl: '',\n })\n const [disabled, setDisabled] = useState(false)\n\n const { countries = [], isLoading: countriesLoading } = useCountries({ shopifyStoreDomain: storeDomain })\n\n const { isMutating: loading, trigger } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n return\n }\n\n if (responseData?.code === 0) {\n fetchCreditInfo(profile?.user_id)\n setStatus('success')\n } else {\n let errorMsg\n let errorImage\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemModal.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.redeemModal.inventoryNotEnough\n setDisabled(true)\n errorImage = copy.redeemModal.inventoryNotEnough\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.redeemModal.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.redeemModal.crossSiteError\n setDisabled(true)\n }\n\n setStatus('error')\n setErrorInfo({\n code: responseData.code,\n imageUrl: errorImage || copy.redeemModal.errorImageUrl || '',\n message: errorMsg || copy.redeemModal.commonError || '',\n })\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n },\n })\n\n const stateInputKey = useMemo(() => {\n const stateInput = copy?.redeemModal.product.form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [copy?.redeemModal.product.form])\n\n const { validate: validateAddress, errors: validateErrors } = useAddressValidate({\n address: address,\n validatorInfo: validatorInfo,\n formData: copy?.redeemModal.product.form?.flat() || [],\n errorLabel: {\n require: copy.redeemModal.product.required,\n email: copy.redeemModal.product.invalidEmail,\n },\n })\n\n const handlePayment = useCallback(async () => {\n const ignoreKeys: string[] = []\n\n if (stateInputKey) {\n const provinces = countries.find(item => item.code === address.country)?.provinces || []\n\n if (!provinces.length) {\n ignoreKeys.push(stateInputKey as never)\n }\n }\n\n if (\n validateAddress({\n force: true,\n ignoreKeys,\n })\n ) {\n // \u5730\u5740\u6821\u9A8C\u9519\u8BEF\n return\n }\n console.log('address', address)\n let requestAddress = { ...address }\n if (requestAddress.name) {\n delete requestAddress.name\n }\n if (requestAddress.country === 'UK') {\n requestAddress.country = 'GB'\n }\n trigger({\n address: btoa(JSON.stringify(requestAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }, [item, trigger, stateInputKey, validateAddress, address, countries])\n\n useEffect(() => {\n if (!props.isOpen) {\n setDisabled(false)\n setErrorInfo({ code: 0, message: '', imageUrl: '' })\n }\n }, [props.isOpen, locale])\n\n return (\n <CreditsModalContainer\n {...props}\n className={classNames(\n 'w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]',\n status !== 'init' && 'w-[740px] md:w-full'\n )}\n scrollClassName=\"mb-0 min-l:px-0 md:mb-0 px-0\"\n titleClassName={classNames('h-[56px]', status === 'init' && 'bg-[#F5F5F7]')}\n title={status === 'address' ? 'Order Confirmation' : ''}\n >\n {status === 'error' && <Error errorInfo={errorInfo} />}\n {status === 'success' && (\n <Success\n copy={copy}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n onClose={props.onClose}\n item={item}\n />\n )}\n {status === 'address' && (\n <Address\n copy={copy}\n shippingAddress={shippingAddress}\n setAddress={setAddress}\n validateAddress={validateAddress}\n validateErrors={validateErrors}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n handlePayment={handlePayment}\n item={item}\n />\n )}\n {status === 'init' && (\n <Init item={item} copy={copy} loading={loading} disabled={disabled} setStatus={setStatus} />\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemProductModal\n"],
5
- "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAuJI,IAAAI,EAAA,6BAvJJC,EAAuB,yBACvBC,EAA0D,iBAC1DC,EAAkC,kCAClCC,EAAyB,+CACzBC,EAA8B,+BAC9BC,EAAmC,kDACnCC,EAAiC,gDAEjCC,EAAsC,sCAEtCC,EAAmC,yBAEnCC,EAAsB,mBACtBC,EAAwB,qBACxBC,EAAwB,qBACxBC,EAAqB,kBAQrB,SAASC,GAAmB,CAAE,KAAAC,EAAM,KAAAC,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/B,CAAC,CACH,EAAG,CAACA,EAAMuB,EAASK,EAAeC,EAAiBhB,EAASM,CAAS,CAAC,EAEtE,sBAAU,IAAM,CACThB,EAAM,SACTe,EAAY,EAAK,EACjBF,EAAa,CAAE,KAAM,EAAG,QAAS,GAAI,SAAU,EAAG,CAAC,EAEvD,EAAG,CAACb,EAAM,OAAQI,CAAM,CAAC,KAGvB,QAAC,yBACE,GAAGJ,EACJ,aAAW,EAAA+B,SACT,sDACAvB,IAAW,QAAU,qBACvB,EACA,gBAAgB,+BAChB,kBAAgB,EAAAuB,SAAW,WAAYvB,IAAW,QAAU,cAAc,EAC1E,MAAOA,IAAW,UAAY,qBAAuB,GAEpD,UAAAA,IAAW,YAAW,OAAC,SAAM,UAAWI,EAAW,EACnDJ,IAAW,cACV,OAAC,WACC,KAAMV,EACN,gBAAiBS,EACjB,QAASY,EACT,QAAST,EACT,SAAUI,EACV,QAASd,EAAM,QACf,KAAMH,EACR,EAEDW,IAAW,cACV,OAAC,WACC,KAAMV,EACN,gBAAiBQ,EACjB,WAAYK,EACZ,gBAAiBe,EACjB,eAAgBC,EAChB,gBAAiBpB,EACjB,QAASY,EACT,QAAST,EACT,SAAUI,EACV,cAAec,EACf,KAAM/B,EACR,EAEDW,IAAW,WACV,OAAC,QAAK,KAAMX,EAAM,KAAMC,EAAM,QAASqB,EAAS,SAAUL,EAAU,UAAWL,EAAW,GAE9F,CAEJ,CAEA,IAAO7B,GAAQgB",
4
+ "sourcesContent": ["import classNames from 'classnames'\nimport { useCallback, useEffect, useMemo, useState } from 'react'\nimport { useCreditsContext } from '../../context/provider'\nimport useCountries from '../../context/hooks/useCountries'\nimport { AlpcErrorCode } from '../../context/const'\nimport { useAddressValidate } from '../../context/hooks/useAddressValidate'\nimport { useRedeemProduct } from '../../context/hooks/useRedeemProduct'\nimport type { ModalContainerProps } from '../../modal/modalContainer'\nimport { CreditsModalContainer } from '../../modal/modalContainer'\nimport type { RedeemableItem as RedeemableItemType } from '../../type'\nimport { useHeadlessContext } from '@anker-in/lib'\nimport { CreditsRedeemListCopy } from '../type'\nimport { Error } from './Error'\nimport { Success } from './Success'\nimport { Address } from './Address'\nimport { Init } from './Init'\n\ntype RedeemProductModalProps = ModalContainerProps & {\n item: RedeemableItemType\n copy: CreditsRedeemListCopy\n onError: (code: AlpcErrorCode) => void\n}\n\nfunction RedeemProductModal({ item, copy, onError, ...props }: RedeemProductModalProps) {\n const { fetchCreditInfo, profile } = useCreditsContext()\n const { storeDomain, locale } = useHeadlessContext()\n\n const { validatorInfo } = copy\n const { shippingAddress, shippingProduct } = copy.redeemModal.product\n\n const [status, setStatus] = useState<'init' | 'address' | 'success' | 'error'>('init')\n const [address, setAddress] = useState<any>()\n const [errorInfo, setErrorInfo] = useState({\n code: 0,\n message: '',\n imageUrl: '',\n })\n const [disabled, setDisabled] = useState(false)\n\n const { countries = [], isLoading: countriesLoading } = useCountries({ shopifyStoreDomain: storeDomain })\n\n const { isMutating: loading, trigger } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n return\n }\n\n if (responseData?.code === 0) {\n fetchCreditInfo(profile?.user_id)\n setStatus('success')\n } else {\n let errorMsg\n let errorImage\n if (responseData.code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy.redeemModal.redeemLimitError\n setDisabled(true)\n } else if (responseData.code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy.redeemModal.inventoryNotEnough\n setDisabled(true)\n errorImage = copy.redeemModal.inventoryNotEnough\n } else if (responseData.code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy.redeemModal.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (responseData.code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy.redeemModal.crossSiteError\n setDisabled(true)\n }\n\n setStatus('error')\n setErrorInfo({\n code: responseData.code,\n imageUrl: errorImage || copy.redeemModal.errorImageUrl || '',\n message: errorMsg || copy.redeemModal.commonError || '',\n })\n onError && onError(responseData.code)\n }\n },\n onError(error) {\n setStatus('error')\n setErrorInfo({\n code: 0,\n imageUrl: copy.redeemModal.errorImageUrl || '',\n message: copy.redeemModal.commonError || '',\n })\n },\n })\n\n const stateInputKey = useMemo(() => {\n const stateInput = copy?.redeemModal.product.form?.flat().find(item => item.type === 'state')\n return stateInput?.key\n }, [copy?.redeemModal.product.form])\n\n const { validate: validateAddress, errors: validateErrors } = useAddressValidate({\n address: address,\n validatorInfo: validatorInfo,\n formData: copy?.redeemModal.product.form?.flat() || [],\n errorLabel: {\n require: copy.redeemModal.product.required,\n email: copy.redeemModal.product.invalidEmail,\n },\n })\n\n const handlePayment = useCallback(async () => {\n const ignoreKeys: string[] = []\n\n if (stateInputKey) {\n const provinces = countries.find(item => item.code === address.country)?.provinces || []\n\n if (!provinces.length) {\n ignoreKeys.push(stateInputKey as never)\n }\n }\n\n if (\n validateAddress({\n force: true,\n ignoreKeys,\n })\n ) {\n // \u5730\u5740\u6821\u9A8C\u9519\u8BEF\n return\n }\n let requestAddress = { ...address }\n if (requestAddress.name) {\n delete requestAddress.name\n }\n if (requestAddress.country === 'UK') {\n requestAddress.country = 'GB'\n }\n trigger({\n address: btoa(JSON.stringify(requestAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }, [item, trigger, stateInputKey, validateAddress, address, countries])\n\n useEffect(() => {\n if (!props.isOpen) {\n setDisabled(false)\n setErrorInfo({ code: 0, message: '', imageUrl: '' })\n }\n }, [props.isOpen, locale])\n\n return (\n <CreditsModalContainer\n {...props}\n className={classNames(\n 'w-[540px] md:h-auto min-md:max-h-[calc(100vh-40px)]',\n status !== 'init' && 'w-[740px] md:w-full'\n )}\n scrollClassName=\"mb-0 min-l:px-0 md:mb-0 px-0\"\n titleClassName={classNames('h-[56px]', status === 'init' && 'bg-[#F5F5F7]')}\n title={status === 'address' ? 'Order Confirmation' : ''}\n >\n {status === 'error' && <Error errorInfo={errorInfo} />}\n {status === 'success' && (\n <Success\n copy={copy}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n onClose={props.onClose}\n item={item}\n />\n )}\n {status === 'address' && (\n <Address\n copy={copy}\n shippingAddress={shippingAddress}\n setAddress={setAddress}\n validateAddress={validateAddress}\n validateErrors={validateErrors}\n shippingProduct={shippingProduct}\n loading={loading}\n address={address}\n disabled={disabled}\n handlePayment={handlePayment}\n item={item}\n />\n )}\n {status === 'init' && (\n <Init item={item} copy={copy} loading={loading} disabled={disabled} setStatus={setStatus} />\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemProductModal\n"],
5
+ "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,aAAAE,KAAA,eAAAC,EAAAH,IAsJI,IAAAI,EAAA,6BAtJJC,EAAuB,yBACvBC,EAA0D,iBAC1DC,EAAkC,kCAClCC,EAAyB,+CACzBC,EAA8B,+BAC9BC,EAAmC,kDACnCC,EAAiC,gDAEjCC,EAAsC,sCAEtCC,EAAmC,yBAEnCC,EAAsB,mBACtBC,EAAwB,qBACxBC,EAAwB,qBACxBC,EAAqB,kBAQrB,SAASC,GAAmB,CAAE,KAAAC,EAAM,KAAAC,EAAM,QAAAC,EAAS,GAAGC,CAAM,EAA4B,CACtF,KAAM,CAAE,gBAAAC,EAAiB,QAAAC,CAAQ,KAAI,qBAAkB,EACjD,CAAE,YAAAC,EAAa,OAAAC,CAAO,KAAI,sBAAmB,EAE7C,CAAE,cAAAC,CAAc,EAAIP,EACpB,CAAE,gBAAAQ,EAAiB,gBAAAC,CAAgB,EAAIT,EAAK,YAAY,QAExD,CAACU,EAAQC,CAAS,KAAI,YAAmD,MAAM,EAC/E,CAACC,EAASC,CAAU,KAAI,YAAc,EACtC,CAACC,EAAWC,CAAY,KAAI,YAAS,CACzC,KAAM,EACN,QAAS,GAC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AAW,YAAW,OAAC,SAAM,UAAWI,EAAW,EACnDJ,IAAW,cACV,OAAC,WACC,KAAMV,EACN,gBAAiBS,EACjB,QAASY,EACT,QAAST,EACT,SAAUI,EACV,QAASd,EAAM,QACf,KAAMH,EACR,EAEDW,IAAW,cACV,OAAC,WACC,KAAMV,EACN,gBAAiBQ,EACjB,WAAYK,EACZ,gBAAiBe,EACjB,eAAgBC,EAChB,gBAAiBpB,EACjB,QAASY,EACT,QAAST,EACT,SAAUI,EACV,cAAec,EACf,KAAM/B,EACR,EAEDW,IAAW,WACV,OAAC,QAAK,KAAMX,EAAM,KAAMC,EAAM,QAASqB,EAAS,SAAUL,EAAU,UAAWL,EAAW,GAE9F,CAEJ,CAEA,IAAO7B,GAAQgB",
6
6
  "names": ["RedeemProductModal_exports", "__export", "RedeemProductModal_default", "__toCommonJS", "import_jsx_runtime", "import_classnames", "import_react", "import_provider", "import_useCountries", "import_const", "import_useAddressValidate", "import_useRedeemProduct", "import_modalContainer", "import_lib", "import_Error", "import_Success", "import_Address", "import_Init", "RedeemProductModal", "item", "copy", "onError", "props", "fetchCreditInfo", "profile", "storeDomain", "locale", "validatorInfo", "shippingAddress", "shippingProduct", "status", "setStatus", "address", "setAddress", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "countries", "countriesLoading", "useCountries", "loading", "trigger", "responseData", "errorMsg", "errorImage", "error", "stateInputKey", "validateAddress", "validateErrors", "handlePayment", "ignoreKeys", "requestAddress", "classNames"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.create;var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var k=(t,l)=>{for(var e in l)m(t,e,{get:l[e],enumerable:!0})},b=(t,l,e,p)=>{if(l&&typeof l=="object"||typeof l=="function")for(let n of T(l))!I.call(t,n)&&n!==e&&m(t,n,{get:()=>l[n],enumerable:!(p=R(l,n))||p.enumerable});return t};var L=(t,l,e)=>(e=t!=null?C(w(t)):{},b(l||!t||!t.__esModule?m(e,"default",{value:t,enumerable:!0}):e,t)),P=t=>b(m({},"__esModule",{value:!0}),t);var E={};k(E,{RedeemableItem:()=>S});module.exports=P(E);var a=require("react/jsx-runtime"),i=require("@anker-in/headless-ui"),d=require("react"),u=L(require("classnames")),_=require("../context/provider"),o=require("../context/const"),y=require("../context/utils"),x=require("../../../helpers/track"),h=require("./NonProductValue");function S({copy:t,className:l,item:e,onRulesOpen:p,onRedeem:n}){const{creditInfo:f,profile:r,gtm:{pageGroup:v}}=(0,_.useCreditsContext)(),s=Object.keys(r||{}).length>0,N=(0,d.useMemo)(()=>!!(e.alpc?.remainingInventory<=0&&e.alpc?.isLimited||e.alpc?.consumeType===o.AlpcConsumeType.Product&&!e.variant?.availableForSale||s&&r?.activated&&e.alpc?.consumeCredits>Number(f?.available_credit||0)),[e.alpc?.remainingInventory,e.alpc?.isLimited,e.alpc?.consumeType,e.alpc?.consumeCredits,s,r?.activated,f?.available_credit,e.variant?.availableForSale]),g=(0,d.useMemo)(()=>s?e.alpc?.consumeType===o.AlpcConsumeType.Product?e.variant?.availableForSale?t.btnRedeem:t?.soldOut||"Sold Out":t.btnRedeem:t.unlockRewards,[s,e.alpc?.consumeType,e.variant?.availableForSale,t.btnRedeem,t.unlockRewards,t?.soldOut]);return(0,a.jsxs)("div",{className:(0,u.default)("flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]",l),children:[e.config?.type===o.ConsumeType.Product?(0,a.jsx)("div",{className:(0,u.default)("relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]"),children:(0,a.jsx)(i.Picture,{className:"h-full w-auto [&_img]:h-full [&_img]:object-contain",source:e.config?.image?.url||e.product.images?.[0]?.url})}):(0,a.jsxs)("div",{className:"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]",children:[(0,a.jsx)(i.Picture,{source:t?.imageMapping[e.config?.type]?.url,className:"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain"}),(0,a.jsx)(h.NoneProductValue,{item:e,copy:t})]}),(0,a.jsxs)("div",{className:(0,u.default)("mt-[22px] flex w-full flex-1 flex-col justify-between"),children:[(0,a.jsx)(i.Text,{html:e.config?.title||e.alpc?.title,title:e.config?.title||e.alpc?.title,size:2,className:"text-[24px] font-bold leading-[1.2] l:text-[16px] l-xxl:text-[20px]"}),e.config?.rules?.length>0&&(0,a.jsx)("button",{type:"button",onClick:()=>{p(e.config?.rules||[]),(0,x.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:r?.activated?"active":"not active",event_parameters:{page_group:v,position:t.title,button_name:t?.ruleLabel,info:e.alpc?.id?.toString()}})},className:"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0",tabIndex:0,onKeyDown:c=>{(c.key==="Enter"||c.key===" ")&&c.preventDefault()},children:t?.ruleLabel}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("div",{className:"mt-[24px] flex items-center l:mt-[12px] l-xl:mt-[16px]",children:[(0,a.jsx)(i.Picture,{className:"size-[20px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),(0,a.jsx)(i.Text,{html:`${(0,y.numberFormat)(e.alpc?.consumeCredits)}`,size:2,as:"p",className:"ml-[4px] text-[28px] font-bold leading-[1.2] md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] "})]}),(0,a.jsx)(i.Button,{disabled:N,variant:"primary",size:"lg",className:"mt-[8px] md:px-[8px] l:w-full",onClick:()=>{n(e),(0,x.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:r?.activated?"active":"not active",event_parameters:{page_group:v,position:t.title,button_name:g,info:e.alpc?.id?.toString()}})},children:g})]})]})]})}
1
+ "use strict";var C=Object.create;var m=Object.defineProperty;var R=Object.getOwnPropertyDescriptor;var T=Object.getOwnPropertyNames;var w=Object.getPrototypeOf,I=Object.prototype.hasOwnProperty;var k=(t,a)=>{for(var e in a)m(t,e,{get:a[e],enumerable:!0})},b=(t,a,e,p)=>{if(a&&typeof a=="object"||typeof a=="function")for(let n of T(a))!I.call(t,n)&&n!==e&&m(t,n,{get:()=>a[n],enumerable:!(p=R(a,n))||p.enumerable});return t};var z=(t,a,e)=>(e=t!=null?C(w(t)):{},b(a||!t||!t.__esModule?m(e,"default",{value:t,enumerable:!0}):e,t)),L=t=>b(m({},"__esModule",{value:!0}),t);var S={};k(S,{RedeemableItem:()=>P});module.exports=L(S);var l=require("react/jsx-runtime"),i=require("@anker-in/headless-ui"),d=require("react"),c=z(require("classnames")),_=require("../context/provider"),o=require("../context/const"),h=require("../context/utils"),x=require("../../../helpers/track"),y=require("./NonProductValue");function P({copy:t,className:a,item:e,onRulesOpen:p,onRedeem:n}){const{creditInfo:f,profile:r,gtm:{pageGroup:v}}=(0,_.useCreditsContext)(),s=Object.keys(r||{}).length>0,N=(0,d.useMemo)(()=>!!(e.alpc?.remainingInventory<=0&&e.alpc?.isLimited||e.alpc?.consumeType===o.AlpcConsumeType.Product&&!e.variant?.availableForSale||s&&r?.activated&&e.alpc?.consumeCredits>Number(f?.available_credit||0)),[e.alpc?.remainingInventory,e.alpc?.isLimited,e.alpc?.consumeType,e.alpc?.consumeCredits,s,r?.activated,f?.available_credit,e.variant?.availableForSale]),g=(0,d.useMemo)(()=>s?e.alpc?.consumeType===o.AlpcConsumeType.Product?e.variant?.availableForSale?t.btnRedeem:t?.soldOut||"Sold Out":t.btnRedeem:t.unlockRewards,[s,e.alpc?.consumeType,e.variant?.availableForSale,t.btnRedeem,t.unlockRewards,t?.soldOut]);return(0,l.jsxs)("div",{className:(0,c.default)("flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]",a),children:[e.config?.type===o.ConsumeType.Product?(0,l.jsx)("div",{className:(0,c.default)("relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]"),children:(0,l.jsx)(i.Picture,{className:"h-full w-auto [&_img]:h-full [&_img]:object-contain",source:e.config?.image?.url||e.product.images?.[0]?.url})}):(0,l.jsxs)("div",{className:"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]",children:[(0,l.jsx)(i.Picture,{source:t?.imageMapping[e.config?.type]?.url,className:"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain"}),(0,l.jsx)(y.NoneProductValue,{item:e,copy:t})]}),(0,l.jsxs)("div",{className:(0,c.default)("mt-[22px] flex w-full flex-1 flex-col justify-between"),children:[(0,l.jsx)(i.Text,{html:e.config?.title||e.alpc?.title,title:e.config?.title||e.alpc?.title,size:2,className:"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]"}),e.config?.rules?.length>0&&(0,l.jsx)("button",{type:"button",onClick:()=>{p(e.config?.rules||[]),(0,x.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:r?.activated?"active":"not active",event_parameters:{page_group:v,position:t.title,button_name:t?.ruleLabel,info:e.alpc?.id?.toString()}})},className:"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0",tabIndex:0,onKeyDown:u=>{(u.key==="Enter"||u.key===" ")&&u.preventDefault()},children:t?.ruleLabel}),(0,l.jsxs)("div",{children:[(0,l.jsxs)("div",{className:"mt-[26px] flex items-center l:mt-[12px] l-xl:mt-[16px]",children:[(0,l.jsx)(i.Picture,{className:"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),(0,l.jsx)(i.Text,{html:`${(0,h.numberFormat)(e.alpc?.consumeCredits)}`,size:2,as:"p",className:"ml-[4px] text-[28px] font-bold mt-[4px] leading-none md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] "})]}),(0,l.jsx)(i.Button,{disabled:N,variant:"primary",size:"lg",className:"mt-[8px] md:px-[8px] l:w-full",onClick:()=>{n(e),(0,x.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:r?.activated?"active":"not active",event_parameters:{page_group:v,position:t.title,button_name:g,info:e.alpc?.id?.toString()}})},children:g})]})]})]})}
2
2
  //# sourceMappingURL=RedeemableItem.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsRedeemList/RedeemableItem.tsx"],
4
- "sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\n\nimport { useMemo } from 'react'\n\nimport classNames from 'classnames'\nimport { useCreditsContext } from '../context/provider'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { AlpcConsumeType, ConsumeType } from '../context/const'\nimport { numberFormat } from '../context/utils'\nimport type { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\nimport { NoneProductValue } from './NonProductValue'\n\nexport function RedeemableItem({\n copy,\n className,\n item,\n onRulesOpen,\n onRedeem,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n item: RedeemableItemType\n onRulesOpen: (rules: string[]) => void\n onRedeem: (item: RedeemableItemType) => void\n}) {\n const {\n creditInfo,\n profile,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const isDisabled = useMemo(() => {\n if (item.alpc?.remainingInventory <= 0 && item.alpc?.isLimited) {\n // \u6709\u5E93\u5B58\u9650\u5236\n return true\n }\n\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n if (!item.variant?.availableForSale) {\n return true\n }\n }\n if (isLogin && profile?.activated && item.alpc?.consumeCredits > Number(creditInfo?.available_credit || 0)) {\n return true\n }\n return false\n }, [\n item.alpc?.remainingInventory,\n item.alpc?.isLimited,\n item.alpc?.consumeType,\n item.alpc?.consumeCredits,\n isLogin,\n profile?.activated,\n creditInfo?.available_credit,\n item.variant?.availableForSale,\n ])\n\n const redeemButtonText = useMemo(() => {\n if (!isLogin) {\n return copy.unlockRewards\n }\n\n // \u7F3A\u8D27\u6587\u6848\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n return item.variant?.availableForSale ? copy.btnRedeem : copy?.soldOut || 'Sold Out'\n }\n return copy.btnRedeem\n }, [\n isLogin,\n item.alpc?.consumeType,\n item.variant?.availableForSale,\n copy.btnRedeem,\n copy.unlockRewards,\n copy?.soldOut,\n ])\n\n return (\n <div\n className={classNames(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n className\n )}\n >\n {item.config?.type === ConsumeType.Product ? (\n <div className={classNames('relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]')}>\n <Picture\n className=\"h-full w-auto [&_img]:h-full [&_img]:object-contain\"\n source={item.config?.image?.url || item.product.images?.[0]?.url}\n ></Picture>\n </div>\n ) : (\n <div className=\"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]\">\n <Picture\n source={copy?.imageMapping[item.config?.type]?.url}\n className=\"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n\n <NoneProductValue item={item} copy={copy} />\n </div>\n )}\n <div className={classNames('mt-[22px] flex w-full flex-1 flex-col justify-between')}>\n <Text\n html={item.config?.title || item.alpc?.title}\n title={item.config?.title || item.alpc?.title}\n size={2}\n className=\"text-[24px] font-bold leading-[1.2] l:text-[16px] l-xxl:text-[20px]\"\n />\n {item.config?.rules?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n onRulesOpen(item.config?.rules || [])\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: pageGroup,\n position: copy.title,\n button_name: copy?.ruleLabel,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copy?.ruleLabel}\n </button>\n )}\n <div>\n <div className=\"mt-[24px] flex items-center l:mt-[12px] l-xl:mt-[16px]\">\n <Picture\n className=\"size-[20px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(item.alpc?.consumeCredits)}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] text-[28px] font-bold leading-[1.2] md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] \"\n />\n </div>\n\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[8px] l:w-full\"\n onClick={() => {\n onRedeem(item)\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: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n >\n {redeemButtonText}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAuFU,IAAAI,EAAA,6BAvFVC,EAAsC,iCAEtCC,EAAwB,iBAExBC,EAAuB,yBACvBC,EAAkC,+BAElCC,EAA6C,4BAC7CC,EAA6B,4BAE7BC,EAAwB,kCACxBC,EAAiC,6BAE1B,SAASV,EAAe,CAC7B,KAAAW,EACA,UAAAC,EACA,KAAAC,EACA,YAAAC,EACA,SAAAC,CACF,EAMG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,IAAK,CAAE,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,MAAM,MACxC,KAAM,EACN,UAAU,sEACZ,EACCA,EAAK,QAAQ,OAAO,OAAS,MAC5B,OAAC,UACC,KAAK,SACL,QAAS,IAAM,CACbC,EAAYD,EAAK,QAAQ,OAAS,CAAC,CAAC,KACpC,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBI,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAaA,GAAM,UACnB,KAAME,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EACA,UAAU,uEACV,SAAU,EACV,UAAWU,GAAK,EACVA,EAAE,MAAQ,SAAWA,EAAE,MAAQ,MACjCA,EAAE,eAAe,CAErB,EAEC,SAAAZ,GAAM,UACT,KAEF,QAAC,OACC,qBAAC,OAAI,UAAU,yDACb,oBAAC,WACC,UAAU,cACV,OAAO,6FACT,KACA,OAAC,QACC,KAAM,MAAG,gBAAaE,EAAK,MAAM,cAAc,CAAC,GAChD,KAAM,EACN,GAAG,IACH,UAAU,kGACZ,GACF,KAEA,OAAC,UACC,SAAUO,EACV,QAAQ,UACR,KAAK,KACL,UAAU,gCACV,QAAS,IAAM,CACbL,EAASF,CAAI,KACb,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBI,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAaU,EACb,KAAMR,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EAEC,SAAAQ,EACH,GACF,GACF,GACF,CAEJ",
4
+ "sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\n\nimport { useMemo } from 'react'\n\nimport classNames from 'classnames'\nimport { useCreditsContext } from '../context/provider'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { AlpcConsumeType, ConsumeType } from '../context/const'\nimport { numberFormat } from '../context/utils'\nimport type { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\nimport { NoneProductValue } from './NonProductValue'\n\nexport function RedeemableItem({\n copy,\n className,\n item,\n onRulesOpen,\n onRedeem,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n item: RedeemableItemType\n onRulesOpen: (rules: string[]) => void\n onRedeem: (item: RedeemableItemType) => void\n}) {\n const {\n creditInfo,\n profile,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const isDisabled = useMemo(() => {\n if (item.alpc?.remainingInventory <= 0 && item.alpc?.isLimited) {\n // \u6709\u5E93\u5B58\u9650\u5236\n return true\n }\n\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n if (!item.variant?.availableForSale) {\n return true\n }\n }\n if (isLogin && profile?.activated && item.alpc?.consumeCredits > Number(creditInfo?.available_credit || 0)) {\n return true\n }\n return false\n }, [\n item.alpc?.remainingInventory,\n item.alpc?.isLimited,\n item.alpc?.consumeType,\n item.alpc?.consumeCredits,\n isLogin,\n profile?.activated,\n creditInfo?.available_credit,\n item.variant?.availableForSale,\n ])\n\n const redeemButtonText = useMemo(() => {\n if (!isLogin) {\n return copy.unlockRewards\n }\n\n // \u7F3A\u8D27\u6587\u6848\n if (item.alpc?.consumeType === AlpcConsumeType.Product) {\n return item.variant?.availableForSale ? copy.btnRedeem : copy?.soldOut || 'Sold Out'\n }\n return copy.btnRedeem\n }, [\n isLogin,\n item.alpc?.consumeType,\n item.variant?.availableForSale,\n copy.btnRedeem,\n copy.unlockRewards,\n copy?.soldOut,\n ])\n\n return (\n <div\n className={classNames(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n className\n )}\n >\n {item.config?.type === ConsumeType.Product ? (\n <div className={classNames('relative mx-auto h-[224px] w-fit md:my-[10px] l:h-[120px] l-xxl:h-[138px]')}>\n <Picture\n className=\"h-full w-auto [&_img]:h-full [&_img]:object-contain\"\n source={item.config?.image?.url || item.product.images?.[0]?.url}\n ></Picture>\n </div>\n ) : (\n <div className=\"relative mx-auto my-[30px] h-[164px] md:my-0 md:h-[66px] l-xxl:h-[138px] md-l:h-[80px]\">\n <Picture\n source={copy?.imageMapping[item.config?.type]?.url}\n className=\"h-full [&_img]:h-full [&_img]:w-auto [&_img]:object-contain\"\n ></Picture>\n\n <NoneProductValue item={item} copy={copy} />\n </div>\n )}\n <div className={classNames('mt-[22px] flex w-full flex-1 flex-col justify-between')}>\n <Text\n html={item.config?.title || item.alpc?.title}\n title={item.config?.title || item.alpc?.title}\n size={2}\n className=\"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]\"\n />\n {item.config?.rules?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n onRulesOpen(item.config?.rules || [])\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: pageGroup,\n position: copy.title,\n button_name: copy?.ruleLabel,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] w-fit text-[16px] font-bold underline md:text-[14px] l:mt-0\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copy?.ruleLabel}\n </button>\n )}\n <div>\n <div className=\"mt-[26px] flex items-center l:mt-[12px] l-xl:mt-[16px]\">\n <Picture\n className=\"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(item.alpc?.consumeCredits)}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] text-[28px] font-bold mt-[4px] leading-none md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] \"\n />\n </div>\n\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[8px] l:w-full\"\n onClick={() => {\n onRedeem(item)\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: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: item.alpc?.id?.toString(),\n },\n })\n }}\n >\n {redeemButtonText}\n </Button>\n </div>\n </div>\n </div>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,oBAAAE,IAAA,eAAAC,EAAAH,GAuFU,IAAAI,EAAA,6BAvFVC,EAAsC,iCAEtCC,EAAwB,iBAExBC,EAAuB,yBACvBC,EAAkC,+BAElCC,EAA6C,4BAC7CC,EAA6B,4BAE7BC,EAAwB,kCACxBC,EAAiC,6BAE1B,SAASV,EAAe,CAC7B,KAAAW,EACA,UAAAC,EACA,KAAAC,EACA,YAAAC,EACA,SAAAC,CACF,EAMG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,KAAI,qBAAkB,EAChBC,EAAU,OAAO,KAAKF,GAAW,CAAC,CAAC,EAAE,OAAS,EAE9CG,KAAa,WAAQ,IACrB,GAAAP,EAAK,MAAM,oBAAsB,GAAKA,EAAK,MAAM,WAKjDA,EAAK,MAAM,cAAgB,kBAAgB,SACzC,CAACA,EAAK,SAAS,kBAIjBM,GAAWF,GAAS,WAAaJ,EAAK,MAAM,eAAiB,OAAOG,GAAY,kBAAoB,CAAC,GAIxG,CACDH,EAAK,MAAM,mBACXA,EAAK,MAAM,UACXA,EAAK,MAAM,YACXA,EAAK,MAAM,eACXM,EACAF,GAAS,UACTD,GAAY,iBACZH,EAAK,SAAS,gBAChB,CAAC,EAEKQ,KAAmB,WAAQ,IAC1BF,EAKDN,EAAK,MAAM,cAAgB,kBAAgB,QACtCA,EAAK,SAAS,iBAAmBF,EAAK,UAAYA,GAAM,SAAW,WAErEA,EAAK,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G,gBAAaE,EAAK,MAAM,cAAc,CAAC,GAChD,KAAM,EACN,GAAG,IACH,UAAU,0GACZ,GACF,KAEA,OAAC,UACC,SAAUO,EACV,QAAQ,UACR,KAAK,KACL,UAAU,gCACV,QAAS,IAAM,CACbL,EAASF,CAAI,KACb,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBI,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EACZ,SAAUP,EAAK,MACf,YAAaU,EACb,KAAMR,EAAK,MAAM,IAAI,SAAS,CAChC,CACF,CAAC,CACH,EAEC,SAAAQ,EACH,GACF,GACF,GACF,CAEJ",
6
6
  "names": ["RedeemableItem_exports", "__export", "RedeemableItem", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_react", "import_classnames", "import_provider", "import_const", "import_utils", "import_track", "import_NonProductValue", "copy", "className", "item", "onRulesOpen", "onRedeem", "creditInfo", "profile", "pageGroup", "isLogin", "isDisabled", "redeemButtonText", "classNames", "e"]
7
7
  }
@@ -8,6 +8,5 @@ export declare function CreditsRedeemList({ copy, className, tabClassName, hideT
8
8
  activate: {
9
9
  openAuthCodePopup: () => void;
10
10
  isSuccess: boolean;
11
- setOnSuccess: (callback: Function) => void;
12
11
  };
13
12
  }): import("react/jsx-runtime").JSX.Element;
@@ -1,2 +1,2 @@
1
- "use strict";var J=Object.create;var C=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var a in t)C(e,a,{get:t[a],enumerable:!0})},S=(e,t,a,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of Q(t))!X.call(e,d)&&d!==a&&C(e,d,{get:()=>t[d],enumerable:!(f=K(t,d))||f.enumerable});return e};var g=(e,t,a)=>(a=e!=null?J(W(e)):{},S(t||!e||!e.__esModule?C(a,"default",{value:e,enumerable:!0}):a,e)),Z=e=>S(C({},"__esModule",{value:!0}),e);var ee={};Y(ee,{CreditsRedeemList:()=>$});module.exports=Z(ee);var n=require("react/jsx-runtime"),r=require("@anker-in/headless-ui"),v=g(require("classnames")),i=require("react"),E=g(require("./RedeemCouponModal")),O=g(require("./RedeemProductModal")),A=require("../context/provider"),M=g(require("../context/hooks/useRedeemableList")),u=require("../context/const"),F=require("@anker-in/lib"),z=require("./RedeemableItem"),D=g(require("../modal/rulesModal")),H=require("../../../helpers/track");function $({copy:e,className:t="",tabClassName:a="",hideTitle:f=!1,cardClassName:d,activate:R}){const{profile:L,openSignUpPopup:j,gtm:{pageGroup:w}}=(0,A.useCreditsContext)(),B=Object.keys(L||{}).length>0,[T,G]=(0,i.useState)(e.list[0].label),[l,b]=(0,i.useState)(void 0),[h,N]=(0,i.useState)(),{listLoading:U,redeemableList:k,getRedeemableList:x}=(0,M.default)(),p=(0,i.useMemo)(()=>k.map(s=>({id:s.id.toString(),title:s.name,consumeCredits:s.consume_credits,remainingInventory:s.remaining_inventory,isLimited:!!s.is_limited,consumeType:s.consume_type,handle:s.sku_handle,sku:s.goods_sku,image:s.goods_url})),[e.list,T,k]),V=p.map(s=>s.handle),{data:_}=(0,F.useProductsByHandles)({handles:V}),q=(0,i.useMemo)(()=>e.list.find(o=>o.label===T)?.list.filter(o=>p.some(c=>c.id===o.id)).map(o=>{const c=p.find(m=>m.id===o.id),y=_?.find(m=>m.handle===c?.handle),P=y?.variants.find(m=>m.sku===c?.sku);return c?.consumeType===u.AlpcConsumeType.Product&&(!y||!P)?null:{alpc:p.find(m=>m.id===o.id),config:o,product:y,variant:P}}).filter(o=>o!==null),[p,_]),I=(0,i.useCallback)(s=>{s===u.AlpcErrorCode.CodeLpcRuleInventoryNotEnough&&x()},[x]);return(0,n.jsxs)(r.Container,{className:(0,v.default)("relative bg-[#F5F5F7]",t),children:[!f&&(0,n.jsx)(r.Heading,{as:"h2",size:"4",html:e.title}),(0,n.jsx)(r.Tabs,{shape:"rounded",align:"left",className:(0,v.default)("sticky top-0 z-20 py-[24px] md:justify-center",a),value:T.toString(),onValueChange:s=>{G(s),(0,H.gaTrack)({event:"ga4Event",event_name:"lp_navigation",event_parameters:{navigation:s,page_group:w}})},children:(0,n.jsx)(r.TabsList,{children:e.list.map(s=>(0,n.jsx)(r.TabsTrigger,{value:s.label,children:s.label},s.label))})}),!!p?.length&&!U&&(0,n.jsx)("div",{className:(0,v.default)("relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3"),children:q?.map(s=>(0,n.jsx)(z.RedeemableItem,{copy:e,item:s,onRedeem:o=>{B?!L?.activated&&!R.isSuccess?(R.openAuthCodePopup(),R.setOnSuccess(()=>{b(o)})):b(o):j()},onRulesOpen:N,className:d},s?.alpc?.id))}),l?.alpc?.consumeType===u.AlpcConsumeType.Coupon&&e?.redeemModal?.coupon&&l&&(0,n.jsx)(E.default,{isOpen:!!l,item:l,copy:e,onError:I,onClose:()=>{b(void 0)}}),l?.alpc?.consumeType===u.AlpcConsumeType.Product&&e?.redeemModal&&l&&(0,n.jsx)(O.default,{isOpen:!!l,item:l,copy:e,onError:I,onClose:()=>{b(void 0)}}),h&&(0,n.jsx)(D.default,{overlayClassName:"md:px-[16px] md:items-center",className:"md:h-fit md:rounded-b-[16px]",isOpen:h.length>0,onClose:()=>N([]),titleClassName:"border-b-transparent h-[56px]",rules:h,scrollClassName:"md:mt-[8px] md:mb-[24px] md:pt-0",title:e?.ruleLabel,ruleClassName:"text-[#1d1d1f] font-bold"})]})}
1
+ "use strict";var J=Object.create;var b=Object.defineProperty;var K=Object.getOwnPropertyDescriptor;var Q=Object.getOwnPropertyNames;var W=Object.getPrototypeOf,X=Object.prototype.hasOwnProperty;var Y=(e,t)=>{for(var a in t)b(e,a,{get:t[a],enumerable:!0})},E=(e,t,a,f)=>{if(t&&typeof t=="object"||typeof t=="function")for(let d of Q(t))!X.call(e,d)&&d!==a&&b(e,d,{get:()=>t[d],enumerable:!(f=K(t,d))||f.enumerable});return e};var g=(e,t,a)=>(a=e!=null?J(W(e)):{},E(t||!e||!e.__esModule?b(a,"default",{value:e,enumerable:!0}):a,e)),Z=e=>E(b({},"__esModule",{value:!0}),e);var ee={};Y(ee,{CreditsRedeemList:()=>$});module.exports=Z(ee);var o=require("react/jsx-runtime"),r=require("@anker-in/headless-ui"),C=g(require("classnames")),i=require("react"),A=g(require("./RedeemCouponModal")),M=g(require("./RedeemProductModal")),S=require("../context/provider"),O=g(require("../context/hooks/useRedeemableList")),u=require("../context/const"),F=require("@anker-in/lib"),z=require("./RedeemableItem"),D=g(require("../modal/rulesModal")),H=require("../../../helpers/track");function $({copy:e,className:t="",tabClassName:a="",hideTitle:f=!1,cardClassName:d,activate:y}){const{profile:L,openSignUpPopup:j,gtm:{pageGroup:w}}=(0,S.useCreditsContext)(),B=Object.keys(L||{}).length>0,[v,G]=(0,i.useState)(e.list[0].label),[l,R]=(0,i.useState)(void 0),[T,N]=(0,i.useState)(),{listLoading:U,redeemableList:k,getRedeemableList:x}=(0,O.default)(),p=(0,i.useMemo)(()=>k.map(s=>({id:s.id.toString(),title:s.name,consumeCredits:s.consume_credits,remainingInventory:s.remaining_inventory,isLimited:!!s.is_limited,consumeType:s.consume_type,handle:s.sku_handle,sku:s.goods_sku,image:s.goods_url})),[e.list,v,k]),V=p.map(s=>s.handle),{data:_}=(0,F.useProductsByHandles)({handles:V}),q=(0,i.useMemo)(()=>e.list.find(n=>n.label===v)?.list.filter(n=>p.some(c=>c.id===n.id)).map(n=>{const c=p.find(m=>m.id===n.id),h=_?.find(m=>m.handle===c?.handle),P=h?.variants.find(m=>m.sku===c?.sku);return c?.consumeType===u.AlpcConsumeType.Product&&(!h||!P)?null:{alpc:p.find(m=>m.id===n.id),config:n,product:h,variant:P}}).filter(n=>n!==null),[p,_]),I=(0,i.useCallback)(s=>{s===u.AlpcErrorCode.CodeLpcRuleInventoryNotEnough&&x()},[x]);return(0,o.jsxs)(r.Container,{className:(0,C.default)("relative bg-[#F5F5F7]",t),children:[!f&&(0,o.jsx)(r.Heading,{as:"h2",size:"4",html:e.title}),(0,o.jsx)(r.Tabs,{shape:"rounded",align:"left",className:(0,C.default)("sticky top-0 z-20 py-[24px] md:justify-center",a),value:v.toString(),onValueChange:s=>{G(s),(0,H.gaTrack)({event:"ga4Event",event_name:"lp_navigation",event_parameters:{navigation:s,page_group:w}})},children:(0,o.jsx)(r.TabsList,{children:e.list.map(s=>(0,o.jsx)(r.TabsTrigger,{value:s.label,children:s.label},s.label))})}),!!p?.length&&!U&&(0,o.jsx)("div",{className:(0,C.default)("relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3"),children:q?.map(s=>(0,o.jsx)(z.RedeemableItem,{copy:e,item:s,onRedeem:n=>{B?!L?.activated&&!y.isSuccess?y.openAuthCodePopup():R(n):j()},onRulesOpen:N,className:d},s?.alpc?.id))}),l?.alpc?.consumeType===u.AlpcConsumeType.Coupon&&e?.redeemModal?.coupon&&l&&(0,o.jsx)(A.default,{isOpen:!!l,item:l,copy:e,onError:I,onClose:()=>{R(void 0)}}),l?.alpc?.consumeType===u.AlpcConsumeType.Product&&e?.redeemModal&&l&&(0,o.jsx)(M.default,{isOpen:!!l,item:l,copy:e,onError:I,onClose:()=>{R(void 0)}}),T&&(0,o.jsx)(D.default,{overlayClassName:"md:px-[16px] md:items-center",className:"md:h-fit md:rounded-b-[16px]",isOpen:T.length>0,onClose:()=>N([]),titleClassName:"border-b-transparent h-[56px]",rules:T,scrollClassName:"md:mt-[8px] md:mb-[24px] md:pt-0",title:e?.ruleLabel,ruleClassName:"text-[#1d1d1f] font-bold"})]})}
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsRedeemList/index.tsx"],
4
- "sourcesContent": ["import { Container, Heading, Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useMemo, useState } from 'react'\n\nimport RedeemCouponModal from './RedeemCouponModal'\nimport RedeemProductModal from './RedeemProductModal'\nimport { useCreditsContext } from '../context/provider'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { AlpcConsumeType, AlpcErrorCode } from '../context/const'\nimport { useProductsByHandles } from '@anker-in/lib'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { RedeemableItem } from './RedeemableItem'\nimport RulesModal from '../modal/rulesModal'\nimport { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\n\nexport function CreditsRedeemList({\n copy,\n className = '',\n tabClassName = '',\n hideTitle = false,\n cardClassName,\n activate,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n tabClassName?: string\n hideTitle?: boolean\n cardClassName?: string\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n setOnSuccess: (callback: Function) => void\n }\n}) {\n const {\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const [activeTab, setActiveTab] = useState<string>(copy.list[0].label)\n\n const [popRedeemData, setPopRedeemData] = useState<RedeemableItemType | undefined>(undefined)\n\n const [rules, setRules] = useState<string | string[]>()\n\n const { listLoading, redeemableList, getRedeemableList } = useRedeemableList()\n\n const alpcList = useMemo(() => {\n return redeemableList.map(item => {\n return {\n id: item.id.toString(),\n title: item.name,\n consumeCredits: item.consume_credits,\n remainingInventory: item.remaining_inventory,\n isLimited: !!item.is_limited,\n consumeType: item.consume_type,\n handle: item.sku_handle,\n sku: item.goods_sku,\n image: item.goods_url,\n }\n })\n }, [copy.list, activeTab, redeemableList])\n\n const handles = alpcList.map(item => item.handle)\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n const currentList = copy.list.find(item => item.label === activeTab)\n return currentList?.list\n .filter(item => alpcList.some(alpcItem => alpcItem.id === item.id))\n .map(item => {\n const alpcItem = alpcList.find(alpcItem => alpcItem.id === item.id)\n const product = products?.find(product => product.handle === alpcItem?.handle)\n const variant = product?.variants.find(variant => variant.sku === alpcItem?.sku)\n if (alpcItem?.consumeType === AlpcConsumeType.Product && (!product || !variant)) return null\n return {\n alpc: alpcList.find(alpcItem => alpcItem.id === item.id),\n config: item,\n product,\n variant,\n }\n })\n .filter(item => item !== null) as unknown as RedeemableItemType[]\n }, [alpcList, products])\n\n const handleRedeemError = useCallback(\n (errorCode: AlpcErrorCode) => {\n if (errorCode === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n getRedeemableList()\n }\n },\n [getRedeemableList]\n )\n\n return (\n <Container className={classNames('relative bg-[#F5F5F7]', className)}>\n {!hideTitle && <Heading as=\"h2\" size=\"4\" html={copy.title} />}\n\n <Tabs\n shape=\"rounded\"\n align=\"left\"\n className={classNames('sticky top-0 z-20 py-[24px] md:justify-center', tabClassName)}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(value)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_navigation',\n event_parameters: {\n navigation: value,\n page_group: pageGroup,\n },\n })\n }}\n >\n <TabsList>\n {copy.list.map(item => (\n <TabsTrigger key={item.label} value={item.label}>\n {item.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n {/* PC\u7AEF */}\n {!!alpcList?.length && !listLoading && (\n <div\n className={classNames('relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3')}\n >\n {list?.map(item => (\n <RedeemableItem\n key={item?.alpc?.id}\n copy={copy}\n item={item}\n onRedeem={(item: RedeemableItemType) => {\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !activate.isSuccess) {\n activate.openAuthCodePopup()\n activate.setOnSuccess(() => {\n setPopRedeemData(item)\n })\n } else {\n setPopRedeemData(item)\n }\n }}\n onRulesOpen={setRules}\n className={cardClassName}\n />\n ))}\n </div>\n )}\n\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Coupon && copy?.redeemModal?.coupon && popRedeemData && (\n <RedeemCouponModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Product && copy?.redeemModal && popRedeemData && (\n <RedeemProductModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {rules && (\n <RulesModal\n overlayClassName=\"md:px-[16px] md:items-center\"\n className=\"md:h-fit md:rounded-b-[16px]\"\n isOpen={rules.length > 0}\n onClose={() => setRules([])}\n titleClassName=\"border-b-transparent h-[56px]\"\n rules={rules}\n scrollClassName=\"md:mt-[8px] md:mb-[24px] md:pt-0\"\n title={copy?.ruleLabel}\n ruleClassName=\"text-[#1d1d1f] font-bold\"\n />\n )}\n </Container>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,uBAAAE,IAAA,eAAAC,EAAAH,IAkGI,IAAAI,EAAA,6BAlGJC,EAAgE,iCAChEC,EAAuB,yBACvBC,EAA+C,iBAE/CC,EAA8B,kCAC9BC,EAA+B,mCAC/BC,EAAkC,+BAClCC,EAA8B,iDAC9BC,EAA+C,4BAC/CC,EAAqC,yBAErCC,EAA+B,4BAC/BC,EAAuB,kCAEvBC,EAAwB,kCAEjB,SAASd,EAAkB,CAChC,KAAAe,EACA,UAAAC,EAAY,GACZ,aAAAC,EAAe,GACf,UAAAC,EAAY,GACZ,cAAAC,EACA,SAAAC,CACF,EAWG,CACD,KAAM,CACJ,QAAAC,EACA,gBAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,KAAI,qBAAkB,EAChBC,EAAU,OAAO,KAAKH,GAAW,CAAC,CAAC,EAAE,OAAS,EAE9C,CAACI,EAAWC,CAAY,KAAI,YAAiBX,EAAK,KAAK,CAAC,EAAE,KAAK,EAE/D,CAACY,EAAeC,CA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,EAAAqB,QAAA,CACC,OAAQ,CAAC,CAACrB,EACV,KAAMA,EACN,KAAMZ,EACN,QAAS4B,EACT,QAAS,IAAM,CACbf,EAAiB,MAAS,CAC5B,EACF,EAEDC,MACC,OAAC,EAAAoB,QAAA,CACC,iBAAiB,+BACjB,UAAU,+BACV,OAAQpB,EAAM,OAAS,EACvB,QAAS,IAAMC,EAAS,CAAC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOd,GAAM,UACb,cAAc,2BAChB,GAEJ,CAEJ",
4
+ "sourcesContent": ["import { Container, Heading, Tabs, TabsList, TabsTrigger } from '@anker-in/headless-ui'\nimport classNames from 'classnames'\nimport { useCallback, useMemo, useState } from 'react'\n\nimport RedeemCouponModal from './RedeemCouponModal'\nimport RedeemProductModal from './RedeemProductModal'\nimport { useCreditsContext } from '../context/provider'\nimport useRedeemableList from '../context/hooks/useRedeemableList'\nimport { AlpcConsumeType, AlpcErrorCode } from '../context/const'\nimport { useProductsByHandles } from '@anker-in/lib'\nimport type { RedeemableItem as RedeemableItemType } from '../type'\nimport { RedeemableItem } from './RedeemableItem'\nimport RulesModal from '../modal/rulesModal'\nimport { CreditsRedeemListCopy } from './type'\nimport { gaTrack } from '../../../helpers/track'\n\nexport function CreditsRedeemList({\n copy,\n className = '',\n tabClassName = '',\n hideTitle = false,\n cardClassName,\n activate,\n}: {\n copy: CreditsRedeemListCopy\n className?: string\n tabClassName?: string\n hideTitle?: boolean\n cardClassName?: string\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n }\n}) {\n const {\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n } = useCreditsContext()\n const isLogin = Object.keys(profile || {}).length > 0\n\n const [activeTab, setActiveTab] = useState<string>(copy.list[0].label)\n\n const [popRedeemData, setPopRedeemData] = useState<RedeemableItemType | undefined>(undefined)\n\n const [rules, setRules] = useState<string | string[]>()\n\n const { listLoading, redeemableList, getRedeemableList } = useRedeemableList()\n\n const alpcList = useMemo(() => {\n return redeemableList.map(item => {\n return {\n id: item.id.toString(),\n title: item.name,\n consumeCredits: item.consume_credits,\n remainingInventory: item.remaining_inventory,\n isLimited: !!item.is_limited,\n consumeType: item.consume_type,\n handle: item.sku_handle,\n sku: item.goods_sku,\n image: item.goods_url,\n }\n })\n }, [copy.list, activeTab, redeemableList])\n\n const handles = alpcList.map(item => item.handle)\n const { data: products } = useProductsByHandles({ handles })\n\n const list = useMemo(() => {\n const currentList = copy.list.find(item => item.label === activeTab)\n return currentList?.list\n .filter(item => alpcList.some(alpcItem => alpcItem.id === item.id))\n .map(item => {\n const alpcItem = alpcList.find(alpcItem => alpcItem.id === item.id)\n const product = products?.find(product => product.handle === alpcItem?.handle)\n const variant = product?.variants.find(variant => variant.sku === alpcItem?.sku)\n if (alpcItem?.consumeType === AlpcConsumeType.Product && (!product || !variant)) return null\n return {\n alpc: alpcList.find(alpcItem => alpcItem.id === item.id),\n config: item,\n product,\n variant,\n }\n })\n .filter(item => item !== null) as unknown as RedeemableItemType[]\n }, [alpcList, products])\n\n const handleRedeemError = useCallback(\n (errorCode: AlpcErrorCode) => {\n if (errorCode === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n getRedeemableList()\n }\n },\n [getRedeemableList]\n )\n\n return (\n <Container className={classNames('relative bg-[#F5F5F7]', className)}>\n {!hideTitle && <Heading as=\"h2\" size=\"4\" html={copy.title} />}\n\n <Tabs\n shape=\"rounded\"\n align=\"left\"\n className={classNames('sticky top-0 z-20 py-[24px] md:justify-center', tabClassName)}\n value={activeTab.toString()}\n onValueChange={value => {\n setActiveTab(value)\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_navigation',\n event_parameters: {\n navigation: value,\n page_group: pageGroup,\n },\n })\n }}\n >\n <TabsList>\n {copy.list.map(item => (\n <TabsTrigger key={item.label} value={item.label}>\n {item.label}\n </TabsTrigger>\n ))}\n </TabsList>\n </Tabs>\n {/* PC\u7AEF */}\n {!!alpcList?.length && !listLoading && (\n <div\n className={classNames('relative grid grid-cols-4 gap-[16px] md:grid-cols-2 md:gap-[12px] md-xl:grid-cols-3')}\n >\n {list?.map(item => (\n <RedeemableItem\n key={item?.alpc?.id}\n copy={copy}\n item={item}\n onRedeem={(item: RedeemableItemType) => {\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !activate.isSuccess) {\n activate.openAuthCodePopup()\n } else {\n setPopRedeemData(item)\n }\n }}\n onRulesOpen={setRules}\n className={cardClassName}\n />\n ))}\n </div>\n )}\n\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Coupon && copy?.redeemModal?.coupon && popRedeemData && (\n <RedeemCouponModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {popRedeemData?.alpc?.consumeType === AlpcConsumeType.Product && copy?.redeemModal && popRedeemData && (\n <RedeemProductModal\n isOpen={!!popRedeemData}\n item={popRedeemData}\n copy={copy}\n onError={handleRedeemError}\n onClose={() => {\n setPopRedeemData(undefined)\n }}\n />\n )}\n {rules && (\n <RulesModal\n overlayClassName=\"md:px-[16px] md:items-center\"\n className=\"md:h-fit md:rounded-b-[16px]\"\n isOpen={rules.length > 0}\n onClose={() => setRules([])}\n titleClassName=\"border-b-transparent h-[56px]\"\n rules={rules}\n scrollClassName=\"md:mt-[8px] md:mb-[24px] md:pt-0\"\n title={copy?.ruleLabel}\n ruleClassName=\"text-[#1d1d1f] font-bold\"\n />\n )}\n </Container>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,GAAA,GAAAC,EAAAD,GAAA,uBAAAE,IAAA,eAAAC,EAAAH,IAiGI,IAAAI,EAAA,6BAjGJC,EAAgE,iCAChEC,EAAuB,yBACvBC,EAA+C,iBAE/CC,EAA8B,kCAC9BC,EAA+B,mCAC/BC,EAAkC,+BAClCC,EAA8B,iDAC9BC,EAA+C,4BAC/CC,EAAqC,yBAErCC,EAA+B,4BA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EACA,YAAaQ,EACb,UAAWX,GAbNiB,GAAM,MAAM,EAcnB,CACD,EACH,EAGDT,GAAe,MAAM,cAAgB,kBAAgB,QAAUZ,GAAM,aAAa,QAAUY,MAC3F,OAAC,EAAAoB,QAAA,CACC,OAAQ,CAAC,CAACpB,EACV,KAAMA,EACN,KAAMZ,EACN,QAAS4B,EACT,QAAS,IAAM,CACbf,EAAiB,MAAS,CAC5B,EACF,EAEDD,GAAe,MAAM,cAAgB,kBAAgB,SAAWZ,GAAM,aAAeY,MACpF,OAAC,EAAAqB,QAAA,CACC,OAAQ,CAAC,CAACrB,EACV,KAAMA,EACN,KAAMZ,EACN,QAAS4B,EACT,QAAS,IAAM,CACbf,EAAiB,MAAS,CAC5B,EACF,EAEDC,MACC,OAAC,EAAAoB,QAAA,CACC,iBAAiB,+BACjB,UAAU,+BACV,OAAQpB,EAAM,OAAS,EACvB,QAAS,IAAMC,EAAS,CAAC,CAAC,EAC1B,eAAe,gCACf,MAAOD,EACP,gBAAgB,mCAChB,MAAOd,GAAM,UACb,cAAc,2BAChB,GAEJ,CAEJ",
6
6
  "names": ["creditsRedeemList_exports", "__export", "CreditsRedeemList", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_classnames", "import_react", "import_RedeemCouponModal", "import_RedeemProductModal", "import_provider", "import_useRedeemableList", "import_const", "import_lib", "import_RedeemableItem", "import_rulesModal", "import_track", "copy", "className", "tabClassName", "hideTitle", "cardClassName", "activate", "profile", "openSignUpPopup", "pageGroup", "isLogin", "activeTab", "setActiveTab", "popRedeemData", "setPopRedeemData", "rules", "setRules", "listLoading", "redeemableList", "getRedeemableList", "useRedeemableList", "alpcList", "item", "handles", "products", "list", "alpcItem", "product", "variant", "handleRedeemError", "errorCode", "classNames", "value", "RedeemCouponModal", "RedeemProductModal", "RulesModal"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var v=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var B=(i,l)=>{for(var o in l)v(i,o,{get:l[o],enumerable:!0})},G=(i,l,o,a)=>{if(l&&typeof l=="object"||typeof l=="function")for(let n of S(l))!A.call(i,n)&&n!==o&&v(i,n,{get:()=>l[n],enumerable:!(a=D(l,n))||a.enumerable});return i};var M=i=>G(v({},"__esModule",{value:!0}),i);var U={};B(U,{CreditsWaysToGetCredits:()=>P});module.exports=M(U);var e=require("react/jsx-runtime"),s=require("@anker-in/headless-ui"),u=require("@heroicons/react/24/outline"),F=require("framer-motion"),f=require("react"),m=require("./type"),y=require("./useActions"),z=require("../context/provider"),k=require("../../../helpers/index");const P=({copy:i,activate:l,subscribe:o,uploadReceipt:a,classNames:n})=>{const[r,C]=(0,f.useState)(!1),{profile:I}=(0,z.useCreditsContext)(),h=!!I,{actions:b}=(0,y.useActions)({copy:i,activate:l,subscribe:o,uploadReceipt:a}),L=(0,f.useMemo)(()=>{const t=i.list.map(d=>{if(!b[d.id])return;const{finished:p,notLogin:N,notFinished:g,completed:T}=b[d.id];let c="",x,w;return h?p?(c=T.buttonLabel,x=void 0):(c=g.buttonLabel,x=g.handleClick,w=g.link):(c=N.buttonLabel,x=N.handleClick),{...d,buttonLabel:c,handleClick:x,finished:p,link:w}}).filter(Boolean);return h?t.sort((d,p)=>d?.finished&&!p?.finished?1:!d?.finished&&p?.finished?-1:0):t},[b,i.list,h]);return(0,e.jsx)(s.Container,{id:"ways-to-get-credits",className:" bg-[#F5F5F7] [&>div]:l:!px-0",children:(0,e.jsxs)("div",{className:"rounded-[16px] bg-[#1D1D1F] py-[64px] px-[140px] text-white md:px-[16px] l:rounded-none md-l:px-[32px] l-xl:px-[77px]",children:[(0,e.jsx)(s.Heading,{as:"h2",size:4,html:i?.title,className:"text-center l:pl-[16px] l:text-left"}),(0,e.jsxs)("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]",children:[(0,e.jsxs)("div",{className:"pl-[16px] l:mt-[40px] desktop:pl-[24px] lg-desktop:pl-[32px]",children:[(0,e.jsx)(s.Heading,{size:3,as:"h3",html:i.subtitle,className:n?.subtitle}),(0,e.jsxs)("div",{className:"mt-[8px] flex items-center",children:[i.creditsIcon?.url&&(0,e.jsx)(s.Picture,{className:"size-[48px] mr-[8px] stroke-brand xl:size-[30px] [&_path]:stroke-brand",source:i.creditsIcon.url,alt:i.creditsIcon.alt||"credits"}),(0,e.jsx)(s.Heading,{html:i.equalCredits,size:4,as:"h3",className:(0,k.cn)("mt-2 text-white md:text-[24px]",n?.equalCreditsText)})]})]}),(0,e.jsx)(s.Picture,{className:"w-full laptop:w-[50%]",source:i.mainImage?.url})]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)(F.motion.div,{className:(0,k.cn)("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"),initial:{height:512},animate:{height:r?"auto":512},transition:{duration:.3},onAnimationComplete:()=>{if(!r&&window.screen.width<768){const t=document.getElementById("ways-to-get-credits");t&&t.scrollIntoView({behavior:"smooth",block:"end"})}},children:[L.map(t=>(0,e.jsxs)("div",{className:"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]",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Heading,{as:"h4",html:t.title,size:2,className:"text-pretty"}),(0,e.jsxs)("div",{className:"mt-[4px] flex items-center",children:[(0,e.jsx)(s.Picture,{className:"size-[24px] xl:size-[18px] [&_path]:size-full",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450"}),(0,e.jsx)(s.Text,{as:"p",html:t.credits,size:2,className:"ml-[4px] mt-[6px] lg-desktop:text-[18px]"})]})]}),t.handleClick&&!(t.id===m.TaskType.UploadReceipt&&a.isSuccess)&&!(t.id===m.TaskType.Activate&&l.isSuccess)&&!(t.id===m.TaskType.Subscribe&&o.isSuccess)?(0,e.jsx)(s.Button,{as:t.link?"a":"button",...t.link&&{href:t.link},...t.handleClick&&{onClick:t.handleClick},variant:"primary",loading:t.id===m.TaskType.Activate&&l.isSendingActivateEmail,size:"lg",className:"mt-[24px] w-fit",children:t.buttonLabel}):(0,e.jsx)(s.Button,{variant:"primary",size:"lg",className:"mt-[24px] w-fit",disabled:!0,children:t.buttonLabel})]},t.id)),!r&&(0,e.jsx)("div",{className:"absolute inset-0 min-md:hidden",style:{background:"linear-gradient(180deg, rgba(29, 29, 31, 0) 66.37%, #1D1D1F 100%"}})]}),r?(0,e.jsx)("button",{className:"mx-auto mt-[12px] block w-fit min-md:hidden",onClick:()=>{C(!1)},children:(0,e.jsx)(u.ChevronUpIcon,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})}):(0,e.jsx)(e.Fragment,{children:(0,e.jsx)("div",{className:"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden",children:(0,e.jsx)("button",{className:"w-fit",onClick:()=>C(!r),children:(0,e.jsx)(u.ChevronDownIcon,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})})})})]})]})})};
1
+ "use strict";var g=Object.defineProperty;var D=Object.getOwnPropertyDescriptor;var S=Object.getOwnPropertyNames;var B=Object.prototype.hasOwnProperty;var A=(i,l)=>{for(var o in l)g(i,o,{get:l[o],enumerable:!0})},G=(i,l,o,d)=>{if(l&&typeof l=="object"||typeof l=="function")for(let n of S(l))!B.call(i,n)&&n!==o&&g(i,n,{get:()=>l[n],enumerable:!(d=D(l,n))||d.enumerable});return i};var M=i=>G(g({},"__esModule",{value:!0}),i);var U={};A(U,{CreditsWaysToGetCredits:()=>P});module.exports=M(U);var e=require("react/jsx-runtime"),s=require("@anker-in/headless-ui"),u=require("@heroicons/react/24/outline"),F=require("framer-motion"),f=require("react"),x=require("./type"),y=require("./useActions"),z=require("../context/provider"),k=require("../../../helpers/index");const P=({copy:i,activate:l,subscribe:o,uploadReceipt:d,classNames:n})=>{const[r,C]=(0,f.useState)(!1),{profile:I}=(0,z.useCreditsContext)(),h=!!I,{actions:b}=(0,y.useActions)({copy:i,activate:l,subscribe:o,uploadReceipt:d}),L=(0,f.useMemo)(()=>{const t=i.list.map(a=>{if(!b[a.id])return;const{finished:p,notLogin:N,notFinished:v,completed:T}=b[a.id];let m="",c,w;return h?p?(m=T.buttonLabel,c=void 0):(m=v.buttonLabel,c=v.handleClick,w=v.link):(m=N.buttonLabel,c=N.handleClick),{...a,buttonLabel:m,handleClick:c,finished:p,link:w}}).filter(Boolean);return h?t.sort((a,p)=>a?.finished&&!p?.finished?1:!a?.finished&&p?.finished?-1:0):t},[b,i.list,h]);return(0,e.jsx)(s.Container,{id:"ways-to-get-credits",className:" bg-[#F5F5F7] [&>div]:l:!px-0",children:(0,e.jsxs)("div",{className:"rounded-[16px] bg-[#1D1D1F] py-[64px] px-[140px] text-white md:px-[16px] l:rounded-none md-l:px-[32px] l-xl:px-[77px]",children:[(0,e.jsx)(s.Heading,{as:"h2",size:4,html:i?.title,className:"text-center l:pl-[16px] l:text-left"}),(0,e.jsxs)("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]",children:[(0,e.jsxs)("div",{className:"pl-[16px] l:mt-[40px] desktop:pl-[24px] lg-desktop:pl-[32px]",children:[(0,e.jsx)(s.Heading,{size:3,as:"h3",html:i.subtitle,className:n?.subtitle}),(0,e.jsxs)("div",{className:"mt-[8px] flex items-center",children:[i.creditsIcon?.url&&(0,e.jsx)(s.Picture,{className:"size-[48px] mr-[8px] stroke-brand xl:size-[30px] [&_path]:stroke-brand",source:i.creditsIcon.url,alt:i.creditsIcon.alt||"credits"}),(0,e.jsx)(s.Heading,{html:i.equalCredits,size:4,as:"h3",className:(0,k.cn)("mt-2 text-white md:text-[24px]",n?.equalCreditsText)})]})]}),(0,e.jsx)(s.Picture,{className:"w-full laptop:w-[50%]",source:i.mainImage?.url})]}),(0,e.jsxs)("div",{className:"relative",children:[(0,e.jsxs)(F.motion.div,{className:(0,k.cn)("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"),initial:{height:512},animate:{height:r?"auto":512},transition:{duration:.3},onAnimationComplete:()=>{if(!r&&window.screen.width<768){const t=document.getElementById("ways-to-get-credits");t&&t.scrollIntoView({behavior:"smooth",block:"end"})}},children:[L.map(t=>(0,e.jsxs)("div",{className:"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]",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)(s.Heading,{as:"h4",html:t.title,size:2,className:"text-pretty"}),(0,e.jsxs)("div",{className:"mt-[4px] flex items-center",children:[(0,e.jsx)(s.Picture,{className:"size-[24px] xl:size-[18px] [&_path]:size-full",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/20250902-153351.png?v=1756798450"}),(0,e.jsx)(s.Text,{as:"p",html:t.credits,size:2,className:"ml-[4px] mt-[6px] lg-desktop:text-[18px]"})]})]}),t.handleClick&&!(t.id===x.TaskType.UploadReceipt&&d.isSuccess)&&!(t.id===x.TaskType.Activate&&l.isSuccess)&&!(t.id===x.TaskType.Subscribe&&o.isSuccess)?(0,e.jsx)(s.Button,{as:t.link?"a":"button",...t.link&&{href:t.link},...t.handleClick&&{onClick:t.handleClick},variant:"primary",size:"lg",className:"mt-[24px] w-fit",children:t.buttonLabel}):(0,e.jsx)(s.Button,{variant:"primary",size:"lg",className:"mt-[24px] w-fit",disabled:!0,children:t.buttonLabel})]},t.id)),!r&&(0,e.jsx)("div",{className:"absolute inset-0 pointer-events-none min-md:hidden",style:{background:"linear-gradient(180deg, rgba(29, 29, 31, 0) 66.37%, #1D1D1F 100%"}})]}),r?(0,e.jsx)("button",{className:"mx-auto mt-[12px] block w-fit min-md:hidden",onClick:()=>{C(!1)},children:(0,e.jsx)(u.ChevronUpIcon,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})}):(0,e.jsx)(e.Fragment,{children:(0,e.jsx)("div",{className:"absolute bottom-0 flex w-full translate-y-1/2 justify-center min-md:hidden",children:(0,e.jsx)("button",{className:"w-fit",onClick:()=>C(!r),children:(0,e.jsx)(u.ChevronDownIcon,{className:"size-[40px] rounded-full bg-[#FFFFFF33] p-[8px]"})})})})]})]})})};
2
2
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/index.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 { cn } from '../../../helpers/index'\n\nexport const CreditsWaysToGetCredits = ({\n copy,\n activate,\n subscribe,\n uploadReceipt,\n classNames,\n}: CreditsWaysToGetCreditsProps) => {\n const [showMore, setShowMore] = useState(false)\n const { profile } = useCreditsContext()\n const isLogin = !!profile\n\n const { actions } = useActions({ copy, activate, subscribe, uploadReceipt })\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 className=\"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 <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=\"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 >\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 && uploadReceipt.isSuccess) &&\n !(item.id === TaskType.Activate && activate.isSuccess) &&\n !(item.id === TaskType.Subscribe && subscribe.isSuccess) ? (\n <Button\n as={item.link ? 'a' : 'button'}\n {...(item.link && { href: item.link })}\n {...(item.handleClick && { onClick: item.handleClick })}\n variant=\"primary\"\n loading={item.id === TaskType.Activate && activate.isSendingActivateEmail}\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 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 </Container>\n )\n}\n"],
5
- "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAiFQ,IAAAI,EAAA,6BAjFRC,EAA0D,iCAC1DC,EAA+C,uCAC/CC,EAAuB,yBACvBC,EAAkC,iBAElCC,EAA4D,kBAC5DC,EAA2B,wBAC3BC,EAAkC,+BAClCC,EAAmB,kCAEZ,MAAMV,EAA0B,CAAC,CACtC,KAAAW,EACA,SAAAC,EACA,UAAAC,EACA,cAAAC,EACA,WAAAC,CACF,IAAoC,CAClC,KAAM,CAACC,EAAUC,CAAW,KAAI,YAAS,EAAK,EACxC,CAAE,QAAAC,CAAQ,KAAI,qBAAkB,EAChCC,EAAU,CAAC,CAACD,EAEZ,CAAE,QAAAE,CAAQ,KAAI,cAAW,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AQ,GACrE,SAAAA,EAAK,YACR,IAhCGA,EAAK,EAkCZ,CACD,EACA,CAACN,MACA,OAAC,OACC,UAAU,iCACV,MAAO,CAAE,WAAY,kEAAmE,EACzF,GAEL,EACCA,KACC,OAAC,UACC,UAAU,8CACV,QAAS,IAAM,CACbC,EAAY,EAAK,CACnB,EAEA,mBAAC,iBAAc,UAAU,kDAAkD,EAC7E,KAEA,mBACE,mBAAC,OAAI,UAAU,6EACb,mBAAC,UAAO,UAAU,QAAQ,QAAS,IAAMA,EAAY,CAACD,CAAQ,EAC5D,mBAAC,mBAAgB,UAAU,kDAAkD,EAC/E,EACF,EACF,GAEJ,GACF,EACF,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_helpers", "copy", "activate", "subscribe", "uploadReceipt", "classNames", "showMore", "setShowMore", "profile", "isLogin", "actions", "list", "item", "finished", "notLogin", "notFinished", "completed", "buttonLabel", "handleClick", "link", "a", "b", "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 { cn } from '../../../helpers/index'\n\nexport const CreditsWaysToGetCredits = ({\n copy,\n activate,\n subscribe,\n uploadReceipt,\n classNames,\n}: CreditsWaysToGetCreditsProps) => {\n const [showMore, setShowMore] = useState(false)\n const { profile } = useCreditsContext()\n const isLogin = !!profile\n\n const { actions } = useActions({ copy, activate, subscribe, uploadReceipt })\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 className=\"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 <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=\"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 >\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 && uploadReceipt.isSuccess) &&\n !(item.id === TaskType.Activate && activate.isSuccess) &&\n !(item.id === TaskType.Subscribe && subscribe.isSuccess) ? (\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 </Container>\n )\n}\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,6BAAAE,IAAA,eAAAC,EAAAH,GAiFQ,IAAAI,EAAA,6BAjFRC,EAA0D,iCAC1DC,EAA+C,uCAC/CC,EAAuB,yBACvBC,EAAkC,iBAElCC,EAA4D,kBAC5DC,EAA2B,wBAC3BC,EAAkC,+BAClCC,EAAmB,kCAEZ,MAAMV,EAA0B,CAAC,CACtC,KAAAW,EACA,SAAAC,EACA,UAAAC,EACA,cAAAC,EACA,WAAAC,CACF,IAAoC,CAClC,KAAM,CAACC,EAAUC,CAA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,SAAAA,EAAK,YACR,KAEA,OAAC,UAAO,QAAQ,UAAU,KAAK,KAAK,UAAU,kBAAkB,SAAQ,GACrE,SAAAA,EAAK,YACR,IA/BGA,EAAK,EAiCZ,CACD,EACA,CAACN,MACA,OAAC,OACC,UAAU,qDACV,MAAO,CAAE,WAAY,kEAAmE,EACzF,GAEL,EACCA,KACC,OAAC,UACC,UAAU,8CACV,QAAS,IAAM,CACbC,EAAY,EAAK,CACnB,EAEA,mBAAC,iBAAc,UAAU,kDAAkD,EAC7E,KAEA,mBACE,mBAAC,OAAI,UAAU,6EACb,mBAAC,UAAO,UAAU,QAAQ,QAAS,IAAMA,EAAY,CAACD,CAAQ,EAC5D,mBAAC,mBAAgB,UAAU,kDAAkD,EAC/E,EACF,EACF,GAEJ,GACF,EACF,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_helpers", "copy", "activate", "subscribe", "uploadReceipt", "classNames", "showMore", "setShowMore", "profile", "isLogin", "actions", "list", "item", "finished", "notLogin", "notFinished", "completed", "buttonLabel", "handleClick", "link", "b", "section"]
7
7
  }
@@ -47,7 +47,6 @@ export type CreditsWaysToGetCreditsProps = {
47
47
  activate: {
48
48
  openAuthCodePopup: () => void;
49
49
  isSuccess: boolean;
50
- isSendingActivateEmail: boolean;
51
50
  };
52
51
  subscribe: {
53
52
  openSubscribePopup: () => void;
@@ -1,2 +1,2 @@
1
- "use strict";var r=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var u=(t,e)=>{for(var o in e)r(t,o,{get:e[o],enumerable:!0})},g=(t,e,o,c)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of l(e))!a.call(t,s)&&s!==o&&r(t,s,{get:()=>e[s],enumerable:!(c=p(e,s))||c.enumerable});return t};var d=t=>g(r({},"__esModule",{value:!0}),t);var m={};u(m,{TaskType:()=>n});module.exports=d(m);var n=(i=>(i.Activate="activate",i.Subscribe="subscribe",i.CompleteProfile="completeProfile",i.FirstPurchase="firstPurchase",i.UploadReceipt="uploadReceipt",i.Shop="shop",i))(n||{});
1
+ "use strict";var r=Object.defineProperty;var n=Object.getOwnPropertyDescriptor;var l=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var u=(e,t)=>{for(var o in t)r(e,o,{get:t[o],enumerable:!0})},g=(e,t,o,p)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of l(t))!a.call(e,s)&&s!==o&&r(e,s,{get:()=>t[s],enumerable:!(p=n(t,s))||p.enumerable});return e};var d=e=>g(r({},"__esModule",{value:!0}),e);var m={};u(m,{TaskType:()=>c});module.exports=d(m);var c=(i=>(i.Activate="activate",i.Subscribe="subscribe",i.CompleteProfile="completeProfile",i.FirstPurchase="firstPurchase",i.UploadReceipt="uploadReceipt",i.Shop="shop",i))(c||{});
2
2
  //# sourceMappingURL=type.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsWaysToGetCredits/type.ts"],
4
- "sourcesContent": ["import type { ReceiptCopy } from '../modal/creditsUploadReceiptModal'\n\nexport type BenefitItem = {\n title: string\n credits: string\n id: string\n}\n\nexport type WaysToGetCreditsCopy = {\n title: string\n subtitle: string\n equalCredits: string\n musicIcon: string\n list: BenefitItem[]\n mainImage: {\n url: string\n alt: string\n }\n joinNow: string\n activate: string\n completed: string\n completeProfile: string\n makeFirstPurchase: string\n goShopLink: string\n uploadReceipt: string\n shopNow: string\n subscribe: string\n sendEmailSuccess: string\n creditsIcon: {\n url: string\n alt: string\n }\n receipt: ReceiptCopy\n}\n\nexport enum TaskType {\n Activate = 'activate',\n Subscribe = 'subscribe',\n CompleteProfile = 'completeProfile',\n FirstPurchase = 'firstPurchase',\n UploadReceipt = 'uploadReceipt',\n Shop = 'shop',\n}\n\nexport type CreditsWaysToGetCreditsProps = {\n copy: WaysToGetCreditsCopy\n classNames?: {\n equalCreditsText?: string\n subtitle?: string\n }\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n isSendingActivateEmail: boolean\n }\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n}\n"],
4
+ "sourcesContent": ["import type { ReceiptCopy } from '../modal/creditsUploadReceiptModal'\n\nexport type BenefitItem = {\n title: string\n credits: string\n id: string\n}\n\nexport type WaysToGetCreditsCopy = {\n title: string\n subtitle: string\n equalCredits: string\n musicIcon: string\n list: BenefitItem[]\n mainImage: {\n url: string\n alt: string\n }\n joinNow: string\n activate: string\n completed: string\n completeProfile: string\n makeFirstPurchase: string\n goShopLink: string\n uploadReceipt: string\n shopNow: string\n subscribe: string\n sendEmailSuccess: string\n creditsIcon: {\n url: string\n alt: string\n }\n receipt: ReceiptCopy\n}\n\nexport enum TaskType {\n Activate = 'activate',\n Subscribe = 'subscribe',\n CompleteProfile = 'completeProfile',\n FirstPurchase = 'firstPurchase',\n UploadReceipt = 'uploadReceipt',\n Shop = 'shop',\n}\n\nexport type CreditsWaysToGetCreditsProps = {\n copy: WaysToGetCreditsCopy\n classNames?: {\n equalCreditsText?: string\n subtitle?: string\n }\n activate: {\n openAuthCodePopup: () => void\n isSuccess: boolean\n }\n subscribe: {\n openSubscribePopup: () => void\n isSuccess: boolean\n }\n uploadReceipt: {\n openUploadReceiptPopup: () => void\n isSuccess: boolean\n }\n}\n"],
5
5
  "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,cAAAE,IAAA,eAAAC,EAAAH,GAmCO,IAAKE,OACVA,EAAA,SAAW,WACXA,EAAA,UAAY,YACZA,EAAA,gBAAkB,kBAClBA,EAAA,cAAgB,gBAChBA,EAAA,cAAgB,gBAChBA,EAAA,KAAO,OANGA,OAAA",
6
6
  "names": ["type_exports", "__export", "TaskType", "__toCommonJS"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import u from"swr/mutation";import{useRedeemCoupon as a}from"./useRedeemCoupon";import{useCreditsContext as d}from"../provider";import{useBuyNow as s}from"@anker-in/lib";const _=(m,t)=>{const{trigger:o}=a(),{profile:n}=d(),{trigger:i}=s({},{throwOnError:!0});return u("redeemAndBuy",async(c,{arg:r})=>{const e=await o({user_id:n?.user_id,rule_id:r.redeemId});if(e&&e?.data?.coupon_code)i({discountCodes:[e.data.coupon_code],lineItems:[{variant:r.productVariant,quantity:r.quantity||1}]});else throw new Error("Redeem failed")},t)};export{_ as useRedeemAndBuy};
1
+ import u from"swr/mutation";import{useRedeemCoupon as a}from"./useRedeemCoupon";import{useCreditsContext as d}from"../provider";import{useBuyNow as s}from"@anker-in/lib";const w=(m,e)=>{const{trigger:t}=a(),{profile:n}=d(),{trigger:i}=s({},{throwOnError:!0});return u("redeemAndBuy",async(c,{arg:o})=>{const r=await t({user_id:n?.user_id,rule_id:o.redeemId});if(console.log("res",r),r&&r?.data?.coupon_code)i({discountCodes:[r.data.coupon_code],lineItems:[{variant:o.productVariant,quantity:o.quantity||1}]});else throw new Error(`Redeem failed: ${r?.msg}, Error code: ${r?.code}`)},e)};export{w as useRedeemAndBuy};
2
2
  //# sourceMappingURL=useRedeemAndBuy.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useRedeemAndBuy.ts"],
4
- "sourcesContent": ["import useSWRMutation, { SWRMutationConfiguration } from 'swr/mutation'\nimport { useRedeemCoupon } from './useRedeemCoupon'\nimport type { ProductVariant } from '@anker-in/lib'\nimport { useCreditsContext } from '../provider'\nimport { useBuyNow } from '@anker-in/lib'\n\nexport const useRedeemAndBuy = (\n _: any,\n swrOptions?: SWRMutationConfiguration<undefined, Error, string, any> & {\n throwOnError?: boolean\n }\n) => {\n const { trigger } = useRedeemCoupon()\n const { profile } = useCreditsContext()\n\n const { trigger: buyNow } = useBuyNow(\n {},\n {\n throwOnError: true,\n }\n )\n\n return useSWRMutation(\n 'redeemAndBuy',\n async (\n _,\n {\n arg,\n }: {\n arg: {\n productVariant: ProductVariant\n quantity?: number\n redeemId: number\n }\n }\n ) => {\n const res = await trigger({\n user_id: profile?.user_id,\n rule_id: arg.redeemId,\n })\n if (res && res?.data?.coupon_code) {\n buyNow({\n discountCodes: [res.data.coupon_code],\n lineItems: [\n {\n variant: arg.productVariant,\n quantity: arg.quantity || 1,\n },\n ],\n })\n } else {\n throw new Error('Redeem failed')\n }\n },\n swrOptions\n )\n}\n"],
5
- "mappings": "AAAA,OAAOA,MAAkD,eACzD,OAAS,mBAAAC,MAAuB,oBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,aAAAC,MAAiB,gBAEnB,MAAMC,EAAkB,CAC7BC,EACAC,IAGG,CACH,KAAM,CAAE,QAAAC,CAAQ,EAAIN,EAAgB,EAC9B,CAAE,QAAAO,CAAQ,EAAIN,EAAkB,EAEhC,CAAE,QAASO,CAAO,EAAIN,EAC1B,CAAC,EACD,CACE,aAAc,EAChB,CACF,EAEA,OAAOH,EACL,eACA,MACEK,EACA,CACE,IAAAK,CACF,IAOG,CACH,MAAMC,EAAM,MAAMJ,EAAQ,CACxB,QAASC,GAAS,QAClB,QAASE,EAAI,QACf,CAAC,EACD,GAAIC,GAAOA,GAAK,MAAM,YACpBF,EAAO,CACL,cAAe,CAACE,EAAI,KAAK,WAAW,EACpC,UAAW,CACT,CACE,QAASD,EAAI,eACb,SAAUA,EAAI,UAAY,CAC5B,CACF,CACF,CAAC,MAED,OAAM,IAAI,MAAM,eAAe,CAEnC,EACAJ,CACF,CACF",
4
+ "sourcesContent": ["import useSWRMutation, { SWRMutationConfiguration } from 'swr/mutation'\nimport { useRedeemCoupon } from './useRedeemCoupon'\nimport type { ProductVariant } from '@anker-in/lib'\nimport { useCreditsContext } from '../provider'\nimport { useBuyNow } from '@anker-in/lib'\n\nexport const useRedeemAndBuy = (\n _: any,\n swrOptions?: SWRMutationConfiguration<undefined, Error, string, any> & {\n throwOnError?: boolean\n }\n) => {\n const { trigger } = useRedeemCoupon()\n const { profile } = useCreditsContext()\n\n const { trigger: buyNow } = useBuyNow(\n {},\n {\n throwOnError: true,\n }\n )\n\n return useSWRMutation(\n 'redeemAndBuy',\n async (\n _,\n {\n arg,\n }: {\n arg: {\n productVariant: ProductVariant\n quantity?: number\n redeemId: number\n }\n }\n ) => {\n const res = await trigger({\n user_id: profile?.user_id,\n rule_id: arg.redeemId,\n })\n console.log('res', res)\n if (res && res?.data?.coupon_code) {\n buyNow({\n discountCodes: [res.data.coupon_code],\n lineItems: [\n {\n variant: arg.productVariant,\n quantity: arg.quantity || 1,\n },\n ],\n })\n } else {\n throw new Error(`Redeem failed: ${res?.msg}, Error code: ${res?.code}`)\n }\n },\n swrOptions\n )\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAkD,eACzD,OAAS,mBAAAC,MAAuB,oBAEhC,OAAS,qBAAAC,MAAyB,cAClC,OAAS,aAAAC,MAAiB,gBAEnB,MAAMC,EAAkB,CAC7BC,EACAC,IAGG,CACH,KAAM,CAAE,QAAAC,CAAQ,EAAIN,EAAgB,EAC9B,CAAE,QAAAO,CAAQ,EAAIN,EAAkB,EAEhC,CAAE,QAASO,CAAO,EAAIN,EAC1B,CAAC,EACD,CACE,aAAc,EAChB,CACF,EAEA,OAAOH,EACL,eACA,MACEK,EACA,CACE,IAAAK,CACF,IAOG,CACH,MAAMC,EAAM,MAAMJ,EAAQ,CACxB,QAASC,GAAS,QAClB,QAASE,EAAI,QACf,CAAC,EAED,GADA,QAAQ,IAAI,MAAOC,CAAG,EAClBA,GAAOA,GAAK,MAAM,YACpBF,EAAO,CACL,cAAe,CAACE,EAAI,KAAK,WAAW,EACpC,UAAW,CACT,CACE,QAASD,EAAI,eACb,SAAUA,EAAI,UAAY,CAC5B,CACF,CACF,CAAC,MAED,OAAM,IAAI,MAAM,kBAAkBC,GAAK,GAAG,iBAAiBA,GAAK,IAAI,EAAE,CAE1E,EACAL,CACF,CACF",
6
6
  "names": ["useSWRMutation", "useRedeemCoupon", "useCreditsContext", "useBuyNow", "useRedeemAndBuy", "_", "swrOptions", "trigger", "profile", "buyNow", "arg", "res"]
7
7
  }
@@ -1,10 +1,11 @@
1
1
  import { type UseMutationConfig } from './useAlpcFetch';
2
2
  type RedeemCouponResponse = {
3
- code: number;
4
3
  data: {
5
4
  success: boolean;
6
5
  coupon_code: string;
7
6
  };
7
+ msg: string;
8
+ code: number;
8
9
  };
9
10
  export declare const useRedeemCoupon: (mutationOptions?: UseMutationConfig<RedeemCouponResponse>) => {
10
11
  isMutating: boolean;
@@ -1,2 +1,2 @@
1
- import{ALPC_COUNTRY_MAP as s}from"../const";import{useAlpcMutation as p}from"./useAlpcFetch";import{useHeadlessContext as r}from"@anker-in/lib";const m=(o={})=>{const{locale:e,appName:n,brand:t}=r();return p({url:"/v1/credit/redeem/coupon",initData:{brand:t,country:s.get(e)||e,app_name:n}},o)};export{m as useRedeemCoupon};
1
+ import{ALPC_COUNTRY_MAP as s}from"../const";import{useAlpcMutation as r}from"./useAlpcFetch";import{useHeadlessContext as p}from"@anker-in/lib";const a=(o={})=>{const{locale:e,appName:n,brand:t}=p();return r({url:"/v1/credit/redeem/coupon",initData:{brand:t,country:s.get(e)||e,app_name:n}},o)};export{a as useRedeemCoupon};
2
2
  //# sourceMappingURL=useRedeemCoupon.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useRedeemCoupon.ts"],
4
- "sourcesContent": ["import { ALPC_COUNTRY_MAP } from '../const'\nimport { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype RedeemCouponResponse = {\n code: number\n data: {\n success: boolean\n coupon_code: string\n }\n}\n\nexport const useRedeemCoupon = (mutationOptions: UseMutationConfig<RedeemCouponResponse> = {}) => {\n const { locale, appName, brand } = useHeadlessContext()\n\n return useAlpcMutation<\n RedeemCouponResponse,\n {\n user_id?: string\n rule_id: number\n }\n >(\n {\n url: `/v1/credit/redeem/coupon`,\n initData: {\n brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n },\n mutationOptions\n )\n}\n"],
5
- "mappings": "AAAA,OAAS,oBAAAA,MAAwB,WACjC,OAAS,mBAAAC,MAA+C,iBACxD,OAAS,sBAAAC,MAA0B,gBAU5B,MAAMC,EAAkB,CAACC,EAA2D,CAAC,IAAM,CAChG,KAAM,CAAE,OAAAC,EAAQ,QAAAC,EAAS,MAAAC,CAAM,EAAIL,EAAmB,EAEtD,OAAOD,EAOL,CACE,IAAK,2BACL,SAAU,CACR,MAAAM,EACA,QAASP,EAAiB,IAAIK,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,EACAF,CACF,CACF",
4
+ "sourcesContent": ["import { ALPC_COUNTRY_MAP } from '../const'\nimport { useAlpcMutation, type UseMutationConfig } from './useAlpcFetch'\nimport { useHeadlessContext } from '@anker-in/lib'\n\ntype RedeemCouponResponse = {\n data: {\n success: boolean\n coupon_code: string\n }\n msg: string // \u62A5\u9519\u4FE1\u606F\n code: number // \u62A5\u9519\u7801\n}\n\nexport const useRedeemCoupon = (mutationOptions: UseMutationConfig<RedeemCouponResponse> = {}) => {\n const { locale, appName, brand } = useHeadlessContext()\n\n return useAlpcMutation<\n RedeemCouponResponse,\n {\n user_id?: string\n rule_id: number\n }\n >(\n {\n url: `/v1/credit/redeem/coupon`,\n initData: {\n brand,\n country: ALPC_COUNTRY_MAP.get(locale) || locale,\n app_name: appName,\n },\n },\n mutationOptions\n )\n}\n"],
5
+ "mappings": "AAAA,OAAS,oBAAAA,MAAwB,WACjC,OAAS,mBAAAC,MAA+C,iBACxD,OAAS,sBAAAC,MAA0B,gBAW5B,MAAMC,EAAkB,CAACC,EAA2D,CAAC,IAAM,CAChG,KAAM,CAAE,OAAAC,EAAQ,QAAAC,EAAS,MAAAC,CAAM,EAAIL,EAAmB,EAEtD,OAAOD,EAOL,CACE,IAAK,2BACL,SAAU,CACR,MAAAM,EACA,QAASP,EAAiB,IAAIK,CAAM,GAAKA,EACzC,SAAUC,CACZ,CACF,EACAF,CACF,CACF",
6
6
  "names": ["ALPC_COUNTRY_MAP", "useAlpcMutation", "useHeadlessContext", "useRedeemCoupon", "mutationOptions", "locale", "appName", "brand"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import r from"swr/mutation";const a=async(d,{arg:{orderName:o}})=>{const t=await fetch("/api/multipass/mktsrv/v1/credit/upload_third_party_order",{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order_name:o})}),{data:e}=await t.json();return console.log("data",e),{ok:e?.code===0,code:e?.code}},s=()=>r("/api/multipass/mktsrv/v1/credit/upload_third_party_order",a);export{a as uploadReceipt,s as useUploadReceipt};
1
+ import r from"swr/mutation";const a=async(d,{arg:{orderName:t}})=>{const o=await fetch("/api/multipass/mktsrv/v1/credit/upload_third_party_order",{credentials:"include",method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({order_name:t})}),{data:e}=await o.json();return{ok:e?.code===0,code:e?.code}},n=()=>r("/api/multipass/mktsrv/v1/credit/upload_third_party_order",a);export{a as uploadReceipt,n as useUploadReceipt};
2
2
  //# sourceMappingURL=useUploadReceipt.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../../src/components/credits/context/hooks/useUploadReceipt.tsx"],
4
- "sourcesContent": ["import useSWRMutation from 'swr/mutation'\n\nexport const uploadReceipt = async (\n _: any,\n { arg: { orderName } }: { arg: { orderName: string } }\n): Promise<{\n ok: boolean\n code: number\n}> => {\n const response = await fetch(`/api/multipass/mktsrv/v1/credit/upload_third_party_order`, {\n credentials: 'include',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n order_name: orderName,\n }),\n })\n const { data } = await response.json()\n console.log('data', data)\n return {\n ok: data?.code === 0,\n code: data?.code,\n }\n}\n\nexport const useUploadReceipt = () => {\n return useSWRMutation('/api/multipass/mktsrv/v1/credit/upload_third_party_order', uploadReceipt)\n}\n"],
5
- "mappings": "AAAA,OAAOA,MAAoB,eAEpB,MAAMC,EAAgB,MAC3BC,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CACJ,MAAMC,EAAW,MAAM,MAAM,2DAA4D,CACvF,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYD,CACd,CAAC,CACH,CAAC,EACK,CAAE,KAAAE,CAAK,EAAI,MAAMD,EAAS,KAAK,EACrC,eAAQ,IAAI,OAAQC,CAAI,EACjB,CACL,GAAIA,GAAM,OAAS,EACnB,KAAMA,GAAM,IACd,CACF,EAEaC,EAAmB,IACvBN,EAAe,2DAA4DC,CAAa",
4
+ "sourcesContent": ["import useSWRMutation from 'swr/mutation'\n\nexport const uploadReceipt = async (\n _: any,\n { arg: { orderName } }: { arg: { orderName: string } }\n): Promise<{\n ok: boolean\n code: number\n}> => {\n const response = await fetch(`/api/multipass/mktsrv/v1/credit/upload_third_party_order`, {\n credentials: 'include',\n method: 'POST',\n headers: {\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({\n order_name: orderName,\n }),\n })\n const { data } = await response.json()\n return {\n ok: data?.code === 0,\n code: data?.code,\n }\n}\n\nexport const useUploadReceipt = () => {\n return useSWRMutation('/api/multipass/mktsrv/v1/credit/upload_third_party_order', uploadReceipt)\n}\n"],
5
+ "mappings": "AAAA,OAAOA,MAAoB,eAEpB,MAAMC,EAAgB,MAC3BC,EACA,CAAE,IAAK,CAAE,UAAAC,CAAU,CAAE,IAIjB,CACJ,MAAMC,EAAW,MAAM,MAAM,2DAA4D,CACvF,YAAa,UACb,OAAQ,OACR,QAAS,CACP,eAAgB,kBAClB,EACA,KAAM,KAAK,UAAU,CACnB,WAAYD,CACd,CAAC,CACH,CAAC,EACK,CAAE,KAAAE,CAAK,EAAI,MAAMD,EAAS,KAAK,EACrC,MAAO,CACL,GAAIC,GAAM,OAAS,EACnB,KAAMA,GAAM,IACd,CACF,EAEaC,EAAmB,IACvBN,EAAe,2DAA4DC,CAAa",
6
6
  "names": ["useSWRMutation", "uploadReceipt", "_", "orderName", "response", "data", "useUploadReceipt"]
7
7
  }
@@ -8,8 +8,6 @@ declare function RedeemableItem({ copy, itemData, setRules, className, authCodeA
8
8
  authCodeActivate: {
9
9
  openAuthCodePopup: Function;
10
10
  isSuccess: boolean;
11
- setOnSuccess: (arg: Function) => void;
12
- isSendingActivateEmail: boolean;
13
11
  };
14
12
  }): import("react/jsx-runtime").JSX.Element;
15
13
  export default RedeemableItem;
@@ -1,2 +1,2 @@
1
- import{jsx as i,jsxs as o}from"react/jsx-runtime";import{Button as w,Text as u,Picture as f}from"@anker-in/headless-ui";import{useMemo as s}from"react";import{cn as p}from"../../../helpers";import{useCreditsContext as I}from"../context/provider";import{useRedeemAndBuy as y}from"../context/hooks/useRedeemAndBuy";import{numberFormat as R}from"../context/utils";import{gaTrack as v}from"../../../helpers/track";function k({copy:t,itemData:e,setRules:g,className:b,authCodeActivate:d}){const{creditInfo:x,profile:l,openSignUpPopup:h,gtm:{pageGroup:m}}=I(),{trigger:C,isMutating:N}=y({},{onError:()=>console.log("error")}),n=s(()=>!!l,[l?.activated]),a=s(()=>n&&l?.activated&&e.alpcData?.consumeCredits>Number(x?.available_credit||0),[n,l?.activated,e.alpcData?.consumeCredits,x?.available_credit]),_=s(()=>!!(e.alpcData?.remainingInventory<=0&&e.alpcData?.isLimited||!e.productVariant?.availableForSale||a),[e.alpcData?.remainingInventory,e.alpcData?.isLimited,e.productVariant?.availableForSale,a]),S=()=>{const r=()=>C({productVariant:e?.productVariant,redeemId:e?.config?.redeemId});n?!l?.activated&&!d.isSuccess?(d.openAuthCodePopup(),d.setOnSuccess(r)):(r(),v({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:m,position:t.title,button_name:c,info:e?.alpcData?.id?.toString()}})):h()},c=s(()=>e.productVariant?.availableForSale?n?t.btnRedeem:t.unlockRewards:t?.soldOut||"Sold Out",[n,e.productVariant?.availableForSale,t.btnRedeem,t.unlockRewards,t?.soldOut]);return o("div",{className:p("flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]",b),children:[i("div",{className:p("relative mx-auto h-[224px] w-fit l:h-[120px] l-xxl:h-[138px]"),children:i(f,{className:"mx-auto h-full w-auto",imgClassName:"h-full object-contain",source:e?.config?.image?.url||e?.productVariant?.metafields?.global?.transparentImg||e?.productVariant?.image?.url})}),o("div",{className:p("mt-[22px] w-full l:mt-[8px]"),children:[i(u,{html:e?.product?.title,title:e.config?.title||e.alpcData?.title||e.product?.title,size:2,className:"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:line-clamp-3 l:h-[56px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]"}),e?.config?.rules?.split("<br>")?.length>0&&i("button",{type:"button",onClick:()=>{g(e?.config?.rules?.split("<br>")),v({event:"ga4Event",event_name:"lp_button",member_active_status:l?.activated?"active":"not active",event_parameters:{page_group:m,position:t.title,button_name:t?.ruleLabel,info:e?.alpcData?.id?.toString()}})},className:"mt-[8px] text-[16px] font-bold underline xxl:text-[14px]",tabIndex:0,onKeyDown:r=>{(r.key==="Enter"||r.key===" ")&&r.preventDefault()},children:t?.ruleLabel}),o("div",{className:"mt-[24px] flex items-center l:mt-[12px] laptop:text-[16px] lg-desktop:text-[18px]",children:[i(f,{className:"size-[20px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),i(u,{html:`${R(e?.alpcData?.consumeCredits)} + ${e?.config?.price}`,size:2,as:"p",className:"ml-[4px] text-[28px] font-bold leading-[1.2] md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] "})]}),o("div",{className:"group relative w-full",children:[i(w,{disabled:_,variant:"primary",size:"lg",className:"mt-[8px] md:px-[10px] l:w-full",loading:N,onClick:()=>{S()},title:a?"Insufficient credit":c,children:c}),i("div",{className:p("absolute -bottom-[20px] left-0 z-10 w-[300px] translate-y-full opacity-0 transition-opacity group-hover:opacity-100 md:-bottom-[14px] md:w-[160px]",a?"block":"hidden"),children:o("div",{className:"relative rounded-[10px] bg-[#6D6D6F] p-[16px] text-[14px] font-medium text-white shadow md:px-[10px] md:py-[8px]",children:[i(u,{as:"p",size:"2",html:t?.insufficientCredits,className:"text-[14px]"}),i("div",{className:"absolute -top-[10px] left-[48px] mb-2 size-[16px] origin-top-left rotate-45 transform rounded-[2px] bg-[#6D6D6F]"})]})})]})]})]})}var M=k;export{M as default};
1
+ import{jsx as l,jsxs as n}from"react/jsx-runtime";import{Button as F,Text as u,Picture as g}from"@anker-in/headless-ui";import{useMemo as s,useState as I}from"react";import{cn as p}from"../../../helpers";import{useCreditsContext as R}from"../context/provider";import{useRedeemAndBuy as k}from"../context/hooks/useRedeemAndBuy";import{numberFormat as y}from"../context/utils";import{gaTrack as b}from"../../../helpers/track";function E({copy:t,itemData:e,setRules:h,className:C,authCodeActivate:x}){const{creditInfo:c,profile:i,openSignUpPopup:N,gtm:{pageGroup:m}}=R(),[f,v]=I(null),{trigger:_,isMutating:w}=k({},{onError:a=>{v(a.message)}}),r=s(()=>!!i,[i?.activated]),o=s(()=>r&&i?.activated&&e.alpcData?.consumeCredits>Number(c?.available_credit||0),[r,i?.activated,e.alpcData?.consumeCredits,c?.available_credit]),S=s(()=>!!(e.alpcData?.remainingInventory<=0&&e.alpcData?.isLimited||!e.productVariant?.availableForSale||o),[e.alpcData?.remainingInventory,e.alpcData?.isLimited,e.productVariant?.availableForSale,o]),z=()=>{v(null),r?!i?.activated&&!x.isSuccess?x.openAuthCodePopup():(_({productVariant:e?.productVariant,redeemId:e?.config?.redeemId}),b({event:"ga4Event",event_name:"lp_button",member_active_status:i?.activated?"active":"not active",event_parameters:{page_group:m,position:t.title,button_name:d,info:e?.alpcData?.id?.toString()}})):N()},d=s(()=>e.productVariant?.availableForSale?r?t.btnRedeem:t.unlockRewards:t?.soldOut||"Sold Out",[r,e.productVariant?.availableForSale,t.btnRedeem,t.unlockRewards,t?.soldOut]);return n("div",{className:p("flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]",C),children:[l("div",{className:p("relative mx-auto h-[224px] w-fit l:h-[120px] l-xxl:h-[138px]"),children:l(g,{className:"mx-auto h-full w-auto",imgClassName:"h-full object-contain",source:e?.config?.image?.url||e?.productVariant?.metafields?.global?.transparentImg||e?.productVariant?.image?.url})}),n("div",{className:p("mt-[22px] w-full l:mt-[8px]"),children:[l(u,{html:e?.product?.title,title:e.config?.title||e.alpcData?.title||e.product?.title,size:2,className:"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]"}),e?.config?.rules?.split("<br>")?.length>0&&l("button",{type:"button",onClick:()=>{h(e?.config?.rules?.split("<br>")),b({event:"ga4Event",event_name:"lp_button",member_active_status:i?.activated?"active":"not active",event_parameters:{page_group:m,position:t.title,button_name:t?.ruleLabel,info:e?.alpcData?.id?.toString()}})},className:"mt-[8px] text-[16px] font-bold underline xxl:text-[14px]",tabIndex:0,onKeyDown:a=>{(a.key==="Enter"||a.key===" ")&&a.preventDefault()},children:t?.ruleLabel}),n("div",{className:"mt-[24px] flex items-center l:mt-[12px] laptop:text-[16px] lg-desktop:text-[18px]",children:[l(g,{className:"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]",source:"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783"}),l(u,{html:`${y(e?.alpcData?.consumeCredits)} + ${e?.config?.price}`,size:2,as:"p",className:"ml-[4px] mt-[4px] text-[28px] font-bold leading-none md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] "})]}),n("div",{className:"group relative w-full",children:[l(F,{disabled:S,variant:"primary",size:"lg",className:"mt-[8px] md:px-[10px] l:w-full",loading:w,onClick:()=>{z()},title:o?t.insufficientCredits:d,children:d}),l("div",{className:p("absolute -bottom-[20px] left-0 z-10 w-[300px] translate-y-full opacity-0 transition-opacity group-hover:opacity-100 md:-bottom-[14px] md:w-[160px]",o?"block":"hidden"),children:n("div",{className:"relative rounded-[10px] bg-[#6D6D6F] p-[16px] text-[14px] font-medium text-white shadow md:px-[10px] md:py-[8px]",children:[l(u,{as:"p",size:"2",html:t?.insufficientCredits,className:"text-[14px]"}),l("div",{className:"absolute -top-[10px] left-[48px] mb-2 size-[16px] origin-top-left rotate-45 transform rounded-[2px] bg-[#6D6D6F]"})]})})]})]}),f&&l("div",{className:"mt-[8px] text-[14px] text-[#FF0000]",children:f})]})}var K=E;export{K as default};
2
2
  //# sourceMappingURL=RedeemableItem.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsCash/RedeemableItem.tsx"],
4
- "sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\nimport { useMemo } from 'react'\nimport { cn } from '../../../helpers'\n\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemAndBuy } from '../context/hooks/useRedeemAndBuy'\nimport { numberFormat } from '../context/utils'\nimport { gaTrack } from '../../../helpers/track'\n\nfunction RedeemableItem({\n copy,\n itemData,\n setRules,\n className,\n authCodeActivate,\n}: {\n copy: CreditsCashCopy\n itemData: RedeemItem\n className?: string\n setRules: (rules: string[]) => void\n currencyCode: string\n authCodeActivate: {\n openAuthCodePopup: Function\n isSuccess: boolean\n setOnSuccess: (arg: Function) => void\n isSendingActivateEmail: boolean\n }\n}) {\n const {\n creditInfo,\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n } = useCreditsContext()\n const { trigger, isMutating } = useRedeemAndBuy(\n {},\n {\n onError: () => console.log('error'),\n }\n )\n\n const isLogin = useMemo(() => {\n return !!profile\n }, [profile?.activated])\n\n const inSufficientCredit = useMemo(() => {\n return (\n isLogin && profile?.activated && itemData.alpcData?.consumeCredits > Number(creditInfo?.available_credit || 0)\n )\n }, [isLogin, profile?.activated, itemData.alpcData?.consumeCredits, creditInfo?.available_credit])\n\n const isDisabled = useMemo(() => {\n // \u5151\u6362\u9650\u5236\n if (itemData.alpcData?.remainingInventory <= 0 && itemData.alpcData?.isLimited) {\n return true\n }\n\n // \u5546\u54C1\u5E93\u5B58\u9650\u5236\n if (!itemData.productVariant?.availableForSale) {\n return true\n }\n\n // \u79EF\u5206\u4E0D\u8DB3\n if (inSufficientCredit) {\n return true\n }\n return false\n }, [\n itemData.alpcData?.remainingInventory,\n itemData.alpcData?.isLimited,\n itemData.productVariant?.availableForSale,\n inSufficientCredit,\n ])\n\n const handleRedeem = () => {\n const buyNow = () =>\n trigger({\n productVariant: itemData?.productVariant,\n redeemId: itemData?.config?.redeemId,\n })\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !authCodeActivate.isSuccess) {\n authCodeActivate.openAuthCodePopup()\n authCodeActivate.setOnSuccess(buyNow)\n } else {\n buyNow()\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: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: itemData?.alpcData?.id?.toString(),\n },\n })\n }\n }\n\n const redeemButtonText = useMemo(() => {\n // \u7F3A\u8D27\u6587\u6848\n if (!itemData.productVariant?.availableForSale) {\n return copy?.soldOut || 'Sold Out'\n } else if (!isLogin) {\n return copy.unlockRewards\n } else {\n return copy.btnRedeem\n }\n }, [isLogin, itemData.productVariant?.availableForSale, copy.btnRedeem, copy.unlockRewards, copy?.soldOut])\n\n return (\n <div\n className={cn(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n className\n )}\n >\n <div className={cn('relative mx-auto h-[224px] w-fit l:h-[120px] l-xxl:h-[138px]')}>\n <Picture\n className=\"mx-auto h-full w-auto\"\n imgClassName=\"h-full object-contain\"\n source={\n itemData?.config?.image?.url ||\n itemData?.productVariant?.metafields?.global?.transparentImg ||\n itemData?.productVariant?.image?.url\n }\n ></Picture>\n </div>\n <div className={cn('mt-[22px] w-full l:mt-[8px]')}>\n <Text\n html={itemData?.product?.title}\n title={itemData.config?.title || itemData.alpcData?.title || itemData.product?.title}\n size={2}\n className=\"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:line-clamp-3 l:h-[56px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]\"\n />\n {itemData?.config?.rules?.split('<br>')?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n setRules(itemData?.config?.rules?.split('<br>'))\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: pageGroup,\n position: copy.title,\n button_name: copy?.ruleLabel,\n info: itemData?.alpcData?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] text-[16px] font-bold underline xxl:text-[14px]\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copy?.ruleLabel}\n </button>\n )}\n <div className=\"mt-[24px] flex items-center l:mt-[12px] laptop:text-[16px] lg-desktop:text-[18px]\">\n <Picture\n className=\"size-[20px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(itemData?.alpcData?.consumeCredits)} + ${itemData?.config?.price}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] text-[28px] font-bold leading-[1.2] md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] \"\n />\n </div>\n\n <div className=\"group relative w-full\">\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[10px] l:w-full\"\n loading={isMutating}\n onClick={() => {\n handleRedeem()\n }}\n title={inSufficientCredit ? 'Insufficient credit' : redeemButtonText}\n >\n {redeemButtonText}\n </Button>\n <div\n className={cn(\n 'absolute -bottom-[20px] left-0 z-10 w-[300px] translate-y-full opacity-0 transition-opacity group-hover:opacity-100 md:-bottom-[14px] md:w-[160px]',\n inSufficientCredit ? 'block' : 'hidden'\n )}\n >\n <div className=\"relative rounded-[10px] bg-[#6D6D6F] p-[16px] text-[14px] font-medium text-white shadow md:px-[10px] md:py-[8px]\">\n <Text as=\"p\" size=\"2\" html={copy?.insufficientCredits} className=\"text-[14px]\" />\n <div className=\"absolute -top-[10px] left-[48px] mb-2 size-[16px] origin-top-left rotate-45 transform rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n </div>\n </div>\n </div>\n )\n}\n\nexport default RedeemableItem\n"],
5
- "mappings": "AAyHQ,cAAAA,EA6CA,QAAAC,MA7CA,oBAzHR,OAAS,UAAAC,EAAQ,QAAAC,EAAM,WAAAC,MAAe,wBACtC,OAAS,WAAAC,MAAe,QACxB,OAAS,MAAAC,MAAU,mBAGnB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,gBAAAC,MAAoB,mBAC7B,OAAS,WAAAC,MAAe,yBAExB,SAASC,EAAe,CACtB,KAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,iBAAAC,CACF,EAYG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,EAAIb,EAAkB,EAChB,CAAE,QAAAc,EAAS,WAAAC,CAAW,EAAId,EAC9B,CAAC,EACD,CACE,QAAS,IAAM,QAAQ,IAAI,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vB,EAAC,OAAI,UAAU,mHACb,UAAAD,EAACG,EAAA,CAAK,GAAG,IAAI,KAAK,IAAI,KAAMS,GAAM,oBAAqB,UAAU,cAAc,EAC/EZ,EAAC,OAAI,UAAU,mHAAmH,GACpI,EACF,GACF,GACF,GACF,CAEJ,CAEA,IAAO8B,EAAQnB",
6
- "names": ["jsx", "jsxs", "Button", "Text", "Picture", "useMemo", "cn", "useCreditsContext", "useRedeemAndBuy", "numberFormat", "gaTrack", "RedeemableItem", "copy", "itemData", "setRules", "className", "authCodeActivate", "creditInfo", "profile", "openSignUpPopup", "pageGroup", "trigger", "isMutating", "isLogin", "inSufficientCredit", "isDisabled", "handleRedeem", "buyNow", "redeemButtonText", "e", "RedeemableItem_default"]
4
+ "sourcesContent": ["import { Button, Text, Picture } from '@anker-in/headless-ui'\nimport { useMemo, useState } from 'react'\nimport { cn } from '../../../helpers'\n\nimport { CreditsCashCopy, RedeemItem } from './type'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemAndBuy } from '../context/hooks/useRedeemAndBuy'\nimport { numberFormat } from '../context/utils'\nimport { gaTrack } from '../../../helpers/track'\n\nfunction RedeemableItem({\n copy,\n itemData,\n setRules,\n className,\n authCodeActivate,\n}: {\n copy: CreditsCashCopy\n itemData: RedeemItem\n className?: string\n setRules: (rules: string[]) => void\n currencyCode: string\n authCodeActivate: {\n openAuthCodePopup: Function\n isSuccess: boolean\n }\n}) {\n const {\n creditInfo,\n profile,\n openSignUpPopup,\n gtm: { pageGroup },\n } = useCreditsContext()\n const [error, setError] = useState<string | null>(null)\n const { trigger, isMutating } = useRedeemAndBuy(\n {},\n {\n onError: error => {\n setError(error.message)\n },\n }\n )\n\n const isLogin = useMemo(() => {\n return !!profile\n }, [profile?.activated])\n\n const inSufficientCredit = useMemo(() => {\n return (\n isLogin && profile?.activated && itemData.alpcData?.consumeCredits > Number(creditInfo?.available_credit || 0)\n )\n }, [isLogin, profile?.activated, itemData.alpcData?.consumeCredits, creditInfo?.available_credit])\n\n const isDisabled = useMemo(() => {\n // \u5151\u6362\u9650\u5236\n if (itemData.alpcData?.remainingInventory <= 0 && itemData.alpcData?.isLimited) {\n return true\n }\n\n // \u5546\u54C1\u5E93\u5B58\u9650\u5236\n if (!itemData.productVariant?.availableForSale) {\n return true\n }\n\n // \u79EF\u5206\u4E0D\u8DB3\n if (inSufficientCredit) {\n return true\n }\n return false\n }, [\n itemData.alpcData?.remainingInventory,\n itemData.alpcData?.isLimited,\n itemData.productVariant?.availableForSale,\n inSufficientCredit,\n ])\n\n const handleRedeem = () => {\n setError(null)\n if (!isLogin) {\n openSignUpPopup()\n } else if (!profile?.activated && !authCodeActivate.isSuccess) {\n authCodeActivate.openAuthCodePopup()\n } else {\n trigger({\n productVariant: itemData?.productVariant,\n redeemId: itemData?.config?.redeemId,\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: pageGroup,\n position: copy.title,\n button_name: redeemButtonText,\n info: itemData?.alpcData?.id?.toString(),\n },\n })\n }\n }\n\n const redeemButtonText = useMemo(() => {\n // \u7F3A\u8D27\u6587\u6848\n if (!itemData.productVariant?.availableForSale) {\n return copy?.soldOut || 'Sold Out'\n } else if (!isLogin) {\n return copy.unlockRewards\n } else {\n return copy.btnRedeem\n }\n }, [isLogin, itemData.productVariant?.availableForSale, copy.btnRedeem, copy.unlockRewards, copy?.soldOut])\n\n return (\n <div\n className={cn(\n 'flex flex-col items-center rounded-[16px] bg-[#EAEAEC] p-[24px] md:rounded-[12px] md:px-[8px] xl:py-[16px] md-xl:px-[16px]',\n className\n )}\n >\n <div className={cn('relative mx-auto h-[224px] w-fit l:h-[120px] l-xxl:h-[138px]')}>\n <Picture\n className=\"mx-auto h-full w-auto\"\n imgClassName=\"h-full object-contain\"\n source={\n itemData?.config?.image?.url ||\n itemData?.productVariant?.metafields?.global?.transparentImg ||\n itemData?.productVariant?.image?.url\n }\n ></Picture>\n </div>\n <div className={cn('mt-[22px] w-full l:mt-[8px]')}>\n <Text\n html={itemData?.product?.title}\n title={itemData.config?.title || itemData.alpcData?.title || itemData.product?.title}\n size={2}\n className=\"line-clamp-2 h-[58px] text-[24px] leading-[1.2] l:h-[40px] l:text-[16px] l-xxl:h-[48px] l-xxl:text-[20px]\"\n />\n {itemData?.config?.rules?.split('<br>')?.length > 0 && (\n <button\n type=\"button\"\n onClick={() => {\n setRules(itemData?.config?.rules?.split('<br>'))\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: pageGroup,\n position: copy.title,\n button_name: copy?.ruleLabel,\n info: itemData?.alpcData?.id?.toString(),\n },\n })\n }}\n className=\"mt-[8px] text-[16px] font-bold underline xxl:text-[14px]\"\n tabIndex={0}\n onKeyDown={e => {\n if (e.key === 'Enter' || e.key === ' ') {\n e.preventDefault()\n }\n }}\n >\n {copy?.ruleLabel}\n </button>\n )}\n <div className=\"mt-[24px] flex items-center l:mt-[12px] laptop:text-[16px] lg-desktop:text-[18px]\">\n <Picture\n className=\"size-[24px] l-xxl:size-[22px] md-l:size-[18px] md:size-[16px]\"\n source=\"https://cdn.shopify.com/s/files/1/0511/6346/3874/files/icon_hire_purchase.png?v=1757496783\"\n />\n <Text\n html={`${numberFormat(itemData?.alpcData?.consumeCredits)} + ${itemData?.config?.price}`}\n size={2}\n as=\"p\"\n className=\"ml-[4px] mt-[4px] text-[28px] font-bold leading-none md:text-[18px] l-xxl:text-[24px] md-l:text-[20px] \"\n />\n </div>\n\n <div className=\"group relative w-full\">\n <Button\n disabled={isDisabled}\n variant=\"primary\"\n size=\"lg\"\n className=\"mt-[8px] md:px-[10px] l:w-full\"\n loading={isMutating}\n onClick={() => {\n handleRedeem()\n }}\n title={inSufficientCredit ? copy.insufficientCredits : redeemButtonText}\n >\n {redeemButtonText}\n </Button>\n <div\n className={cn(\n 'absolute -bottom-[20px] left-0 z-10 w-[300px] translate-y-full opacity-0 transition-opacity group-hover:opacity-100 md:-bottom-[14px] md:w-[160px]',\n inSufficientCredit ? 'block' : 'hidden'\n )}\n >\n <div className=\"relative rounded-[10px] bg-[#6D6D6F] p-[16px] text-[14px] font-medium text-white shadow md:px-[10px] md:py-[8px]\">\n <Text as=\"p\" size=\"2\" html={copy?.insufficientCredits} className=\"text-[14px]\" />\n <div className=\"absolute -top-[10px] left-[48px] mb-2 size-[16px] origin-top-left rotate-45 transform rounded-[2px] bg-[#6D6D6F]\" />\n </div>\n </div>\n </div>\n </div>\n {error && <div className=\"mt-[8px] text-[14px] text-[#FF0000]\">{error}</div>}\n </div>\n )\n}\n\nexport default RedeemableItem\n"],
5
+ "mappings": "AAwHQ,cAAAA,EA6CA,QAAAC,MA7CA,oBAxHR,OAAS,UAAAC,EAAQ,QAAAC,EAAM,WAAAC,MAAe,wBACtC,OAAS,WAAAC,EAAS,YAAAC,MAAgB,QAClC,OAAS,MAAAC,MAAU,mBAGnB,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,gBAAAC,MAAoB,mBAC7B,OAAS,WAAAC,MAAe,yBAExB,SAASC,EAAe,CACtB,KAAAC,EACA,SAAAC,EACA,SAAAC,EACA,UAAAC,EACA,iBAAAC,CACF,EAUG,CACD,KAAM,CACJ,WAAAC,EACA,QAAAC,EACA,gBAAAC,EACA,IAAK,CAAE,UAAAC,CAAU,CACnB,EAAIb,EAAkB,EAChB,CAACc,EAAOC,CAAQ,EAAIjB,EAAwB,IAAI,EAChD,CAAE,QAAAkB,EAAS,WAAAC,CAAW,EAAIhB,EAC9B,CAAC,EACD,CACE,QAASa,GAAS,CAChBC,EAASD,EAAM,OAAO,CACxB,CACF,CACF,EAEMI,EAAUrB,EAAQ,IACf,CAAC,CAACc,EACR,CAACA,GAAS,SAAS,CAAC,EAEjBQ,EAAqBtB,EAAQ,IAE/BqB,GAAWP,GAAS,WAAaL,EAAS,UAAU,eAAiB,OAAOI,GA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AU,sCAAuC,SAAAsB,EAAM,GACxE,CAEJ,CAEA,IAAOU,EAAQpB",
6
+ "names": ["jsx", "jsxs", "Button", "Text", "Picture", "useMemo", "useState", "cn", "useCreditsContext", "useRedeemAndBuy", "numberFormat", "gaTrack", "RedeemableItem", "copy", "itemData", "setRules", "className", "authCodeActivate", "creditInfo", "profile", "openSignUpPopup", "pageGroup", "error", "setError", "trigger", "isMutating", "isLogin", "inSufficientCredit", "isDisabled", "handleRedeem", "redeemButtonText", "e", "RedeemableItem_default"]
7
7
  }