PageSourceSearch

https://maasy.ai/assets/AdminPartnersPanel-sVZ4X_is.js

js maasy.ai collected 2026-09-24 13:57:03 UTC 8,637 bytes, 2 lines download raw bytes

1import{z as Y,bt as D,c6 as I,D as f,s as P,r as d,j as e,n as E,q as B,aH as G,aI as X,aB as $,a3 as U,S as y,a as N,b as w,c as C,d as c,Q as _,ct as W,cu as Z,cv as M,cw as o,cx as ee,cy as u,p as S,h as se,B as A,at as ae,au as re,av as te,aw as ne,ay as le,R as ce,Y as ie,ag as de}from"./index-CuMcGkrh.js";import{B as oe}from"./building-2-JF30UcJJ.js";import{f as z}from"./format-2IgJ5YnW.js";import"./en-US-xHSDCZDo.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new a.Error().stack;n&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[n]="ad91216b-f352-40f1-94b9-c0166d80d960",a._sentryDebugIdIdentifier="sentry-dbid-ad91216b-f352-40f1-94b9-c0166d80d960")}catch{}})();const O="efab7355-6fe1-40b8-b31d-4d947d08a069",ue="5f85a2db-ae28-48da-bec9-795022f53fa2",me={creator:O};function xe(){return Y({queryKey:["partner-submissions"],queryFn:async()=>{const{data:a,error:n}=await P.from("crm_web_form_submissions").select("*").in("form_id",[O,ue]).order("created_at",{ascending:!1}).limit(500);if(n)throw n;return a||[]}})}function he(){const a=D();return I({mutationFn:async n=>{const{data:r,error:l}=await P.functions.invoke("approve-partner",{body:n});if(l)throw l;if(r!=null&&r.error)throw new Error(r.error);return r},onSuccess:()=>{a.invalidateQueries({queryKey:["partner-submissions"]}),f.success("toast_success.partner_aprobado","Partner aprobado")},onError:n=>f.error("toast_error.operation_failed",n.message)})}function pe(){const a=D();return I({mutationFn:async n=>{const{data:r,error:l}=await P.functions.invoke("reject-partner",{body:n});if(l)throw l;if(r!=null&&r.error)throw new Error(r.error);return r},onSuccess:()=>{a.invalidateQueries({queryKey:["partner-submissions"]}),f.success("toast_success.partner_rechazado","Partner rechazado")},onError:n=>f.error("toast_error.operation_failed",n.message)})}function m(a){return a.form_id===me.creator?"creator":"agency"}function ve(){const{data:a,isLoading:n}=xe(),r=he(),l=pe(),[x,H]=d.useState("all"),[h,q]=d.useState("all"),[p,Q]=d.useState(""),[t,j]=d.useState(null),[T,F]=d.useState("maker"),[g,R]=d.useState(""),k=d.useMemo(()=>a?a.filter(s=>{if(x!=="all"&&m(s)!==x||h!=="all"&&s.status!==h)return!1;if(p){const i=p.toLowerCase();if(!JSON.stringify(s.data).toLowerCase().includes(i))return!1}return!0}):[],[a,x,h,p]),b=d.useMemo(()=>a?{total:a.length,pending:a.filter(s=>s.status==="processed").length,approved:a.filter(s=>s.status==="approved").length,rejected:a.filter(s=>s.status==="rejected").length}:{total:0,pending:0,approved:0,rejected:0},[a]),V=s=>{j(s),F("maker"),R("")},K=async()=>{t&&(await r.mutateAsync({submission_id:t.id,kind:m(t),tier:m(t)==="creator"?T:void 0,notes:g||void 0}),j(null))},L=async()=>{t&&(await l.mutateAsync({submission_id:t.id,kind:m(t),notes:g||void 0}),j(null))},J=s=>{const v={processed:{label:"Pendiente",cls:"bg-amber-500/10 text-amber-400 border-amber-500/30"},approved:{label:"Aprobado",cls:"bg-emerald-500/10 text-emerald-400 border-emerald-500/30"},rejected:{label:"Rechazado",cls:"bg-red-500/10 text-red-400 border-red-500/30"}}[s]||{label:s,cls:""};return e.jsx(S,{className:`border ${v.cls}`,children:v.label})};return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"grid gap-4 md:grid-cols-4",children:[{label:"Total",value:b.total},{label:"Pendientes",value:b.pending},{label:"Aprobados",value:b.approved},{label:"Rechazados",value:b.rejected}].map(s=>e.jsx(E,{children:e.jsxs(B,{className:"p-4",children:[e.jsx("p",{className:"text-xs text-muted-foreground",children:s.label}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:s.value})]})},s.label))}),e.jsxs(E,{children:[e.jsx(G,{className:"flex flex-row items-center justify-between gap-3",children:e.jsx(X,{children:"Aplicaciones a Partners"})}),e.jsxs(B,{className:"space-y-4",children:[e.jsxs("div",{className:"flex flex-wrap gap-3",children:[e.jsxs("div",{className:"relative flex-1 min-w-[200px]",children:[e.jsx($,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(U,{placeholder:"Buscar por nombre, email, país...",value:p,onChange:s=>Q(s.target.value),className:"pl-9"})]}),e.jsxs(y,{value:x,onValueChange:s=>H(s),children:[e.jsx(N,{className:"w-[160px]",children:e.jsx(w,{})}),e.jsxs(C,{children:[e.jsx(c,{value:"all",children:"Todos los tipos"}),e.jsx(c,{value:"creator",children:"Creators"}),e.jsx(c,{value:"agency",children:"Agencias"})]})]}),e.jsxs(y,{value:h,onValueChange:s=>q(s),children:[e.jsx(N,{className:"w-[160px]",children:e.jsx(w,{})}),e.jsxs(C,{children:[e.jsx(c,{value:"all",children:"Todos los estados"}),e.jsx(c,{value:"processed",children:"Pendientes"}),e.jsx(c,{value:"approved",children:"Aprobados"}),e.jsx(c,{value:"rejected",children:"Rechazados"})]})]})]}),n?e.jsxs("div",{className:"flex items-center justify-center py-10 text-muted-foreground",children:[e.jsx(_,{className:"h-5 w-5 animate-spin mr-2"})," Cargando..."]}):k.length===0?e.jsx("p",{className:"text-center text-sm text-muted-foreground py-10",children:"No hay aplicaciones con esos filtros."}):e.jsx("div",{className:"overflow-x-auto",children:e.jsxs(W,{children:[e.jsx(Z,{children:e.jsxs(M,{children:[e.jsx(o,{children:"Tipo"}),e.jsx(o,{children:"Nombre"}),e.jsx(o,{children:"Email"}),e.jsx(o,{children:"País"}),e.jsx(o,{children:"Estado"}),e.jsx(o,{children:"Fecha"}),e.jsx(o,{})]})}),e.jsx(ee,{children:k.map(s=>{const i=m(s);return e.jsxs(M,{className:"cursor-pointer",onClick:()=>V(s),children:[e.jsx(u,{children:i==="creator"?e.jsxs(S,{className:"bg-[#FF3CAC]/10 text-[#FF3CAC] border border-[#FF3CAC]/30",children:[e.jsx(se,{className:"h-3 w-3 mr-1"})," Creator"]}):e.jsxs(S,{className:"bg-[#2B86C5]/10 text-[#2B86C5] border border-[#2B86C5]/30",children:[e.jsx(oe,{className:"h-3 w-3 mr-1"})," Agencia"]})}),e.jsx(u,{className:"font-medium",children:s.data.nombre||s.data.agency_name||"—"}),e.jsx(u,{className:"text-muted-foreground",children:s.data.email||"—"}),e.jsx(u,{children:s.data.country||s.data.pais||"—"}),e.jsx(u,{children:J(s.status)}),e.jsx(u,{className:"text-xs text-muted-foreground",children:z(new Date(s.created_at),"dd/MM/yy HH:mm")}
1),e.jsx(u,{children:e.jsx(A,{size:"sm",variant:"ghost",children:"Ver"})})]},s.id)})})]})})]})]}),e.jsx(ae,{open:!!t,onOpenChange:s=>!s&&j(null),children:e.jsx(re,{side:"right",className:"w-full sm:max-w-2xl overflow-y-auto",children:t&&e.jsxs(e.Fragment,{children:[e.jsxs(te,{children:[e.jsx(ne,{children:m(t)==="creator"?"Aplicación Creator":"Aplicación Agencia"}),e.jsxs(le,{children:["Recibida"," ",z(new Date(t.created_at),"dd MMM yyyy 'a las' HH:mm")]})]}),e.jsxs("div",{className:"mt-6 space-y-4",children:[e.jsx("div",{className:"rounded-lg border bg-muted/30 p-4 space-y-2",children:Object.entries(t.data).map(([s,i])=>e.jsxs("div",{className:"grid grid-cols-3 gap-2 text-sm",children:[e.jsx("span",{className:"text-muted-foreground capitalize",children:s.replace(/_/g," ")}),e.jsx("span",{className:"col-span-2 break-words",children:typeof i=="object"?JSON.stringify(i):String(i||"—")})]},s))}),t.status==="processed"&&e.jsxs(e.Fragment,{children:[m(t)==="creator"&&e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Tier asignado"}),e.jsxs(y,{value:T,onValueChange:s=>F(s),children:[e.jsx(N,{children:e.jsx(w,{})}),e.jsxs(C,{children:[e.jsx(c,{value:"maker",children:"Maker (20% / 12 meses)"}),e.jsx(c,{value:"pro",children:"Pro Partner (25% / 18 meses)"}),e.jsx(c,{value:"elite",children:"Elite (35% / 24 meses)"})]})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx("label",{className:"text-sm font-medium",children:"Notas internas (opcional)"}),e.jsx(ce,{value:g,onChange:s=>R(s.target.value),rows:3,placeholder:"Razón, condiciones especiales, etc."})]}),e.jsxs("div",{className:"flex gap-3 pt-4 border-t",children:[e.jsxs(A,{onClick:K,disabled:r.isPending||l.isPending,className:"flex-1 bg-emerald-600 hover:bg-emerald-700",children:[r.isPending?e.jsx(_,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(ie,{className:"h-4 w-4 mr-2"}),"Aprobar"]}),e.jsxs(A,{onClick:L,disabled:r.isPending||l.isPending,variant:"destructive",className:"flex-1",children:[l.isPending?e.jsx(_,{className:"h-4 w-4 animate-spin mr-2"}):e.jsx(de,{className:"h-4 w-4 mr-2"}),"Rechazar"]})]})]}),t.status!=="processed"&&e.jsxs("div",{className:"rounded-lg border p-4 text-sm text-muted-foreground",children:["Esta aplicación ya fue ",t.status==="approved"?"aprobada":"rechazada","."]})]})]})})})]})}export{ve as default};
2//# sourceMappingURL=AdminPartnersPanel-sVZ4X_is.js.map

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.