PageSourceSearch

https://portal.heyfilo.ai/assets/ScheduleApprovalsPage-DL4nAazh.js

js heyfilo.ai collected 2026-10-05 14:28:29 UTC 7,682 bytes, 1 lines download raw bytes

1import{A as G,d as W,b as X,r as u,g as Z,k as q,j as t,ah as ee,P as te,B as c,N as ae,J as se,K as le,z as r,p as I,a0 as ne}from"./index-BIdkve2-.js";function re(p,d){const i=(p||"").replace(/<[^>]*>/g," ").replace(/\s+/g," ").trim();return i.length>d?`${i.slice(0,d)}…`:i}function de(p){var d;return((d=ne.find(i=>i.key===p))==null?void 0:d.color)||"#888"}function ce(){var z;const p=G(),{user:d,activeTenant:i,isSuperAdmin:E,isReadOnlyTenant:S}=W(),[M,A]=X(),[g,h]=u.useState(null),[B,v]=u.useState(null),[C,f]=u.useState(""),[K,j]=u.useState(null),[N,_]=u.useState(""),[F,k]=u.useState(new Set),R=!!E||!!(d!=null&&d.id&&((z=i==null?void 0:i.owner)!=null&&z.id)&&d.id===i.owner.id),{data:P,isLoading:Q,refetch:T}=Z({queryKey:["approvals","pending"],queryFn:async()=>{const a=(await I.listApprovals({pending_only:"true"})).data;return Array.isArray(a)?a:(a==null?void 0:a.results)||[]},enabled:R}),m=u.useMemo(()=>P||[],[P]),y=M.get("request");u.useEffect(()=>{y&&m.some(e=>e.id===y)&&h(y)},[y,m]);const x=q({mutationFn:async({id:e,body:a})=>(await I.patchApproval(e,a)).data,onSuccess:()=>{p.invalidateQueries({queryKey:["approvals"]})}}),$=u.useCallback(e=>{k(a=>new Set(a).add(e)),window.setTimeout(()=>{k(a=>{const s=new Set(a);return s.delete(e),s}),p.invalidateQueries({queryKey:["approvals"]})},1500)},[p]),H=async e=>{var a,s;try{await x.mutateAsync({id:e,body:{status:"approved"}}),r.success("Approved ✓"),$(e),g===e&&h(null)}catch(l){const n=(s=(a=l==null?void 0:l.response)==null?void 0:a.data)==null?void 0:s.detail;r.error(typeof n=="string"?n:"Approve failed")}},L=async e=>{var a,s;try{await x.mutateAsync({id:e,body:{status:"rejected",rejection_note:C.trim()}}),r.success("Rejected"),v(null),f(""),$(e),g===e&&h(null)}catch(l){const n=(s=(a=l==null?void 0:l.response)==null?void 0:a.data)==null?void 0:s.detail;r.error(typeof n=="string"?n:"Reject failed")}},O=async e=>{var a,s;if(!N)return r.error("Pick a date and time.");try{await x.mutateAsync({id:e,body:{override_scheduled_time:new Date(N).toISOString()}}),r.success("Date updated"),j(null),T()}catch(l){const n=(s=(a=l==null?void 0:l.response)==null?void 0:a.data)==null?void 0:s.detail;r.error(typeof n=="string"?n:"Update failed")}},V=async()=>{const e=m.filter(n=>n.status==="pending");if(e.length===0)return;r.loading(`Approving ${e.length}…`,{id:"approve-all"});const a=await Promise.allSettled(e.map(n=>x.mutateAsync({id:n.id,body:{status:"approved"}})));r.dismiss("approve-all");const s=a.filter(n=>n.status==="fulfilled").length,l=a.length-s;s?r.success(`Approved ${s} post(s)${l?` (${l} failed)`:""} ✓`):r.error("Could not approve posts"),p.invalidateQueries({queryKey:["approvals"]})};if(!R)return t.jsx(ee,{to:"/",replace:!0});if(Q)return t.jsx(te,{});const w=g?m.find(e=>e.id===g):null,D=(e,a=!1)=>{const s=e.schedule_detail,l=(s==null?void 0:s.platform)||"",n=(s==null?void 0:s.content_body_html)||"",J=F.has(e.id);return t.jsxs("div",{className:`rounded-2xl border border-claude-border bg-claude-surface p-5 shadow-soft transition-opacity duration-300 ${J?"opacity-40 pointer-events-none":""}`,children:[t.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[t.jsxs("div",{children:[t.jsx("h3",{className:"text-base font-semibold text-claude-text",children:e.schedule_title}),t.jsxs("div",{className:"mt-2 flex flex-wrap items-center gap-2 text-xs text-claude-text-secondary",children:[t.jsx("span",{className:"inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 font-medium bg-claude-bg-alt",style:{borderLeft:`3px solid ${de(l)}`},children:e.platform_display||l}),t.jsxs("span",{children:["Submitted by ",e.requested_by_name||"Member"]}),t.jsx("span",{className:"text-claude-text-tertiary",children:ae(e.created_at)})]})]}),t.jsx(se,{className:"bg-amber-50 text-amber-900 border border-amber-200/80",children:"Pending Approval"})]}),t.jsx("p",{className:"mt-3 text-sm text-claude-text-secondary leading-relaxed",children:a?t.jsx("span",{dangerouslySetInnerHTML:{__html:n||"<p>(No body)</p>"}}):re(n,150)}),t.jsx("p",{className:"mt-2 text-sm text-claude-text-secondary",children:e.is_instant_post?t.jsx("span",{className:"font-medium text-claude-accent-text",children:"Publish Now"}):t.jsxs(t.Fragment,{children:["Scheduled: ",le(e.schedule_date)]})}),B===e.id&&t.jsxs("div",{className:"mt-4 rounded-xl border border-claude-border bg-claude-bg-alt/50 p-3 space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-claude-text-secondary",children:"Reason (visible to creator)"}),t.jsx("textarea",{className:"w-full rounded-xl border border-claude-border bg-claude-surface px-3 py-2 text-sm min-h-[80px]",value:C,onChange:o=>f(o.target.value),placeholder:"Explain what should change…"}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c,{size:"sm",variant:"primary",onClick:()=>L(e.id),children:"Confirm rejection"}),t.jsx(c,{size:"sm",variant:"outline",onClick:()=>{v(null),f("")},children:"Cancel"})]})]}),K===e.id&&t.jsxs("div",{className:"mt-4 rounded-xl border border-claude-border bg-claude-bg-alt/50 p-3 space-y-2",children:[t.jsx("label",{className:"text-xs font-medium text-claude-text-secondary",children:"New date & time"}),t.jsx("input",{type:"datetime-local",className:"w-full rounded-xl border border-claude-border bg-claude-surface px-3 py-2 text-sm",value:N,onChange:o=>_(o.target.value)}),t.jsxs("div",{className:"flex gap-2",children:[t.jsx(c,{size:"sm",variant:"primary",onClick:()=>O(e.id),children:"Save date"}),t.jsx(c,{size:"sm",variant:"outline",onClick:()=>j(null),children:"Cancel"})]})]}),!S&&t.jsxs("div",{className:"mt-4 flex flex-wrap gap-2",children:[t.jsx(c,{size:"sm",variant:"primary",disabled:x.isPending,onClick:()=>H(e.id),children:"Approve"}),t.jsx(c,{size:"sm",variant:"outline",onClick:()=>{v(e.id),f("")},children:"Reject"}),t.jsx(c,{size:"sm",variant:"outline",onClick:()=>{j(e.id);const o=e.schedule_date?new Date(e.schedule_date):new Date,b=Y=>String(Y).padStart(2,"0"),U=`${o.getFullYear()}-${b(o.getMonth()+1)}-${b(o.getDate())}T${b(o.getHours())}:${b(o.getMinutes())}`;_(U)},children:"Change date"}),!a&&t.jsx(c,{size:"sm",variant:"outline",onClick:()=>{h(e.id),A({request:e.id})},children:"View full post"})]})]},e.id)};if(w){const e=w.schedule_detail;
1return t.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[t.jsxs("div",{className:"flex items-center justify-between gap-4",children:[t.jsx("h1",{className:"text-2xl font-semibold text-claude-text",children:"Review post"}),t.jsx(c,{variant:"outline",onClick:()=>{h(null),A({})},children:"← Back to all pending"})]}),D(w,!0),e!=null&&e.content_featured_image?t.jsx("div",{className:"rounded-2xl border border-claude-border overflow-hidden",children:t.jsx("img",{src:e.content_featured_image,alt:"",className:"max-h-96 w-full object-contain bg-claude-bg-alt"})}):null]})}return t.jsxs("div",{className:"max-w-4xl mx-auto space-y-6",children:[t.jsxs("div",{className:"flex flex-wrap items-center justify-between gap-4",children:[t.jsxs("div",{children:[t.jsx("h1",{className:"text-2xl font-semibold text-claude-text tracking-tight",children:"Schedule approvals"}),t.jsx("p",{className:"text-sm text-claude-text-tertiary mt-1",children:"Review posts submitted by your team before they go live."})]}),!S&&m.length>0&&t.jsxs(c,{variant:"primary",disabled:x.isPending,onClick:V,children:["Approve all (",m.length,")"]})]}),m.length===0?t.jsx("div",{className:"rounded-2xl border border-claude-border bg-claude-surface p-12 text-center text-sm text-claude-text-secondary",children:"No posts waiting for approval."}):t.jsx("div",{className:"space-y-4",children:m.map(e=>D(e,!1))})]})}export{ce as ScheduleApprovalsPage};

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.