PageSourceSearch

https://www-diltube-com.lovable.app/assets/Drafts-FSC2sFBf.js

js www-diltube-com.lovable.app collected 2026-10-03 03:49:21 UTC 5,107 bytes, 1 lines download raw bytes

1import{u as C,r as d,N as k,j as t,Y as I,C as w,G as B,d as l,ah as q,B as h,V as F,O as L,s as o,Z as r}from"./index-B4uU8uFL.js";import{H as z,F as E}from"./HomeHeader-C5Jr0K4-.js";import{B as H}from"./BackToFeed-DDvYO2kb.js";import{f as N}from"./format-DbNIfM_0.js";import"./ShareAppDialog-D65xZIm9.js";import"./circle-check-big-dNRec2pf.js";import"./shield-BFRAXl0i.js";import"./shield-alert-GCl78zLm.js";import"./bell-DLABeHUL.js";import"./user-BTruzePb.js";import"./bot-BZbXnPVY.js";import"./flame-BPvqj8Sm.js";import"./user-plus-CkAcFUUj.js";import"./store-Bb091AsP.js";import"./wallet-DCQmgPcG.js";import"./gauge-B1G2_uxB.js";import"./chart-column-DpOgq9No.js";import"./badge-check-DDoEjv-a.js";import"./database-BxtL3cor.js";import"./radio-B-0D8lYy.js";import"./clipboard-list-w0knwEbQ.js";import"./activity-D-Da8pKM.js";import"./megaphone-CAye8W5w.js";import"./package-BjstwNy4.js";import"./arrow-left-BVyl_oZu.js";import"./en-US-DSSwd-Ay.js";function ce(){const{session:n}=C(),c=n==null?void 0:n.user.id,[p,x]=d.useState([]),[f,g]=d.useState(!0),[m,i]=d.useState(null),[j,_]=d.useState(""),v=p.filter(e=>k(j,e.content,e.document_name)),u=async()=>{if(!c)return;g(!0);const e=new Date().toISOString(),{data:s,error:a}=await o.from("posts").select("id,content,image_url,images,video_url,audio_url,document_name,is_draft,scheduled_at,created_at").eq("user_id",c).or(`is_draft.eq.true,and(scheduled_at.gt.${e})`).order("created_at",{ascending:!1}).limit(100);a&&r({title:"Failed to load drafts",description:a.message,variant:"destructive"}),x(s??[]),g(!1)};d.useEffect(()=>{u()},[c]);const b=async e=>{if(!confirm("Publish this draft now?"))return;i(e);const{error:s}=await o.from("posts").update({is_draft:!1,scheduled_at:null}).eq("id",e);if(i(null),s)return r({title:"Publish failed",description:s.message,variant:"destructive"});r({title:"Published ✓"}),u()},y=async e=>{if(!confirm("Cancel the scheduled publish? The post will move back to drafts."))return;i(e);const{error:s}=await o.from("posts").update({scheduled_at:null,is_draft:!0}).eq("id",e);if(i(null),s)return r({title:"Update failed",description:s.message,variant:"destructive"});r({title:"Moved to drafts"}),u()},P=async e=>{if(!confirm("Delete this draft permanently?"))return;i(e);const{error:s}=await o.from("posts").delete().eq("id",e);if(i(null),s)return r({title:"Delete failed",description:s.message,variant:"destructive"});r({title:"Deleted"}),x(a=>a.filter(D=>D.id!==e))},S=e=>{var s;return e.image_url||((s=e.images)==null?void 0:s[0])||null};return t.jsxs("div",{className:"min-h-screen bg-background",children:[t.jsx(z,{}),t.jsxs("div",{className:"mx-auto max-w-3xl px-3 py-4",children:[t.jsx(H,{}),t.jsxs("div",{className:"mt-3 flex items-center gap-2",children:[t.jsx(E,{className:"h-5 w-5 text-primary"}),t.jsx("h1",{className:"text-xl font-bold",children:"Drafts & Scheduled"})]}),t.jsx("p",{className:"mt-1 text-sm text-muted-foreground",children:"Posts you saved as drafts or scheduled for later. Publish, reschedule, or delete anytime."}),t.jsx(I,{value:j,onChange:_,placeholder:"Search drafts on this page…",resultCount:v.length,className:"mt-4"}),t.jsxs("div",{className:"mt-4 space-y-3",children:[f&&t.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}),!f&&p.length===0&&t.jsx(w,{className:"p-6 text-center text-sm text-muted-foreground",children:"No drafts or scheduled posts. Save a draft from the composer to see it here."}),v.map(e=>{const s=e.scheduled_at&&new Date(e.scheduled_at)>new Date,a=S(e);return t.jsxs(w,{className:"p-3",children:[t.jsxs("div",{className:"flex gap-3",children:[a?t.jsx("img",{src:a,alt:"",className:"h-16 w-16 rounded object-cover"}):t.jsx("div",{className:"flex h-16 w-16 items-center justify-center rounded bg-muted",children:t.jsx(B,{className:"h-6 w-6 text-muted-foreground"})}),t.jsxs("div",{className:"min-w-0 flex-1",children:[t.jsxs("div",{className:"flex flex-wrap items-center gap-2",children:[s?t.jsxs(l,{variant:"secondary",className:"gap-1",children:[t.jsx(q,{className:"h-3 w-3"}),"Scheduled · ",N(new Date(e.scheduled_at),"PPP p")]}):t.jsx(l,{variant:"outline",children:"Draft"}),e.video_url&&t.jsx(l,{variant:"outline",children:"Video"}),e.audio_url&&t.jsx(l,{variant:"outline",children:"Audio"}),e.document_name&&t.jsx(l,{variant:"outline",children:"Doc"})]}),t.jsx("p",{className:"mt-1 line-clamp-2 text-sm",children:e.content||t.jsx("span",{className:"text-muted-foreground italic",children:"(no text)"})}),t.jsxs("p",{className:"mt-1 text-[11px] text-muted-foreground",children:["Saved ",N(new Date(e.created_at),"PPP p")]})]})]}),t.jsxs("div",{className:"mt-3 flex flex-wrap gap-2",children:[t.jsxs(h,{size:"sm",onClick:()=>b(e.id),disabled:m===e.id,children:[t.jsx(F,{className:"mr-1 h-4 w-4"})," Publish now"]}),s&&t.jsx(h,{size:"sm",variant:"outline",onClick:()=>y(e.id),disabled:m===e.id,children:"Cancel schedule"}),t.jsxs(h,{size:"sm",variant:"ghost",className:"text-destructive",onClick:()=>P(e.id),disabled:m===e.id,children:[t.jsx(L,{className:"mr-1 h-4 w-4"})," Delete"]})]})]},e.id)})]})]})]})}export{ce as default};

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.