1import{b as g,r as l,j as s}from"./react-DlBquRhq.js";import{useToast as j}from"./AdminLayout-BBBM0EpE.js";import{l as _,s as w,e as S}from"./admin-api-CCPnmQge.js";import{c as u,t as h}from"./theme-DpdrwuOw.js";import{B as d,a}from"./Select-DEo2NNmK.js";import{P as n}from"./Pill-BJH7jFXq.js";import{C as k}from"./Card-BLbAeVwm.js";import{E as A}from"./EmptyState-DtB-HTut.js";import{P as b}from"./PageHeader-CJBBT1Jp.js";import{L as P}from"./Spinner-DamV4FPX.js";import"./index-CVeKy3HG.js";import"./supabase-CpRTRdvQ.js";import"./animation-B0WpSdC-.js";function E(r){return r?(Date.now()-Date.parse(r))/36e5>24:!1}function R(){const{showToast:r}=j(),p=g(),[i,x]=l.useState(null),[m,y]=l.useState(null);async function o(){try{const{properties:e}=await _();x(e)}catch(e){r(e.message,"error")}}l.useEffect(()=>{o()},[]);async function f(e,c){y(e);try{const t=await w(e);r(`Synced ${c}: ${t.status}`,t.status==="success"?"success":"error"),await o()}catch(t){r(t.message,"error")}finally{y(null)}}async function v(e){if(confirm(`Archive ${e.name}? Bookings remain, but the property is hidden from the public site. This is reversible in SQL.`))try{await S(e.id),r("Property archived"),await o()}catch(c){r(c.message,"error")}}return s.jsxs("div",{children:[s.jsx(b,{title:"Properties",description:"Manage IBE credentials, feature toggles, and inventory sync per property.",actions:s.jsx(d,{onClick:()=>p("/wip/admin/properties/new"),variant:"accent",children:"+ Add property"})}),i===null?s.jsx(P,{}):i.length===0?s.jsx(A,{title:"No properties yet",description:"Each property maps to an Apaleo account and an Adyen merchant.",action:s.jsx(a,{to:"/wip
1/admin/properties/new",variant:"accent",children:"Add your first property"})}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:10},children:i.map(e=>s.jsx(k,{padding:"18px 20px",children:s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:16},children:[s.jsxs("div",{style:{flex:1,minWidth:0},children:[s.jsxs("div",{style:{display:"flex",alignItems:"center",gap:6,flexWrap:"wrap"},children:[s.jsx("span",{style:{...h.h3,color:u.dark},children:e.name}),s.jsx(n,{tone:e.booking_enabled?"success":"neutral",uppercase:!0,children:e.booking_enabled?"Live":"Coming soon"}),s.jsxs(n,{tone:e.has_apaleo_creds?"success":"warn",uppercase:!0,children:["Apaleo ",e.has_apaleo_creds?"â":"â"]}),s.jsxs(n,{tone:e.has_adyen_creds?"success":"warn",uppercase:!0,children:["Adyen ",e.has_adyen_creds?"â":"â"]}),e.adyen_environment&&s.jsx(n,{tone:e.adyen_environment==="live"?"success":"neutral",uppercase:!0,children:e.adyen_environment}),E(e.last_synced_at)&&s.jsx(n,{tone:"warn",uppercase:!0,children:"Sync > 24h"})]}),s.jsxs("div",{style:{...h.caption,color:u.text55,marginTop:6},children:["/",e.slug," · ",e.currency??"â"," · ",e.reference_prefix??"â"," · last synced"," ",e.last_synced_at?new Date(e.last_synced_at).toLocaleString():"never"]})]}),s.jsxs("div",{style:{display:"flex",gap:6,flexShrink:0,flexWrap:"wrap",justifyContent:"flex-end"},children:[s.jsx(d,{onClick:()=>f(e.id,e.slug),disabled:m===e.id||!e.has_apaleo_creds,variant:"secondary",size:"sm",title:e.has_apaleo_creds?"Sync from Apaleo":"Add Apaleo credentials first",children:m===e.id?"Syncingâ¦":"â» Sync"}),s.jsx(a,{to:`/wip/admin/properties/${e.id}/services`,variant:"secondary",size:"sm",children:"Services"}),s.jsx(a,{to:`/wip/admin/properties/${e.id}/sync-runs`,variant:"secondary",size:"sm",children:"History"}),s.jsx(a,{to:`/wip/admin/properties/${e.id}/edit`,variant:"dark",size:"sm",children:"Edit"}),s.jsx(d,{onClick:()=>v(e),variant:"danger",size:"sm",children:"Archive"})]})]})},e.id))})]})}export{R 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.