PageSourceSearch

https://gestioncastellamare.lovable.app/assets/Cleaning-BncbJUd2.js

js gestioncastellamare.lovable.app collected 2026-10-03 03:27:55 UTC 21,719 bytes, 17 lines download raw bytes

1import{F as Ce,m as ke,C as ye,a6 as je,aa as Te,r as T,G as W,s as b,j as e,B as E,_ as Se,S as oe,U as me,O as Be,Q as De,V as Ae,W as Ee,z as $e,I as X,a9 as qe}from"./index-BBqSIRFr.js";import{u as J}from"./useQuery-DPg6d1Np.js";import{S as Le,a as Ie,b as Fe,c as Pe,d as he}from"./select-d7X3N2Ha.js";import{C as fe,a as ue}from"./card-DH1FG-vU.js";import{B as G}from"./badge-COWdW-ZL.js";import{C as ze}from"./checkbox-DW4qkGtm.js";import{e as Ue,C as Ke,i as Ge}from"./isBefore-CyVZIlQW.js";import{S as Oe}from"./settings-2-DP5rUNfK.js";import{C as pe}from"./copy-BNheMoyQ.js";import{L as Re}from"./link-2-FsNliosK.js";import{S as te}from"./spray-can-IDZDEWOk.js";import{C as ne}from"./calendar-fFlbWCDH.js";import{P as xe}from"./phone-Bs5GHP0F.js";import{M as Qe}from"./moon-CjLFEwEA.js";import{C as ge}from"./clock-DwqBdcZb.js";import{P as Ve}from"./plus-90LfiCG6.js";import{T as He}from"./trash-2-fPFfrrJ9.js";import{s as We,a as se}from"./startOfMonth-HqllfQ-t.js";import{f as _,d as Je}from"./format-CxF-eFL9.js";import{s as ae}from"./subMonths-BUG6DqlW.js";import{p as L}from"./parseISO-CVSgkjRz.js";import{i as ie}from"./isWithinInterval-Cem_78Rf.js";import{f as O}from"./fr-Cg1n1akz.js";import"./index-BdQq_4o_.js";import"./index-CgiT_1mT.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 Xe=Ce("UserCheck",[["path",{d:"M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2",key:"1yyitq"}],["circle",{cx:"9",cy:"7",r:"4",key:"nufk8"}],["polyline",{points:"16 11 18 13 22 9",key:"1pwet4"}]]);function Ye(){const{user:n}=ke(),{toast:w}=ye();je();const{isDemoMode:p,demoUserId:k}=Te(),[P,S]=T.useState("all"),[$,R]=T.useState(new Date),[z,Q]=T.useState(!1),{data:B=[]}=J({queryKey:["host-listings-cleaning",n==null?void 0:n.id,p],queryFn:async()=>{if(p&&k)return(W.getSnapshot(k).listings||[]).map(r=>({id:r.id,title:r.title}));if(!(n!=null&&n.id))return[];const{data:t,error:s}=await b.from("listings").select("id, title, checkin_from, checkout_until").eq("host_user_id",n.id).order("title");if(s)throw s;return t},enabled:p?!!k:!!(n!=null&&n.id)}),M=We($),D=Ue($),{data:U=[]}=J({queryKey:["host-cleaning-bookings",n==null?void 0:n.id,_(M,"yyyy-MM-dd"),p],queryFn:async()=>{if(p&&k){const f=W.getSnapshot(k),l=_(ae(M,1),"yyyy-MM-dd"),x=_(se(D,1),"yyyy-MM-dd");return(f.hostBookings||[]).filter(a=>["confirmed","completed","owner_blocked"].includes(a.status)&&a.checkout_date>=l&&a.checkin_date<=x)}if(!(n!=null&&n.id))return[];const t=_(ae(M,1),"yyyy-MM-dd"),s=_(se(D,1),"yyyy-MM-dd"),{data:c,error:r}=await b.from("bookings").select("id, listing_id, checkin_date, checkout_date, checkin_time, checkout_time, nights, notes, pricing_breakdown, status").in("status",["confirmed","completed","owner_blocked"]).gte("checkout_date",t).lte("checkin_date",s).order("checkin_date");if(r)throw r;return c},enabled:p?!!k:!!(n!=null&&n.id)}),{data:q=[]}=J({queryKey:["host-tenants-cleaning",n==null?void 0:n.id,p],queryFn:async()=>{if(p&&k)return(W.getSnapshot(k).tenants||[]).map(r=>({id:r.id,first_name:r.first_name,last_name:r.last_name,phone:r.phone}));if(!(n!=null&&n.id))return[];const{data:t,error:s}=await b.from("tenants").select("id, first_name, last_name, phone").eq("host_user_id",n.id);if(s)throw s;return t},enabled:p?!!k:!!(n!=null&&n.id)}),{data:I=[]}=J({queryKey:["cleaning-staff",n==null?void 0:n.id,p],queryFn:async()=>{if(p&&k)return W.getSnapshot(k).cleaningStaff||[];if(!(n!=null&&n.id))return[];const{data:t,error:s}=await b.from("cleaning_staff").select("id, name, phone, access_token, portal_past_months, portal_future_months").eq("host_user_id",n.id).order("name");if(s)throw s;return t},enabled:p?!!k:!!(n!=null&&n.id)}),{data:V=[]}=J({queryKey:["cleaning-staff-listings",n==null?void 0:n.id,p],queryFn:async()=>{if(p&&k)return W.getSnapshot(k).cleaningStaffListings||[];if(!(n!=null&&n.id))return[];const{data:t,error:s}=await b.from("cleaning_staff_listings").select("id, cleaning_staff_id, listing_id").eq("host_user_id",n.id);if(s)throw s;return t},enabled:p?!!k:!!(n!=null&&n.id)}),H=T.useMemo(()=>{const t=new Map;for(const s of q)t.set(s.id,s);return t},[q]),m=T.useMemo(()=>{const t=new Map;for(const s of V){const c=I.find(r=>
6r.id===s.cleaning_staff_id);c&&t.set(s.listing_id,c)}return t},[V,I]),y=t=>{const s=t.pricing_breakdown;return s!=null&&s.tenant_id&&H.get(s.tenant_id)||null},g=T.useMemo(()=>{var r,f,l,x,a,i;const t=P==="all"?U:U.filter(o=>o.listing_id===P),s=new Map;for(const o of t){const j=s.get(o.listing_id)||[];j.push(o),s.set(o.listing_id,j)}const c=[];for(const[o,j]of s){const d=[...j].sort((u,N)=>u.checkin_date.localeCompare(N.checkin_date)),h=B.find(u=>u.id===o);for(let u=0;u<d.length;u++){const N=d[u],v=L(N.checkout_date);if(!ie(v,{start:M,end:D}))continue;const A=d[u+1]||null,Z=A?Je(L(A.checkin_date),v)*24:null;c.push({cleaningDate:v,checkoutBooking:N,nextCheckinBooking:A,tenant:y(N),nextTenant:A?y(A):null,listingId:o,listingTitle:(h==null?void 0:h.title)||"Bien inconnu",hoursAvailable:Z,staffMember:m.get(o)||null,checkoutTime:((r=N.checkout_time)==null?void 0:r.slice(0,5))||((f=h==null?void 0:h.checkout_until)==null?void 0:f.slice(0,5))||null,checkinTime:((l=N.checkin_time)==null?void 0:l.slice(0,5))||((x=h==null?void 0:h.checkin_from)==null?void 0:x.slice(0,5))||null,nextCheckinTime:A&&(((a=A.checkin_time)==null?void 0:a.slice(0,5))||((i=h==null?void 0:h.checkin_from)==null?void 0:i.slice(0,5)))||null})}}return c.sort((o,j)=>o.cleaningDate.getTime()-j.cleaningDate.getTime())},[U,P,B,M,D,H,m]),C=T.useCallback(t=>{var f,l,x,a;const s=[],c=new Set,r=new Map;for(const i of t)r.set(i.checkoutBooking.id,{booking:i.checkoutBooking,listingId:i.listingId,listingTitle:i.listingTitle,staffMember:i.staffMember}),i.nextCheckinBooking&&r.set(i.nextCheckinBooking.id,{booking:i.nextCheckinBooking,listingId:i.listingId,listingTitle:i.listingTitle,staffMember:i.staffMember});for(const[,{booking:i,listingId:o,listingTitle:j,staffMember:d}]of r){const h=i.status==="owner_blocked",u=y(i),N=h?ce(i.notes)||"Bloqué":u?`${u.first_name} ${u.last_name||""}`.trim():re(i.notes)||"Non renseigné",v=B.find(F=>F.id===o),A=L(i.checkout_date);if(ie(A,{start:M,end:D})){const F=`${i.id}-dep`;if(!c.has(F)){c.add(F);const ee=((f=i.checkout_time)==null?void 0:f.slice(0,5))||((l=v==null?void 0:v.checkout_until)==null?void 0:l.slice(0,5))||null;s.push({date:i.checkout_date,listingId:o,listingTitle:j,type:h?"block_end":"departure",tenantName:N,phone:!h&&(u!=null&&u.phone)?u.phone:null,time:h?null:ee,nights:h?null:i.nights,booking:i,staffMember:d})}}const Z=L(i.checkin_date);if(ie(Z,{start:M,end:D})){const F=`${i.id}-arr`;if(!c.has(F)){c.add(F);const ee=((x=i.checkin_time)==null?void 0:x.slice(0,5))||((a=v==null?void 0:v.checkin_from)==null?void 0:a.slice(0,5))||null;s.push({date:i.checkin_date,listingId:o,listingTitle:j,type:h?"block_start":"arrival",tenantName:N,phone:!h&&(u!=null&&u.phone)?u.phone:null,time:h?null:ee,nights:h?null:i.nights,booking:i,staffMember:d})}}}return s.sort((i,o)=>
6{if(i.date!==o.date)return i.date.localeCompare(o.date);const j={departure:0,block_end:0,arrival:1,block_start:1};return j[i.type]!==j[o.type]?j[i.type]-j[o.type]:i.listingTitle.localeCompare(o.listingTitle)}),s},[M,D,B,H]),Y=(t,s)=>{let c=[];if(c.push(`  🏠 ${t.listingTitle}`),t.type==="departure"){let r=`  🚪 DÉPART — ${t.tenantName}`;t.time&&(r+=` — 🕐 ${t.time}`),c.push(r)}else if(t.type==="block_end")c.push(`  🔒 FIN BLOCAGE — ${t.tenantName}`);else if(t.type==="arrival"){let r=`  🔑 ARRIVÉE — ${t.tenantName}`;t.time&&(r+=` — 🕐 ${t.time}`),t.phone&&(r+=` — 📞 ${t.phone}`),t.nights&&(r+=` — ${t.nights} nuit${t.nights>1?"s":""}`),c.push(r)}else t.type==="block_start"&&c.push(`  🔒 DÉBUT BLOCAGE — ${t.tenantName}`);return c.join(`
7`)},le=(t,s)=>{if(t.length===0)return"";let c=s+`
8`+"═".repeat(40)+`
9`;const r=new Map;for(const l of t){const x=r.get(l.date)||[];x.push(l),r.set(l.date,x)}let f=!0;for(const[l,x]of r){f||(c+=`
10  `+"─".repeat(30)+`
11`),f=!1;const a=_(L(l),"EEEE dd MMMM",{locale:O});c+=`
12📅 ${a.toUpperCase()}
13
14`;const i=new Set(x.filter(d=>d.type==="departure"||d.type==="block_end").map(d=>d.listingId)),o=new Set(x.filter(d=>d.type==="arrival"||d.type==="block_start").map(d=>d.listingId)),j=new Set([...i].filter(d=>o.has(d)));for(const d of x){const h=j.has(d.listingId)&&(d.type==="departure"||d.type==="block_end");c+=Y(d),h&&(c+=`
15  ⚠️ Enchaînement serré !`),c+=`
16`}}return c.trim()},_e=()=>{const t=C(g),s=_($,"MMMM yyyy",{locale:O});return le(t,`🧹 PLANNING MÉNAGE — ${s.toUpperCase()}`)},Ne=t=>{const s=g.filter(f=>{var l;return((l=f.staffMember)==null?void 0:l.id)===t.id}).sort((f,l)=>f.cleaningDate.getTime()-l.cleaningDate.getTime()),c=C(s),r=_($,"MMMM yyyy",{locale:O});return le(c,`🧹 PLANNING MÉNAGE — ${t.name.toUpperCase()}
17📆 ${r.charAt(0).toUpperCase()+r.slice(1)}`)},ve=()=>{const t=_e();if(!t){w({title:"Aucun ménage",description:"Aucun ménage prévu pour ce mois."});return}navigator.clipboard.writeText(t),w({title:"Copié !",description:"Le planning complet a été copié."})},we=t=>{const s=Ne(t);if(!s){w({title:"Aucun ménage",description:`Aucun ménage prévu pour ${t.name} ce mois.`});return}navigator.clipboard.writeText(s),w({title:"Copié !",description:`Planning de ${t.name} copié.`})},K=t=>t.hoursAvailable!==null&&t.hoursAvailable<=24,de=t=>t.hoursAvailable!==null&&t.hoursAvailable<=48&&!K(t),be=t=>Ge(t.cleaningDate,new Date)&&_(t.cleaningDate,"yyyy-MM-dd")!==_(new Date,"yyyy-MM-dd"),Me=T.useMemo(()=>{const t=new Map;for(const s of g)s.staffMember&&t.set(s.staffMember.id,(t.get(s.staffMember.id)||0)+1);return t},[g]);return e.jsxs("div",{className:"container mx-auto px-4 py-6 lg:px-8 space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row items-start sm:items-center gap-4 flex-wrap",children:[e.jsxs(Le,{value:P,onValueChange:S,children:[e.jsx(Ie,{className:"w-[260px]",children:e.jsx(Fe,{placeholder:"Tous les biens"})}),e.jsxs(Pe,{children:[e.jsx(he,{value:"all",children:"Tous les biens"}),B.map(t=>e.jsx(he,{value:t.id,children:t.title},t.id))]})]}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(E,{variant:"outline",size:"icon",onClick:()=>R(t=>ae(t,1)),children:e.jsx(Ke,{className:"h-4 w-4"})}),e.jsx("span",{className:"text-sm font-medium w-[140px] text-center capitalize",children:_($,"MMMM yyyy",{locale:O})}),e.jsx(E,{variant:"outline",size:"icon",onClick:()=>R(t=>se(t,1)),children:e.jsx(Se,{className:"h-4 w-4"})})]}),e.jsxs("div",{className:"flex items-center gap-2 ml-auto",children:[e.jsxs(E,{onClick:()=>Q(!0),variant:"outline",size:"sm",children:[e.jsx(Oe,{className:"h-4 w-4 mr-2"}),"Équipe ménage"]}),e.jsxs(E,{onClick:ve,variant:"outline",size:"sm",children:[e.jsx(pe,{className:"h-4 w-4 mr-2"}),"Copier tout"]})]})]}),I.length>0&&e.jsx("div",{className:"flex gap-2 flex-wrap",children:I.map(t=>{const s=Me.get(t.id)||0,c=`${window.location.origin}/cleaning-portal/${t.access_token}`;return e.jsxs("div",{className:"flex gap-1",children:[e.jsxs(E,{variant:"secondary",size:"sm",onClick:()=>we(t),className:"gap-2",children:[e.jsx(pe,{className:"h-3.5 w-3.5"}),t.name,s>0&&e.jsx(G,{variant:"outline",className:"ml-1 text-xs px-1.5",children:s})]}),e.jsx(E,{variant:"outline",size:"sm",onClick:()=>{navigator.clipboard.writeText(c),w({title:"Lien copié !",description:`Lien du planning de ${t.name} copié.`})},title:`Copier le lien du planning de ${t.name}`,children:e.jsx(Re,{className:"h-3.5 w-3.5"})})]},t.id)})}),e.jsxs("div",{className:"flex gap-3 flex-wrap",children:[e.jsxs(G,{variant:"secondary",className:"gap-1",children:[e.jsx(te,{className:"h-3 w-3"}),g.length," ménage",g.length!==1?"s":""]}),g.filter(K).length>0&&e.jsxs(G,{variant:"destructive",className:"gap-1",children:["⚠️ ",g.filter(K).length," urgent",g.filter(K).length>
171?"s":""]})]}),g.length===0?e.jsx(fe,{children:e.jsxs(ue,{className:"py-12 text-center text-muted-foreground",children:[e.jsx(te,{className:"h-10 w-10 mx-auto mb-3 opacity-50"}),e.jsx("p",{children:"Aucun ménage prévu pour ce mois."})]})}):e.jsx("div",{className:"space-y-8",children:(()=>{var r;const t=new Map,s="__unassigned__";for(const f of g){const l=((r=f.staffMember)==null?void 0:r.id)||s;t.has(l)||t.set(l,{staff:f.staffMember,slots:[]}),t.get(l).slots.push(f)}for(const f of t.values())f.slots.sort((l,x)=>l.cleaningDate.getTime()-x.cleaningDate.getTime());return[...t.entries()].sort(([f,l],[x,a])=>{var i,o;return f===s?1:x===s?-1:(((i=l.staff)==null?void 0:i.name)||"").localeCompare(((o=a.staff)==null?void 0:o.name)||"")}).map(([f,l])=>{var x;return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-3 mb-4",children:[e.jsx("div",{className:"h-px flex-1 bg-border"}),e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(Xe,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"text-sm font-bold uppercase tracking-wider text-primary",children:((x=l.staff)==null?void 0:x.name)||"Non attribué"})]}),e.jsxs(G,{variant:"outline",className:"text-xs",children:[l.slots.length," ménage",l.slots.length>1?"s":""]}),e.jsx("div",{className:"h-px flex-1 bg-border"})]}),e.jsx("div",{className:"space-y-2",children:l.slots.map((a,i)=>{var u,N,v;const o=a.checkoutBooking.status==="owner_blocked",j=o?ce(a.checkoutBooking.notes)||"Bloqué":a.tenant?`${a.tenant.first_name} ${a.tenant.last_name||""}`.trim():re(a.checkoutBooking.notes),d=((u=a.nextCheckinBooking)==null?void 0:u.status)==="owner_blocked",h=d?ce(a.nextCheckinBooking.notes)||"Blocage":a.nextTenant?`${a.nextTenant.first_name} ${a.nextTenant.last_name||""}`.trim():a.nextCheckinBooking?re(a.nextCheckinBooking.notes):null;return e.jsx(fe,{className:`transition-colors ${be(a)?"opacity-50":K(a)?"border-destructive/50 bg-destructive/5":de(a)?"border-accent/80 bg-accent/10":""}`,children:e.jsx(ue,{className:"py-4 px-5",children:e.jsxs("div",{className:"flex flex-col lg:flex-row lg:items-start gap-4",children:[e.jsxs("div",{className:"flex-shrink-0 lg:w-[200px]",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-1",children:[e.jsx(te,{className:"h-4 w-4 text-primary"}),e.jsx("span",{className:"font-semibold",children:a.listingTitle})]}),e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground capitalize",children:[e.jsx(ne,{className:"h-3.5 w-3.5"}),e.jsx("span",{children:_(a.cleaningDate,"EEEE dd MMMM",{locale:O})})]}),K(a)&&e.jsx(G,{variant:"destructive",className:"mt-1 text-xs",children:"⚠️ Enchaînement immédiat"}),de(a)&&e.jsx(G,{variant:"outline",className:"mt-1 text-xs",children:"⏰ Enchaînement serré"})]}),e.jsx(oe,{orientation:"vertical",className:"hidden lg:block h-auto self-stretch"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:o?"Fin blocage":"Départ"}),e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:j||"Non renseigné"})]}),!o&&((N=a.tenant)==null?void 0:N.phone)&&e.jsxs("div",{className:"flex items-center gap-2 text-sm mt-0.5",children:[e.jsx(xe,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{children:a.tenant.phone})]}),!o&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mt-0.5",children:[e.jsx(ne,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsxs("span",{children:[_(L(a.checkoutBooking.checkin_date),"dd/MM")," → ",_(L(a.checkoutBooking.checkout_date),"dd/MM")]}),e.jsx(Qe,{className:"h-3.5 w-3.5 flex-shrink-0 ml-1"}),e.jsxs("span",{children:[a.checkoutBooking.nights," nuit",a.checkoutBooking.nights>1?"s":""]})]}),!o&&a.checkoutTime&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mt-0.5",children:[e.jsx(ge,{className:"h-3.5 w-3.5 flex-shrink-0"}
17),e.jsxs("span",{children:["Départ à ",a.checkoutTime]})]})]}),e.jsx(oe,{orientation:"vertical",className:"hidden lg:block h-auto self-stretch"}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-1",children:d?"Début blocage":"Arrivée suivante"}),a.nextCheckinBooking?e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"flex items-center gap-2 text-sm",children:[e.jsx(me,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{className:"font-medium",children:h||"Non renseigné"})]}),!d&&((v=a.nextTenant)==null?void 0:v.phone)&&e.jsxs("div",{className:"flex items-center gap-2 text-sm mt-0.5",children:[e.jsx(xe,{className:"h-3.5 w-3.5 text-muted-foreground flex-shrink-0"}),e.jsx("span",{children:a.nextTenant.phone})]}),e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mt-0.5",children:[e.jsx(ne,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsx("span",{className:"capitalize",children:_(L(a.nextCheckinBooking.checkin_date),"EEEE dd/MM",{locale:O})})]}),a.nextCheckinTime&&e.jsxs("div",{className:"flex items-center gap-2 text-sm text-muted-foreground mt-0.5",children:[e.jsx(ge,{className:"h-3.5 w-3.5 flex-shrink-0"}),e.jsxs("span",{children:["Arrivée à ",a.nextCheckinTime]})]}),a.hoursAvailable!==null&&e.jsxs("p",{className:"text-xs text-muted-foreground mt-1",children:["⏱️ ",Math.floor(a.hoursAvailable/24)," jour",Math.floor(a.hoursAvailable/24)>1?"s":""," entre les deux"]})]}):e.jsx("p",{className:"text-sm text-muted-foreground",children:"Pas de réservation suivante"})]})]})})},a.checkoutBooking.id+"-"+i)})})]},f)})})()}),e.jsx(Ze,{open:z,onOpenChange:Q,staff:I,assignments:V,listings:B})]})}function Ze({open:n,onOpenChange:w,staff:p,assignments:k,listings:P}){const{user:S}=ke(),{toast:$}=ye(),R=je(),[z,Q]=T.useState(""),[B,M]=T.useState(""),[D,U]=T.useState(!1),q=()=>{R.invalidateQueries({queryKey:["cleaning-staff"]}),R.invalidateQueries({queryKey:["cleaning-staff-listings"]})},I=async()=>{if(!(S!=null&&S.id)||!z.trim())return;U(!0);const{error:m}=await b.from("cleaning_staff").insert({host_user_id:S.id,name:z.trim(),phone:B.trim()||null});if(U(!1),m){$({title:"Erreur",description:m.message,variant:"destructive"});return}Q(""),M(""),q()},V=async m=>{const{error:y}=await b.from("cleaning_staff").delete().eq("id",m);if(y){$({title:"Erreur",description:y.message,variant:"destructive"});return}q()},H=async(m,y)=>{if(!(S!=null&&S.id))return;const g=k.find(C=>C.cleaning_staff_id===m&&C.listing_id===y);if(g)await b.from("cleaning_staff_listings").delete().eq("id",g.id);else{const C=k.find(Y=>Y.listing_id===y);C&&await b.from("cleaning_staff_listings").delete().eq("id",C.id),await b.from("cleaning_staff_listings").insert({cleaning_staff_id:m,listing_id:y,host_user_id:S.id})}q()};return e.jsx(Be,{open:n,onOpenChange:w,children:e.jsxs(De,{className:"sm:max-w-lg max-h-[85vh] overflow-y-auto",children:[e.jsx(Ae,{children:e.jsx(Ee,{children:"Équipe de ménage"})}),e.jsxs("div",{className:"space-y-6",children:[e.jsxs("div",{className:"space-y-3",children:[e.jsx($e,{className:"text-sm font-medium",children:"Ajouter une personne"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(X,{placeholder:"Nom",value:z,onChange:m=>Q(m.target.value),className:"flex-1"}),e.jsx(X,{placeholder:"Téléphone",value:B,onChange:m=>M(m.target.value),className:"w-[140px]"}),e.jsx(E,{onClick:I,disabled:!z.trim()||D,size:"icon",children:e.jsx(Ve,{className:"h-4 w-4"})})]})]}),e.jsx(oe,{}),p.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-4",children:"Aucune personne ajoutée."}):e.jsx("div",{className:"space-y-5",children:p.map(m=>e.jsxs("div",{className:"space-y-2",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("span",{className:"font-medium text-sm",children:m.name}),m.phone&&e.jsx("span",{className:"text-xs text-muted-foreground ml-2",children:m.phone})]}),e.jsx(E,{variant:"ghost",size:"icon",className:"h-7 w-7",onClick:()=>V(m.id),children:e.jsx(He,{className:"h-3.5 w-3.5 text-destructive"})})]}),e.jsxs("div",{className:"pl-2 flex items-center gap-3 text-xs text-muted-foreground",children:[e.jsx("span",{children:"Visibilité portail :"}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(X,{type:"number",min:0,max:12,value:m.portal_past_months,onChange:async y=>{const g=Math.max(0,Math.min(12,parseInt(y.target.value)||0));await b.from("cleaning_staff").update({portal_past_months:g}).eq("id",m.id),q()},className:"w-14 h-7 text-xs text-center"}),e.jsx("span",{children:"mois passés"})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(X,{type:"number",min:1,max:12,value:m.portal_future_months,onChange:async y=>{const g=Math.max(1,Math.min(12,parseInt(y.target.value)||1));await b.from("cleaning_staff").update({portal_future_months:g}).eq("id",m.id),q()},className:"w-14 h-7 text-xs text-center"}),e.jsx("span",{children:"mois futurs"})]})]}),e.jsx("div",{className:"pl-2 space-y-1.5",children:P.map(y=>{const g=k.some(C=>C.cleaning_staff_id===m.id&&C.listing_id===y.id);return e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer text-sm",children:[e.jsx(ze,{checked:g,onCheckedChange:()=>H(m.id,y.id)}),y.title]},y.id)})})]},m.id))})]}),e.jsx(qe,{children:e.jsx(E,{variant:"outline",onClick:()=>w(!1),children:"Fermer"})})]})})}function re(n){if(!n)return null;const w=n.match(/Locataire:\s*([^|]+)/);return w?w[1].trim():null}function ce(n){var p;return n&&((p=n.split(" | ")[0])==null?void 0:p.trim())||null}const bt=()=>e.jsx(Ye,{});export{bt 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.