1/*! For license information please see 214.cc1708f4.chunk.js.LICENSE.txt */ 2"use strict";(self.webpackChunkfrontend=self.webpackChunkfrontend||[]).push([[214],{2214(e,t,a){a.r(t),a.d(t,{default:()=>v});var s=a(9379),l=a(5043),i=a(2024),o=a(4596),d=a(4632),n=a(8487),r=a(1360),c=a(8693),m=a(9855),p=a(4405),x=a(614),u=a(6328),h=a(9189),b=a(1559),f=a(4298),g=a(579);function v(){const[e,t]=(0,l.useState)(null),[a,i]=(0,l.useState)(null),n=()=>h.FH.get("/admin/social").then(e=>t(e.data)).catch(()=>u.oR.error("Failed to load"));(0,l.useEffect)(()=>{n()},[]);return(0,g.jsxs)("div",{"data-testid":"social-manager",children:[(0,g.jsxs)("div",{className:"flex flex-wrap items-start justify-between gap-4 mb-8",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("div",{className:"text-[10px] uppercase tracking-[0.2em] font-bold text-[#FF5722]",children:"Engagement"}),(0,g.jsx)("h1",{className:"mt-1 font-display font-black text-3xl tracking-tighter text-[#0B2545]",children:"Social Feed"}),(0,g.jsx)("p",{className:"mt-1 text-sm text-[#6B7280]",children:'Curate the "From the SoBS feed" section. Paste an X post link to auto-fill, or enter a Facebook post manually.'})]}),(0,g.jsxs)("button",{onClick:()=>i({platform:"x",url:"",text:"",image_url:"",author:"SoBS Somalia",posted_at:(new Date).toISOString().slice(0,10),status:"published"}),className:"inline-flex items-center gap-2 px-4 py-2.5 text-xs font-bold uppercase tracking-[0.14em] bg-[#0B2545] text-white rounded-sm hover:bg-[#081C36]","data-testid":"add-social-btn",children:[(0,g.jsx)(r.A,{size:14})," Add post"]})]}),(0,g.jsxs)("div",{className:"bg-white border border-black/10 rounded-sm divide-y divide-black/5",children:[null===e&&(0,g.jsx)("div",{className:"p-10 text-center text-sm text-[#6B7280]",children:"Loading\u2026"}),e&&0===e.length&&(0,g.jsx)("div",{className:"p-10 text-center text-sm text-[#6B7280]","data-testid":"social-empty",children:'No posts yet \u2014 the website shows a "Follow us" banner instead.'}),(e||[]).map(e=>{return(0,g.jsxs)("div",{className:"p-4 sm:p-5 flex items-start gap-4","data-testid":"admin-social-row-".concat(e.id),children:[(0,g.jsx)("div",{className:"w-9 h-9 rounded-full flex items-center justify-center text-white flex-shrink-0 ".concat("facebook"===e.platform?"bg-[#1877F2]":"bg-black"),children:"facebook"===e.platform?(0,g.jsx)(d.A,{size:15}):(0,g.jsx)(p.A,{size:15})}),e.image_url&&(0,g.jsx)("img",{src:(0,b.SG)(e.image_url),alt:"",className:"w-16 h-16 object-cover rounded-sm flex-shrink-0 hidden sm:block"}),(0,g.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,g.jsxs)("div",{className:"flex items-center gap-2 flex-wrap text-[10px] uppercase tracking-[0.16em] font-bold",children:[(0,g.jsx)("span",{className:"text-[#FF5722]",children:"facebook"===e.platform?"Facebook":"X"}),(0,g.jsx)("span",{className:"px-2 py-0.5 rounded-sm ".concat("draft"===e.status?"bg-amber-100 text-amber-800":"bg-emerald-100 text-emerald-800"),children:e.status}),(0,g.jsxs)("span",{className:"text-[#6B7280] font-medium",children:[(t=e.posted_at,t?new Date(t).toLocaleDateString("en-GB",{day:"numeric",month:"short",year:"numeric"}):"")," \xb7 ",e.author]})]}),(0,g.jsx)("p",{className:"mt-1.5 text-sm text-[#0B2545] line-clamp-2",children:e.text})]}),(0,g.jsx)("button",{onClick:()=>i((0,s.A)((0,s.A)({},e),{},{posted_at:(e.posted_at||"").slice(0,10)})),className:"p-2 hover:bg-black/5 rounded-sm","data-testid":"edit-social-".concat(e.id),children:(0,g.jsx)(o.A,{size:15})}),(0,g.jsx)("button",{onClick:()=>(async e=>{if(window.confirm("Delete this post from the website feed?"))try{await h.FH.delete("/admin/social/".concat(e)),u.oR.success("Deleted"),n()}catch(t){u.oR.error("Delete failed")}})(e.id),className:"p-2 hover:bg-red-50 text-red-600 rounded-sm","data-testid":"delete-social-".concat(e.id),children:(0,g.jsx)(m.A,{size:15})})]},e.id);var t})]}),a&&(0,g.jsx)(j,{item:a,onClose:()=>i(null),onSave:async e=>{if(!e.text.trim())return void u.oR.error("Post text is required");if(!e.url.trim())return void u.oR.error("Link to the original post is required");const t=(0,s.A)((0,s.A)({},e),{},{posted_at:e.posted_at?new Date(e.posted_at).toISOString():void 0});try{e.id?await h.FH.put("/admin/social/".concat(e.id),t):await h.FH.post("/admin/social",t),u.oR.success("Saved \u2014 live on the website"),i(null),n()}catch(o){var a,l;u.oR.error((null===o||void 0===o||null===(a=o.response)||void 0===a||null===(l=a.data)||void 0===l?void 0:l.detail)||"Save failed")}}})]})}function j(e){let{item:t,onClose:a,onSave:o}=e;const[d,r]=(0,l.useState)(t),[m,p]=(0,l.useState)(!1),[b,v]=(0,l.useState)(!1),j=e=>t=>r(a=>(0,s.A)((0,s.A)({},a),{},{[e]:t}));return(0,g.jsx)("div",{className:"fixed inset-0 z-50 bg-black/60 backdrop-blur-sm flex items-start justify-center p-4 overflow-y-auto","data-testid":"social-editor-modal",children:(0,g.jsxs)("div",{className:"bg-white max-w-2xl w-full p-6 sm:p-8 my-6 relative rounded-sm",children:[(0,g.jsx)("button",{onClick:a,className:"absolute top-4 right-4 p-2 hover:bg-black/5 rounded-sm","data-testid":"social-editor-close",children:(0,g.jsx)(x.A,{size:18})}),(0,g.jsxs)("h2",{className:"font-display font-black text-2xl tracking-tighter text-[#0B2545]",children:[t.id?"Edit":"Add"," social post"]}),(0,g.jsxs)("div",{className:"mt-6 grid gap-5",children:[(0,g.jsxs)("div",{children:[(0,g.jsx)("label",{className:f.NZ,children:"Link to the original post"}),(0,g.jsxs)("div",{className:"mt-1.5 flex gap-2",children:[(0,g.jsx)("input",{value:d.url,onChange:e=>j("url")(e.target.value),placeholder:"https://x.com/SobsSomalia/status/\u2026 or https://www.facebook.com/sobs.gov.so/posts/\u2026",className:"".concat(f.TN," !mt-0 flex-1"),"data-testid":"sp-url"}),(0,g.jsxs)("button",{type:"button",onClick:async()=>
2{if(d.url.trim()){p(!0);try{const e=await h.FH.post("/admin/social/fetch",{url:d.url});r(t=>(0,s.A)((0,s.A)({},t),{},{platform:e.data.platform,text:e.data.text||t.text,author:e.data.author||t.author,posted_at:e.data.posted_at?e.data.posted_at.slice(0,10):t.posted_at})),e.data.note?u.oR.info(e.data.note):u.oR.success("Post details fetched")}catch(a){var e,t;u.oR.error((null===a||void 0===a||null===(e=a.response)||void 0===e||null===(t=e.data)||void 0===t?void 0:t.detail)||"Fetch failed")}p(!1)}else u.oR.error("Paste the post link first")},disabled:m,className:"inline-flex items-center gap-2 px-3.5 text-xs font-bold uppercase tracking-[0.12em] bg-[#FFC107] text-[#0B2545] rounded-sm whitespace-nowrap disabled:opacity-60","data-testid":"sp-fetch",children:[m?(0,g.jsx)(i.A,{size:13,className:"animate-spin"}):(0,g.jsx)(n.A,{size:13})," Fetch"]})]})]}),(0,g.jsxs)("div",{className:"grid sm:grid-cols-3 gap-4",children:[(0,g.jsx)(f.zM,{label:"Platform",value:d.platform,onChange:j("platform"),options:[{value:"x",label:"X (Twitter)"},{value:"facebook",label:"Facebook"}],testid:"sp-platform"}),(0,g.jsx)(f.A_,{label:"Account name",value:d.author,onChange:j("author"),testid:"sp-author"}),(0,g.jsx)(f.A_,{label:"Post date",type:"date",value:d.posted_at,onChange:j("posted_at"),testid:"sp-date"})]}),(0,g.jsx)(f.fs,{label:"Post text",rows:5,value:d.text,onChange:j("text"),testid:"sp-text"}),(0,g.jsx)(f.CT,{label:"Photo (optional)",value:d.image_url,onChange:j("image_url"),testid:"sp-image"}),(0,g.jsx)(f.zM,{label:"Status",value:d.status,onChange:j("status"),options:[{value:"published",label:"Published (live)"},{value:"draft",label:"Draft (hidden)"}],testid:"sp-status"}),(0,g.jsxs)("div",{className:"flex gap-3 pt-2",children:[(0,g.jsxs)("button",{onClick:async()=>{v(!0),await o(d),v(!1)},disabled:b,className:"inline-flex items-center gap-2 px-5 py-2.5 text-xs font-bold uppercase tracking-[0.14em] bg-[#0B2545] text-white rounded-sm disabled:opacity-60","data-testid":"sp-save",children:[b?(0,g.jsx)(i.A,{size:13,className:"animate-spin"}):(0,g.jsx)(c.A,{size:13})," Save & publish"]}),(0,g.jsx)("button",{onClick:a,className:"px-4 py-2.5 text-xs uppercase tracking-[0.14em] font-bold text-[#6B7280]","data-testid":"sp-cancel",children:"Cancel"})]})]})]})})}},4596(e,t,a){a.d(t,{A:()=>s});const s=(0,a(7784).A)("pen-line",[["path",{d:"M12 20h9",key:"t2du7b"}],["path",{d:"M16.376 3.622a1 1 0 0 1 3.002 3.002L7.368 18.635a2 2 0 0 1-.855.506l-2.872.838a.5.5 0 0 1-.62-.62l.838-2.872a2 2 0 0 1 .506-.854z",key:"1ykcvy"}]])},8487(e,t,a){a.d(t,{A:()=>s});const s=(0,a(7784).A)("link-2",[["path",{d:"M9 17H7A5 5 0 0 1 7 7h2",key:"8i5ue5"}],["path",{d:"M15 7h2a5 5 0 1 1 0 10h-2",key:"1b9ql8"}],["line",{x1:"8",x2:"16",y1:"12",y2:"12",key:"1jonct"}]])}}]); 3//# sourceMappingURL=214.cc1708f4.chunk.js.map
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.