PageSourceSearch

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

js downundervisa.com collected 2026-10-09 05:17:24 UTC 19,020 bytes, 1 lines download raw bytes

1import{r as x,j as e,dA as z,u as X,L as g,dB as Z,dC as _,dD as ee,dE as te,dF as se,dG as ae}from"./main-Bo0oayNO.js";import{f as H}from"./index-ThM9GGfP.js";function re({isOpen:A,onClose:d,selectedCount:y,categories:E,tags:B,authors:$,onSubmit:V}){const[M,R]=x.useState(!1),[n,f]=x.useState(""),[c,j]=x.useState(""),[o,v]=x.useState([]),[m,N]=x.useState([]),[h,k]=x.useState([]),[u,w]=x.useState([]),[D,T]=x.useState(""),[C,F]=x.useState(""),P=async s=>{s.preventDefault();const a={};if(n&&(a.status=n),c&&(a.authorId=c),o.length>0&&(a.addCategoryIds=o),m.length>0&&(a.removeCategoryIds=m),h.length>0&&(a.addTagIds=h),u.length>0&&(a.removeTagIds=u),D==="true"?a.isFeatured=!0:D==="false"&&(a.isFeatured=!1),C==="true"?a.isSticky=!0:C==="false"&&(a.isSticky=!1),Object.keys(a).length===0){d();return}R(!0);try{await V(a),d()}finally{R(!1)}},I=(s,a)=>{a==="add"?o.includes(s)?v(o.filter(l=>l!==s)):(v([...o,s]),N(m.filter(l=>l!==s))):m.includes(s)?N(m.filter(l=>l!==s)):(N([...m,s]),v(o.filter(l=>l!==s)))},S=(s,a)=>{a==="add"?h.includes(s)?k(h.filter(l=>l!==s)):(k([...h,s]),w(u.filter(l=>l!==s))):u.includes(s)?w(u.filter(l=>l!==s)):(w([...u,s]),k(h.filter(l=>l!==s)))},L=()=>{f(""),j(""),v([]),N([]),k([]),w([]),T(""),F("")},b=()=>{L(),d()};return A?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:b}),e.jsxs("div",{className:"relative w-full max-w-2xl 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 ",y," Post",y!==1?"s":""]}),e.jsx("button",{onClick:b,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:P,children:[e.jsxs("div",{className:"max-h-[60vh] overflow-y-auto 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-6",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:n,onChange:s=>f(s.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:c,onChange:s=>j(s.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"— No change —"}),$.map(s=>e.jsx("option",{value:s.id,children:s.displayName||s.username},s.id))]})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Featured"}),e.jsxs("select",{value:D,onChange:s=>T(s.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"— No change —"}),e.jsx("option",{value:"true",children:"Yes"}),e.jsx("option",{value:"false",children:"No"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1",children:"Sticky"}),e.jsxs("select",{value:C,onChange:s=>F(s.target.value),className:"input w-full",children:[e.jsx("option",{value:"",children:"— No change —"}),e.jsx("option",{value:"true",children:"Yes"}),e.jsx("option",{value:"false",children:"No"})]})]})]}),E.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Categories"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Click once to add, click again to remove from selected posts"}),e.jsx("div",{className:"flex flex-wrap gap-2 max-h-32 overflow-y-auto p-2 border rounded-lg bg-gray-50",children:E.map(s=>
1{const a=o.includes(s.id),l=m.includes(s.id);return e.jsxs("button",{type:"button",onClick:()=>I(s.id,l?"add":a?"remove":"add"),className:`px-2 py-1 text-xs rounded-full border transition-colors ${a?"bg-green-100 border-green-300 text-green-800":l?"bg-red-100 border-red-300 text-red-800":"bg-white border-gray-300 text-gray-700 hover:bg-gray-100"}`,children:[a&&"+ ",l&&"- ",s.name]},s.id)})}),(o.length>0||m.length>0)&&e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:[o.length>0&&e.jsxs("span",{className:"text-green-600",children:["Adding: ",o.length," categor",o.length===1?"y":"ies"]}),o.length>0&&m.length>0&&" | ",m.length>0&&e.jsxs("span",{className:"text-red-600",children:["Removing: ",m.length," categor",m.length===1?"y":"ies"]})]})]}),B.length>0&&e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-2",children:"Tags"}),e.jsx("p",{className:"text-xs text-gray-500 mb-2",children:"Click once to add, click again to remove from selected posts"}),e.jsx("div",{className:"flex flex-wrap gap-2 max-h-32 overflow-y-auto p-2 border rounded-lg bg-gray-50",children:B.map(s=>{const a=h.includes(s.id),l=u.includes(s.id);return e.jsxs("button",{type:"button",onClick:()=>S(s.id,l?"add":a?"remove":"add"),className:`px-2 py-1 text-xs rounded-full border transition-colors ${a?"bg-green-100 border-green-300 text-green-800":l?"bg-red-100 border-red-300 text-red-800":"bg-white border-gray-300 text-gray-700 hover:bg-gray-100"}`,children:[a&&"+ ",l&&"- ",s.name]},s.id)})}),(h.length>0||u.length>0)&&e.jsxs("div",{className:"mt-2 text-xs text-gray-600",children:[h.length>0&&e.jsxs("span",{className:"text-green-600",children:["Adding: ",h.length," tag",h.length===1?"":"s"]}),h.length>0&&u.length>0&&" | ",u.length>0&&e.jsxs("span",{className:"text-red-600",children:["Removing: ",u.length," tag",u.length===1?"":"s"]})]})]})]})]}),e.jsxs("div",{className:"flex justify-end gap-3 border-t px-6 py-4",children:[e.jsx("button",{type:"button",onClick:b,className:"btn-secondary",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:M,className:"btn-primary",children:M?"Updating...":`Update ${y} Post${y!==1?"s":""}`})]})]})]})]})}):null}function ie(){const{posts:A,pagination:d,seoScores:y,viewCounts:E,statusCounts:B,currentUserId:$,categories:V,tags:M,authors:R}=z.useLoaderData(),n=z.useSearch(),f=X(),[c,j]=x.useState([]),[o,v]=x.useState(!1),[m,N]=x.useState(!1),[h,k]=x.useState(!1),[u,w]=x.useState(null),[D,T]=x.useState(!1),[C,F]=x.useState("date"),[P,I]=x.useState("desc"),S=n.status==="trash",L=t=>{C===t?I(P==="asc"?"desc":"asc"):(F(t),I("asc"))},b=({field:t})=>e.jsx("span",{className:"ml-1 inline-block",children:C===t?P==="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"})})}),s=[...A].sort((t,r)=>{let p,i;switch(C){case"title":p=t.title.toLowerCase(),i=r.title.toLowerCase();break;case"author":p=(t.author?.displayName||t.author?.username||"").toLowerCase(),i=(r.author?.displayName||r.author?.username||"").toLowerCase();break;case"status":p=t.status,i=r.status;break;case"date":p=new Date(t.createdAt).getTime(),i=new Date(r.createdAt).getTime();break}return p<i?P==="asc"?-1:1:p>i?P==="asc"?1:-1:0}),a=t=>{t.target.checked?j(s.map(r=>r.id)):j([])},l=t=>{j(r=>r.includes(t)?r.filter(p=>p!==t):[...r,t])},O=async()=>{if(c.length===0)return;const t=S?`Permanently delete ${c.length} posts? This cannot be undone.`:`Move ${c.length} posts to trash?`;if(confirm(t)){v(!0);try{S?await _({data:c}):await ee({data:c}),j([]),f({to:"/admin/posts",search:n})}finally{v(!1)}}},Y=async()=>
1{if(c.length!==0&&confirm(`Restore ${c.length} posts from trash?`)){N(!0);try{await Z({data:c}),j([]),f({to:"/admin/posts",search:n})}finally{N(!1)}}},G=async()=>{if(confirm("Permanently delete all posts in trash? This cannot be undone.")){k(!0);try{await te(),f({to:"/admin/posts",search:n})}finally{k(!1)}}},J=async t=>{if($){w(t);try{const r=await se({data:{id:t,authorId:$}});r.success&&r.post&&f({to:"/admin/posts/$id",params:{id:r.post.id}})}finally{w(null)}}},q=async t=>{await ae({data:{ids:c,...t}}),j([]),f({to:"/admin/posts",search:n})},K=t=>{t.preventDefault();const r=new FormData(t.currentTarget);f({to:"/admin/posts",search:{...n,search:r.get("search"),page:1}})},U={published:"bg-green-100 text-green-800",draft:"bg-gray-100 text-gray-800",scheduled:"bg-purple-100 text-purple-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:"Posts"}),e.jsx("p",{className:"text-gray-600",children:"Manage your blog posts"})]}),e.jsxs(g,{to:"/admin/posts/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 Post"]})]}),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","scheduled","private","pending","trash"].map(t=>{const r=B[t]??0;return e.jsxs(g,{to:"/admin/posts",search:{...n,status:t,page:1},className:`px-3 py-1.5 text-sm font-medium rounded-lg transition-colors ${n.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),r>0&&e.jsx("span",{className:`ml-1.5 px-1.5 py-0.5 text-xs rounded-full ${n.status===t?t==="trash"?"bg-red-200 text-red-800":"bg-primary-200 text-primary-800":"bg-gray-200 text-gray-600"}`,children:r})]},t)})}),e.jsxs("div",{className:"flex gap-4 items-center",children:[e.jsxs("form",{onSubmit:K,className:"flex gap-2",children:[e.jsx("input",{type:"text",name:"search",defaultValue:n.search,placeholder:"Search posts...",className:"input w-64"}),e.jsx("button",{type:"submit",className:"btn-secondary",children:"Search"})]}),e.jsxs("select",{value:n.limit,onChange:t=>f({to:"/admin/posts",search:{...n,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"})]})]})]})}),c.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:[c.length," selected"]}),S?e.jsxs(e.Fragment,{children:[e.jsx("button",{onClick:Y,disabled:m,className:"btn-secondary text-sm",children:m?"Restoring...":"Restore Selected"}),e.jsx("button",{onClick:O,disabled:o,className:"btn-danger text-sm",children:o?"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:O,disabled:o,className:"btn-danger text-sm",children:o?"Moving...":"Move to Trash"})]}),e.jsx("button",{onClick:()=>j([]),className:"text-sm text-gray-600 hover:text-gray-900",children:"Clear selection"})]}),S&&A.length>0&&e.jsx("div",{className:"flex justify-end",children:e.jsx("button",{onClick:G,disabled:h,className:"btn-danger text-sm",children:h?"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:c.length===s.length&&s.length>0,onChange:a,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:()=>L("title"),children:["Title",e.jsx(b,{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:()=>L("author"),children:["Author",e.jsx(b,{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:()=>L("status"),children:["Status",e.jsx(b,{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.jsx("th",{className:"px-6 py-3 text-center text-xs font-medium text-gray-500 uppercase tracking-wider",children:"Views"}),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:()=>L("date"),children:["Date",e.jsx(b,{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:s.length===0?e.jsx("tr",{children:e.jsxs("td",{colSpan:8,className:"px-6 py-12 text-center text-gray-500",children:["No posts found."," ",e.jsx(g,{to:"/admin/posts/new",className:"text-primary-600 hover:underline",children:"Create your first post"})]})}):s.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:c.includes(t.id),onChange:()=>l(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",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(g,{to:"/admin/posts/$id",params:{id:t.id},className:"text-gray-900 font-medium hover:text-primary-600",children:t.title}),t.isFeatured&&e.jsx("span",{title:"Featured",className:"text-yellow-500",children:e.jsx("svg",{className:"w-4 h-4",fill:"
1currentColor",viewBox:"0 0 20 20",children:e.jsx("path",{d:"M9.049 2.927c.3-.921 1.603-.921 1.902 0l1.07 3.292a1 1 0 00.95.69h3.462c.969 0 1.371 1.24.588 1.81l-2.8 2.034a1 1 0 00-.364 1.118l1.07 3.292c.3.921-.755 1.688-1.54 1.118l-2.8-2.034a1 1 0 00-1.175 0l-2.8 2.034c-.784.57-1.838-.197-1.539-1.118l1.07-3.292a1 1 0 00-.364-1.118L2.98 8.72c-.783-.57-.38-1.81.588-1.81h3.461a1 1 0 00.951-.69l1.07-3.292z"})})}),t.isSticky&&e.jsx("span",{title:"Sticky",className:"text-blue-500",children:e.jsx("svg",{className:"w-4 h-4",fill:"none",stroke:"currentColor",viewBox:"0 0 24 24",children:e.jsx("path",{strokeLinecap:"round",strokeLinejoin:"round",strokeWidth:2,d:"M5 5a2 2 0 012-2h10a2 2 0 012 2v16l-7-3.5L5 21V5z"})})})]}),e.jsx("p",{className:"text-sm text-gray-500 truncate max-w-xs",children:t.slug})]}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:"Jeff Harvie"}),e.jsxs("td",{className:"px-6 py-4",children:[e.jsx("span",{className:`inline-flex px-2 py-1 text-xs font-medium rounded-full ${U[t.status]||U.draft}`,children:t.status}),t.status==="scheduled"&&t.publishedAt&&e.jsx("p",{className:"text-xs text-gray-500 mt-1",children:H(t.publishedAt)})]}),e.jsx("td",{className:"px-6 py-4 text-center",children:y[t.id]?e.jsxs("div",{className:"inline-flex items-center gap-1 cursor-help",title:`SEO Score: ${y[t.id].score}/100`,children:[e.jsx("div",{className:`w-3 h-3 rounded-full ${y[t.id].status==="good"?"bg-green-500":y[t.id].status==="needs-improvement"?"bg-yellow-500":"bg-red-500"}`}),e.jsx("span",{className:"text-xs text-gray-500",children:y[t.id].score})]}):e.jsx("span",{className:"text-xs text-gray-400",children:"-"})}),e.jsx("td",{className:"px-6 py-4 text-center",children:e.jsx(g,{to:"/admin/posts/$id/performance",params:{id:t.id},search:{days:30},className:"text-sm text-gray-600 hover:text-primary-600 font-medium",title:"View performance analytics",children:E[t.id]??0})}),e.jsx("td",{className:"px-6 py-4 text-sm text-gray-600",children:H(t.createdAt)}),e.jsx("td",{className:"px-6 py-4 text-right",children:e.jsxs("div",{className:"flex justify-end gap-3",children:[!S&&e.jsx("button",{onClick:()=>J(t.id),disabled:u===t.id,className:"text-gray-600 hover:text-gray-900 text-sm font-medium disabled:opacity-50",title:"Duplicate post",children:u===t.id?"Duplicating...":"Duplicate"}),e.jsx(g,{to:"/admin/posts/$id",params:{id:t.id},className:"text-primary-600 hover:text-primary-900 text-sm font-medium",children:"Edit"})]})})]},t.id))})]})}),d.totalPages>1&&e.jsxs("div",{className:"flex justify-between items-center",children:[e.jsxs("p",{className:"text-sm text-gray-600",children:["Page ",d.page," of ",d.totalPages," (",d.total," posts)"]}),e.jsxs("div",{className:"flex gap-1 items-center",children:[d.page>2&&e.jsx(g,{to:"/admin/posts",search:{...n,page:1},className:"btn-secondary text-sm px-2 py-1",children:"First"}),d.page>1&&e.jsx(g,{to:"/admin/posts",search:{...n,page:d.page-1},className:"btn-secondary text-sm px-2 py-1",children:"Prev"}),(()=>{const t=[],r=d.totalPages,p=d.page;if(r<=7)for(let i=1;i<=r;i++)t.push(i);else{t.push(1),p>3&&t.push("ellipsis-start");const i=Math.max(2,p-1),Q=Math.min(r-1,p+1);for(let W=i;W<=Q;W++)t.push(W);p<r-2&&t.push("ellipsis-end"),t.push(r)}return t.map(i=>typeof i=="string"?e.jsx("span",{className:"px-1 text-gray-400 text-sm",children:"..."},i):i===p?e.jsx("span",{className:"px-3 py-1 text-sm font-medium bg-primary-600 text-white rounded-sm",children:i},i):e.jsx(g,{to:"/admin/posts",search:{...n,page:i},className:"px-3 py-1 text-sm font-medium text-gray-600 hover:bg-gray-100 rounded-sm",children:i},i))})(),d.page<d.totalPages&&e.jsx(g,{to:"/admin/posts",search:{...n,page:d.page+1},className:"btn-secondary text-sm px-2 py-1",children:"Next"}),d.page<d.totalPages-1&&e.jsx(g,{to:"/admin/posts",search:{...n,page:d.totalPages},className:"btn-secondary text-sm px-2 py-1",children:"Last"})]})]}),e.jsx(re,{isOpen:D,onClose:()=>T(!1),selectedCount:c.length,categories:V,tags:M,authors:R,onSubmit:q})]})}export{ie 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.