PageSourceSearch

https://portal.ionixpayments.com/_next/static/chunks/pages/commerc…/subscribers/create-7fa18726187c3db4.js

js ionixpayments.com collected 2026-10-09 17:50:59 UTC 15,206 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3276],{23801:(e,l,a)=>{"use strict";a.d(l,{A:()=>u});var s=a(37876),i=a(14232),n=a(40010),r=a(68394),t=a(40935),o=a(55757),d=a(34907),c=a(89632);let u=()=>{let{subscriberId:e}=(0,d.A)(),[l,a]=(0,i.useState)(!1),u=!!e,{data:m,isLoading:p}=(0,c.A)(e),x=null==m?void 0:m.customer;return(0,s.jsx)(n.A,{title:u?"Editar suscriptor":"Crear nuevo suscriptor",shouldConfirm:l,children:p?(0,s.jsx)(o.a,{}):(0,s.jsxs)(s.Fragment,{children:[u&&(0,s.jsx)("div",{className:"mx-auto mb-8 max-w-3xl px-12",children:(0,s.jsxs)(t.l,{variant:"info",className:"font-medium",children:["Est\xe1s editando la informaci\xf3n de"," ",(0,s.jsx)("span",{className:"font-semibold",children:null==x?void 0:x.fullname})]})}),(0,s.jsx)(r.A,{type:u?"edit":"create",subscriber:x,subscriberId:e,setShouldConfirm:a})]})})}},61233:(e,l,a)=>{"use strict";a.r(l),a.d(l,{default:()=>c});var s=a(37876),i=a(76976),n=a(23801),r=a(27954),t=a(78800),o=a(59735);let d=()=>(0,s.jsx)(i.I,{paymentOriginId:"subscriptions",pageTitle:"Creaci\xf3n de suscriptor",children:(0,s.jsx)(r.A,{children:(0,s.jsx)(n.A,{})})});d.getLayout=(0,o.k)({headerComponent:(0,s.jsx)(t.A,{title:"Crear Suscriptor"}),config:{hideCaptcha:!0,content:{mobile:{padding:"16px"}}}});let c=d},68394:(e,l,a)=>{"use strict";a.d(l,{A:()=>U});var s=a(37876),i=a(14232),n=a(48230),r=a.n(n),t=a(88992),o=a(23138),d=a(72378),c=a(40935),u=a(76050),m=a(66485),p=a(1613),x=a(80515),h=a(41161),f=a(45411),v=a(34907),j=a(48691),b=a(71170);let g={menuPortal:e=>({...e,zIndex:1100})},N=e=>"string"==typeof e&&b.jk.some(l=>l.value===e)?e:"days",_=e=>{var l,a;let{value:n,onChange:r,errors:t,formTrigger:o}=e,{commerceId:_}=(0,v.A)(),[y,w]=(0,i.useState)(""),{data:A,isLoading:C}=(0,j.Ol)({query:{commerce_id:_,name:y}},{skip:!_}),k=(0,f.A)(e=>{w(e)}),E=[];(null==A||null==(l=A.data)?void 0:l.data)&&(E=A.data.data.map(e=>{var l;return{label:e.name,value:e.id,trial_days:Number(null!=(l=e.free_trial_period)?l:0),trial_period_unit:N(e.free_trial_period_unit),is_plan_active:e.active}}));let S=null==t||null==(a=t.plans)?void 0:a.message,F=n.some(e=>!e.is_plan_active),I=n.filter(e=>!e.is_plan_active).length>1;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)(h.A,{classNames:{container:()=>"w-full"},isLoading:C,value:n,onChange:e=>{r(e.map(e=>{var l,a,s,i,n,r,t,o;let d="number"!=typeof e.trial_days||Number.isNaN(e.trial_days)?Number(null!=(t=null==A||null==(s=A.data)||null==(a=s.data)||null==(l=a.find(l=>l.id===e.value))?void 0:l.free_trial_period)?t:0):e.trial_days,c=null!=(o=e.trial_period_unit)?o:N(null==A||null==(r=A.data)||null==(n=r.data)||null==(i=n.find(l=>l.id===e.value))?void 0:i.free_trial_period_unit);return{...e,trial_days:d,trial_period_unit:c}})),o()},tooltipInfo:"Asigna un plan (creado con anterioridad) al suscriptor.",label:"Asigna uno o m\xe1s planes al suscriptor",options:E,noOptionsMessage:()=>"No se encontraron planes",placeholder:"Selecciona un plan",onInputChange:k,renderOption:(e,l,a)=>{var i,d,c,h,f,v,j,N;let _=null==t?void 0:t.plans,y=null!=(j=null!=(v=null==_||null==(d=_[a])||null==(i=d.trial_days)?void 0:i.message)?v:null==_||null==(h=_[a])||null==(c=h.trial_period_unit)?void 0:c.message)?j:"";return(0,s.jsxs)("div",{className:"flex w-full min-w-0 flex-col gap-2 sm:gap-0",children:[(0,s.jsxs)("div",{className:"flex w-full min-w-0 items-start gap-2",children:[(0,s.jsx)("button",{onClick:l,className:"mt-1 shrink-0 rounded-full p-1 text-text-primary transition-colors hover:bg-neutral-200 sm:mt-7",type:"button","aria-label":"Eliminar ".concat(e.label),children:(0,s.jsx)(x.A,{})}),(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col gap-3 sm:flex-row sm:items-end sm:gap-3",children:[(0,s.jsxs)("div",{className:"flex min-w-0 flex-1 flex-col font-semibold",children:[(0,s.jsx)("span",{className:"text-xs font-medium text-text-primary sm:hidden",children:"Plan de suscripci\xf3n"}),(0,s.jsx)("div",{className:"flex h-[42px] w-full min-w-0 items-center rounded-lg border border-neutral-150 bg-white px-3",children:(0,s.jsx)("span",{className:"min-w-0 break-words text-sm font-semibold text-text-primary sm:text-base",title:String(e.label),children:e.label})})]}),(0,s.jsxs)("div",{className:"w-full shrink-0 font-normal sm:w-auto 
1sm:min-w-[12.5rem] sm:max-w-[14rem]",children:[(0,s.jsx)("span",{className:"block text-xs font-medium leading-tight text-text-secondary",children:"Periodo de prueba"}),(0,s.jsxs)("div",{className:"mt-1.5 flex min-w-0 flex-wrap items-end gap-2 sm:flex-nowrap",children:[(0,s.jsxs)("div",{className:"min-w-[4.5rem] shrink-0 sm:w-20",children:[(0,s.jsx)("span",{className:"mb-0.5 block text-xs font-medium text-text-primary sm:hidden",children:"Cantidad"}),(0,s.jsx)(u.p,{id:"trial-period-".concat(String(e.value)),width:"full",maxLength:2,min:0,max:40,className:"!h-[42px]",value:null==(f=n.find(l=>l.value===e.value))?void 0:f.trial_days,onChange:l=>{let a=l.target.value.replaceAll(p.f8,"");r(n.map(l=>{var s;return l.value===e.value?{...l,trial_days:Number(a),trial_period_unit:null!=(s=l.trial_period_unit)?s:"days"}:l})),o()}})]}),(0,s.jsxs)("div",{className:"min-w-0 flex-1 basis-[8rem] sm:basis-auto",children:[(0,s.jsx)("span",{className:"mb-0.5 block text-xs font-medium text-text-primary sm:hidden",children:"Unidad de tiempo"}),(0,s.jsx)(m.l,{inputId:"trial-unit-".concat(String(e.value)),className:"w-full min-w-0",options:b.jk,value:null!=(N=b.jk.find(l=>{var a;return l.value===(null==(a=n.find(l=>l.value===e.value))?void 0:a.trial_period_unit)}))?N:b.jk[0],onChange:l=>{let a=l.value;r(n.map(l=>l.value===e.value?{...l,trial_period_unit:a}:l)),o()},placeholder:"Unidad",menuPortalTarget:"undefined"!=typeof document?document.body:void 0,menuPosition:"fixed",styles:{...g,control:e=>({...e,minHeight:"42px",height:"42px"})}})]})]})]})]})]}),y?(0,s.jsx)("span",{className:"pl-10 text-sm text-red",children:String(y)}):null]})}}),(0,s.jsx)("p",{className:"text-center text-sm font-medium text-gray-300 sm:text-base",children:"Ac\xe1 se ir\xe1n a\xf1adiendo los planes que quieres asignar al suscriptor."}),(0,s.jsx)(d.A,{className:"mt-2 sm:mt-3",children:"El periodo de prueba es opcional. Puedes dejar la cantidad vac\xeda o en cero (0)."}),S?(0,s.jsx)("span",{className:"text-sm font-medium text-red",children:S}):null,F&&(0,s.jsx)(c.l,{variant:"warning",className:"font-medium","aria-label":"Aviso de planes inactivos seleccionados","data-testid":"inactive-plans-notice",children:(0,s.jsxs)("div",{children:[(0,s.jsx)("p",{children:I?"Los siguientes planes de suscripci\xf3n volver\xe1n a estar activos:":"El siguiente plan de suscripci\xf3n volver\xe1 a estar activo:"}),(0,s.jsx)("ul",{className:"list-inside list-disc pl-3",children:n.map(e=>e.is_plan_active?null:(0,s.jsx)("li",{children:(0,s.jsx)("span",{className:"font-semibold",children:e.label})},e.value))})]})})]})};var y=a(30361),w=a(48752);function A(e){return e.reduce((e,l)=>{var a;return e[l.value]={period:l.trial_days,period_unit:null!=(a=l.trial_period_unit)?a:"days"},e},{})}var C=a(89297),k=a(14561),E=a(63397),S=a(79681),F=a(18124),I=a(49462),q=a(16843),P=a(30036),L=a(86465),O=a(55715),$=a(83475),T=a(93830);let D=()=>{let{commerceId:e}=(0,v.A)();return(0,s.jsxs)("p",{children:["Este email pertenece a un suscriptor ya creado. Puedes buscar al suscriptor en"," ",(0,s.jsx)(r(),{className:"!inline-block !font-medium !underline",href:(0,o.Vf6)({commerceId:e}),children:"Mis suscriptores"})," ","para asignarle una suscripci\xf3n o ingresa otro email."]})},U=e=>{var l,a,n;let{type:d,subscriber:m,subscriberId:p,setShouldConfirm:x}=e,[h,f]=(0,i.useState)(!1),j="edit"===d,b="add-plan"===d,{commerceId:g}=(0,v.A)(),[N,{isLoading:U,isSuccess:z,isError:M,isUninitialized:V,reset:B}]=(0,$.cA)(),[J,{isLoading:Q,isSuccess:X,isError:H,isUninitialized:K,reset:W}]=(0,$.B)(),[G,{isLoading:R}]=(0,$.D$)(),Y="create"===d?B:W,Z=()=>f(!1),ee=async()=>{if(!g)return console.error("handleSubscriberMutation - Missing params",{commerceId:g});let e=ea.getValues();try{"create"===d&&await N({commerce_id:g,fullname:e.fullname,email:e.email,phone:e.phone,plan_id_trials:A(e.plans)}).unwrap(),"add-plan"===d&&await J({commerce_id:g,customer_id:p,plan_id_trials:A(e.plans)}).unwrap(),"edit"===d&&(await G({customer_id:p,commerce_id:g,fullname:e.fullname,phone:e.phone}).unwrap(),(0,I.Te)("Suscriptor editado con \xe9xito"),Y())}catch(e){if((0,C.a)(e))return Z(),(0,I.Qg)((0,s.jsx)(D,{}));if((0,C.$)(e))return(0,I.Qg)("No puedes asignar usuarios a planes inactivos.");(0,O.Ay)(e)}},el="+56";
1(null==m?void 0:m.phone)&&(el=(null==m?void 0:m.phone.startsWith("+"))?null==m?void 0:m.phone:"+"+(null==m?void 0:m.phone));let ea=(0,T.A)({defaultValues:{fullname:"",email:"",phone:"+56",plans:[]},schema:(e=>{let{isEdit:l}=e;return w.Ay.object().shape({fullname:w.PW,email:y.D.required(w.gJ),phone:w.D6,plans:w.Ay.array().of(w.Ay.object().shape({label:w.Ay.string(),value:w.Ay.string(),is_plan_active:w.Ay.boolean(),trial_days:w.Ay.number().min(0,"El periodo de prueba no puede ser menor a 0").max(40,"El periodo de prueba no puede ser mayor a 40"),trial_period_unit:w.Ay.string().oneOf(["days","months"],"Unidad de tiempo inv\xe1lida").required()})).when([],{is:()=>!l,then:e=>e.min(1,"Debes seleccionar un plan"),otherwise:e=>e})})})({isEdit:j}),values:{fullname:(null==m?void 0:m.fullname)||"",email:(null==m?void 0:m.email)||"",phone:el,plans:[]},submitHandler:()=>{if(j)return ee();Y(),f(!0)}});(0,i.useEffect)(()=>{x(ea.formState.isDirty)},[ea.formState.isDirty,x]);let es=(null==(l=ea.emailField.error)?void 0:l.type)==="already-exists"?(0,s.jsx)(D,{}):null==(a=ea.emailField.error)?void 0:a.message,ei=ea.watch("fullname"),en=ea.watch("phone"),er=ea.watch("email");return(0,s.jsxs)("form",{className:"mx-auto flex w-full max-w-3xl flex-col gap-4 px-12",onSubmit:ea.handleSubmit,children:[(0,s.jsxs)(L.A,{isOpen:h,onClose:Z,children:[(U||Q)&&(0,s.jsx)("div",{className:"flex justify-center py-8",children:(0,s.jsx)(F.A,{})}),("create"===d?V:K)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"Confirmar inscripci\xf3n al plan"}),(0,s.jsx)("p",{className:"pt-2 font-medium text-text-primary",children:"Le enviaremos un email con un link para pagar el plan de suscripci\xf3n."}),(0,s.jsxs)("p",{className:"font-medium text-text-primary",children:[" ",(0,s.jsx)("span",{className:"font-semibold",children:ei})," tendr\xe1 72 horas para pagar el plan antes de que caduque el link."]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-10 pt-10",children:[(0,s.jsx)(k.$,{type:"button",variant:"outline",className:"px-0",onClick:Z,children:"Cancelar"}),(0,s.jsx)(k.$,{type:"button",onClick:ee,children:"Enviar email"})]})]}),("create"===d?M:H)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"Atenci\xf3n"}),(0,s.jsxs)("p",{className:"pt-2 font-medium text-text-primary",children:["Parece que ha habido un error al intentar enviar el email a"," ",(0,s.jsx)("span",{className:"font-semibold",children:ei}),". \xbfQuieres intentarlo de nuevo?"]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-10 pt-10",children:[(0,s.jsx)(k.$,{type:"button",variant:"outline",className:"px-0",onClick:()=>{Y(),Z()},children:"Cancelar"}),(0,s.jsx)(k.$,{type:"button",onClick:ee,children:"Reintentar"})]})]}),("create"===d?z:X)&&(0,s.jsxs)("div",{children:[(0,s.jsx)("h2",{className:"text-xl font-semibold",children:"Env\xedo confirmado"}),(0,s.jsxs)("p",{className:"pt-2 font-medium text-text-primary",children:["El email fue enviado a"," ",(0,s.jsx)("span",{className:"font-semibold",children:ei}),". Ahora, puedes salir o asignar otra suscripci\xf3n."]}),(0,s.jsxs)("div",{className:"flex items-center justify-end gap-10 pt-10",children:[(0,s.jsx)(r(),{href:(0,o.Vf6)({commerceId:g}),className:(0,q.cn)((0,S.X)(),"text-lg font-medium"),children:"Finalizar"}),(0,s.jsx)(k.$,{type:"button",onClick:()=>{ea.reset(),Z()},children:"Crear otro suscriptor"})]})]})]}),b&&(0,s.jsxs)("div",{className:"flex w-full flex-col gap-6 text-text-primary",children:[(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold",children:"Nombre completo del suscriptor"}),(0,s.jsx)("span",{children:ei})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold",children:"Email del suscriptor"}),(0,s.jsx)("span",{children:er})]}),(0,s.jsxs)("div",{className:"flex flex-col",children:[(0,s.jsx)("span",{className:"font-semibold",children:"Tel\xe9fono del suscriptor"}),(0,s.jsx)("span",{children:en})]})]}),!b&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("p",{className:"font-semibold text-error-200",children:"*Campos obligatorios"}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-1",children:[(0,s.jsx)(E.J,{htmlFor:"subscriber-fullname",variant:"required",className:"text-text-primary",children:"Nombre completo del suscriptor"}),(0,s.jsx)(u.p,{id:"subscriber-fullname",...ea.fullnameField,className:"w-full",variant:ea.fullnameField.error?"error":void 0}),(null==(n=ea.fullnameField.error)?void 0:n.message)?(0,s.jsx)("p",{className:"text-sm text-error-200",children:ea.fullnameField.error.message}):null]}),(0,s.jsxs)("div",{className:"flex w-full flex-col gap-1",children:[(0,s.jsx)(E.J,{htmlFor:"subscriber-email",variant:"required",className:"text-text-primary",children:"Correo electr\xf3nico del suscriptor"}),(0,s.jsx)(u.p,{id:"subscriber-email",...ea.emailField,className:"w-full",disabled:j,variant:es?"error":void 0}),es?(0,s.jsx)("div",{className:"text-sm text-error-200",children:es}):null]}),(0,s.jsx)(t.xI,{name:"phone",control:ea.control,render:e=>{let{field:l,fieldState:{error:a}}=e;return(0,s.jsx)(P.A,{...l,country:"cl",error:null==a?void 0:a.message,className:"w-full",required:!0,label:"Celular de contacto del suscriptor",tooltipInfo:"Indica el n\xfamero de tel\xe9fono del suscriptor.",onChange:e=>{l.onChange("+"+e)},onBlur:l.onBlur,value:l.value})}})]}),!j&&(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("h2",{className:"text-center text-lg font-bold text-light-black",children:"Asignar suscripci\xf3n(es) (opcional)"}),b&&(0,s.jsxs)(c.l,{variant:"info",className:"mb-2",children:["Puedes asignarle una o m\xe1s suscripciones a"," ",(0,s.jsx)("span",{className:"font-bold",children:null==m?void 0:m.fullname})]}),(0,s.jsx)(t.xI,{name:"plans",control:ea.control,render:e=>{let{field:l,formState:{errors:a}}=e;return(0,s.jsx)(_,{value:l.value,onChange:l.onChange,errors:a,formTrigger:ea.trigger})}})]}),(0,s.jsx)(k.$,{type:"submit",disabled:R||U||Q,className:"w-full",children:function(e){let l="Guardar cambios";return"add-plan"===e&&(l="Asignar suscripci\xf3n"),"create"===e&&(l="Crear suscriptor"),l}(d)})]})}},87088:(e,l,a)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/commerce/[commerceId]/subscriptions/subscribers/create",function(){return a(61233)}])},89632:(e,l,a)=>{"use strict";a.d(l,{A:()=>i});var s=a(83475);function i(e){return(0,s.KK)({query:{limit:10,page:1,name_subscription:""},subscriber_id:e},{skip:!e})}}},e=>{e.O(0,[9135,8230,4587,9749,7046,2262,748,3314,5182,4930,2135,8992,2909,3406,8181,4085,15,6678,563,5715,964,1552,9261,6761,659,1878,260,636,6593,8792],()=>e(e.s=87088)),_N_E=e.O()}]);

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.