PageSourceSearch

https://downundervisa.com/assets/index-BoqryPoV.js

js downundervisa.com collected 2026-10-09 05:17:28 UTC 14,598 bytes, 1 lines download raw bytes

1import{r as d,j as e,dK as O,u as Q,L as m,dL as X,dM as Y,dN as Z,dO as _,cn as ee,dP as te}from"./main-Bo0oayNO.js";import{f as se}from"./index-ThM9GGfP.js";function ae({isOpen:f,onClose:y,selectedCount:a,selectedIds:p,authors:E,parentPages:w,onSubmit:M}){const[k,l]=d.useState(!1),[o,i]=d.useState(""),[x,u]=d.useState(""),[g,N]=d.useState(""),S=async r=>{r.preventDefault();const h={};if(o&&(h.status=o),x&&(h.authorId=x),g==="none"?h.parentId=null:g&&(h.parentId=g),Object.keys(h).length===0){y();return}l(!0);try{await M(h),y()}finally{l(!1)}},P=()=>{i(""),u(""),N("")},j=()=>{P(),y()},C=w.filter(r=>!p.includes(r.id));return f?e.jsx("div",{className:"fixed inset-0 z-50 overflow-y-auto",children:e.jsxs("div",{className:"flex min-h-screen items-center justify-center p-4",children:[e.jsx("div",{className:"fixed inset-0 bg-black/50 transition-opacity",onClick:j}),e.jsxs("div",{className:"relative w-full max-w-lg rounded-lg bg-white shadow-xl",children:[e.jsxs("div",{className:"flex items-center justify-between border-b px-6 py-4",children:[e.jsxs("h2",{className:"text-lg font-semibold text-gray-900",children:["Bulk Edit ",a," Page",a!==1?"s":""]}),e.jsx("button",{onClick:j,className:"rounded-lg p-1 text-gray-400 hover:bg-gray-100 hover:text-gray-600",children:e.jsx("svg",{className:"h-5 w-5",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M6 18L18 6M6 6l12 12"})})})]}),e.jsxs("form",{onSubmit:S,children:[e.jsxs("div",{className:"px-6 py-4",children:[e.jsx("p",{className:"mb-4 text-sm text-gray-600",children:"Only fields you change will be updated. Leave fields empty to keep existing values."}),e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Status"}),e.jsxs("select",{value:o,onChange:r=>i(r.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"— No change —"}),e.jsx("option",{value:"draft",children:"Draft"}),e.jsx("option",{value:"published",children:"Published"}),e.jsx("option",{value:"private",children:"Private"}),e.jsx("option",{value:"pending",children:"Pending Review"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Author"}),e.jsxs("select",{value:x,onChange:r=>u(r.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"— No change —"}),E.map(r=>e.jsx("option",{value:r.id,children:r.displayName||r.username},r.id))]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Parent Page"}),e.jsxs("select",{value:g,onChange:r=>N(r.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"— No change —"}),e.jsx("option",{value:"none",children:"No parent (top level)"}),C.map(r=>e.jsx("option",{value:r.id,children:r.title},r.id))]}),a>1&&e.jsx("p",{className:"mt-1 text-xs text-gray-500",children:"Note: Selected pages cannot be set as their own parent"})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 border-t px-6 py-4",children:[e.jsx("button",{type:"button",onClick:j,className:"btn-secondary",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:k,className:"btn-primary",children:k?"Updating...":`Update ${a} Page${a!==1?"s":""}`})]})]})]})]})}):null}function le(){const{pages:f,parentMap:y,pagination:a,seoScores:p,statusCounts:E,currentUserId:w,parentPages:M,authors:k}=O.useLoaderData(),l=O.useSearch(),o=Q(),[i,x]=d.useState([]),[u,g]=d.useState(!1),[N,S]=d.useState(!1),[P,j]=d.useState(!1),[C,r]=d.useState(null),[h,T]=d.useState(!1),[D,U]=d.useState(null),[L,A]=d.useState("desc"),b=l.status==="trash",I=t=>{D===t?A(L==="asc"?"desc":"asc"):(U(t),A("asc"))},$=({field:t})=>e.jsx("span",{className:"ml-1 inline-block",children:D===t?L==="asc"?e.jsx("svg",{className:"w-4 h-4 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 15l7-7 7 7"})}):e.jsx("svg",{className:"w-4 h-4 inline",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M19 9l-7 7-7-7"})}):e.jsx("svg",{className:"w-4 h-4 inline opacity-30",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M7 16V4m0 0L3 8m4-4l4 4m6 0v12m0 0l4-4m-4 4l-4-4"})})}),v=D?[...f].sort((t,s)=>{let c,n;switch(D){case"title":c=t.title.toLowerCase(),n=s.title.toLowerCase();break;case"author":c=(t.author?.displayName||t.author?.username||"").toLowerCase(),n=(s.author?.displayName||s.author?.username||"").toLowerCase();break;case"status":c=t.status,n=s.status;break;case"date":c=new Date(t.createdAt).getTime(),n=new Date(s.createdAt).getTime();break}return c<n?L==="asc"?-1:1:c>n?L==="asc"?1:-1:0}):f,V=t=>{t.target.checked?x(v.map(s=>s.id)):x([])},W=t=>{x(s=>s.includes(t)?s.filter(c=>c!==t):[...s,t])},R=async()=>
1{if(i.length===0)return;const t=b?`Permanently delete ${i.length} pages? This cannot be undone.`:`Move ${i.length} pages to trash?`;if(confirm(t)){g(!0);try{b?await Y({data:i}):await Z({data:i}),x([]),o({to:"/admin/pages",search:l})}finally{g(!1)}}},z=async()=>{if(i.length!==0&&confirm(`Restore ${i.length} pages from trash?`)){S(!0);try{await X({data:i}),x([]),o({to:"/admin/pages",search:l})}finally{S(!1)}}},H=async()=>{if(confirm("Permanently delete all pages in trash? This cannot be undone.")){j(!0);try{await _(),o({to:"/admin/pages",search:l})}finally{j(!1)}}},K=async t=>{if(w){r(t);try{const s=await ee({data:{id:t,authorId:w}});s.success&&s.page&&o({to:"/admin/pages/$id",params:{id:s.page.id}})}finally{r(null)}}},q=async t=>{await te({data:{ids:i,...t}}),x([]),o({to:"/admin/pages",search:l})},G=t=>{t.preventDefault();const s=new FormData(t.currentTarget);o({to:"/admin/pages",search:{...l,search:s.get("search"),page:1}})},F={published:"bg-green-100 text-green-800",draft:"bg-gray-100 text-gray-800",private:"bg-yellow-100 text-yellow-800",pending:"bg-blue-100 text-blue-800",trash:"bg-red-100 text-red-800"};return e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-bold text-gray-900",children:"Pages"}),e.jsx("p",{className:"text-gray-600",children:"Manage your site pages"})]}),e.jsxs(m,{to:"/admin/pages/new",className:"btn-primary",children:[e.jsx("svg",{className:"w-4 h-4 mr-2",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M12 4v16m8-8H4"})}),"Add New Page"]})]}),e.jsx("div",{className:"card p-4",children:e.jsxs("div",{className:"flex flex-wrap gap-4 items-center justify-between",children:[e.jsx("div",{className:"flex gap-2 flex-wrap",children:["all","published","draft","private","pending","trash"].map(t=>{const s=E[t]??0;return e.jsxs(m,{to:"/admin/pages",search:{...l,status:t,page:1},className:`px-3 py-1.5 text-sm font-medium rounded-lg transition-colors ${l.status===t?t==="trash"?"bg-red-100 text-red-700":"bg-primary-100 text-primary-700":"text-gray-600 hover:bg-gray-100"}`,children:[t.charAt(0).toUpperCase()+t.slice(1),s>0&&e.jsx("span",{className:`ml-1.5 px-1.5 py-0.5 text-xs rounded-full ${l.status===t?t==="trash"?"bg-red-200 text-red-800":"bg-primary-200 text-primary-800":"bg-gray-200 text-gray-600"}`,children:s})]},t)})}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsxs("form",{onSubmit:G,className:"flex gap-2",children:[e.jsx("input",{type:"text",name:"search",defaultValue:l.search,placeholder:"Search pages...",className:"input w-64"}),e.jsx("button",{type:"submit",className:"btn-secondary",children:"Search"})]}),e.jsxs("select",{value:l.limit,onChange:t=>o({to:"/admin/pages",search:{...l,limit:Number(t.target.value),page:1}}),className:"input w-auto text-sm",children:[[10,25,50,100].map(t=>e.jsxs("option",{value:t,children:[t," per page"]},t)),e.jsx("option",{value:9999,children:"All"})]})]})]})}),i.length>0&&e.jsxs("div",{className:"card p-4 bg-gray-50 flex items-center gap-4",children:[e.jsxs("span",{className:"text-sm text-gray-600",children:[i.length," selected"]}),b?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:z,disabled:N,className:"btn-secondary text-sm",children:N?"Restoring...":"Restore Selected"}),e.jsx("button",{onClick:R,disabled:u,className:"btn-danger text-sm",children:u?"Deleting...":"Delete Permanently"})]}):e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:()=>T(!0),className:"btn-primary text-sm",children:"Bulk Edit"}),e.jsx("button",{onClick:R,disabled:u,className:"btn-danger text-sm",children:u?"Moving...":"Move to Trash"})]}),e.jsx("button",{onClick:()=>x([]),className:"text-sm text-gray-600 hover:text-gray-900",children:"Clear selection"})]}),b&&f.length>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:H,disabled:P,className:"btn-danger text-sm",children:P?"Emptying...":"Empty Trash"})}),e.jsx("div",{className:"card overflow-hidden",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"w-12 px-6 py-3",children:e.jsx("input",{type:"checkbox",checked:i.length===v.length&&v.length>0,onChange:V,className:"h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded-sm"})}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>I("title"),children:["Title",e.jsx($,{field:"title"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>I("author"),children:["Author",e.jsx($,{field:"author"})]}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>I("status"),children:["Status",e.jsx($,{field:"status"})]}),e.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"SEO"}),e.jsxs("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider cursor-pointer hover:text-gray-700",onClick:()=>I("date"),children:["Date",e.jsx($,{field:"date"})]}),e.jsx("th",{className:"px-6 py-3 text-right text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Actions"})]})}),e.jsx("tbody",{className:"bg-white divide-y divide-gray-200",children:v.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:7,className:"px-6 py-12 text-center text-gray-500",children:["No pages found."," ",e.jsx(m,{to:"/admin/pages/new",className:"text-primary-600 hover:underline",children:"Create your first page"})]})}):v.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-6 py-4",children:e.jsx("input",{type:"checkbox",checked:i.includes(t.id),onChange:()=>W(t.id),className:"h-4 w-4 text-primary-600 focus:ring-primary-500 border-gray-300 rounded-sm"})}),e.jsxs("td",{className:`px-6 py-4${t.parentId?" pl-12":""}`,children:[e.jsxs(m,{to:"/admin/pages/$id",params:{id:t.id},className:"text-gray-900 font-medium hover:text-primary-600",children:[t.parentId&&e.jsx("span",{className:"text-gray-400 mr-1",children:"—"}),t.title]}),e.jsx("p",{className:"text-sm text-gray-500 truncate max-w-xs",children:t.parentId&&y[t.parentId]?`/${y[t.parentId].slug}/${t.slug}`:`/${t.slug}`})]}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:t.author?.displayName||t.author?.username||"Unknown"}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${F[t.status]||F.draft}`,children:t.status})}),e.jsx("td",{className:"px-6 py-4 text-center",children:p[t.id]?e.jsxs("div",{className:"inline-flex items-center gap-1 cursor-help",title:`SEO Score: ${p[t.id].score}/100`,children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${p[t.id].status==="good"?"bg-green-500":p[t.id].status==="needs-improvement"?"bg-yellow-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-500",children:p[t.id].score})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"-"})}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:se(t.createdAt)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-3",children:[!b&&e.jsx("button",{onClick:()=>K(t.id),disabled:C===t.id,className:"text-gray-600 hover:text-gray-900 text-sm font-medium disabled:opacity-50",title:"Duplicate page",children:C===t.id?"Duplicating...":"Duplicate"}),e.jsx(m,{to:"/admin/pages/$id",params:{id:t.id},className:"text-primary-600 hover:text-primary-900 text-sm font-medium",children:"Edit"})]})})]},t.id))})]})}),a.totalPages>1&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Page ",a.page," of ",a.totalPages," (",a.total," pages)"]}),e.jsxs("div",{className:"flex gap-1 items-center",children:[a.page>2&&e.jsx(m,{to:"/admin/pages",search:{...l,page:1},className:"btn-secondary text-sm px-2 py-1",children:"First"}),a.page>1&&e.jsx(m,{to:"/admin/pages",search:{...l,page:a.page-1},className:"btn-secondary text-sm px-2 py-1",children:"Prev"}),(()=>{const t=[],s=a.totalPages,c=a.page;if(s<=7)for(let n=1;n<=s;n++)t.push(n);else{t.push(1),c>3&&t.push("ellipsis-start");const n=Math.max(2,c-1),J=Math.min(s-1,c+1);for(let B=n;B<=J;B++)t.push(B);c<s-2&&t.push("ellipsis-end"),t.push(s)}return t.map(n=>typeof n=="string"?e.jsx("span",{className:"px-1 text-gray-400 text-sm",children:"..."},n):n===c?e.jsx("span",{className:"px-3 py-1 text-sm font-medium bg-primary-600 text-white rounded-sm",children:n},n):e.jsx(m,{to:"/admin/pages",search:{...l,page:n},className:"px-3 py-1 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-sm",children:n},n))})(),a.page<a.totalPages&&e.jsx(m,{to:"/admin/pages",search:{...l,page:a.page+1},className:"btn-secondary text-sm px-2 py-1",children:"Next"}),a.page<a.totalPages-1&&e.jsx(m,{to:"/admin/pages",search:{...l,page:a.totalPages},className:"btn-secondary text-sm px-2 py-1",children:"Last"})]})]}),e.jsx(ae,{isOpen:h,onClose:()=>T(!1),selectedCount:i.length,selectedIds:i,authors:k,parentPages:M,onSubmit:q})]})}
1export{le as component};

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.