1import{c as b,p as _,t as C,r as i,s as d,j as e,L,w as j,B as o}from"./index-EAq5y75j.js";import{A as T}from"./arrow-left-KW0r_ypi.js";import{T as F}from"./trash-2-DVjEO5a1.js";import{P as I}from"./plus-C6nqLGr5.js";import{S as q}from"./save-B2XwoyJl.js";/** 2 * @license lucide-react v0.462.0 - ISC 3 * 4 * This source code is licensed under the ISC license. 5 * See the LICENSE file in the root directory of this source tree. 6 */const P=b("ArrowDown",[["path",{d:"M12 5v14",key:"s699le"}],["path",{d:"m19 12-7 7-7-7",key:"1idqje"}]]);/** 7 * @license lucide-react v0.462.0 - ISC 8 * 9 * This source code is licensed under the ISC license. 10 * See the LICENSE file in the root directory of this source tree. 11 */const D=b("ArrowUp",[["path",{d:"m5 12 7-7 7 7",key:"hav0vg"}],["path",{d:"M12 19V5",key:"x0mq9r"}]]),E=[{label:"Revenue (FY24)",value:"â¹12.8 Cr"},{label:"Growth YoY",value:"42%"},{label:"Products",value:"50+"},{label:"Franchise Partners",value:"100+"}],B=()=>{const{isAdmin:c}=_(),{toast:m}=C(),[r,l]=i.useState(E),[u,x]=i.useState(null),[w,N]=i.useState(!0),[h,p]=i.useState(!1);i.useEffect(()=>{c&&(async()=>{const{data:a}=await d.from("site_content").select("id, content").eq("page","investors").eq("section_key","financial_performance").maybeSingle();if(a){x(a.id);const s=a.content;Array.isArray(s==null?void 0:s.stats)&&l(s.stats)}N(!1)})()},[c]);const f=(a,s,t)=>l(n=>n.map((g,k)=>k===a?{...g,[s]:t}:g)),v=(a,s)=>{const t=a+s;if(t<0||t>=r.length)return;const n=[...r];[n[a],n[t]]=[n[t],n[a]],l(n)},S=a=>l(s=>
11s.filter((t,n)=>n!==a)),y=()=>l(a=>[...a,{label:"New Stat",value:"0"}]),A=async()=>{p(!0);const a={stats:r};try{if(u){const{error:s}=await d.from("site_content").update({content:a,updated_at:new Date().toISOString()}).eq("id",u);if(s)throw s}else{const{data:s,error:t}=await d.from("site_content").insert({page:"investors",section_key:"financial_performance",content:a}).select("id").single();if(t)throw t;x(s.id)}m({title:"Stats saved"})}catch(s){m({title:"Save failed",description:s.message,variant:"destructive"})}p(!1)};return c?e.jsxs("div",{className:"min-h-screen bg-muted/30",children:[e.jsx("header",{className:"bg-primary text-primary-foreground p-4",children:e.jsxs("div",{className:"max-w-3xl mx-auto flex items-center gap-3",children:[e.jsx(L,{to:"/admin",children:e.jsx(T,{className:"h-5 w-5"})}),e.jsx("h1",{className:"font-bold text-lg",children:"Financial Performance Stats"})]})}),e.jsxs("main",{className:"max-w-3xl mx-auto px-4 py-8",children:[e.jsxs("p",{className:"text-sm text-muted-foreground mb-6",children:["These appear as the 4 green cards on the ",e.jsx("span",{className:"font-medium",children:"Investors â Financial Results"})," page."]}),w?e.jsx("p",{className:"text-muted-foreground",children:"Loading..."}):e.jsxs("div",{className:"bg-white border border-border rounded-2xl p-6 space-y-4",children:[r.map((a,s)=>e.jsxs("div",{className:"grid grid-cols-1 md:grid-cols-[1fr,1fr,auto] gap-3 items-end border-b pb-4 last:border-0 last:pb-0",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Label"}),e.jsx(j,{value:a.label,onChange:t=>f(s,"label",t.target.value)})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground mb-1 block",children:"Value"}),e.jsx(j,{value:a.value,onChange:t=>f(s,"value",t.target.value)})]}),e.jsxs("div",{className:"flex gap-1",children:[e.jsx(o,{size:"icon",variant:"ghost",onClick:()=>v(s,-1),disabled:s===0,children:e.jsx(D,{className:"h-4 w-4"})}),e.jsx(o,{size:"icon",variant:"ghost",onClick:()=>v(s,1),disabled:s===r.length-1,children:e.jsx(P,{className:"h-4 w-4"})}),e.jsx(o,{size:"icon",variant:"ghost",onClick:()=>S(s),className:"text-destructive",children:e.jsx(F,{className:"h-4 w-4"})})]})]},s)),e.jsxs("div",{className:"flex gap-2 pt-2",children:[e.jsxs(o,{variant:"outline",onClick:y,className:"rounded-xl",children:[e.jsx(I,{className:"h-4 w-4 mr-1"})," Add Stat"]}),e.jsxs(o,{onClick:A,disabled:h,className:"rounded-xl ml-auto",children:[e.jsx(q,{className:"h-4 w-4 mr-1"})," ",h?"Saving...":"Save All"]})]})]})]})]}):e.jsx("div",{className:"min-h-screen flex items-center justify-center",children:e.jsx("p",{children:"Access denied."})})};export{B 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.