PageSourceSearch

https://rackety.tv/_next/static/chunks/pages/admin/distributors-15ccbcdef87989eb.js

js rackety.tv collected 2026-10-09 00:02:52 UTC 12,905 bytes, 1 lines download raw bytes

1(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[7426],{1187:(e,r,t)=>{"use strict";t.d(r,{f:()=>j});var a=t(15383),n=t(64935),s=t(62007),l=t(34701),i=t(22274),d=t(40630),o=t(29982),c=t(38399),u=t(13266),m=t(46722),x=t(43486),h=t(97422),p=t(22453),g=t(99068),f=t(39075),b=t(96649),v=t(58811);function j(e){let{id:r,options:t,value:j,onChange:N,placeholder:w="Buscar…",emptyText:y="Sin resultados",removeLabel:C="Quitar",disabled:A,invalid:S,className:M,...D}=e,E=new Map(t.map(e=>[e.value,e])),F=j.map(e=>E.get(e)).filter(Boolean);return(0,a.jsxs)(l.i,{multiple:!0,items:t,value:F,onValueChange:e=>N(e.map(e=>e.value)),isItemEqualToValue:(e,r)=>e.value===r.value,itemToStringLabel:e=>e.label,disabled:A,modal:!1,children:[(0,a.jsxs)(i.H,{"aria-invalid":S||void 0,className:(0,v.cn)("flex min-h-8 w-full flex-wrap items-center gap-1 rounded-lg border border-input bg-transparent px-1.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30",A&&"pointer-events-none opacity-50",M),children:[(0,a.jsx)(d.p,{children:e=>e.map(e=>(0,a.jsxs)(o.e,{className:"flex h-6 items-center gap-1 rounded-md bg-secondary pr-0.5 pl-1.5 text-xs font-medium text-secondary-foreground",children:[e.icon,e.label,(0,a.jsx)(c.a,{"aria-label":C,className:"flex size-5 items-center justify-center rounded text-muted-foreground hover:bg-muted hover:text-foreground",children:(0,a.jsx)(n.A,{className:"size-3"})})]},e.value))}),(0,a.jsx)(u.o,{id:r,placeholder:F.length?"":w,"aria-label":D["aria-label"],"aria-describedby":D["aria-describedby"],className:"h-6 min-w-24 flex-1 bg-transparent px-1 text-sm outline-none placeholder:text-muted-foreground"})]}),(0,a.jsx)(m.K,{children:(0,a.jsx)(x.o,{side:"bottom",align:"start",sideOffset:4,className:"isolate z-[110001]",children:(0,a.jsxs)(h.I,{className:"flex max-h-(--available-height) w-(--anchor-width) min-w-64 flex-col overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10 duration-100 data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95 data-closed:animate-out data-closed:fade-out-0 data-closed:zoom-out-95",children:[(0,a.jsx)(p.$,{className:"px-3 py-2 text-sm text-muted-foreground empty:hidden",children:y}),(0,a.jsx)(g.e,{className:"overflow-y-auto p-1",children:e=>(0,a.jsxs)(f.x,{value:e,className:"flex cursor-default items-center gap-2 rounded-md px-2 py-1.5 text-sm outline-none select-none data-highlighted:bg-accent data-highlighted:text-accent-foreground data-selected:font-medium",children:[e.icon,(0,a.jsx)("span",{className:"truncate",children:e.label}),(0,a.jsx)(b.Q,{className:"ml-auto",children:(0,a.jsx)(s.A,{className:"size-4"})})]},e.value)})]})})})]})}},1982:(e,r,t)=>{"use strict";t.d(r,{R:()=>d});var a=t(33089),n=t.n(a),s=t(80478),l=t.n(s);n().extend(l());class i{standardFormat(e){return n()(e).format("DD/MM/YYYY")}monthFormat(e){return n()(e).format("DD MMM")}hourFormat(e){return n()(e).format("HH:mm DD/MM/YYYY")}hourMinuteFormat(e){return n()(e).format("HH:mm")}footerFormat(e){return n()(e).format("DD/MM - HH:mm")}durationHourFormat(e){return n().duration(e,"seconds").format("HH:mm:ss")}durationMinuteFormat(e){let r=n().duration(e,"seconds").asMinutes();return"".concat(r.toFixed(0),":00")}durationMinuteSecondFormat(e){let r=Math.trunc(e/60),t=Math.trunc(e%60);return t<10?"".concat(r,":0").concat(t):"".concat(r,":").concat(t)}getAge(e){var r=new Date,t=new Date(e),a=r.getFullYear()-t.getFullYear(),n=r.getMonth()-t.getMonth();return(n<0||0===n&&r.getDate()<t.getDate())&&a--,a}}let d=new i},39153:(e,r,t)=>{"use strict";t.r(r),t.d(r,{__N_SSP:()=>L,default:()=>z});var a=t(15383),n=t(14343),s=t(27058),l=t(22895),i=t(55630),d=t(54972),o=t(25258),c=t(6720),u=t(15823),m=t(8887),x=t(88720),h=t(82741),p=t(99170),g=t(1982),f=t(99385),b=t(41196),v=t(90105),j=t(43226);let N=(0,m.FB)();function w(e){let{distributors:r,handleUpdateCallback:t}=e,s=(0,u.useRouter)(),{confirm:l,dialog:d}=(0,f.S)(),o=async e=>{if(await l({title:"Eliminar distribuidor",description:"\xbfEliminar este distribuidor? Esta acci\xf3n no se puede deshacer.",confirmLabel:"Eliminar",destructive:!0}))try{await i.A.delete("/admin/distributors/".concat(e)),p.oR.success("Distribuidor eliminado"),t()}catch(e){var r,a,n,s;p.oR.error((null==e||null==(r=e.response)?void 0:r.status)===409?"El distribuidor tiene clubs adju
1ntos. Desvinc\xfalalos antes de eliminarlo.":null!=(s=null==e||null==(n=e.response)||null==(a=n.data)?void 0:a.message)?s:"Error al eliminar el distribuidor")}},c=(0,n.useMemo)(()=>[N.accessor("name",{header:"Nombre",meta:{filter:"text"},cell:e=>(0,a.jsx)(j.N,{href:"/admin/distributors/".concat(e.row.original.id),className:"font-semibold hover:underline",children:e.getValue()})}),N.display({id:"clubs",header:"Clubs",cell:e=>{var r;let t=null!=(r=e.row.original.clubs)?r:[];return 0===t.length?(0,a.jsx)(b.E,{variant:"outline",children:"Sin clubs"}):(0,a.jsxs)("span",{className:"flex flex-wrap gap-1",children:[t.slice(0,2).map(e=>(0,a.jsx)(b.E,{variant:"secondary",children:e.name},e.id)),t.length>2&&(0,a.jsxs)(b.E,{variant:"outline",children:["+",t.length-2]})]})}}),N.accessor(e=>{var r,t;return null!=(t=null==(r=e._count)?void 0:r.clubs)?t:0},{id:"clubCount",header:"N\xba clubs",meta:{align:"right"}}),N.accessor(e=>{var r,t;return null!=(t=null==(r=e._count)?void 0:r.admins)?t:0},{id:"adminCount",header:"N\xba admins",meta:{align:"right"}}),N.accessor(e=>{var r;return null!=(r=e.createdAt)?r:""},{id:"createdAt",header:"Creado",cell:e=>e.getValue()?g.R.standardFormat(e.getValue()):""}),N.display({id:"actions",header:()=>(0,a.jsx)("span",{className:"block text-right",children:"Acciones"}),meta:{className:"w-24"},cell:e=>(0,a.jsx)(v.uX,{actions:[{label:"Ver detalle",icon:(0,a.jsx)(x.A,{}),onSelect:()=>s.push("/admin/distributors/".concat(e.row.original.id))},{label:"Eliminar",icon:(0,a.jsx)(h.A,{}),onSelect:()=>o(e.row.original.id),destructive:!0}]})})],[s,t]);return(0,a.jsxs)(a.Fragment,{children:[d,(0,a.jsx)(v.bQ,{columns:c,data:null!=r?r:[],getRowId:e=>e.id,pageSize:20,pageSizeOptions:[10,20,50]})]})}var y=t(85098),C=t(63818),A=t(94423),S=t(34482),M=t(72810),D=t(95941),E=t(54136);function F(e){let{open:r,onClose:t,clubs:l=[],onCreated:d}=e,{data:o}
1=(0,s.useSession)(),[c,u]=(0,n.useState)(""),[m,x]=(0,n.useState)([]),[h,p]=(0,n.useState)(""),[g,f]=(0,n.useState)(!1),b=()=>{u(""),x([]),p("")},v=()=>{g||(b(),t())},j=async e=>{if(e.preventDefault(),c.trim()){f(!0),p("");try{let e=await i.A.post("/admin/distributors",{name:c.trim(),clubIds:m},{headers:{Authorization:"Bearer ".concat(null==o?void 0:o.accessToken)}});b(),d(e.data)}catch(e){var r,t,a;p(null!=(a=null==e||null==(t=e.response)||null==(r=t.data)?void 0:r.message)?a:"Error al crear el distribuidor")}finally{f(!1)}}};return(0,a.jsx)(M.lG,{open:r,onOpenChange:e=>!e&&v(),children:(0,a.jsx)(M.Cf,{className:"sm:max-w-md",children:(0,a.jsxs)("form",{onSubmit:j,className:"flex flex-col gap-4",children:[(0,a.jsx)(M.c7,{children:(0,a.jsx)(M.L3,{children:"Nuevo distribuidor"})}),(0,a.jsx)(y.jQ,{children:h}),(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(E.J,{htmlFor:"distributor-name",children:"Nombre"}),(0,a.jsx)(D.p,{id:"distributor-name",value:c,onChange:e=>u(e.target.value),required:!0})]}),(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)(C.A,{id:"create-distributor-clubs",clubs:l,selectedClubIds:m,onChange:x})}),m.length>0&&(0,a.jsx)(A.L7,{tone:"warning",children:"Al adjuntar estos clubs, su facturaci\xf3n propia ACTIVA se desactivar\xe1 y pasar\xe1n a facturarse en la factura consolidada del distribuidor."}),(0,a.jsxs)(M.Es,{children:[(0,a.jsx)(S.$,{type:"button",variant:"outline",onClick:v,disabled:g,children:"Cancelar"}),(0,a.jsx)(S.$,{type:"submit",pending:g,disabled:!c.trim(),children:"Crear"})]})]})})})}var k=t(8378);let _=async(e,r)=>{try{var t;return null!=(t=(await i.A.get(e,{headers:{Authorization:"Bearer ".concat(r)}})).data)?t:[]}catch(e){return console.error(e),[]}};var L=!0;function z(e){let{initialDistributors:r,initialClubs:t}=e,{data:i}=(0,s.useSession)(),[u,m]=(0,n.useState)(r),[x,h]=(0,n.useState)(!1),p=async()=>m(await _("/admin/distributors",null==i?void 0:i.accessToken));return(0,a.jsx)(o.A,{roles:["ADMIN"],children:(0,a.jsxs)(c.A,{menuLinks:d.P,children:[(0,a.jsx)(k.z,{title:"Distribuidores",actions:(0,a.jsxs)(S.$,{onClick:()=>h(!0),children:[(0,a.jsx)(l.A,{"data-icon":"inline-start"}),"Nuevo distribuidor"]})}),(0,a.jsx)("div",{className:"w-full",children:(0,a.jsx)(w,{distributors:u,handleUpdateCallback:p})}),(0,a.jsx)(F,{open:x,onClose:()=>h(!1),clubs:t,onCreated:async()=>{h(!1),await p()}})]})})}},63818:(e,r,t)=>{"use strict";t.d(r,{A:()=>i});var a=t(15383),n=t(74098),s=t(54136),l=t(1187);function i(e){let{id:r="clubs-select",clubs:t,selectedClubIds:i,onChange:d}=e,o=(0,n.A)("pages.AdminApiClientsPage");return(0,a.jsxs)("div",{className:"flex flex-col gap-1.5",children:[(0,a.jsx)(s.J,{htmlFor:r,children:o("clubsLabel")}),(0,a.jsx)(l.f,{id:r,options:t.map(e=>({value:e.id,label:e.name})),value:i,onChange:d,"aria-describedby":"".concat(r,"-helper")}),(0,a.jsx)("p",{id:"".concat(r,"-helper"),className:"text-xs text-muted-foreground",children:o("clubsHelper")})]})}},83575:(e,r,t)=>{(window.__NEXT_P=window.__NEXT_P||[]).push(["/admin/distributors",function(){return t(39153)}])},91147:(e,r,t)=>{"use strict";t.d(r,{T:()=>i});var a=t(15383),n=t(14343),s=t(34482),l=t(72810);function i(e){let{open:r,onOpenChange:t,title:i,description:d,children:o,confirmLabel:c,cancelLabel:u,onConfirm:m,destructive:x=!1}=e,[h,p]=(0,n.useState)(!1),g=async()=>{p(!0);try{await m()}finally{p(!1)}};return(0,a.jsx)(l.lG,{open:r,onOpenChange:t,children:(0,a.jsxs)(l.Cf,{className:"sm:max-w-md",children:[(0,a.jsxs)(l.c7,{children:[(0,a.jsx)(l.L3,{children:i}),d&&(0,a.jsx)(l.rr,{children:d})]}),o,(0,a.jsxs)(l.Es,{children:[(0,a.jsx)(s.$,{variant:"outline",onClick:()=>t(!1),children:u}),(0,a.jsx)(s.$,{variant:x?"destructive":"default",pending:h,onClick:g,children:c})]})]})})}},94423:(e,r,t)=>{"use strict";t.d(r,{D0:()=>c,L7:()=>u,MT:()=>m,TB:()=>x,XY:()=>o});var a=t(15383),n=t(33089),s=t.n(n),l=t(29563),i=t(58811),d=t(54136);function o(e){let{title:r,description:t,actions:n,children:s,className:l}=e;return(0,a.jsxs)("section",{className:(0,i.cn)("flex flex-col gap-5 rounded-2xl border bg-background p-5 md:p-6",l),children:[(0,a.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[(0,a.jsxs)("div",{className:"flex flex-col gap-1",children:[(0,a.jsx)("h2",{className:"text-lg font-semibold",children:r}),t&&(0,a.jsx)("p",{className:"max-w-2xl text-sm text-muted-foreground",children:t})]}),n&&(0,a.jsx)("div",{className:"flex flex-wrap items-center gap-2",children:n})]}),s]})}function c(e){let{id:r,label:t,hint:n,error:s,required:l,children:o,className:c}=e;return(0,a.jsxs)("div",{className:(0,i.cn)("flex flex-col gap-1.5",c),children:[(0,a.jsxs)(d.J,{htmlFor:r,children:[t,l&&(0,a.jsx)("span",{className:"ml-0.5 text-destructive",children:"*"})]}),o,s?(0,a.jsx)("p",{className:"text-xs text-destructive",children:s}):n?(0,a.jsx)("p",{className:"text-xs text-muted-foreground",children:n}):null]})}function u(e){let{tone:r="info",children:t,className:n}=e;return(0,a.jsxs)("p",{role:"status",className:(0,i.cn)("flex items-start gap-2 rounded-lg border px-3 py-2 text-sm","info"===r&&"bg-muted/50 text-muted-foreground","success"===r&&"border-primary/30 bg-primary/5 text-primary","warning"===r&&"border-premium/60 bg-premium/15 text-premium-foreground","error"===r&&"border-destructive/30 bg-destructive/5 text-destructive",n),children:[(0,a.jsx)(l.A,{className:"mt-0.5 size-4 shrink-0","aria-hidden":!0}),(0,a.jsx)("span",{children:t})]})}function m(e,r){if(!e)return;let t=new FileReader;t.onload=e=>{var t;"string"==typeof(null==(t=e.target)?void 0:t.result)&&r(e.target.result)}
1,t.readAsDataURL(e)}function x(e){if(!e)return null;let[r,t]=e.split(":").map(Number);return!Number.isInteger(r)||!Number.isInteger(t)||r>23||t>59?null:s()().hour(r).minute(t).second(0).millisecond(0)}},99385:(e,r,t)=>{"use strict";t.d(r,{S:()=>i});var a=t(15383),n=t(14343),s=t(74098),l=t(91147);function i(){var e,r;let t=(0,s.A)("ConfirmDialog"),[i,d]=(0,n.useState)(null),o=(0,n.useRef)(null),c=(0,n.useCallback)(e=>new Promise(r=>{var t;null==(t=o.current)||t.call(o,!1),o.current=r,d(e)}),[]),u=e=>{var r;null==(r=o.current)||r.call(o,e),o.current=null,d(null)};return{confirm:c,dialog:i?(0,a.jsx)(l.T,{open:!0,onOpenChange:e=>!e&&u(!1),title:i.title,description:i.description,confirmLabel:null!=(e=i.confirmLabel)?e:t("confirm"),cancelLabel:null!=(r=i.cancelLabel)?r:t("cancel"),destructive:i.destructive,onConfirm:()=>u(!0)}):null}}}},e=>{e.O(0,[9999,3692,6839,3833,9192,9441,2276,25,7098,636,6593,8792],()=>e(e.s=83575)),_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.