PageSourceSearch

https://limabici.com/assets/AdminLogsPage-C02PfG18.js

js limabici.com collected 2026-10-09 22:52:40 UTC 13,895 bytes, 11 lines download raw bytes

1import{c as T,n as P,r as n,s as E,j as e,C as O}from"./index-xXh8ZB1k.js";import{S as L}from"./scroll-text-BNV0SBRZ.js";import{R as U}from"./refresh-cw-C26scEdZ.js";import{S as H}from"./search-DEEoZfe-.js";import{C as G}from"./chevron-up-BGKsJzgq.js";import{U as z}from"./user-plus-2CrKcf1w.js";import{S as W}from"./shield-check-BId9r53I.js";import{U as V}from"./user-x-BcZOZRm2.js";import{U as X}from"./user-cog-D9YvXlHV.js";import{B as Z}from"./bike-BnOvcYbc.js";import{C as J}from"./credit-card-DV4qVvkF.js";import{T as K}from"./trash-2-C-yufIAc.js";import{W as Q}from"./wrench-STB1p0Iy.js";import{A as Y}from"./alert-triangle-BnsoM-ux.js";import{S as ee}from"./settings-yyfeKTST.js";import{F as se}from"./file-text-9wIwwUCe.js";/**
2 * @license lucide-react v0.344.0 - ISC
3 *
4 * This source code is licensed under the ISC license.
5 * See the LICENSE file in the root directory of this source tree.
6 */const v=T("ArrowRightLeft",[["path",{d:"m16 3 4 4-4 4",key:"1x1c3m"}],["path",{d:"M20 7H4",key:"zbl0bi"}],["path",{d:"m8 21-4-4 4-4",key:"h9nckh"}],["path",{d:"M4 17h16",key:"g4d7ey"}]]);/**
7 * @license lucide-react v0.344.0 - ISC
8 *
9 * This source code is licensed under the ISC license.
10 * See the LICENSE file in the root directory of this source tree.
11 */const R=T("PlusCircle",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M8 12h8",key:"1wcyev"}],["path",{d:"M12 8v8",key:"napkw2"}]]),ae={super_admin:{label:"Super Admin",className:"bg-amber-100 text-amber-800 border border-amber-200"},admin:{label:"Admin",className:"bg-red-100 text-red-700 border border-red-200"},collaborator:{label:"Collaborateur",className:"bg-sky-100 text-sky-700 border border-sky-200"}},D={create_team_member:{label:"Nuevo miembro",icon:e.jsx(z,{className:"w-3.5 h-3.5"}),colorClass:"text-emerald-600",bgClass:"bg-emerald-50",category:"Equipo"},change_role:{label:"Cambio de rol",icon:e.jsx(W,{className:"w-3.5 h-3.5"}),colorClass:"text-blue-600",bgClass:"bg-blue-50",category:"Equipo"},deactivate_team_member:{label:"Miembro desactivado",icon:e.jsx(V,{className:"w-3.5 h-3.5"}),colorClass:"text-red-500",bgClass:"bg-red-50",category:"Equipo"},booking_created:{label:"Reserva creada",icon:e.jsx(R,{className:"w-3.5 h-3.5"}),colorClass:"text-emerald-600",bgClass:"bg-emerald-50",category:"Reservas"},booking_status_change:{label:"Estado de reserva",icon:e.jsx(v,{className:"w-3.5 h-3.5"}),colorClass:"text-blue-600",bgClass:"bg-blue-50",category:"Reservas"},guide_assigned:{label:"Guía asignado",icon:e.jsx(X,{className:"w-3.5 h-3.5"}),colorClass:"text-violet-600",bgClass:"bg-violet-50",category:"Reservas"},bike_rental_created:{label:"Alquiler creado",icon:e.jsx(Z,{className:"w-3.5 h-3.5"}),colorClass:"text-emerald-600",bgClass:"bg-emerald-50",category:"Alquileres"},partner_booking_status_change:{label:"Estado reserva socio",icon:e.jsx(v,{className:"w-3.5 h-3.5"}),colorClass:"text-blue-600",bgClass:"bg-blue-50",category:"Socios"},bike_created:{label:"Bici creada",icon:e.jsx(R,{className:"w-3.5 h-3.5"}),colorClass:"text-emerald-600",bgClass:"bg-emerald-50",category:"Bicicletas"},bike_updated:{label:"Bici modificada",icon:e.jsx(J,{className:"w-3.5 h-3.5"}),colorClass:"text-blue-600",bgClass:"bg-blue-50",category:"Bicicletas"},bike_deleted:{label:"Bici eliminada",icon:e.jsx(K,{className:"w-3.5 h-3.5"}),colorClass:"text-red-500",bgClass:"bg-red-50",category:"Bicicletas"},bike_status_change:{label:"Estado de bici",icon:e.jsx(v,{className:"w-3.5 h-3.5"}),colorClass:"text-blue-600",bgClass:"bg-blue-50",category:"Bicicletas"},bike_maintenance_started:{label:"Mantenimiento iniciado",icon:e.jsx(Q,{className:"w-3.5 h-3.5"}),colorClass:"text-amber-600",bgClass:"bg-amber-50",category:"Bicicletas"},bike_maintenance_forced:{label:"Mantenimiento forzado",icon:e.jsx(Y,{className:"w-3.5 h-3.5"}),colorClass:"text-red-500",bgClass:"bg-red-50",category:"Bicicletas"},update:{label:"Actualización config",icon:e.jsx(ee,{className:"w-3.5 h-3.5"}),colorClass:"text-gray-600",bgClass:"bg-gray-100",category:"Sistema"}},te=["Todos","Reservas","Alquileres","Socios","Bicicletas","Equipo","Sistema"];function re(s){return D[s]||{label:s.replace(/_/g," "),icon:e.jsx(se,{className:"w-3.5 h-3.5"}),colorClass:"text-gray-500",bgClass:"bg-gray-100",category:"Otro"}}function le(s){const l=new Date(s),o=new Date().getTime()-l.getTime(),r=Math.floor(o/6e4),c=Math.floor(r/60),d=Math.floor(c/24);return r<1?"Ahora mismo":r<60?`Hace ${r} min`:c<24?`Hace ${c}h`:d===1?"Ayer":d<7?`Hace ${d} días`:l.toLocaleDateString("es-PE",{day:"2-digit",month:"short",year:"numeric"})}
11function ie(s){return new Date(s).toLocaleString("fr-FR",{day:"2-digit",month:"2-digit",year:"numeric",hour:"2-digit",minute:"2-digit",second:"2-digit"})}function oe(s){return s==null?"—":typeof s=="boolean"?s?"Oui":"Non":Array.isArray(s)?s.join(", "):String(s)}const ne={old_status:"Ancien statut",new_status:"Nouveau statut",booking_ref:"Référence",request_ref:"Référence",rental_refs:"Références location",guide_id:"ID guide",customer_name:"Client",customer_email:"Email client",booking_date:"Date",adults:"Adultes",children:"Enfants",total_price:"Prix total",source:"Source",tour_id:"ID tour",duration:"Durée",bikes_count:"Nb vélos",name:"Nom",brand:"Marque",model:"Modèle",serial_number:"N° série",type:"Type",size:"Taille",status:"Statut",email:"Email",role:"Rôle",new_role:"Nouveau rôle",admin_notes:"Notes admin",updated_routes:"Routes mises à jour",rental_date:"Date location"};function ce({details:s}){const l=Object.entries(s).filter(([,i])=>i!=null&&i!=="");return l.length===0?e.jsx("span",{className:"text-gray-400 text-xs",children:"—"}):e.jsx("div",{className:"flex flex-wrap gap-x-4 gap-y-1.5 mt-1",children:l.map(([i,o])=>e.jsxs("div",{className:"flex items-center gap-1 text-xs",children:[e.jsxs("span",{className:"text-gray-400",children:[ne[i]||i.replace(/_/g," "),":"]}),e.jsx("span",{className:"text-gray-700 font-medium",children:oe(o)})]},i))})}function de({log:s}){var d;const[l,i]=n.useState(!1),o=re(s.action),r=ae[s.user_role],c=s.details&&Object.keys(s.details).length>0;return e.jsx("div",{className:`border-b border-gray-100 last:border-0 transition-colors ${l?"bg-gray-50/70":"hover:bg-gray-50/50"}`,children:e.jsxs("div",{className:`flex items-start gap-4 px-5 py-3.5 ${c?"cursor-pointer":""}`,onClick:()=>c&&i(x=>!x),children:[e.jsx("div",{className:`mt-0.5 flex-shrink-0 w-7 h-7 rounded-full flex items-center justify-center ${o.bgClass} ${o.colorClass}`,children:o.icon}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center flex-wrap gap-2",children:[e.jsx("span",{className:"text-sm font-semibold text-gray-900",children:o.label}),s.resource_id&&e.jsxs("span",{className:"font-mono text-[10px] text-gray-400 bg-gray-100 px-1.5 py-0.5 rounded",children:["#",s.resource_id.slice(0,8)]}),e.jsx("span",{className:`text-[10px] font-bold px-1.5 py-0.5 rounded uppercase tracking-wide flex-shrink-0 ${(r==null?void 0:r.className)||"bg-gray-100 text-gray-500"}`,children:(r==null?void 0:r.label)||s.user_role})]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5 flex-wrap",children:[((d=s.profile)==null?void 0:d.full_name)&&e.jsx("span",{className:"text-xs font-medium text-gray-700",children:s.profile.full_name}),e.jsx("span",{className:"text-xs text-gray-400 truncate max-w-[200px]",children:s.user_email}),s.resource_type&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-gray-300",children:"·"}),e.jsx("span",{className:"text-[11px] font-mono text-gray-400",children:s.resource_type.replace(/_/g," ")})]})]}),l&&c&&s.details&&e.jsx("div",{className:"mt-2 pt-2 border-t border-gray-200",children:e.jsx(ce,{details:s.details})})]}),e.jsxs("div",{className:"flex items-center gap-2 flex-shrink-0",children:[e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-gray-500 whitespace-nowrap",children:le(s.created_at)}),e.jsx("p",{className:"text-[10px] text-gray-400 font-mono whitespace-nowrap",children:ie(s.created_at)})]}),c&&e.jsx("div",{className:"text-gray-400",children:l?e.jsx(G,{className:"w-3.5 h-3.5"}):e.jsx(O,{className:"w-3.5 h-3.5"})})]})]})})}const j=50;function Se(){const{isSuperAdmin:s}=P(),[l,i]=n.useState([]),[o,r]=n.useState(!0),[c,d]=n.useState(!1),[x,M]=n.useState(""),[p,B]=n.useState(""),[f,$]=n.useState("Tous"),[m,b]=n.useState(0),[u,q]=n.useState(0),k=a=>a==="Tous"?[]:Object.entries(D).filter(([,t])=>t.category===a).map(([t])=>t),N=n.useCallback(async(a=!1)=>{a?d(!0):r(!0);let t=E.from("admin_logs").select("*",{count:"exact"}).order("created_at",{ascending:!1}).range(m*j,(m+1)*j-1);p&&(t=t.eq("user_role",p));const h=k(f);h.length>0&&(t=t.in("action",h));const{data:F,count:I}=await t,S=F||[],A=[...new Set(S.map(g=>
11g.user_id).filter(Boolean))];let _={};if(A.length>0){const{data:g}=await E.from("profiles").select("id, full_name").in("id",A);for(const C of g??[])C.full_name&&(_[C.id]=C.full_name)}i(S.map(g=>({...g,profile:_[g.user_id]?{full_name:_[g.user_id]}:null}))),q(I||0),r(!1),d(!1)},[m,p,f]);n.useEffect(()=>{N()},[N]);const w=x?l.filter(a=>{var t,h;return a.user_email.toLowerCase().includes(x.toLowerCase())||a.action.toLowerCase().includes(x.toLowerCase())||((t=a.resource_type)==null?void 0:t.toLowerCase().includes(x.toLowerCase()))||(((h=a.profile)==null?void 0:h.full_name)??"").toLowerCase().includes(x.toLowerCase())}):l;if(!s)return e.jsx("div",{className:"flex items-center justify-center h-64",children:e.jsxs("div",{className:"text-center",children:[e.jsx(L,{className:"w-12 h-12 text-gray-300 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-500 font-semibold",children:"Accès réservé au Super Admin"})]})});const y=Math.ceil(u/j);return e.jsxs("div",{className:"max-w-5xl mx-auto space-y-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-black text-gray-900",children:"Activity Logs"}),e.jsx("p",{className:"text-gray-500 text-sm mt-0.5",children:u>0?`${u.toLocaleString("fr-FR")} action${u>1?"s":""} enregistrée${u>1?"s":""}`:"Historique des actions admin"})]}),e.jsx("button",{onClick:()=>N(!0),className:`p-2 hover:bg-gray-100 transition-colors rounded-full ${c?"animate-spin":""}`,title:"Actualiser",children:e.jsx(U,{className:"w-4 h-4 text-gray-500"})})]}),e.jsx("div",{className:"flex gap-2 flex-wrap",children:te.map(a=>{const t=a==="Tous"?0:k(a).length;return e.jsxs("button",{onClick:()=>{$(a),b(0)},className:`px-3 py-1.5 text-xs font-semibold transition-colors border ${f===a?"bg-gray-900 text-white border-gray-900":"bg-white text-gray-600 border-gray-200 hover:border-gray-400"}`,children:[a,t>0&&f!==a&&e.jsxs("span",{className:"ml-1 text-gray-400 font-normal",children:["(",t,")"]})]},a)})}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("div",{className:"relative flex-1",children:[e.jsx(H,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),e.jsx("input",{type:"text",value:x,onChange:a=>M(a.target.value),placeholder:"Buscar por correo, acción, recurso...",className:"w-full pl-9 pr-4 py-2 border border-gray-200 text-sm focus:outline-none focus:ring-2 focus:ring-[#EE3449] bg-white"})]}),e.jsxs("select",{value:p,onChange:a=>{B(a.target.value),b(0)},className:"px-3 py-2 border border-gray-200 text-sm bg-white focus:outline-none focus:ring-2 focus:ring-[#EE3449] min-w-[160px]",children:[e.jsx("option",{value:"",children:"Todos los roles"}),e.jsx("option",{value:"super_admin",children:"Super Admin"}),e.jsx("option",{value:"admin",children:"Admin"}),e.jsx("option",{value:"collaborator",children:"Colaborador"})]})]}),e.jsx("div",{className:"bg-white border border-gray-200 shadow-sm overflow-hidden",children:o?e.jsx("div",{className:"divide-y divide-gray-100",children:Array.from({length:8}).map((a,t)=>e.jsxs("div",{className:"flex items-start gap-4 px-5 py-4",children:[e.jsx("div",{className:"w-7 h-7 rounded-full bg-gray-100 animate-pulse flex-shrink-0"}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsx("div",{className:"h-3.5 bg-gray-100 animate-pulse rounded w-48"}),e.jsx("div",{className:"h-2.5 bg-gray-100 animate-pulse rounded w-32"})]}),e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("div",{className:"h-2.5 bg-gray-100 animate-pulse rounded w-20"}),e.jsx("div",{className:"h-2 bg-gray-100 animate-pulse rounded w-28"})]})]},t))}):w.length===0?e.jsxs("div",{className:"py-16 text-center",children:[e.jsx(L,{className:"w-10 h-10 text-gray-200 mx-auto mb-3"}),e.jsx("p",{className:"text-gray-400 text-sm font-medium",children:"No se encontraron acciones"}),e.jsx("p",{className:"text-gray-300 text-xs mt-1",children:"Intente modificar los filtros"})]}):e.jsx("div",{children:w.map(a=>e.jsx(de,{log:a},a.id))})}),!o&&u>j&&e.jsxs("div",{className:"flex justify-between items-center text-sm text-gray-500",children:[e.jsxs("span",{className:"text-xs",children:["Page ",m+1," sur ",y," · ",w.length," sur ",u," entrées"]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx("button",{onClick:()=>b(0),disabled:m===0,className:"px-2.5 py-1 border border-gray-200 disabled:opacity-40 hover:bg-gray-50 transition-colors text-xs",children:"«"}),e.jsx("button",{onClick:()=>b(a=>Math.max(0,a-1)),disabled:m===0,className:"px-3 py-1 border border-gray-200 disabled:opacity-40 hover:bg-gray-50 transition-colors text-xs",children:"Anterior"}),e.jsx("span",{className:"px-3 py-1 bg-gray-900 text-white text-xs font-semibold",children:m+1}),e.jsx("button",{onClick:()=>b(a=>a+1),disabled:m>=y-1,className:"px-3 py-1 border border-gray-200 disabled:opacity-40 hover:bg-gray-50 transition-colors text-xs",children:"Siguiente"}),e.jsx("button",{onClick:()=>b(y-1),disabled:m>=y-1,className:"px-2.5 py-1 border border-gray-200 disabled:opacity-40 hover:bg-gray-50 transition-colors text-xs",children:"»"})]})]})]})}export{Se as AdminLogsPage};

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.