Files
biiproject-kit-v2/public/build/assets/Index-D9_r9v0x.js
T

1 line
11 KiB
JavaScript

import{c as e,d as t,i as n,n as r,t as i}from"./app-CBC6ZGaO.js";import{t as a}from"./AuthenticatedLayout-DI4WLw0Y.js";import{n as o,t as s}from"./lodash-LlLUQFZC.js";import{t as c}from"./Portal-DJRNWzaL.js";var l=t(e(),1),u=t(s(),1),d=i();function f({activity:e,onClose:t}){let[n,r]=(0,l.useState)(!1),i=JSON.stringify(e.properties,null,4);return(0,d.jsx)(c,{children:(0,d.jsx)(`div`,{className:`fixed inset-0 z-50 flex items-center justify-center p-4 bg-[#3D4E4B]/60 backdrop-blur-md anim-fade`,children:(0,d.jsxs)(`div`,{className:`bg-white w-full max-w-2xl rounded-2xl shadow-2xl overflow-hidden anim-zoom border border-gray-100 flex flex-col max-h-[90vh]`,children:[(0,d.jsxs)(`div`,{className:`p-8 border-b border-gray-50 shrink-0`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-2`,children:[(0,d.jsx)(`h2`,{className:`text-xl font-bold text-[#3D4E4B] tracking-tight`,children:`Activity Details`}),(0,d.jsx)(`button`,{onClick:t,className:`p-2 hover:bg-gray-50 rounded-xl transition-colors`,children:(0,d.jsx)(`svg`,{className:`w-5 h-5 text-gray-400`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,d.jsx)(`path`,{d:`M6 18L18 6M6 6l12 12`})})})]}),(0,d.jsx)(`p`,{className:`text-sm text-gray-400 font-medium`,children:e.description})]}),(0,d.jsxs)(`div`,{className:`p-8 overflow-y-auto custom-scrollbar space-y-8`,children:[(0,d.jsxs)(`div`,{className:`grid grid-cols-2 gap-8`,children:[(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-gray-400 uppercase tracking-widest`,children:`Performed By`}),(0,d.jsx)(`p`,{className:`text-sm font-bold text-[#3D4E4B]`,children:e.causer?`${e.causer.first_name} ${e.causer.last_name}`:`System`})]}),(0,d.jsxs)(`div`,{className:`space-y-1 text-right`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-gray-400 uppercase tracking-widest`,children:`Date & Time`}),(0,d.jsx)(`p`,{className:`text-sm font-bold text-[#3D4E4B]`,children:new Date(e.created_at).toLocaleString()})]}),(0,d.jsxs)(`div`,{className:`space-y-1`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-gray-400 uppercase tracking-widest`,children:`Log Name`}),(0,d.jsx)(`p`,{className:`text-sm font-bold text-[#3D4E4B]`,children:e.log_name})]}),(0,d.jsxs)(`div`,{className:`space-y-1 text-right`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-gray-400 uppercase tracking-widest`,children:`Subject`}),(0,d.jsxs)(`p`,{className:`text-sm font-bold text-[#3D4E4B]`,children:[e.subject_type.split(`\\`).pop(),` #`,e.subject_id]})]})]}),(0,d.jsxs)(`div`,{className:`space-y-4`,children:[(0,d.jsxs)(`div`,{className:`flex items-center justify-between`,children:[(0,d.jsx)(`label`,{className:`text-[10px] font-bold text-gray-400 uppercase tracking-widest`,children:`Data Changes / Properties`}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsx)(`button`,{onClick:()=>{navigator.clipboard.writeText(i),r(!0),setTimeout(()=>r(!1),2e3)},className:`text-[10px] font-bold px-2 py-0.5 rounded-lg border transition-all uppercase tracking-tight flex items-center gap-1 ${n?`bg-green-500/10 text-green-500 border-green-500/20`:`bg-[#D4A017]/5 text-[#D4A017] border-[#D4A017]/10 hover:bg-[#D4A017]/10`}`,children:n?(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:3,children:(0,d.jsx)(`path`,{d:`M5 13l4 4L19 7`})}),`Copied`]}):(0,d.jsxs)(d.Fragment,{children:[(0,d.jsx)(`svg`,{className:`w-3 h-3`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,d.jsx)(`path`,{d:`M8 7v8a2 2 0 002 2h6M8 7V5a2 2 0 012-2h4.586a1 1 0 01.707.293l4.414 4.414a1 1 0 01.293.707V15a2 2 0 01-2 2h-2M8 7H6a2 2 0 00-2 2v10a2 2 0 002 2h8a2 2 0 002-2v-2`})}),`Copy JSON`]})}),(0,d.jsx)(`span`,{className:`text-[10px] font-bold text-gray-400 bg-gray-50 px-2 py-0.5 rounded-lg border border-gray-100 uppercase tracking-tight`,children:`JSON Format`})]})]}),(0,d.jsx)(`div`,{className:`bg-[#1E1E1E] p-6 overflow-hidden shadow-inner border border-white/5 relative group`,children:(0,d.jsx)(`pre`,{className:`text-[11px] font-mono text-gray-300 whitespace-pre-wrap break-all leading-relaxed custom-scrollbar max-h-[400px] overflow-y-auto`,children:i})})]})]}),(0,d.jsx)(`div`,{className:`p-8 border-t border-gray-50 bg-gray-50/30 shrink-0 flex justify-end`,children:(0,d.jsx)(`button`,{onClick:t,className:`h-11 px-8 bg-white border border-gray-200 rounded-xl text-sm font-bold text-[#3D4E4B] hover:bg-gray-50 transition-all shadow-sm`,children:`Close`})})]})})})}function p({activities:e,filters:t,availableLogNames:i,availableEvents:s}){let[p,m]=(0,l.useState)(!1),[h,g]=(0,l.useState)(null),[_,v]=(0,l.useState)([]),[y,b]=(0,l.useState)({search:t.search||``,log_name:t.log_name||``,event:t.event||``,per_page:t.per_page||15}),x=(0,l.useCallback)(u.default.debounce(e=>{m(!0),n.get(route(`activity-logs.index`),e,{preserveState:!0,preserveScroll:!0,replace:!0,only:[`activities`,`filters`],onFinish:()=>m(!1)})},400),[]),S=(e,t)=>{let n={...y,[e]:t};b(n);let r={...n,page:1};v([]),x(r)};return(0,d.jsxs)(a,{children:[(0,d.jsx)(r,{title:`Activity Logs`}),(0,d.jsxs)(`div`,{className:`flex items-center justify-between mb-8 anim-down`,children:[(0,d.jsxs)(`div`,{children:[(0,d.jsx)(`h1`,{className:`text-xl font-bold text-[#3D4E4B] tracking-tight leading-none`,children:`Activity Logs`}),(0,d.jsx)(`p`,{className:`text-sm font-semibold text-gray-400 tracking-tight mt-2`,children:`Audit trail of system events and user actions`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsxs)(`div`,{className:`relative w-[240px]`,children:[(0,d.jsx)(`svg`,{className:`absolute left-3.5 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400 pointer-events-none`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,d.jsx)(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M21 21l-6-6m2-5a7 7 0 11-14 0 7 7 0 0114 0z`})}),(0,d.jsx)(`input`,{type:`text`,placeholder:`Search logs…`,value:y.search,onChange:e=>S(`search`,e.target.value),className:`w-full h-11 pl-10 pr-4 rounded-2xl border border-gray-100 bg-white text-sm font-semibold text-gray-700 placeholder-gray-400 focus:outline-none focus:border-[#D4A017] focus:ring-4 focus:ring-[#D4A017]/5 transition-all shadow-sm`})]}),(0,d.jsxs)(`select`,{value:y.log_name,onChange:e=>S(`log_name`,e.target.value),className:`h-11 px-4 rounded-2xl border border-gray-100 bg-white text-sm font-semibold text-gray-700 focus:outline-none focus:border-[#D4A017] focus:ring-4 focus:ring-[#D4A017]/5 transition-all shadow-sm cursor-pointer min-w-[140px]`,children:[(0,d.jsx)(`option`,{value:``,children:`All Logs`}),i.map(e=>(0,d.jsx)(`option`,{value:e,children:e},e))]}),(0,d.jsxs)(`select`,{value:y.event,onChange:e=>S(`event`,e.target.value),className:`h-11 px-4 rounded-2xl border border-gray-100 bg-white text-sm font-semibold text-gray-700 focus:outline-none focus:border-[#D4A017] focus:ring-4 focus:ring-[#D4A017]/5 transition-all shadow-sm cursor-pointer min-w-[140px]`,children:[(0,d.jsx)(`option`,{value:``,children:`All Events`}),s.map(e=>(0,d.jsx)(`option`,{value:e,children:e},e))]})]})]}),(0,d.jsx)(`div`,{className:`anim-up`,children:(0,d.jsx)(o,{data:e.data,columns:[{header:`Activity`,accessorKey:`description`,cell:e=>(0,d.jsxs)(`div`,{className:`flex flex-col`,children:[(0,d.jsx)(`span`,{className:`text-sm font-bold text-[#3D4E4B] tracking-tight`,children:e.description}),(0,d.jsx)(`span`,{className:`text-[10px] text-gray-400 font-bold uppercase tracking-widest mt-0.5`,children:e.log_name})]})},{header:`Causer`,accessorKey:`causer`,cell:e=>(0,d.jsxs)(`div`,{className:`flex items-center gap-3`,children:[(0,d.jsx)(`div`,{className:`w-8 h-8 rounded-lg bg-gray-100 flex items-center justify-center text-[10px] font-bold text-gray-500`,children:e.causer?`${e.causer.first_name[0]}${e.causer.last_name[0]}`:`SYS`}),(0,d.jsxs)(`div`,{className:`flex flex-col`,children:[(0,d.jsx)(`span`,{className:`text-xs font-bold text-[#3D4E4B]`,children:e.causer?`${e.causer.first_name} ${e.causer.last_name}`:`System`}),(0,d.jsx)(`span`,{className:`text-[10px] text-gray-400 font-semibold`,children:e.causer?.email||`automated@system`})]})]})},{header:`Properties`,accessorKey:`properties`,cell:e=>(0,d.jsx)(`div`,{className:`max-w-[300px] truncate`,children:(0,d.jsx)(`code`,{className:`text-[10px] bg-gray-50 px-1.5 py-0.5 rounded text-gray-500 font-semibold`,children:JSON.stringify(e.properties)})})},{header:`Date & Time`,accessorKey:`created_at`,cell:e=>(0,d.jsx)(`span`,{className:`text-xs font-semibold text-gray-400 tracking-tight`,children:new Date(e.created_at).toLocaleString(`en-US`,{day:`2-digit`,month:`short`,year:`numeric`,hour:`2-digit`,minute:`2-digit`})})},{header:`Action`,accessorKey:`actions`,cell:e=>(0,d.jsx)(`div`,{className:`flex justify-end pr-4`,children:(0,d.jsx)(`button`,{onClick:()=>g(e),className:`p-2 rounded-xl text-gray-400 hover:text-[#D4A017] hover:bg-[#D4A017]/5 transition-all opacity-0 group-hover:opacity-100 translate-x-2 group-hover:translate-x-0`,title:`View Details`,children:(0,d.jsxs)(`svg`,{className:`w-5 h-5`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:[(0,d.jsx)(`path`,{d:`M15 12a3 3 0 11-6 0 3 3 0 016 0z`}),(0,d.jsx)(`path`,{d:`M2.458 12C3.732 7.943 7.523 5 12 5c4.478 0 8.268 2.943 9.542 7-1.274 4.057-5.064 7-9.542 7-4.477 0-8.268-2.943-9.542-7z`})]})})})}],meta:e.meta,links:e.links,filters:y,isLoading:p,selectedIds:_,onSelectionChange:v})}),h&&(0,d.jsx)(f,{activity:h,onClose:()=>g(null)}),(0,d.jsx)(c,{children:(0,d.jsx)(`div`,{className:`fixed bottom-8 left-1/2 -translate-x-1/2 z-40 transition-all duration-500 ${_.length>0?`translate-y-0 opacity-100`:`translate-y-20 opacity-0 pointer-events-none`}`,children:(0,d.jsxs)(`div`,{className:`bg-[#3D4E4B] rounded-2xl shadow-2xl px-6 py-4 flex items-center gap-6 border border-white/10 backdrop-blur-xl`,children:[(0,d.jsxs)(`div`,{className:`flex items-center gap-3 pr-6 border-r border-white/10`,children:[(0,d.jsx)(`span`,{className:`w-8 h-8 rounded-lg bg-white/10 flex items-center justify-center text-white text-xs font-bold`,children:_.length}),(0,d.jsx)(`span`,{className:`text-white text-sm font-bold tracking-tight`,children:`Logs selected`})]}),(0,d.jsxs)(`div`,{className:`flex items-center gap-2`,children:[(0,d.jsxs)(`button`,{onClick:()=>{let e=_.length;swal.confirm(`Purge Logs?`,`Are you sure you want to permanently delete ${e} activity logs?`,`Purge`).then(t=>{t.isConfirmed&&n.post(route(`activity-logs.bulk-delete`),{ids:_},{preserveScroll:!0,onSuccess:()=>{v([]),swal.success(`Purged`,`${e} logs deleted successfully.`)}})})},className:`h-10 px-5 rounded-xl bg-red-500 text-white text-xs font-bold hover:bg-red-600 transition-all flex items-center gap-2`,children:[(0,d.jsx)(`svg`,{className:`w-4 h-4`,fill:`none`,viewBox:`0 0 24 24`,stroke:`currentColor`,strokeWidth:2.5,children:(0,d.jsx)(`path`,{d:`M19 7l-.867 12.142A2 2 0 0116.138 21H7.862a2 2 0 01-1.995-1.858L5 7m5 4v6m4-6v6m1-10V4a1 1 0 00-1-1h-4a1 1 0 00-1 1v3M4 7h16`})}),`Bulk Purge`]}),(0,d.jsx)(`button`,{onClick:()=>v([]),className:`h-10 px-4 text-white/40 text-xs font-bold hover:text-white transition-colors`,children:`Cancel`})]})]})})})]})}export{p as default};