1import{r as U}from"./rolldown-runtime-b3L32Ng1.js";import{f as O,g as R,i as q,m as G,u as Q}from"./vendor-react-B4z8l9H_.js";import{Di as C,Dn as V,Dr as S,Er as k,Gt as T,Ln as F,Lt as X,Mn as J,On as K,Ui as c,hi as W,sa as Y,si as Z,v as L,z as $}from"./lucideRegistry-QWKS7J2W.js";import{t as i}from"./button-CsktFLsW.js";import{n as A,r as ee}from"./AppDialogProvider-CY6KPDLC.js";import{t as se}from"./AppTopBar-BCanSRYI.js";import{t as g}from"./badge-D-6zwUSe.js";import{a as te,i as n,n as ae,o as E,r as o,t as re}from"./table-BeDzP7rt.js";import{i as ie,n as le,r as ne}from"./hospitalityApartmentsService-548GhKCn.js";var d=U(R()),e=G();function I(a){if(!a)return"";try{return encodeURI(a.trim())}catch{return""}}function z(a,r){if(!a)return"â";const t=new Date(a);return Number.isNaN(t.getTime())?a:t.toLocaleString(r,{dateStyle:"short",timeStyle:"short"})}function B(a,r){return a.ical_last_sync_status?a.ical_last_sync_status==="success"?r("hospitality.apartments.syncOk"):a.ical_last_sync_status==="error"?r("hospitality.apartments.syncError"):a.ical_last_sync_status:r("hospitality.apartments.neverSynced")}function y(a){return!!(a.ical_import_url&&a.ical_import_url.trim())}function oe(a){return a.ical_last_sync_status==="success"?"bg-emerald-500/10 text-emerald-600":a.ical_last_sync_status==="error"?"bg-rose-500/10 text-rose-600":"bg-slate-500/10 text-slate-600"}function ye(){const{siteId:a}=O(),r=Q(),{t,i18n:b}=Y("apps"),j=b.resolvedLanguage||b.language,[D,N]=(0,d.useState)(!0),[H,m]=(0,d.useState)([]),[x,v]=(0,d.useState)("grid"),[p,P]=(0,d.useState)("");(0,d.useEffect)(()=>{a&&M()},[a]);async function M(){try{N(!0),m(await ne(a))}catch(s){console.error("Errore caricamento alloggi:",s)}finally{N(!1)}}async function _(s){try{const l=!s.is_public;await ie(s.id,{is_public:l}),m(u=>u.map(f=>f.id===s.id?{...f,is_public:l}:f))}catch{await A(t("hospitality.apartments.visibilityError"),{title:t("hospitality.apartments.error")})}}
1async function w(s){if(await ee(t("hospitality.apartments.deleteConfirm"),{title:t("hospitality.apartments.deleteTitle"),confirmText:t("hospitality.apartments.delete"),variant:"destructive"}))try{await le(s),m(l=>l.filter(u=>u.id!==s))}catch{await A(t("hospitality.apartments.deleteError"),{title:t("hospitality.apartments.error")})}}const h=H.filter(s=>s.name.toLowerCase().includes(p.toLowerCase()));return D?(0,e.jsx)("div",{className:"flex h-64 items-center justify-center",children:(0,e.jsx)(V,{className:"h-8 w-8 animate-spin text-muted-foreground"})}):(0,e.jsxs)("div",{className:"flex flex-col flex-1 w-full",children:[(0,e.jsx)(se,{title:t("hospitality.apartments.title"),searchValue:p,onSearchChange:P,searchPlaceholder:t("hospitality.apartments.search"),rightActions:(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{className:"flex shrink-0 rounded-lg border border-border bg-muted/50 p-1 mr-2",children:[(0,e.jsxs)("button",{onClick:()=>v("grid"),className:`flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold transition-all ${x==="grid"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[(0,e.jsx)(F,{className:"h-4 w-4"})," ",(0,e.jsx)("span",{className:"hidden sm:inline",children:t("hospitality.apartments.grid")})]}),(0,e.jsxs)("button",{onClick:()=>v("list"),className:`flex items-center gap-2 rounded-md px-3 py-1.5 text-xs font-semibold transition-all ${x==="list"?"bg-accent text-foreground":"text-muted-foreground hover:text-foreground"}`,children:[(0,e.jsx)(K,{className:"h-4 w-4"})," ",(0,e.jsx)("span",{className:"hidden sm:inline",children:t("hospitality.apartments.list")})]})]}),(0,e.jsx)(i,{asChild:!0,className:"bg-primary text-primary-foreground hover:bg-primary/90 h-9 shrink-0 gap-2 px-4 font-semibold",children:(0,e.jsxs)(q,{to:`/sites/${a}/hospitality/apartments/new`,children:[(0,e.jsx)(X,{className:"h-4 w-4"})," ",(0,e.jsx)("span",{className:"hidden sm:inline",children:t("hospitality.apartments.new")})]})})]})}),(0,e.jsx)("div",{className:"mx-auto w-full max-w-7xl space-y-8 p-6 md:p-8 animate-in fade-in duration-500",children:h.length===0?(0,e.jsxs)("div",{className:"flex flex-col items-center justify-center rounded-xl border-2 border-dashed border-border/50 py-20 text-center",children:[(0,e.jsx)("div",{className:"mb-4 rounded-full bg-muted/50 p-4 text-muted-foreground",children:(0,e.jsx)(c,{className:"h-8 w-8 opacity-50"})}),(0,e.jsx)("h3",{className:"text-lg font-semibold text-foreground",children:t("hospitality.apartments.empty")}),(0,e.jsx)("p",{className:"mt-1 max-w-sm text-sm text-muted-foreground",children:t(p?"hospital
1ity.apartments.noSearchResults":"hospitality.apartments.emptyHint")})]}):x==="grid"?(0,e.jsx)("div",{className:"grid grid-cols-1 gap-6 md:grid-cols-2 lg:grid-cols-3",children:h.map(s=>(0,e.jsxs)("div",{className:"group overflow-hidden rounded-xl border border-border bg-card",children:[(0,e.jsxs)("div",{className:"relative aspect-video overflow-hidden bg-muted",children:[s.cover_image_url?(0,e.jsx)("img",{src:I(s.cover_image_url),alt:s.name,className:"h-full w-full object-cover transition-transform duration-500 group-hover:scale-105"}):(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center text-muted-foreground/30",children:(0,e.jsx)(c,{className:"h-10 w-10"})}),(0,e.jsxs)("div",{className:"absolute left-3 top-3 flex flex-wrap gap-2",children:[(0,e.jsx)(g,{variant:"secondary",className:`border-none px-2 py-0.5 text-[10px] font-bold uppercase text-white ${s.is_public?"bg-[#2fb380]":"bg-amber-500"}`,children:s.is_public?t("hospitality.apartments.public"):t("hospitality.apartments.private")}),(0,e.jsx)(g,{variant:"secondary",className:`border-none px-2 py-0.5 text-[10px] font-bold uppercase ${oe(s)}`,children:B(s,t)})]})]}),(0,e.jsxs)("div",{className:"p-5",children:[(0,e.jsxs)("div",{className:"mb-3 flex items-start justify-between gap-3",children:[(0,e.jsxs)("div",{children:[(0,e.jsx)("h4",{className:"text-lg font-bold leading-tight text-foreground",children:s.name}),(0,e.jsx)("span",{className:"text-[10px] font-bold uppercase tracking-wider text-muted-foreground",children:s.apartment_type||t("hospitality.apartments.unit")})]}),(0,e.jsx)("div",{className:"text-right",children:(0,e.jsxs)("span",{className:"text-lg font-bold text-foreground",children:["â¬",s.price_per_night]})})]}),(0,e.jsxs)("div",{className:"mb-4 flex items-center gap-4 text-xs font-semibold text-muted-foreground",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2 py-1",children:[(0,e.jsx)(L,{className:"h-3.5 w-3.5 text-primary"}),s.capacity]}),(0,e.jsxs)("span",{className:"flex items-center gap-1.5 rounded-md bg-muted/50 px-2 py-1",children:[(0,e.jsx)(c,{className:"h-3.5 w-3.5 text-primary"}),s.bedrooms||0]})]}),(0,e.jsxs)("div",{className:"mb-5 space-y-2 rounded-lg border border-border/60 bg-muted/20 p-3",children:[(0,e.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,e.jsx)(J,{className:"h-3.5 w-3.5"}),t("hospitality.apartments.icsImport")]}),(0,e.jsx)("span",{className:`font-semibold ${y(s)?"text-emerald-600":"text-muted-foreground"}`,children:y(s)?t("hospitality.apartments.configured"):t("hospitality.apartments.missing")})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between text-xs",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1.5 text-muted-foreground",children:[(0,e.jsx)(C,{className:"h-3.5 w-3.5"}),t("hospitality.apartments.lastSync")]}),(0,e.jsx)("span",{className:"font-medium text-foreground",children:z(s.ical_last_sync,j)})]})]}),(0,e.jsxs)("div",{className:"flex items-center justify-between border-t border-border/50 pt-4",children:[(0,e.jsxs)("div",{className:"flex gap-1",children:[(0,e.jsxs)(i,{variant:"outline",size:"sm",className:"h-9 border-border/60 px-3 font-semibold",onClick:()=>r(`/sites/${a}/hospitality/apartments/${s.id}`),children:[(0,e.jsx)(T,{className:"mr-2 h-4 w-4"}),t("hospitality.apartments.edit")]}),(0,e.jsx)(i,{variant:"ghost",size:"icon",className:`h-9 w-9 ${s.is_public?"text-emerald-600":"text-amber-600"}`,onClick:()=>_(s),children:s.is_public?(0,e.jsx)(k,{className:"h-4 w-4"}):(0,e.jsx)(S,{className:"h-4 w-4"})})]}),(0,e.jsx)(i,{variant:"ghost",size:"icon",className:"h-9 w-9 text-muted-foreground hover:text-rose-500",onClick:()=>w(s.id),children:(0,e.jsx)($,{className:"h-4 w-4"})})]})]})]},s.id))}):(0,e.jsx)("div",{className:"overflow-hidden rounded-xl border border-border bg-card",children:(0,e.jsxs)(re,{children:[(0,e.jsx)(te,{className:"bg-muted/30",children:(0,e.jsxs)(E,{className:"border-border/50 hover:bg-transparent",children:[(0,e.jsx)(n,{className:"py-4 pl-6 text-xs font-bold uppercase text-muted-foreground",children:t("hospital
1ity.apartments.accommodation")}),(0,e.jsx)(n,{className:"py-4 text-xs font-bold uppercase text-muted-foreground",children:t("hospitality.apartments.details")}),(0,e.jsx)(n,{className:"py-4 text-xs font-bold uppercase text-muted-foreground",children:"iCal"}),(0,e.jsx)(n,{className:"py-4 text-xs font-bold uppercase text-muted-foreground",children:t("hospitality.apartments.price")}),(0,e.jsx)(n,{className:"py-4 text-center text-xs font-bold uppercase text-muted-foreground",children:t("hospitality.apartments.status")}),(0,e.jsx)(n,{className:"py-4 pr-6 text-right text-xs font-bold uppercase text-muted-foreground",children:t("hospitality.apartments.actions")})]})}),(0,e.jsx)(ae,{children:h.map(s=>(0,e.jsxs)(E,{className:"group border-border/50 transition-colors hover:bg-muted/30",children:[(0,e.jsx)(o,{className:"py-4 pl-6",children:(0,e.jsxs)("div",{className:"flex items-center gap-4",children:[(0,e.jsx)("div",{className:"h-10 w-14 shrink-0 overflow-hidden rounded-md border border-border/50 bg-muted",children:s.cover_image_url?(0,e.jsx)("img",{src:I(s.cover_image_url),alt:s.name,className:"h-full w-full object-cover"}):(0,e.jsx)("div",{className:"flex h-full w-full items-center justify-center",children:(0,e.jsx)(c,{className:"h-4 w-4 text-muted-foreground/30"})})}),(0,e.jsxs)("div",{className:"flex flex-col",children:[(0,e.jsx)("span",{className:"leading-none font-bold text-foreground",children:s.name}),(0,e.jsx)("span",{className:"mt-1 text-[10px] font-bold uppercase text-muted-foreground",children:s.apartment_type||t("hospitality.apartments.unit")})]})]})}),(0,e.jsx)(o,{className:"py-4 text-sm font-semibold text-muted-foreground",children:(0,e.jsxs)("div",{className:"flex items-center gap-3",children:[(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)(L,{className:"h-3 w-3 text-primary"}),s.capacity]}),(0,e.jsxs)("span",{className:"flex items-center gap-1",children:[(0,e.jsx)(c,{className:"h-3 w-3 text-primary"}),s.bedrooms||0]})]})}),(0,e.jsx)(o,{className:"py-4",children:(0,e.jsxs)("div",{className:"space-y-1 text-xs",children:[(0,e.jsxs)("div",{className:"flex items-center gap-2",children:[s.ical_last_sync_status==="success"?(0,e.jsx)(W,{className:"h-3.5 w-3.5 text-emerald-600"}):s.ical_last_sync_status==="error"?(0,e.jsx)(Z,{className:"h-3.5 w-3.5 text-rose-600"}):(0,e.jsx)(C,{className:"h-3.5 w-3.5 text-muted-foreground"}),(0,e.jsx)("span",{className:"font-semibold text-foreground",children:B(s,t)})]}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[t("hospitality.apartments.import"),":"," ",(0,e.jsx)("span",{className:"font-medium text-foreground",children:y(s)?t("hospitality.apartments.yes"):t("hospitality.apartments.no")})]}),(0,e.jsxs)("div",{className:"text-muted-foreground",children:[t("hospitality.apartments.last"),":"," ",(0,e.jsx)("span",{className:"font-medium text-foreground",children:z(s.ical_last_sync,j)})]})]})}),(0,e.jsx)(o,{className:"py-4",children:(0,e.jsxs)("span",{className:"text-sm font-bold text-foreground",children:["â¬",s.price_per_night]})}),(0,e.jsx)(o,{className:"py-4 text-center",children:(0,e.jsx)("div",{className:"flex flex-col items-center gap-2",children:(0,e.jsx)(g,{variant:"outline",className:`border-none text-[10px] font-bold ${s.is_public?"bg-[#2fb380]/10 text-[#2fb380]":"bg-amber-500/10 text-amber-600"}`,children:s.is_public?t("hospitality.apartments.public"):t("hospitality.apartments.private")})})}),(0,e.jsx)(o,{className:"py-4 pr-6 text-right",children:(0,e.jsxs)("div",{className:"flex items-center justify-end gap-2",children:[(0,e.jsx)(i,{variant:"ghost",size:"icon",className:"h-8 w-8 text-primary",onClick:()=>r(`/sites/${a}/hospitality/apartments/${s.id}`),children:(0,e.jsx)(T,{className:"h-4 w-4"})}),(0,e.jsx)(i,{variant:"ghost",size:"icon",className:`h-8 w-8 ${s.is_public?"text-[#2fb380]":"text-amber-600"}`,onClick:()=>_(s),children:s.is_public?(0,e.jsx)(k,{className:"h-4 w-4"}):(0,e.jsx)(S,{className:"h-4 w-4"})}),(0,e.jsx)(i,{variant:"ghost",size:"icon",className:"h-8 w-8 text-rose-500",onClick:()=>w(s.id),children:(0,e.jsx)($,{className:"h-4 w-4"})})]})})]},s.id))})]})})})]})}export{ye 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.