@anker-in/campaign-ui 0.4.5-beta.4 → 0.4.5-beta.6

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.
@@ -1,4 +1,3 @@
1
- "use strict";var B=Object.create;var a=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var N=(e,i)=>{for(var t in i)a(e,t,{get:i[t],enumerable:!0})},f=(e,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let s of x(i))!k.call(e,s)&&s!==t&&a(e,s,{get:()=>i[s],enumerable:!(n=w(i,s))||n.enumerable});return e};var h=(e,i,t)=>(t=e!=null?B(I(e)):{},f(i||!e||!e.__esModule?a(t,"default",{value:e,enumerable:!0}):t,e)),_=e=>f(a({},"__esModule",{value:!0}),e);var z={};N(z,{CreditsBenefits:()=>S});module.exports=_(z);var o=require("react/jsx-runtime"),y=require("swiper/css"),D=require("swiper/css/grid"),G=require("swiper/css/pagination"),d=require("@anker-in/headless-ui"),b=require("react"),m=require("swiper/modules"),p=require("swiper/react"),g=h(require("./BenefitItem")),C=require("../context/provider"),c=require("@anker-in/lib");const S=({copy:e,id:i})=>{const[t,n]=(0,b.useState)(null),{profile:s,gtm:v}=(0,C.useCreditsContext)(),u=({item:l,index:r})=>{(0,c.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:s?.activated?"active":"not active",event_parameters:{page_group:v.pageGroup,position:e.title,button_name:l.text,info:""}}),t===r?n(null):(n(r),setTimeout(()=>{n(null)},5e3))};return(0,o.jsxs)(d.Container,{id:i,className:"!z-[30] bg-[#F5F5F7]",children:[(0,o.jsx)(d.Heading,{as:"h2",size:"4",html:e?.title}),(0,o.jsx)("div",{className:"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch",children:e.benefits.map((l,r)=>(0,o.jsx)(g.default,{item:l,handleClick:u,isNoteActive:t===r,index:r,bigIcon:e.bigIcon,cardBgColor:e.cardBgColor,cardBorderColor:e.cardBorderColor},r))}),(0,o.jsxs)("div",{className:"mt-[24px] hidden l:block",children:[(0,o.jsx)(p.Swiper,{spaceBetween:16,slidesPerView:2,slidesPerGroup:2,grid:{rows:2,fill:"row"},breakpoints:{768:{slidesPerView:3,slidesPerGroup:3}},wrapperClass:"!items-stretch",modules:[m.Grid,m.Pagination],pagination:{clickable:!0,el:"#benefits-pagination",renderBullet(l,r){return`<div class='${r} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>
2
- </div>`}},children:e.benefits.map((l,r)=>(0,o.jsx)(p.SwiperSlide,{className:(0,c.classNames)("!h-auto !flex",t===r&&"!z-[100]"),children:(0,o.jsx)(g.default,{item:l,handleClick:u,isNoteActive:t===r,index:r,bigIcon:e.bigIcon,cardBgColor:e.cardBgColor,cardBorderColor:e.cardBorderColor})},r))}),(0,o.jsx)("div",{id:"benefits-pagination",className:`mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active>div]:!bg-[#151515]
3
- [&_.swiper-pagination-bullet]:cursor-pointer [&_.swiper-pagination-bullet]:rounded-full`})]}),t&&(0,o.jsx)("div",{role:"button",tabIndex:0,className:"fixed inset-0 z-10",onClick:()=>n(null),onKeyDown:l=>l.key==="Escape"&&n(null)})]})};
1
+ "use strict";var B=Object.create;var l=Object.defineProperty;var w=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var I=Object.getPrototypeOf,k=Object.prototype.hasOwnProperty;var N=(e,i)=>{for(var t in i)l(e,t,{get:i[t],enumerable:!0})},u=(e,i,t,n)=>{if(i&&typeof i=="object"||typeof i=="function")for(let a of x(i))!k.call(e,a)&&a!==t&&l(e,a,{get:()=>i[a],enumerable:!(n=w(i,a))||n.enumerable});return e};var h=(e,i,t)=>(t=e!=null?B(I(e)):{},u(i||!e||!e.__esModule?l(t,"default",{value:e,enumerable:!0}):t,e)),_=e=>u(l({},"__esModule",{value:!0}),e);var z={};N(z,{CreditsBenefits:()=>S});module.exports=_(z);var o=require("react/jsx-runtime"),y=require("swiper/css"),D=require("swiper/css/grid"),G=require("swiper/css/pagination"),d=require("@anker-in/headless-ui"),C=require("react"),m=require("swiper/modules"),c=require("swiper/react"),g=h(require("./BenefitItem")),b=require("../context/provider"),p=require("@anker-in/lib");const S=({copy:e,id:i})=>{const[t,n]=(0,C.useState)(null),{profile:a,gtm:v}=(0,b.useCreditsContext)(),f=({item:s,index:r})=>{(0,p.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:a?.activated?"active":"not active",event_parameters:{page_group:v.pageGroup,position:e.title,button_name:s.text,info:""}}),t===r?n(null):(n(r),setTimeout(()=>{n(null)},5e3))};return(0,o.jsxs)(d.Container,{id:i,className:"!z-[30] bg-[#F5F5F7]",children:[(0,o.jsx)(d.Heading,{as:"h2",size:"4",html:e?.title}),(0,o.jsx)("div",{className:"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch",children:e.benefits.map((s,r)=>(0,o.jsx)(g.default,{item:s,handleClick:f,isNoteActive:t===r,index:r,bigIcon:e.bigIcon,cardBgColor:e.cardBgColor,cardBorderColor:e.cardBorderColor},r))}),(0,o.jsxs)("div",{className:"mt-[24px] hidden l:block",children:[(0,o.jsx)(c.Swiper,{spaceBetween:16,slidesPerView:2,slidesPerGroup:2,grid:{rows:2,fill:"row"},breakpoints:{768:{slidesPerView:3,slidesPerGroup:3}},wrapperClass:"!items-stretch",modules:[m.Grid,m.Pagination],pagination:{clickable:!0,el:"#benefits-pagination",renderBullet(s,r){return`<div class='${r} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>
2
+ </div>`}},children:e.benefits.map((s,r)=>(0,o.jsx)(c.SwiperSlide,{className:(0,p.classNames)("!h-auto !flex",t===r&&"!z-[100]"),children:(0,o.jsx)(g.default,{item:s,handleClick:f,isNoteActive:t===r,index:r,bigIcon:e.bigIcon,cardBgColor:e.cardBgColor,cardBorderColor:e.cardBorderColor})},r))}),(0,o.jsx)("div",{id:"benefits-pagination",className:"mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active]:!bg-[#151515]"})]}),t&&(0,o.jsx)("div",{role:"button",tabIndex:0,className:"fixed inset-0 z-10",onClick:()=>n(null),onKeyDown:s=>s.key==="Escape"&&n(null)})]})};
4
3
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsBenefits/index.tsx"],
4
- "sourcesContent": ["import 'swiper/css'\nimport 'swiper/css/grid'\nimport 'swiper/css/pagination'\n\nimport { Container, Heading } from '@anker-in/headless-ui'\nimport { useState } from 'react'\nimport { Grid, Pagination } from 'swiper/modules'\nimport { Swiper, SwiperSlide } from 'swiper/react'\n\nimport BenefitItem, { type BenefitItemCopy } from './BenefitItem'\nimport { useCreditsContext } from '../context/provider'\nimport { gaTrack, classNames as cn } from '@anker-in/lib'\n\nexport type CreditsBenefitsCopy = {\n title: string\n benefits: BenefitItemCopy[]\n bigIcon?: boolean\n cardBgColor?: string\n cardBorderColor?: string\n}\n\nexport const CreditsBenefits = ({ copy, id }: { copy: CreditsBenefitsCopy; id?: string }) => {\n const [activeNoteIndex, setActiveNoteIndex] = useState<number | null>(null)\n const { profile, gtm } = useCreditsContext()\n const handleClick = ({ item, index }: { item: BenefitItemCopy; index: number }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: copy.title,\n button_name: item.text,\n info: '',\n },\n })\n if (activeNoteIndex === index) {\n setActiveNoteIndex(null)\n } else {\n setActiveNoteIndex(index)\n setTimeout(() => {\n setActiveNoteIndex(null)\n }, 5000)\n }\n }\n\n return (\n <Container id={id} className=\"!z-[30] bg-[#F5F5F7]\">\n <Heading as=\"h2\" size=\"4\" html={copy?.title} />\n <div className=\"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch\">\n {copy.benefits.map((item, index) => (\n <BenefitItem\n key={index}\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n ))}\n </div>\n <div className=\"mt-[24px] hidden l:block\">\n <Swiper\n spaceBetween={16}\n slidesPerView={2}\n slidesPerGroup={2}\n grid={{\n rows: 2,\n fill: 'row',\n }}\n breakpoints={{\n 768: {\n slidesPerView: 3,\n slidesPerGroup: 3,\n },\n }}\n wrapperClass=\"!items-stretch\"\n modules={[Grid, Pagination]}\n pagination={{\n clickable: true,\n el: '#benefits-pagination',\n renderBullet(index, className) {\n return `<div class='${className} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>\n </div>`\n },\n }}\n >\n {copy.benefits.map((item, index) => (\n <SwiperSlide key={index} className={cn('!h-auto !flex', activeNoteIndex === index && '!z-[100]')}>\n <BenefitItem\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n </SwiperSlide>\n ))}\n </Swiper>\n <div\n id=\"benefits-pagination\"\n className=\"mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active>div]:!bg-[#151515] \n [&_.swiper-pagination-bullet]:cursor-pointer [&_.swiper-pagination-bullet]:rounded-full\"\n ></div>\n </div>\n\n {activeNoteIndex && (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"fixed inset-0 z-10\"\n onClick={() => setActiveNoteIndex(null)}\n onKeyDown={e => e.key === 'Escape' && setActiveNoteIndex(null)}\n />\n )}\n </Container>\n )\n}\n"],
5
- "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,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AAC,OAAM,YAAU,EAC1B,WAAY,CACV,UAAW,GACX,GAAI,uBACJ,aAAaA,EAAOE,EAAW,CAC7B,MAAO,eAAeA,CAAS;AAAA,qBAEjC,CACF,EAEC,SAAAV,EAAK,SAAS,IAAI,CAACO,EAAMC,OACxB,OAAC,eAAwB,aAAW,EAAAG,YAAG,gBAAiBT,IAAoBM,GAAS,UAAU,EAC7F,mBAAC,EAAAC,QAAA,CACC,KAAMF,EACN,YAAaD,EACb,aAAcJ,IAAoBM,EAClC,MAAOA,EACP,QAASR,EAAK,QACd,YAAaA,EAAK,YAClB,gBAAiBA,EAAK,gBACxB,GATgBQ,CAUlB,CACD,EACH,KACA,OAAC,OACC,GAAG,sBACH,UAAU;AAAA,mGAEX,GACH,EAECN,MACC,OAAC,OACC,KAAK,SACL,SAAU,EACV,UAAU,qBACV,QAAS,IAAMC,EAAmB,IAAI,EACtC,UAAWS,GAAKA,EAAE,MAAQ,UAAYT,EAAmB,IAAI,EAC/D,GAEJ,CAEJ",
4
+ "sourcesContent": ["import 'swiper/css'\nimport 'swiper/css/grid'\nimport 'swiper/css/pagination'\n\nimport { Container, Heading } from '@anker-in/headless-ui'\nimport { useState } from 'react'\nimport { Grid, Pagination } from 'swiper/modules'\nimport { Swiper, SwiperSlide } from 'swiper/react'\n\nimport BenefitItem, { type BenefitItemCopy } from './BenefitItem'\nimport { useCreditsContext } from '../context/provider'\nimport { gaTrack, classNames as cn } from '@anker-in/lib'\n\nexport type CreditsBenefitsCopy = {\n title: string\n benefits: BenefitItemCopy[]\n bigIcon?: boolean\n cardBgColor?: string\n cardBorderColor?: string\n}\n\nexport const CreditsBenefits = ({ copy, id }: { copy: CreditsBenefitsCopy; id?: string }) => {\n const [activeNoteIndex, setActiveNoteIndex] = useState<number | null>(null)\n const { profile, gtm } = useCreditsContext()\n const handleClick = ({ item, index }: { item: BenefitItemCopy; index: number }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: copy.title,\n button_name: item.text,\n info: '',\n },\n })\n if (activeNoteIndex === index) {\n setActiveNoteIndex(null)\n } else {\n setActiveNoteIndex(index)\n setTimeout(() => {\n setActiveNoteIndex(null)\n }, 5000)\n }\n }\n\n return (\n <Container id={id} className=\"!z-[30] bg-[#F5F5F7]\">\n <Heading as=\"h2\" size=\"4\" html={copy?.title} />\n <div className=\"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch\">\n {copy.benefits.map((item, index) => (\n <BenefitItem\n key={index}\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n ))}\n </div>\n <div className=\"mt-[24px] hidden l:block\">\n <Swiper\n spaceBetween={16}\n slidesPerView={2}\n slidesPerGroup={2}\n grid={{\n rows: 2,\n fill: 'row',\n }}\n breakpoints={{\n 768: {\n slidesPerView: 3,\n slidesPerGroup: 3,\n },\n }}\n wrapperClass=\"!items-stretch\"\n modules={[Grid, Pagination]}\n pagination={{\n clickable: true,\n el: '#benefits-pagination',\n renderBullet(index, className) {\n return `<div class='${className} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>\n </div>`\n },\n }}\n >\n {copy.benefits.map((item, index) => (\n <SwiperSlide key={index} className={cn('!h-auto !flex', activeNoteIndex === index && '!z-[100]')}>\n <BenefitItem\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n </SwiperSlide>\n ))}\n </Swiper>\n <div\n id=\"benefits-pagination\"\n className=\"mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active]:!bg-[#151515]\"\n ></div>\n </div>\n\n {activeNoteIndex && (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"fixed inset-0 z-10\"\n onClick={() => setActiveNoteIndex(null)}\n onKeyDown={e => e.key === 'Escape' && setActiveNoteIndex(null)}\n />\n )}\n </Container>\n )\n}\n"],
5
+ "mappings": "0jBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GAgDM,IAAAI,EAAA,6BAhDNC,EAAO,sBACPC,EAAO,2BACPC,EAAO,iCAEPC,EAAmC,iCACnCC,EAAyB,iBACzBC,EAAiC,0BACjCD,EAAoC,wBAEpCE,EAAkD,4BAClDC,EAAkC,+BAClCC,EAA0C,yBAUnC,MAAMX,EAAkB,CAAC,CAAE,KAAAY,EAAM,GAAAC,CAAG,IAAkD,CAC3F,KAAM,CAACC,EAAiBC,CAAkB,KAAI,YAAwB,IAAI,EACpE,CAAE,QAAAC,EAAS,IAAAC,CAAI,KAAI,qBAAkB,EACrCC,EAAc,CAAC,CAAE,KAAAC,EAAM,MAAAC,CAAM,IAAgD,IACjF,WAAQ,CACN,MAAO,WACP,WAAY,YACZ,qBAAsBJ,GAAS,UAAY,SAAW,aACtD,iBAAkB,CAChB,WAAYC,EAAI,UAChB,SAAUL,EAAK,MACf,YAAaO,EAAK,KAClB,KAAM,EACR,CACF,CAAC,EACGL,IAAoBM,EACtBL,EAAmB,IAAI,GAEvBA,EAAmBK,CAAK,EACxB,WAAW,IAAM,CACfL,EAAmB,IAAI,CACzB,EAAG,GAAI,EAEX,EAEA,SACE,QAAC,aAAU,GAAIF,EAAI,UAAU,uBAC3B,oBAAC,WAAQ,GAAG,KAAK,KAAK,IAAI,KAAMD,GAAM,MAAO,KAC7C,OAAC,OAAI,UAAU,+DACZ,SAAAA,EAAK,SAAS,IAAI,CAACO,EAAMC,OACxB,OAAC,EAAAC,QAAA,CAEC,KAAMF,EACN,YAAaD,EACb,aAAcJ,IAAoBM,EAClC,MAAOA,EACP,QAASR,EAAK,QACd,YAAaA,EAAK,YAClB,gBAAiBA,EAAK,iBAPjBQ,CAQP,CACD,EACH,KACA,QAAC,OAAI,UAAU,2BACb,oBAAC,UACC,aAAc,GACd,cAAe,EACf,eAAgB,EAChB,KAAM,CACJ,KAAM,EACN,KAAM,KACR,EACA,YAAa,CACX,IAAK,CACH,cAAe,EACf,eAAgB,CAClB,CACF,EACA,aAAa,iBACb,QAAS,CAAC,OAAM,YAAU,EAC1B,WAAY,CACV,UAAW,GACX,GAAI,uBACJ,aAAaA,EAAOE,EAAW,CAC7B,MAAO,eAAeA,CAAS;AAAA,qBAEjC,CACF,EAEC,SAAAV,EAAK,SAAS,IAAI,CAACO,EAAMC,OACxB,OAAC,eAAwB,aAAW,EAAAG,YAAG,gBAAiBT,IAAoBM,GAAS,UAAU,EAC7F,mBAAC,EAAAC,QAAA,CACC,KAAMF,EACN,YAAaD,EACb,aAAcJ,IAAoBM,EAClC,MAAOA,EACP,QAASR,EAAK,QACd,YAAaA,EAAK,YAClB,gBAAiBA,EAAK,gBACxB,GATgBQ,CAUlB,CACD,EACH,KACA,OAAC,OACC,GAAG,sBACH,UAAU,iGACX,GACH,EAECN,MACC,OAAC,OACC,KAAK,SACL,SAAU,EACV,UAAU,qBACV,QAAS,IAAMC,EAAmB,IAAI,EACtC,UAAWS,GAAKA,EAAE,MAAQ,UAAYT,EAAmB,IAAI,EAC/D,GAEJ,CAEJ",
6
6
  "names": ["creditsBenefits_exports", "__export", "CreditsBenefits", "__toCommonJS", "import_jsx_runtime", "import_css", "import_grid", "import_pagination", "import_headless_ui", "import_react", "import_modules", "import_BenefitItem", "import_provider", "import_lib", "copy", "id", "activeNoteIndex", "setActiveNoteIndex", "profile", "gtm", "handleClick", "item", "index", "BenefitItem", "className", "cn", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- "use strict";var C=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var s in e)C(t,s,{get:e[s],enumerable:!0})},z=(t,e,s,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of V(e))!k.call(t,m)&&m!==s&&C(t,m,{get:()=>e[m],enumerable:!(u=A(e,m))||u.enumerable});return t};var J=t=>z(C({},"__esModule",{value:!0}),t);var H={};B(H,{default:()=>q});module.exports=J(H);var l=require("react/jsx-runtime"),R=require("@anker-in/headless-ui"),d=require("react"),M=require("../context/provider"),I=require("../context/hooks/useRedeemGoGift"),S=require("../context/hooks/useRedeemProduct"),n=require("../context/const"),y=require("../modal/ModalContainer"),P=require("@anker-in/lib"),L=require("./RedeemVirtualProductModal/VirtualProductInit"),F=require("./RedeemVirtualProductModal/VirtualProductSuccess");function U({item:t,copy:e,onError:s,...u}){const[m,c]=(0,d.useState)(),[b,a]=(0,d.useState)(),[x,f]=(0,d.useState)(!1),{profile:o,fetchCreditInfo:p,gtm:E}=(0,M.useCreditsContext)(),g=t.config?.type===n.ConsumeType.GoGift,v=t.config?.type===n.ConsumeType.GiftCard,{isMutating:T,trigger:N}=(0,I.useRedeemGoGift)({onSuccess(r){if(!r){a(e?.commonError);return}const i=r?.data||r;i?.id?(c(i.id),p(o?.user_id)):h(r.code)},onError(r){a(r.message||e?.commonError)}}),{isMutating:O,trigger:G}=(0,S.useRedeemProduct)({onSuccess(r){if(!r){a(e?.commonError);return}r?.code===0?(c("success"),p(o?.user_id)):h(r.code)},onError(){a(e?.commonError)}}),_=g?T:O,h=r=>{let i;r===n.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(i=e?.redeemLimitError,f(!0)):r===n.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(i=e?.inventoryNotEnough,f(!0)):r===n.AlpcErrorCode.CodeLpcNotEnoughCredits?(i=e?.creditsNotEnough,f(!0),p(o?.user_id)):r===n.AlpcErrorCode.CodeCrossSiteError&&(i=e?.crossSiteError,f(!0)),a(i||e?.commonError||""),s&&s(r)},w=(0,d.useCallback)(async()=>{if(a(""),(0,P.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:E.pageGroup,position:"redeem virtual product modal",button_name:e.confirmButton,info:t.alpc?.id}}),g)N({user_id:o?.user_id,rule_id:Number(t.alpc?.id)});else if(v){const r={email:o?.email||"",firstName:o?.firstName||"",lastName:o?.lastName||"",address1:"Default Address",city:"Default City",province:"Default Province",country:"US",zip:"00000"};G({address:btoa(JSON.stringify(r)),rule_id:Number(t.alpc?.id)})}},[t,o,N,G,g,v,e.confirmButton,E.pageGroup]);return(0,d.useEffect)(()=>()=>{f(!1),a(""),c(void 0)},[]),(0,l.jsxs)(y.CreditsModalContainer,{...u,isOpen:!!t,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-0 md:mb-[24px] px-0",titleClassName:"h-[56px] bg-[#F5F5F7]",children:[m&&!_?(0,l.jsx)(F.VirtualProductSuccess,{item:t,copy:e,disabled:x,onClose:u.onClose}):(0,l.jsx)(L.VirtualProductInit,{item:t,copy:e,loading:_,disabled:x,onConfirm:w}),b&&(0,l.jsx)("div",{className:"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]",children:(0,l.jsx)(R.Text,{className:"text-[14px] font-semibold text-[#1F2021]",html:b})})]})}var q=U;
1
+ "use strict";var C=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var V=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var B=(t,e)=>{for(var s in e)C(t,s,{get:e[s],enumerable:!0})},z=(t,e,s,u)=>{if(e&&typeof e=="object"||typeof e=="function")for(let m of V(e))!k.call(t,m)&&m!==s&&C(t,m,{get:()=>e[m],enumerable:!(u=A(e,m))||u.enumerable});return t};var J=t=>z(C({},"__esModule",{value:!0}),t);var H={};B(H,{default:()=>q});module.exports=J(H);var l=require("react/jsx-runtime"),R=require("@anker-in/headless-ui"),d=require("react"),M=require("../context/provider"),I=require("../context/hooks/useRedeemGoGift"),S=require("../context/hooks/useRedeemProduct"),n=require("../context/const"),y=require("../modal/ModalContainer"),P=require("@anker-in/lib"),L=require("./RedeemVirtualProductModal/VirtualProductInit"),F=require("./RedeemVirtualProductModal/VirtualProductSuccess");function U({item:t,copy:e,onError:s,...u}){const[m,c]=(0,d.useState)(),[b,a]=(0,d.useState)(),[x,f]=(0,d.useState)(!1),{profile:o,fetchCreditInfo:p,gtm:E}=(0,M.useCreditsContext)(),g=t.config?.type===n.ConsumeType.GoGift,v=t.config?.type===n.ConsumeType.GiftCard,{isMutating:T,trigger:_}=(0,I.useRedeemGoGift)({onSuccess(r){if(!r){a(e?.commonError);return}const i=r?.data||r;i?.id?(c(i.id),p(o?.user_id)):h(r.code)},onError(r){a(r.message||e?.commonError)}}),{isMutating:O,trigger:G}=(0,S.useRedeemProduct)({onSuccess(r){if(!r){a(e?.commonError);return}r?.code===0?(c("success"),p(o?.user_id)):h(r.code)},onError(){a(e?.commonError)}}),N=g?T:O,h=r=>{let i;r===n.AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit?(i=e?.redeemLimitError,f(!0)):r===n.AlpcErrorCode.CodeLpcRuleInventoryNotEnough?(i=e?.inventoryNotEnough,f(!0)):r===n.AlpcErrorCode.CodeLpcNotEnoughCredits?(i=e?.creditsNotEnough,f(!0),p(o?.user_id)):r===n.AlpcErrorCode.CodeCrossSiteError&&(i=e?.crossSiteError,f(!0)),a(i||e?.commonError||""),s&&s(r)},w=(0,d.useCallback)(async()=>{if(a(""),(0,P.gaTrack)({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:E.pageGroup,position:"redeem virtual product modal",button_name:e.confirmButton,info:t.alpc?.id}}),g)_({user_id:o?.user_id,rule_id:Number(t.alpc?.id)});else if(v){const r={email:o?.email||"",first_name:o?.firstName||"",last_name:o?.lastName||"",address1:"Default Address",city:"Default City",province:"Default Province",country:"US",zip:"00000"};G({address:btoa(JSON.stringify(r)),rule_id:Number(t.alpc?.id)})}},[t,o,_,G,g,v,e.confirmButton,E.pageGroup]);return(0,d.useEffect)(()=>()=>{f(!1),a(""),c(void 0)},[]),(0,l.jsxs)(y.CreditsModalContainer,{...u,isOpen:!!t,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-0 md:mb-[24px] px-0",titleClassName:"h-[56px] bg-[#F5F5F7]",children:[m&&!N?(0,l.jsx)(F.VirtualProductSuccess,{item:t,copy:e,disabled:x,onClose:u.onClose}):(0,l.jsx)(L.VirtualProductInit,{item:t,copy:e,loading:N,disabled:x,onConfirm:w}),b&&(0,l.jsx)("div",{className:"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]",children:(0,l.jsx)(R.Text,{className:"text-[14px] font-semibold text-[#1F2021]",html:b})})]})}var q=U;
2
2
  //# sourceMappingURL=RedeemVirtualProductModal.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsRedeemList/RedeemVirtualProductModal.tsx"],
4
- "sourcesContent": ["import { Text } from '@anker-in/headless-ui'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { ModalContainerProps } from '../modal/ModalContainer'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemGoGift } from '../context/hooks/useRedeemGoGift'\nimport { useRedeemProduct } from '../context/hooks/useRedeemProduct'\nimport { AlpcErrorCode, ConsumeType } from '../context/const'\nimport { CreditsModalContainer } from '../modal/ModalContainer'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../type'\nimport { gaTrack } from '@anker-in/lib'\nimport { VirtualProductInit } from './RedeemVirtualProductModal/VirtualProductInit'\nimport { VirtualProductSuccess } from './RedeemVirtualProductModal/VirtualProductSuccess'\n\nfunction RedeemVirtualProductModal({\n item,\n copy,\n onError,\n ...props\n}: Omit<ModalContainerProps, 'isOpen'> & {\n item: RedeemableItemType\n copy: RedeemModalCommon\n onError: (code: number) => void\n}) {\n const [giftCardId, setGiftCardId] = useState<string>()\n const [errorInfo, setErrorInfo] = useState<string>()\n\n const [disabled, setDisabled] = useState(false)\n\n const { profile, fetchCreditInfo, gtm } = useCreditsContext()\n\n // \u5224\u65AD\u662F GoGift \u8FD8\u662F GiftCard \u7C7B\u578B\n const isGoGift = item.config?.type === ConsumeType.GoGift\n const isGiftCard = item.config?.type === ConsumeType.GiftCard\n\n // GoGift \u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n const { isMutating: goGiftLoading, trigger: triggerGoGift } = useRedeemGoGift({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n const data = responseData?.data || responseData\n if (data?.id) {\n setGiftCardId(data.id)\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError(error) {\n setErrorInfo(error.message || copy?.commonError)\n },\n })\n\n // GiftCard \u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F46\u4E0D\u9700\u8981\u5730\u5740\n const { isMutating: productLoading, trigger: triggerProduct } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n if (responseData?.code === 0) {\n setGiftCardId('success')\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError() {\n setErrorInfo(copy?.commonError)\n },\n })\n\n const loading = isGoGift ? goGiftLoading : productLoading\n\n const handleRedeemError = (code: number) => {\n let errorMsg: string | undefined\n if (code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy?.redeemLimitError\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy?.inventoryNotEnough\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy?.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy?.crossSiteError\n setDisabled(true)\n }\n\n setErrorInfo(errorMsg || copy?.commonError || '')\n onError && onError(code)\n }\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: 'redeem virtual product modal',\n button_name: copy.confirmButton,\n info: item.alpc?.id,\n },\n })\n\n if (isGoGift) {\n // GoGift \u7C7B\u578B\u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n triggerGoGift({\n user_id: profile?.user_id,\n rule_id: Number(item.alpc?.id),\n })\n } else if (isGiftCard) {\n // GiftCard \u7C7B\u578B\u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F20\u9012\u9ED8\u8BA4\u5730\u5740\n const defaultAddress = {\n email: profile?.email || '',\n firstName: profile?.firstName || '',\n lastName: profile?.lastName || '',\n address1: 'Default Address',\n city: 'Default City',\n province: 'Default Province',\n country: 'US',\n zip: '00000',\n }\n triggerProduct({\n address: btoa(JSON.stringify(defaultAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }\n }, [item, profile, triggerGoGift, triggerProduct, isGoGift, isGiftCard, copy.confirmButton, gtm.pageGroup])\n\n useEffect(() => {\n return () => {\n setDisabled(false)\n setErrorInfo('')\n setGiftCardId(undefined)\n }\n }, [])\n\n return (\n <CreditsModalContainer\n {...props}\n isOpen={!!item}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-0 md:mb-[24px] px-0\"\n titleClassName=\"h-[56px] bg-[#F5F5F7]\"\n >\n {giftCardId && !loading ? (\n <VirtualProductSuccess item={item} copy={copy} disabled={disabled} onClose={props.onClose} />\n ) : (\n <VirtualProductInit item={item} copy={copy} loading={loading} disabled={disabled} onConfirm={handleConfirm} />\n )}\n {errorInfo && (\n <div className=\"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]\">\n <Text className=\"text-[14px] font-semibold text-[#1F2021]\" html={errorInfo}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IACD,IAAM,CACXH,EAAY,EAAK,EACjBF,EAAa,EAAE,EACfF,EAAc,MAAS,CACzB,EACC,CAAC,CAAC,KAGH,QAAC,yBACE,GAAGF,EACJ,OAAQ,CAAC,CAACH,EACV,UAAU,sBACV,gBAAgB,yCAChB,eAAe,wBAEd,UAAAI,GAAc,CAACmB,KACd,OAAC,yBAAsB,KAAMvB,EAAM,KAAMC,EAAM,SAAUO,EAAU,QAASL,EAAM,QAAS,KAE3F,OAAC,sBAAmB,KAAMH,EAAM,KAAMC,EAAM,QAASsB,EAAS,SAAUf,EAAU,UAAWkB,EAAe,EAE7GpB,MACC,OAAC,OAAI,UAAU,0FACb,mBAAC,QAAK,UAAU,2CAA2C,KAAMA,EAAW,EAC9E,GAEJ,CAEJ,CAEA,IAAOpB,EAAQa",
4
+ "sourcesContent": ["import { Text } from '@anker-in/headless-ui'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { ModalContainerProps } from '../modal/ModalContainer'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemGoGift } from '../context/hooks/useRedeemGoGift'\nimport { useRedeemProduct } from '../context/hooks/useRedeemProduct'\nimport { AlpcErrorCode, ConsumeType } from '../context/const'\nimport { CreditsModalContainer } from '../modal/ModalContainer'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../type'\nimport { gaTrack } from '@anker-in/lib'\nimport { VirtualProductInit } from './RedeemVirtualProductModal/VirtualProductInit'\nimport { VirtualProductSuccess } from './RedeemVirtualProductModal/VirtualProductSuccess'\n\nfunction RedeemVirtualProductModal({\n item,\n copy,\n onError,\n ...props\n}: Omit<ModalContainerProps, 'isOpen'> & {\n item: RedeemableItemType\n copy: RedeemModalCommon\n onError: (code: number) => void\n}) {\n const [giftCardId, setGiftCardId] = useState<string>()\n const [errorInfo, setErrorInfo] = useState<string>()\n\n const [disabled, setDisabled] = useState(false)\n\n const { profile, fetchCreditInfo, gtm } = useCreditsContext()\n\n // \u5224\u65AD\u662F GoGift \u8FD8\u662F GiftCard \u7C7B\u578B\n const isGoGift = item.config?.type === ConsumeType.GoGift\n const isGiftCard = item.config?.type === ConsumeType.GiftCard\n\n // GoGift \u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n const { isMutating: goGiftLoading, trigger: triggerGoGift } = useRedeemGoGift({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n const data = responseData?.data || responseData\n if (data?.id) {\n setGiftCardId(data.id)\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError(error) {\n setErrorInfo(error.message || copy?.commonError)\n },\n })\n\n // GiftCard \u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F46\u4E0D\u9700\u8981\u5730\u5740\n const { isMutating: productLoading, trigger: triggerProduct } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n if (responseData?.code === 0) {\n setGiftCardId('success')\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError() {\n setErrorInfo(copy?.commonError)\n },\n })\n\n const loading = isGoGift ? goGiftLoading : productLoading\n\n const handleRedeemError = (code: number) => {\n let errorMsg: string | undefined\n if (code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy?.redeemLimitError\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy?.inventoryNotEnough\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy?.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy?.crossSiteError\n setDisabled(true)\n }\n\n setErrorInfo(errorMsg || copy?.commonError || '')\n onError && onError(code)\n }\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: 'redeem virtual product modal',\n button_name: copy.confirmButton,\n info: item.alpc?.id,\n },\n })\n\n if (isGoGift) {\n // GoGift \u7C7B\u578B\u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n triggerGoGift({\n user_id: profile?.user_id,\n rule_id: Number(item.alpc?.id),\n })\n } else if (isGiftCard) {\n // GiftCard \u7C7B\u578B\u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F20\u9012\u9ED8\u8BA4\u5730\u5740\n const defaultAddress = {\n email: profile?.email || '',\n first_name: profile?.firstName || '',\n last_name: profile?.lastName || '',\n address1: 'Default Address',\n city: 'Default City',\n province: 'Default Province',\n country: 'US',\n zip: '00000',\n }\n triggerProduct({\n address: btoa(JSON.stringify(defaultAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }\n }, [item, profile, triggerGoGift, triggerProduct, isGoGift, isGiftCard, copy.confirmButton, gtm.pageGroup])\n\n useEffect(() => {\n return () => {\n setDisabled(false)\n setErrorInfo('')\n setGiftCardId(undefined)\n }\n }, [])\n\n return (\n <CreditsModalContainer\n {...props}\n isOpen={!!item}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-0 md:mb-[24px] px-0\"\n titleClassName=\"h-[56px] bg-[#F5F5F7]\"\n >\n {giftCardId && !loading ? (\n <VirtualProductSuccess item={item} copy={copy} disabled={disabled} onClose={props.onClose} />\n ) : (\n <VirtualProductInit item={item} copy={copy} loading={loading} disabled={disabled} onConfirm={handleConfirm} />\n )}\n {errorInfo && (\n <div className=\"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]\">\n <Text className=\"text-[14px] font-semibold text-[#1F2021]\" html={errorInfo} />\n </div>\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemVirtualProductModal\n"],
5
+ "mappings": "yaAAA,IAAAA,EAAA,GAAAC,EA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,GAAGF,EACJ,OAAQ,CAAC,CAACH,EACV,UAAU,sBACV,gBAAgB,yCAChB,eAAe,wBAEd,UAAAI,GAAc,CAACmB,KACd,OAAC,yBAAsB,KAAMvB,EAAM,KAAMC,EAAM,SAAUO,EAAU,QAASL,EAAM,QAAS,KAE3F,OAAC,sBAAmB,KAAMH,EAAM,KAAMC,EAAM,QAASsB,EAAS,SAAUf,EAAU,UAAWkB,EAAe,EAE7GpB,MACC,OAAC,OAAI,UAAU,0FACb,mBAAC,QAAK,UAAU,2CAA2C,KAAMA,EAAW,EAC9E,GAEJ,CAEJ,CAEA,IAAOpB,EAAQa",
6
6
  "names": ["RedeemVirtualProductModal_exports", "__export", "RedeemVirtualProductModal_default", "__toCommonJS", "import_jsx_runtime", "import_headless_ui", "import_react", "import_provider", "import_useRedeemGoGift", "import_useRedeemProduct", "import_const", "import_ModalContainer", "import_lib", "import_VirtualProductInit", "import_VirtualProductSuccess", "RedeemVirtualProductModal", "item", "copy", "onError", "props", "giftCardId", "setGiftCardId", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "profile", "fetchCreditInfo", "gtm", "isGoGift", "isGiftCard", "goGiftLoading", "triggerGoGift", "responseData", "data", "handleRedeemError", "error", "productLoading", "triggerProduct", "loading", "code", "errorMsg", "handleConfirm", "defaultAddress"]
7
7
  }
@@ -1,4 +1,3 @@
1
- import{jsx as r,jsxs as a}from"react/jsx-runtime";import"swiper/css";import"swiper/css/grid";import"swiper/css/pagination";import{Container as c,Heading as g}from"@anker-in/headless-ui";import{useState as u}from"react";import{Grid as f,Pagination as b}from"swiper/modules";import{Swiper as C,SwiperSlide as v}from"swiper/react";import s from"./BenefitItem";import{useCreditsContext as B}from"../context/provider";import{gaTrack as w,classNames as x}from"@anker-in/lib";const G=({copy:t,id:d})=>{const[o,n]=u(null),{profile:m,gtm:p}=B(),l=({item:i,index:e})=>{w({event:"ga4Event",event_name:"lp_button",member_active_status:m?.activated?"active":"not active",event_parameters:{page_group:p.pageGroup,position:t.title,button_name:i.text,info:""}}),o===e?n(null):(n(e),setTimeout(()=>{n(null)},5e3))};return a(c,{id:d,className:"!z-[30] bg-[#F5F5F7]",children:[r(g,{as:"h2",size:"4",html:t?.title}),r("div",{className:"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch",children:t.benefits.map((i,e)=>r(s,{item:i,handleClick:l,isNoteActive:o===e,index:e,bigIcon:t.bigIcon,cardBgColor:t.cardBgColor,cardBorderColor:t.cardBorderColor},e))}),a("div",{className:"mt-[24px] hidden l:block",children:[r(C,{spaceBetween:16,slidesPerView:2,slidesPerGroup:2,grid:{rows:2,fill:"row"},breakpoints:{768:{slidesPerView:3,slidesPerGroup:3}},wrapperClass:"!items-stretch",modules:[f,b],pagination:{clickable:!0,el:"#benefits-pagination",renderBullet(i,e){return`<div class='${e} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>
2
- </div>`}},children:t.benefits.map((i,e)=>r(v,{className:x("!h-auto !flex",o===e&&"!z-[100]"),children:r(s,{item:i,handleClick:l,isNoteActive:o===e,index:e,bigIcon:t.bigIcon,cardBgColor:t.cardBgColor,cardBorderColor:t.cardBorderColor})},e))}),r("div",{id:"benefits-pagination",className:`mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active>div]:!bg-[#151515]
3
- [&_.swiper-pagination-bullet]:cursor-pointer [&_.swiper-pagination-bullet]:rounded-full`})]}),o&&r("div",{role:"button",tabIndex:0,className:"fixed inset-0 z-10",onClick:()=>n(null),onKeyDown:i=>i.key==="Escape"&&n(null)})]})};export{G as CreditsBenefits};
1
+ import{jsx as r,jsxs as l}from"react/jsx-runtime";import"swiper/css";import"swiper/css/grid";import"swiper/css/pagination";import{Container as p,Heading as g}from"@anker-in/headless-ui";import{useState as f}from"react";import{Grid as u,Pagination as C}from"swiper/modules";import{Swiper as b,SwiperSlide as v}from"swiper/react";import a from"./BenefitItem";import{useCreditsContext as B}from"../context/provider";import{gaTrack as w,classNames as x}from"@anker-in/lib";const G=({copy:t,id:d})=>{const[o,n]=f(null),{profile:m,gtm:c}=B(),s=({item:i,index:e})=>{w({event:"ga4Event",event_name:"lp_button",member_active_status:m?.activated?"active":"not active",event_parameters:{page_group:c.pageGroup,position:t.title,button_name:i.text,info:""}}),o===e?n(null):(n(e),setTimeout(()=>{n(null)},5e3))};return l(p,{id:d,className:"!z-[30] bg-[#F5F5F7]",children:[r(g,{as:"h2",size:"4",html:t?.title}),r("div",{className:"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch",children:t.benefits.map((i,e)=>r(a,{item:i,handleClick:s,isNoteActive:o===e,index:e,bigIcon:t.bigIcon,cardBgColor:t.cardBgColor,cardBorderColor:t.cardBorderColor},e))}),l("div",{className:"mt-[24px] hidden l:block",children:[r(b,{spaceBetween:16,slidesPerView:2,slidesPerGroup:2,grid:{rows:2,fill:"row"},breakpoints:{768:{slidesPerView:3,slidesPerGroup:3}},wrapperClass:"!items-stretch",modules:[u,C],pagination:{clickable:!0,el:"#benefits-pagination",renderBullet(i,e){return`<div class='${e} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>
2
+ </div>`}},children:t.benefits.map((i,e)=>r(v,{className:x("!h-auto !flex",o===e&&"!z-[100]"),children:r(a,{item:i,handleClick:s,isNoteActive:o===e,index:e,bigIcon:t.bigIcon,cardBgColor:t.cardBgColor,cardBorderColor:t.cardBorderColor})},e))}),r("div",{id:"benefits-pagination",className:"mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active]:!bg-[#151515]"})]}),o&&r("div",{role:"button",tabIndex:0,className:"fixed inset-0 z-10",onClick:()=>n(null),onKeyDown:i=>i.key==="Escape"&&n(null)})]})};export{G as CreditsBenefits};
4
3
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsBenefits/index.tsx"],
4
- "sourcesContent": ["import 'swiper/css'\nimport 'swiper/css/grid'\nimport 'swiper/css/pagination'\n\nimport { Container, Heading } from '@anker-in/headless-ui'\nimport { useState } from 'react'\nimport { Grid, Pagination } from 'swiper/modules'\nimport { Swiper, SwiperSlide } from 'swiper/react'\n\nimport BenefitItem, { type BenefitItemCopy } from './BenefitItem'\nimport { useCreditsContext } from '../context/provider'\nimport { gaTrack, classNames as cn } from '@anker-in/lib'\n\nexport type CreditsBenefitsCopy = {\n title: string\n benefits: BenefitItemCopy[]\n bigIcon?: boolean\n cardBgColor?: string\n cardBorderColor?: string\n}\n\nexport const CreditsBenefits = ({ copy, id }: { copy: CreditsBenefitsCopy; id?: string }) => {\n const [activeNoteIndex, setActiveNoteIndex] = useState<number | null>(null)\n const { profile, gtm } = useCreditsContext()\n const handleClick = ({ item, index }: { item: BenefitItemCopy; index: number }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: copy.title,\n button_name: item.text,\n info: '',\n },\n })\n if (activeNoteIndex === index) {\n setActiveNoteIndex(null)\n } else {\n setActiveNoteIndex(index)\n setTimeout(() => {\n setActiveNoteIndex(null)\n }, 5000)\n }\n }\n\n return (\n <Container id={id} className=\"!z-[30] bg-[#F5F5F7]\">\n <Heading as=\"h2\" size=\"4\" html={copy?.title} />\n <div className=\"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch\">\n {copy.benefits.map((item, index) => (\n <BenefitItem\n key={index}\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n ))}\n </div>\n <div className=\"mt-[24px] hidden l:block\">\n <Swiper\n spaceBetween={16}\n slidesPerView={2}\n slidesPerGroup={2}\n grid={{\n rows: 2,\n fill: 'row',\n }}\n breakpoints={{\n 768: {\n slidesPerView: 3,\n slidesPerGroup: 3,\n },\n }}\n wrapperClass=\"!items-stretch\"\n modules={[Grid, Pagination]}\n pagination={{\n clickable: true,\n el: '#benefits-pagination',\n renderBullet(index, className) {\n return `<div class='${className} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>\n </div>`\n },\n }}\n >\n {copy.benefits.map((item, index) => (\n <SwiperSlide key={index} className={cn('!h-auto !flex', activeNoteIndex === index && '!z-[100]')}>\n <BenefitItem\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n </SwiperSlide>\n ))}\n </Swiper>\n <div\n id=\"benefits-pagination\"\n className=\"mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active>div]:!bg-[#151515] \n [&_.swiper-pagination-bullet]:cursor-pointer [&_.swiper-pagination-bullet]:rounded-full\"\n ></div>\n </div>\n\n {activeNoteIndex && (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"fixed inset-0 z-10\"\n onClick={() => setActiveNoteIndex(null)}\n onKeyDown={e => e.key === 'Escape' && setActiveNoteIndex(null)}\n />\n )}\n </Container>\n )\n}\n"],
5
- "mappings": "AAgDM,cAAAA,EAeA,QAAAC,MAfA,oBAhDN,MAAO,aACP,MAAO,kBACP,MAAO,wBAEP,OAAS,aAAAC,EAAW,WAAAC,MAAe,wBACnC,OAAS,YAAAC,MAAgB,QACzB,OAAS,QAAAC,EAAM,cAAAC,MAAkB,iBACjC,OAAS,UAAAC,EAAQ,eAAAC,MAAmB,eAEpC,OAAOC,MAA2C,gBAClD,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,WAAAC,EAAS,cAAcC,MAAU,gBAUnC,MAAMC,EAAkB,CAAC,CAAE,KAAAC,EAAM,GAAAC,CAAG,IAAkD,CAC3F,KAAM,CAACC,EAAiBC,CAAkB,EAAIb,EAAwB,IAAI,EACpE,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CACC,KAAMY,EACN,YAAaD,EACb,aAAcJ,IAAoBM,EAClC,MAAOA,EACP,QAASR,EAAK,QACd,YAAaA,EAAK,YAClB,gBAAiBA,EAAK,gBACxB,GATgBQ,CAUlB,CACD,EACH,EACAtB,EAAC,OACC,GAAG,sBACH,UAAU;AAAA,mGAEX,GACH,EAECgB,GACChB,EAAC,OACC,KAAK,SACL,SAAU,EACV,UAAU,qBACV,QAAS,IAAMiB,EAAmB,IAAI,EACtC,UAAWO,GAAKA,EAAE,MAAQ,UAAYP,EAAmB,IAAI,EAC/D,GAEJ,CAEJ",
4
+ "sourcesContent": ["import 'swiper/css'\nimport 'swiper/css/grid'\nimport 'swiper/css/pagination'\n\nimport { Container, Heading } from '@anker-in/headless-ui'\nimport { useState } from 'react'\nimport { Grid, Pagination } from 'swiper/modules'\nimport { Swiper, SwiperSlide } from 'swiper/react'\n\nimport BenefitItem, { type BenefitItemCopy } from './BenefitItem'\nimport { useCreditsContext } from '../context/provider'\nimport { gaTrack, classNames as cn } from '@anker-in/lib'\n\nexport type CreditsBenefitsCopy = {\n title: string\n benefits: BenefitItemCopy[]\n bigIcon?: boolean\n cardBgColor?: string\n cardBorderColor?: string\n}\n\nexport const CreditsBenefits = ({ copy, id }: { copy: CreditsBenefitsCopy; id?: string }) => {\n const [activeNoteIndex, setActiveNoteIndex] = useState<number | null>(null)\n const { profile, gtm } = useCreditsContext()\n const handleClick = ({ item, index }: { item: BenefitItemCopy; index: number }) => {\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: copy.title,\n button_name: item.text,\n info: '',\n },\n })\n if (activeNoteIndex === index) {\n setActiveNoteIndex(null)\n } else {\n setActiveNoteIndex(index)\n setTimeout(() => {\n setActiveNoteIndex(null)\n }, 5000)\n }\n }\n\n return (\n <Container id={id} className=\"!z-[30] bg-[#F5F5F7]\">\n <Heading as=\"h2\" size=\"4\" html={copy?.title} />\n <div className=\"mt-[24px] grid grid-cols-4 gap-[16px] l:hidden items-stretch\">\n {copy.benefits.map((item, index) => (\n <BenefitItem\n key={index}\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n ))}\n </div>\n <div className=\"mt-[24px] hidden l:block\">\n <Swiper\n spaceBetween={16}\n slidesPerView={2}\n slidesPerGroup={2}\n grid={{\n rows: 2,\n fill: 'row',\n }}\n breakpoints={{\n 768: {\n slidesPerView: 3,\n slidesPerGroup: 3,\n },\n }}\n wrapperClass=\"!items-stretch\"\n modules={[Grid, Pagination]}\n pagination={{\n clickable: true,\n el: '#benefits-pagination',\n renderBullet(index, className) {\n return `<div class='${className} !flex justify-center size-[8px] rounded-full bg-[#D9D9D9] cursor-pointer items-center'>\n </div>`\n },\n }}\n >\n {copy.benefits.map((item, index) => (\n <SwiperSlide key={index} className={cn('!h-auto !flex', activeNoteIndex === index && '!z-[100]')}>\n <BenefitItem\n item={item}\n handleClick={handleClick}\n isNoteActive={activeNoteIndex === index}\n index={index}\n bigIcon={copy.bigIcon}\n cardBgColor={copy.cardBgColor}\n cardBorderColor={copy.cardBorderColor}\n />\n </SwiperSlide>\n ))}\n </Swiper>\n <div\n id=\"benefits-pagination\"\n className=\"mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active]:!bg-[#151515]\"\n ></div>\n </div>\n\n {activeNoteIndex && (\n <div\n role=\"button\"\n tabIndex={0}\n className=\"fixed inset-0 z-10\"\n onClick={() => setActiveNoteIndex(null)}\n onKeyDown={e => e.key === 'Escape' && setActiveNoteIndex(null)}\n />\n )}\n </Container>\n )\n}\n"],
5
+ "mappings": "AAgDM,cAAAA,EAeA,QAAAC,MAfA,oBAhDN,MAAO,aACP,MAAO,kBACP,MAAO,wBAEP,OAAS,aAAAC,EAAW,WAAAC,MAAe,wBACn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,cAAe,EACf,eAAgB,CAClB,CACF,EACA,aAAa,iBACb,QAAS,CAACF,EAAMC,CAAU,EAC1B,WAAY,CACV,UAAW,GACX,GAAI,uBACJ,aAAagB,EAAOC,EAAW,CAC7B,MAAO,eAAeA,CAAS;AAAA,qBAEjC,CACF,EAEC,SAAAT,EAAK,SAAS,IAAI,CAACO,EAAMC,IACxBtB,EAACQ,EAAA,CAAwB,UAAWI,EAAG,gBAAiBI,IAAoBM,GAAS,UAAU,EAC7F,SAAAtB,EAACS,EAAA,CACC,KAAMY,EACN,YAAaD,EACb,aAAcJ,IAAoBM,EAClC,MAAOA,EACP,QAASR,EAAK,QACd,YAAaA,EAAK,YAClB,gBAAiBA,EAAK,gBACxB,GATgBQ,CAUlB,CACD,EACH,EACAtB,EAAC,OACC,GAAG,sBACH,UAAU,iGACX,GACH,EAECgB,GACChB,EAAC,OACC,KAAK,SACL,SAAU,EACV,UAAU,qBACV,QAAS,IAAMiB,EAAmB,IAAI,EACtC,UAAWO,GAAKA,EAAE,MAAQ,UAAYP,EAAmB,IAAI,EAC/D,GAEJ,CAEJ",
6
6
  "names": ["jsx", "jsxs", "Container", "Heading", "useState", "Grid", "Pagination", "Swiper", "SwiperSlide", "BenefitItem", "useCreditsContext", "gaTrack", "cn", "CreditsBenefits", "copy", "id", "activeNoteIndex", "setActiveNoteIndex", "profile", "gtm", "handleClick", "item", "index", "className", "e"]
7
7
  }
@@ -1,2 +1,2 @@
1
- import{jsx as m,jsxs as B}from"react/jsx-runtime";import{Text as S}from"@anker-in/headless-ui";import{useCallback as y,useEffect as P,useState as f}from"react";import{useCreditsContext as L}from"../context/provider";import{useRedeemGoGift as F}from"../context/hooks/useRedeemGoGift";import{useRedeemProduct as T}from"../context/hooks/useRedeemProduct";import{AlpcErrorCode as s,ConsumeType as _}from"../context/const";import{CreditsModalContainer as O}from"../modal/ModalContainer";import{gaTrack as w}from"@anker-in/lib";import{VirtualProductInit as A}from"./RedeemVirtualProductModal/VirtualProductInit";import{VirtualProductSuccess as V}from"./RedeemVirtualProductModal/VirtualProductSuccess";function k({item:t,copy:r,onError:c,...p}){const[h,a]=f(),[g,n]=f(),[C,d]=f(!1),{profile:o,fetchCreditInfo:l,gtm:b}=L(),u=t.config?.type===_.GoGift,x=t.config?.type===_.GiftCard,{isMutating:R,trigger:E}=F({onSuccess(e){if(!e){n(r?.commonError);return}const i=e?.data||e;i?.id?(a(i.id),l(o?.user_id)):G(e.code)},onError(e){n(e.message||r?.commonError)}}),{isMutating:M,trigger:v}=T({onSuccess(e){if(!e){n(r?.commonError);return}e?.code===0?(a("success"),l(o?.user_id)):G(e.code)},onError(){n(r?.commonError)}}),N=u?R:M,G=e=>{let i;e===s.CodeLpcShopifyCouponRuleRedeemLimit?(i=r?.redeemLimitError,d(!0)):e===s.CodeLpcRuleInventoryNotEnough?(i=r?.inventoryNotEnough,d(!0)):e===s.CodeLpcNotEnoughCredits?(i=r?.creditsNotEnough,d(!0),l(o?.user_id)):e===s.CodeCrossSiteError&&(i=r?.crossSiteError,d(!0)),n(i||r?.commonError||""),c&&c(e)},I=y(async()=>{if(n(""),w({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:b.pageGroup,position:"redeem virtual product modal",button_name:r.confirmButton,info:t.alpc?.id}}),u)E({user_id:o?.user_id,rule_id:Number(t.alpc?.id)});else if(x){const e={email:o?.email||"",firstName:o?.firstName||"",lastName:o?.lastName||"",address1:"Default Address",city:"Default City",province:"Default Province",country:"US",zip:"00000"};v({address:btoa(JSON.stringify(e)),rule_id:Number(t.alpc?.id)})}},[t,o,E,v,u,x,r.confirmButton,b.pageGroup]);return P(()=>()=>{d(!1),n(""),a(void 0)},[]),B(O,{...p,isOpen:!!t,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-0 md:mb-[24px] px-0",titleClassName:"h-[56px] bg-[#F5F5F7]",children:[h&&!N?m(V,{item:t,copy:r,disabled:C,onClose:p.onClose}):m(A,{item:t,copy:r,loading:N,disabled:C,onConfirm:I}),g&&m("div",{className:"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]",children:m(S,{className:"text-[14px] font-semibold text-[#1F2021]",html:g})})]})}var Z=k;export{Z as default};
1
+ import{jsx as m,jsxs as B}from"react/jsx-runtime";import{Text as S}from"@anker-in/headless-ui";import{useCallback as y,useEffect as P,useState as f}from"react";import{useCreditsContext as L}from"../context/provider";import{useRedeemGoGift as F}from"../context/hooks/useRedeemGoGift";import{useRedeemProduct as T}from"../context/hooks/useRedeemProduct";import{AlpcErrorCode as s,ConsumeType as N}from"../context/const";import{CreditsModalContainer as O}from"../modal/ModalContainer";import{gaTrack as w}from"@anker-in/lib";import{VirtualProductInit as A}from"./RedeemVirtualProductModal/VirtualProductInit";import{VirtualProductSuccess as V}from"./RedeemVirtualProductModal/VirtualProductSuccess";function k({item:t,copy:r,onError:c,...p}){const[h,a]=f(),[g,n]=f(),[C,d]=f(!1),{profile:o,fetchCreditInfo:l,gtm:b}=L(),u=t.config?.type===N.GoGift,x=t.config?.type===N.GiftCard,{isMutating:R,trigger:E}=F({onSuccess(e){if(!e){n(r?.commonError);return}const i=e?.data||e;i?.id?(a(i.id),l(o?.user_id)):G(e.code)},onError(e){n(e.message||r?.commonError)}}),{isMutating:M,trigger:v}=T({onSuccess(e){if(!e){n(r?.commonError);return}e?.code===0?(a("success"),l(o?.user_id)):G(e.code)},onError(){n(r?.commonError)}}),_=u?R:M,G=e=>{let i;e===s.CodeLpcShopifyCouponRuleRedeemLimit?(i=r?.redeemLimitError,d(!0)):e===s.CodeLpcRuleInventoryNotEnough?(i=r?.inventoryNotEnough,d(!0)):e===s.CodeLpcNotEnoughCredits?(i=r?.creditsNotEnough,d(!0),l(o?.user_id)):e===s.CodeCrossSiteError&&(i=r?.crossSiteError,d(!0)),n(i||r?.commonError||""),c&&c(e)},I=y(async()=>{if(n(""),w({event:"ga4Event",event_name:"lp_button",member_active_status:o?.activated?"active":"not active",event_parameters:{page_group:b.pageGroup,position:"redeem virtual product modal",button_name:r.confirmButton,info:t.alpc?.id}}),u)E({user_id:o?.user_id,rule_id:Number(t.alpc?.id)});else if(x){const e={email:o?.email||"",first_name:o?.firstName||"",last_name:o?.lastName||"",address1:"Default Address",city:"Default City",province:"Default Province",country:"US",zip:"00000"};v({address:btoa(JSON.stringify(e)),rule_id:Number(t.alpc?.id)})}},[t,o,E,v,u,x,r.confirmButton,b.pageGroup]);return P(()=>()=>{d(!1),n(""),a(void 0)},[]),B(O,{...p,isOpen:!!t,className:"w-[540px] md:h-auto",scrollClassName:"mb-[40px] min-l:px-0 md:mb-[24px] px-0",titleClassName:"h-[56px] bg-[#F5F5F7]",children:[h&&!_?m(V,{item:t,copy:r,disabled:C,onClose:p.onClose}):m(A,{item:t,copy:r,loading:_,disabled:C,onConfirm:I}),g&&m("div",{className:"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]",children:m(S,{className:"text-[14px] font-semibold text-[#1F2021]",html:g})})]})}var Z=k;export{Z as default};
2
2
  //# sourceMappingURL=RedeemVirtualProductModal.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../../../src/components/credits/creditsRedeemList/RedeemVirtualProductModal.tsx"],
4
- "sourcesContent": ["import { Text } from '@anker-in/headless-ui'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { ModalContainerProps } from '../modal/ModalContainer'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemGoGift } from '../context/hooks/useRedeemGoGift'\nimport { useRedeemProduct } from '../context/hooks/useRedeemProduct'\nimport { AlpcErrorCode, ConsumeType } from '../context/const'\nimport { CreditsModalContainer } from '../modal/ModalContainer'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../type'\nimport { gaTrack } from '@anker-in/lib'\nimport { VirtualProductInit } from './RedeemVirtualProductModal/VirtualProductInit'\nimport { VirtualProductSuccess } from './RedeemVirtualProductModal/VirtualProductSuccess'\n\nfunction RedeemVirtualProductModal({\n item,\n copy,\n onError,\n ...props\n}: Omit<ModalContainerProps, 'isOpen'> & {\n item: RedeemableItemType\n copy: RedeemModalCommon\n onError: (code: number) => void\n}) {\n const [giftCardId, setGiftCardId] = useState<string>()\n const [errorInfo, setErrorInfo] = useState<string>()\n\n const [disabled, setDisabled] = useState(false)\n\n const { profile, fetchCreditInfo, gtm } = useCreditsContext()\n\n // \u5224\u65AD\u662F GoGift \u8FD8\u662F GiftCard \u7C7B\u578B\n const isGoGift = item.config?.type === ConsumeType.GoGift\n const isGiftCard = item.config?.type === ConsumeType.GiftCard\n\n // GoGift \u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n const { isMutating: goGiftLoading, trigger: triggerGoGift } = useRedeemGoGift({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n const data = responseData?.data || responseData\n if (data?.id) {\n setGiftCardId(data.id)\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError(error) {\n setErrorInfo(error.message || copy?.commonError)\n },\n })\n\n // GiftCard \u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F46\u4E0D\u9700\u8981\u5730\u5740\n const { isMutating: productLoading, trigger: triggerProduct } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n if (responseData?.code === 0) {\n setGiftCardId('success')\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError() {\n setErrorInfo(copy?.commonError)\n },\n })\n\n const loading = isGoGift ? goGiftLoading : productLoading\n\n const handleRedeemError = (code: number) => {\n let errorMsg: string | undefined\n if (code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy?.redeemLimitError\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy?.inventoryNotEnough\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy?.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy?.crossSiteError\n setDisabled(true)\n }\n\n setErrorInfo(errorMsg || copy?.commonError || '')\n onError && onError(code)\n }\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: 'redeem virtual product modal',\n button_name: copy.confirmButton,\n info: item.alpc?.id,\n },\n })\n\n if (isGoGift) {\n // GoGift \u7C7B\u578B\u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n triggerGoGift({\n user_id: profile?.user_id,\n rule_id: Number(item.alpc?.id),\n })\n } else if (isGiftCard) {\n // GiftCard \u7C7B\u578B\u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F20\u9012\u9ED8\u8BA4\u5730\u5740\n const defaultAddress = {\n email: profile?.email || '',\n firstName: profile?.firstName || '',\n lastName: profile?.lastName || '',\n address1: 'Default Address',\n city: 'Default City',\n province: 'Default Province',\n country: 'US',\n zip: '00000',\n }\n triggerProduct({\n address: btoa(JSON.stringify(defaultAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }\n }, [item, profile, triggerGoGift, triggerProduct, isGoGift, isGiftCard, copy.confirmButton, gtm.pageGroup])\n\n useEffect(() => {\n return () => {\n setDisabled(false)\n setErrorInfo('')\n setGiftCardId(undefined)\n }\n }, [])\n\n return (\n <CreditsModalContainer\n {...props}\n isOpen={!!item}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-0 md:mb-[24px] px-0\"\n titleClassName=\"h-[56px] bg-[#F5F5F7]\"\n >\n {giftCardId && !loading ? (\n <VirtualProductSuccess item={item} copy={copy} disabled={disabled} onClose={props.onClose} />\n ) : (\n <VirtualProductInit item={item} copy={copy} loading={loading} disabled={disabled} onConfirm={handleConfirm} />\n )}\n {errorInfo && (\n <div className=\"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]\">\n <Text className=\"text-[14px] font-semibold text-[#1F2021]\" html={errorInfo} />\n </div>\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemVirtualProductModal\n"],
5
- "mappings": "AAmJI,OAQI,OAAAA,EARJ,QAAAC,MAAA,oBAnJJ,OAAS,QAAAC,MAAY,wBACrB,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,iBAAAC,EAAe,eAAAC,MAAmB,mBAC3C,OAAS,yBAAAC,MAA6B,0BAEtC,OAAS,WAAAC,MAAe,gBACxB,OAAS,sBAAAC,MAA0B,iDACnC,OAAS,yBAAAC,MAA6B,oDAEtC,SAASC,EAA0B,CACjC,KAAAC,EACA,KAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EAIG,CACD,KAAM,CAACC,EAAYC,CAAa,EAAIhB,EAAiB,EAC/C,CAACiB,EAAWC,CAAY,EAAIlB,EAAiB,EAE7C,CAACmB,EAAUC,CAAW,EAAIpB,EAAS,EAAK,EAExC,CAAE,QAAAqB,EAAS,gBAAAC,EAAiB,IAAAC,CAAI,EAAItB,EAAkB,EAGtDuB,EAAWb,EAAK,QAAQ,OAASN,EAAY,OAC7CoB,EAAad,EAAK,QAAQ,OAASN,EAAY,SAG/C,CAAE,WAAYqB,EAAe,QAASC,CAAc,EAAIzB,EAAgB,CAC5E,UAAU0B,EAAc,CACtB,GAAI,CAACA,EAAc,CACjBV,EAAaN,GAAM,WAAW,EAC9B,MACF,CAEA,MAAMiB,EAAOD,GAAc,MAAQA,EAC/BC,GAAM,IACRb,EAAca,EAAK,EAAE,EACrBP,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B,GAAS,OAAS,GACzB,UAAWA,GAAS,WAAa,GACjC,SAAUA,GAAS,UAAY,GAC/B,SAAU,kBACV,KAAM,eACN,SAAU,mBACV,QAAS,KACT,IAAK,OACP,EACAY,EAAe,CACb,QAAS,KAAK,KAAK,UAAUK,CAAc,CAAC,EAC5C,QAAS,OAAO3B,EAAK,MAAM,EAAE,CAC/B,CAAC,CACH,CACF,EAAG,CAACA,EAAMU,EAASM,EAAeM,EAAgBT,EAAUC,EAAYb,EAAK,cAAeW,EAAI,SAAS,CAAC,EAE1G,OAAAxB,EAAU,IACD,IAAM,CACXqB,EAAY,EAAK,EACjBF,EAAa,EAAE,EACfF,EAAc,MAAS,CACzB,EACC,CAAC,CAAC,EAGHpB,EAACU,EAAA,CACE,GAAGQ,EACJ,OAAQ,CAAC,CAACH,EACV,UAAU,sBACV,gBAAgB,yCAChB,eAAe,wBAEd,UAAAI,GAAc,CAACmB,EACdvC,EAACc,EAAA,CAAsB,KAAME,EAAM,KAAMC,EAAM,SAAUO,EAAU,QAASL,EAAM,QAAS,EAE3FnB,EAACa,EAAA,CAAmB,KAAMG,EAAM,KAAMC,EAAM,QAASsB,EAAS,SAAUf,EAAU,UAAWkB,EAAe,EAE7GpB,GACCtB,EAAC,OAAI,UAAU,0FACb,SAAAA,EAACE,EAAA,CAAK,UAAU,2CAA2C,KAAMoB,EAAW,EAC9E,GAEJ,CAEJ,CAEA,IAAOsB,EAAQ7B",
4
+ "sourcesContent": ["import { Text } from '@anker-in/headless-ui'\nimport { useCallback, useEffect, useState } from 'react'\nimport type { ModalContainerProps } from '../modal/ModalContainer'\nimport { useCreditsContext } from '../context/provider'\nimport { useRedeemGoGift } from '../context/hooks/useRedeemGoGift'\nimport { useRedeemProduct } from '../context/hooks/useRedeemProduct'\nimport { AlpcErrorCode, ConsumeType } from '../context/const'\nimport { CreditsModalContainer } from '../modal/ModalContainer'\nimport type { RedeemableItem as RedeemableItemType, RedeemModalCommon } from '../type'\nimport { gaTrack } from '@anker-in/lib'\nimport { VirtualProductInit } from './RedeemVirtualProductModal/VirtualProductInit'\nimport { VirtualProductSuccess } from './RedeemVirtualProductModal/VirtualProductSuccess'\n\nfunction RedeemVirtualProductModal({\n item,\n copy,\n onError,\n ...props\n}: Omit<ModalContainerProps, 'isOpen'> & {\n item: RedeemableItemType\n copy: RedeemModalCommon\n onError: (code: number) => void\n}) {\n const [giftCardId, setGiftCardId] = useState<string>()\n const [errorInfo, setErrorInfo] = useState<string>()\n\n const [disabled, setDisabled] = useState(false)\n\n const { profile, fetchCreditInfo, gtm } = useCreditsContext()\n\n // \u5224\u65AD\u662F GoGift \u8FD8\u662F GiftCard \u7C7B\u578B\n const isGoGift = item.config?.type === ConsumeType.GoGift\n const isGiftCard = item.config?.type === ConsumeType.GiftCard\n\n // GoGift \u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n const { isMutating: goGiftLoading, trigger: triggerGoGift } = useRedeemGoGift({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n const data = responseData?.data || responseData\n if (data?.id) {\n setGiftCardId(data.id)\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError(error) {\n setErrorInfo(error.message || copy?.commonError)\n },\n })\n\n // GiftCard \u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F46\u4E0D\u9700\u8981\u5730\u5740\n const { isMutating: productLoading, trigger: triggerProduct } = useRedeemProduct({\n onSuccess(responseData) {\n if (!responseData) {\n setErrorInfo(copy?.commonError)\n return\n }\n\n if (responseData?.code === 0) {\n setGiftCardId('success')\n fetchCreditInfo(profile?.user_id)\n } else {\n handleRedeemError(responseData.code)\n }\n },\n onError() {\n setErrorInfo(copy?.commonError)\n },\n })\n\n const loading = isGoGift ? goGiftLoading : productLoading\n\n const handleRedeemError = (code: number) => {\n let errorMsg: string | undefined\n if (code === AlpcErrorCode.CodeLpcShopifyCouponRuleRedeemLimit) {\n errorMsg = copy?.redeemLimitError\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcRuleInventoryNotEnough) {\n errorMsg = copy?.inventoryNotEnough\n setDisabled(true)\n } else if (code === AlpcErrorCode.CodeLpcNotEnoughCredits) {\n errorMsg = copy?.creditsNotEnough\n setDisabled(true)\n fetchCreditInfo(profile?.user_id)\n } else if (code === AlpcErrorCode.CodeCrossSiteError) {\n errorMsg = copy?.crossSiteError\n setDisabled(true)\n }\n\n setErrorInfo(errorMsg || copy?.commonError || '')\n onError && onError(code)\n }\n\n const handleConfirm = useCallback(async () => {\n setErrorInfo('')\n\n gaTrack({\n event: 'ga4Event',\n event_name: 'lp_button',\n member_active_status: profile?.activated ? 'active' : 'not active',\n event_parameters: {\n page_group: gtm.pageGroup,\n position: 'redeem virtual product modal',\n button_name: copy.confirmButton,\n info: item.alpc?.id,\n },\n })\n\n if (isGoGift) {\n // GoGift \u7C7B\u578B\u4F7F\u7528\u4E13\u7528\u63A5\u53E3\n triggerGoGift({\n user_id: profile?.user_id,\n rule_id: Number(item.alpc?.id),\n })\n } else if (isGiftCard) {\n // GiftCard \u7C7B\u578B\u4F7F\u7528 Product \u63A5\u53E3\uFF0C\u4F20\u9012\u9ED8\u8BA4\u5730\u5740\n const defaultAddress = {\n email: profile?.email || '',\n first_name: profile?.firstName || '',\n last_name: profile?.lastName || '',\n address1: 'Default Address',\n city: 'Default City',\n province: 'Default Province',\n country: 'US',\n zip: '00000',\n }\n triggerProduct({\n address: btoa(JSON.stringify(defaultAddress)),\n rule_id: Number(item.alpc?.id),\n })\n }\n }, [item, profile, triggerGoGift, triggerProduct, isGoGift, isGiftCard, copy.confirmButton, gtm.pageGroup])\n\n useEffect(() => {\n return () => {\n setDisabled(false)\n setErrorInfo('')\n setGiftCardId(undefined)\n }\n }, [])\n\n return (\n <CreditsModalContainer\n {...props}\n isOpen={!!item}\n className=\"w-[540px] md:h-auto\"\n scrollClassName=\"mb-[40px] min-l:px-0 md:mb-[24px] px-0\"\n titleClassName=\"h-[56px] bg-[#F5F5F7]\"\n >\n {giftCardId && !loading ? (\n <VirtualProductSuccess item={item} copy={copy} disabled={disabled} onClose={props.onClose} />\n ) : (\n <VirtualProductInit item={item} copy={copy} loading={loading} disabled={disabled} onConfirm={handleConfirm} />\n )}\n {errorInfo && (\n <div className=\"mx-auto max-w-full bg-white px-[48px] py-[12px] text-center text-[#FF0000] md:px-[16px]\">\n <Text className=\"text-[14px] font-semibold text-[#1F2021]\" html={errorInfo} />\n </div>\n )}\n </CreditsModalContainer>\n )\n}\n\nexport default RedeemVirtualProductModal\n"],
5
+ "mappings": "AAmJI,OAQI,OAAAA,EARJ,QAAAC,MAAA,oBAnJJ,OAAS,QAAAC,MAAY,wBACrB,OAAS,eAAAC,EAAa,aAAAC,EAAW,YAAAC,MAAgB,QAEjD,OAAS,qBAAAC,MAAyB,sBAClC,OAAS,mBAAAC,MAAuB,mCAChC,OAAS,oBAAAC,MAAwB,oCACjC,OAAS,iBAAAC,EAAe,eAAAC,MAAmB,mBAC3C,OAAS,yBAAAC,MAA6B,0BAEtC,OAAS,WAAAC,MAAe,gBACxB,OAAS,sBAAAC,MAA0B,iDACnC,OAAS,yBAAAC,MAA6B,oDAEtC,SAASC,EAA0B,CACjC,KAAAC,EACA,KAAAC,EACA,QAAAC,EACA,GAAGC,CACL,EAIG,CACD,KAAM,CAACC,EAAYC,CAAa,EAAIhB,EAAiB,EAC/C,CAACiB,EAAWC,CAAY,EAAIlB,EAAiB,EAE7C,CAACmB,EAAUC,CAAW,EAAIpB,EAAS,EAAK,EAExC,CAAE,QAAAqB,EAAS,gBAAAC,EAAiB,IAAAC,CAAI,EAAItB,EAAkB,EAGtDuB,EAAWb,EAAK,QAAQ,OAASN,EAAY,OAC7CoB,EAAad,EAAK,QAAQ,OAASN,EAAY,SAG/C,CAAE,WAAYqB,EAAe,QAASC,CAAc,EAAIzB,EAAgB,CAC5E,UAAU0B,EAAc,CACtB,GAAI,CAACA,EAAc,CACjBV,EAAaN,GAAM,WAAW,EA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,QAAS,OAAOV,EAAK,MAAM,EAAE,CAC/B,CAAC,UACQc,EAAY,CAErB,MAAMa,EAAiB,CACrB,MAAOjB,GAAS,OAAS,GACzB,WAAYA,GAAS,WAAa,GAClC,UAAWA,GAAS,UAAY,GAChC,SAAU,kBACV,KAAM,eACN,SAAU,mBACV,QAAS,KACT,IAAK,OACP,EACAY,EAAe,CACb,QAAS,KAAK,KAAK,UAAUK,CAAc,CAAC,EAC5C,QAAS,OAAO3B,EAAK,MAAM,EAAE,CAC/B,CAAC,CACH,CACF,EAAG,CAACA,EAAMU,EAASM,EAAeM,EAAgBT,EAAUC,EAAYb,EAAK,cAAeW,EAAI,SAAS,CAAC,EAE1G,OAAAxB,EAAU,IACD,IAAM,CACXqB,EAAY,EAAK,EACjBF,EAAa,EAAE,EACfF,EAAc,MAAS,CACzB,EACC,CAAC,CAAC,EAGHpB,EAACU,EAAA,CACE,GAAGQ,EACJ,OAAQ,CAAC,CAACH,EACV,UAAU,sBACV,gBAAgB,yCAChB,eAAe,wBAEd,UAAAI,GAAc,CAACmB,EACdvC,EAACc,EAAA,CAAsB,KAAME,EAAM,KAAMC,EAAM,SAAUO,EAAU,QAASL,EAAM,QAAS,EAE3FnB,EAACa,EAAA,CAAmB,KAAMG,EAAM,KAAMC,EAAM,QAASsB,EAAS,SAAUf,EAAU,UAAWkB,EAAe,EAE7GpB,GACCtB,EAAC,OAAI,UAAU,0FACb,SAAAA,EAACE,EAAA,CAAK,UAAU,2CAA2C,KAAMoB,EAAW,EAC9E,GAEJ,CAEJ,CAEA,IAAOsB,EAAQ7B",
6
6
  "names": ["jsx", "jsxs", "Text", "useCallback", "useEffect", "useState", "useCreditsContext", "useRedeemGoGift", "useRedeemProduct", "AlpcErrorCode", "ConsumeType", "CreditsModalContainer", "gaTrack", "VirtualProductInit", "VirtualProductSuccess", "RedeemVirtualProductModal", "item", "copy", "onError", "props", "giftCardId", "setGiftCardId", "errorInfo", "setErrorInfo", "disabled", "setDisabled", "profile", "fetchCreditInfo", "gtm", "isGoGift", "isGiftCard", "goGiftLoading", "triggerGoGift", "responseData", "data", "handleRedeemError", "error", "productLoading", "triggerProduct", "loading", "code", "errorMsg", "handleConfirm", "defaultAddress", "RedeemVirtualProductModal_default"]
7
7
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anker-in/campaign-ui",
3
- "version": "0.4.5-beta.04",
3
+ "version": "0.4.5-beta.06",
4
4
  "description": "Campaign UI components and utilities for Anker projects",
5
5
  "main": "./dist/cjs/index.js",
6
6
  "module": "./dist/esm/index.js",
@@ -103,8 +103,7 @@ export const CreditsBenefits = ({ copy, id }: { copy: CreditsBenefitsCopy; id?:
103
103
  </Swiper>
104
104
  <div
105
105
  id="benefits-pagination"
106
- className="mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active>div]:!bg-[#151515]
107
- [&_.swiper-pagination-bullet]:cursor-pointer [&_.swiper-pagination-bullet]:rounded-full"
106
+ className="mx-auto mt-[12px] grid !w-fit grid-flow-col [&_.swiper-pagination-bullet-active]:!bg-[#151515]"
108
107
  ></div>
109
108
  </div>
110
109
 
@@ -121,8 +121,8 @@ function RedeemVirtualProductModal({
121
121
  // GiftCard 类型使用 Product 接口,传递默认地址
122
122
  const defaultAddress = {
123
123
  email: profile?.email || '',
124
- firstName: profile?.firstName || '',
125
- lastName: profile?.lastName || '',
124
+ first_name: profile?.firstName || '',
125
+ last_name: profile?.lastName || '',
126
126
  address1: 'Default Address',
127
127
  city: 'Default City',
128
128
  province: 'Default Province',