PageSourceSearch

https://parisrentaparts.com/assets/Dashboard-CVKRnhEk.js

js parisrentaparts.com collected 2026-10-09 22:03:15 UTC 35,275 bytes, 21 lines download raw bytes

1import{H as z,r as k,aw as G,a as I,s as S,j as e,ac as ie,am as oe,ad as ce,an as Ie,c as y,a6 as Ee,p as $,f as _,M as J,ap as ke,B as H,a3 as O,a9 as Pe,al as Oe,ao as ve,U as Re,n as We,ar as He,as as Fe,at as le,au as de}from"./index-D5R9CWr2.js";import{u as Ue}from"./useBookingSettings-f5VwVmfS.js";import{u as ze,A as me,B as Ge}from"./AppLayout-CreL9Axy.js";import{S as C}from"./skeleton-Cjb14kQh.js";import{A as Ke}from"./activity-BnFfB00f.js";import{S as be}from"./square-pen-B_u-65q4.js";import{D as ue}from"./dollar-sign-CFXmjBgO.js";import{C as E}from"./calendar-D7YPT7FB.js";import{W as K}from"./wrench-CpPDVHpr.js";import{F as pe}from"./file-text-D50dZpGo.js";import{T as Ve}from"./trash-2-KxEfpDSI.js";import{f as W}from"./formatDistanceToNow-BOhoyb6f.js";import{p as v}from"./parseISO-CPTq0D6Q.js";import{u as Z}from"./useBookings-De1zVr58.js";import{g as Q}from"./tenant-DU35DUNp.js";import{B as we}from"./badge-B4iIB_GH.js";import{C as F}from"./circle-arrow-right-BfQP8Ug_.js";import{C as _e}from"./clock-D72xm9Eo.js";import{d as xe}from"./differenceInDays-Dc8ONZsv.js";import{u as Ce}from"./useTickets-CzTfYPa1.js";import{C as Xe}from"./credit-card-C-BRGzyw.js";import{C as Me}from"./clipboard-list-rp5yggzp.js";import{T as U}from"./triangle-alert-Dz_0sbeG.js";import{u as Ye}from"./usePlatformColorLookup-CvVHh6fK.js";import{M as Qe}from"./message-circle-DCWMh_x0.js";import{S as Se}from"./sparkles-BbYLz8O8.js";import{C as Je}from"./circle-check-CLbUexCi.js";import{u as Te,a as Ze}from"./usePlanning-CXruU2qN.js";import{e as qe}from"./differenceInMonths-6myfc76I.js";import{P as et}from"./plus-C_cXJ1zJ.js";import{C as tt}from"./camera-NN7rfbIY.js";import{i as st}from"./isToday-CS1muC96.js";import{i as nt}from"./isTomorrow-7hrNdpZi.js";import{C as he}from"./calendar-days-Wd9GQrKs.js";import{S as at}from"./sun-TXt7TxHw.js";import{S as rt}from"./sunset-BtP1Pznq.js";import{M as it}from"./moon-DG2-WNHL.js";import"./house-BSdFTc93.js";import"./pull-to-refresh-8r31CQoz.js";import"./send-DYbGN6xe.js";import"./wallet-NSknHVIW.js";import"./chart-column-DDD70TP6.js";import"./message-square-_pho9Wsv.js";import"./database-CyS6yrr_.js";import"./upload-DnTsq47q.js";import"./sheet-BMeEmOG3.js";import"./index-BQJE0D3x.js";import"./index-Cj3i9dis.js";import"./receipt-B0GYoCdB.js";import"./drawer-B05fz228.js";import"./dialog-CLC4v4pI.js";import"./textarea-rQZs_wSe.js";import"./ticket-plus-CmgMFVQN.js";import"./arrow-left-ZzXpuph4.js";import"./constructNow-DQ2n3FBI.js";import"./usePlatformProviders-azUNS-RB.js";import"./booking-source-B4YacL2l.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 ee=z("CircleArrowLeft",[["circle",{cx:"12",cy:"12",r:"10",key:"1mglay"}],["path",{d:"M16 12H8",key:"1fr5h0"}],["path",{d:"m12 8-4 4 4 4",key:"15vm53"}]]);/**
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 ot=z("ClipboardCheck",[["rect",{width:"8",height:"4",x:"8",y:"2",rx:"1",ry:"1",key:"tgr4d6"}],["path",{d:"M16 4h2a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H6a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h2",key:"116196"}],["path",{d:"m9 14 2 2 4-4",key:"df797q"}]]);/**
12 * @license lucide-react v0.462.0 - ISC
13 *
14 * This source code is licensed under the ISC license.
15 * See the LICENSE file in the root directory of this source tree.
16 */const ge=z("UserRound",[["circle",{cx:"12",cy:"8",r:"5",key:"1hypcn"}],["path",{d:"M20 21a8 8 0 0 0-16 0",key:"rfgkzh"}]]);/**
17 * @license lucide-react v0.462.0 - ISC
18 *
19 * This source code is licensed under the ISC license.
20 * See the LICENSE file in the root directory of this source tree.
21 */const ct=z("UserX",[["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"}],["line",{x1:"17",x2:"22",y1:"8",y2:"13",key:"3nzzx3"}],["line",{x1:"22",x2:"17",y1:"8",y2:"13",key:"1swrse"}]]),lt={payment:ue,booking:E,ticket:K,intervention:Ee,payout:ue,create:pe,update:be,delete:Ve,document:pe},dt={payment:"bg-success/10 text-success",booking:"bg-primary/10 text-primary",ticket:"bg-warning/10 text-warning",intervention:"bg-info/10 text-info",payout:"bg-success/10 text-success",create:"bg-primary/10 text-primary",update:"bg-warning/10 text-warning",delete:"bg-destructive/10 text-destructive",document:"bg-info/10 text-info"},fe=k.forwardRef(function({agentId:d,userId:a},h){const{workspace:s}=G(),u=!!a,{data:o=[]}=I({queryKey:["dashboard-activity-log",a,s==null?void 0:s.id],queryFn:async()=>
21{if(!(s!=null&&s.id)||!a)return[];const{data:l}=await S.from("activity_log").select("*").eq("workspace_id",s.id).eq("user_id",a).order("created_at",{ascending:!1}).limit(10);return l||[]},enabled:!!(s!=null&&s.id)&&!!a,refetchInterval:6e4}),{data:t=[]}=I({queryKey:["dashboard-recent-payments",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:l}=await S.from("payments").select("id, amount, status, created_at, paid_at, booking:bookings!payments_booking_fk(booking_number, property:properties(name))").eq("workspace_id",s.id).eq("status","paid").order("paid_at",{ascending:!1}).limit(5);return l||[]},enabled:!!(s!=null&&s.id)&&!u,refetchInterval:6e4}),{data:i=[]}=I({queryKey:["dashboard-recent-bookings",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:l}=await S.from("bookings").select("id, booking_number, status, created_at, property:properties(name), tenant:tenants(name)").eq("workspace_id",s.id).order("created_at",{ascending:!1}).limit(5);return l||[]},enabled:!!(s!=null&&s.id)&&!u,refetchInterval:6e4}),{data:p=[]}=I({queryKey:["dashboard-recent-tickets",s==null?void 0:s.id],queryFn:async()=>{if(!(s!=null&&s.id))return[];const{data:l}=await S.from("tickets").select("id, title, status, created_at, property:properties(name)").eq("workspace_id",s.id).order("created_at",{ascending:!1}).limit(5);return l||[]},enabled:!!(s!=null&&s.id)&&!u,refetchInterval:6e4}),f=k.useMemo(()=>{if(u)return o.map(n=>{var b;const c={created:"create",updated:"update",deleted:"delete",status_changed:"update"},N={payment:"payment",expense:"payment",deposit:"payment",payout:"payout",booking:"booking",document:"document",ticket:"ticket",intervention:"intervention"}[n.entity_type]||c[n.action]||"update";return{id:n.id,type:N,title:n.description||`${n.action} ${n.entity_type}`,description:[n.field_changed&&`Field: ${n.field_changed}`,(b=n.entity_id)==null?void 0:b.slice(0,8)].filter(Boolean).join(" · ")||n.action,time:W(v(n.created_at),{addSuffix:!0}),createdAt:v(n.created_at)}});const l=[];return t.forEach(n=>{var c,j,N;l.push({id:`payment-${n.id}`,type:"payment",title:`Payment – €${Number(n.amount).toLocaleString()}`,description:((j=(c=n.booking)==null?void 0:c.property)==null?void 0:j.name)||`Booking #${((N=n.booking)==null?void 0:N.booking_number)||"N/A"}`,time:W(v(n.paid_at||n.created_at),{addSuffix:!0}),createdAt:v(n.paid_at||n.created_at)})}
21),i.forEach(n=>{var c,j;l.push({id:`booking-${n.id}`,type:"booking",title:`Booking #${n.booking_number}`,description:`${((c=n.tenant)==null?void 0:c.name)||"Guest"} · ${((j=n.property)==null?void 0:j.name)||"Property"}`,time:W(v(n.created_at),{addSuffix:!0}),createdAt:v(n.created_at)})}),p.forEach(n=>{var c;l.push({id:`ticket-${n.id}`,type:"ticket",title:n.title||"New Ticket",description:((c=n.property)==null?void 0:c.name)||"Property",time:W(v(n.created_at),{addSuffix:!0}),createdAt:v(n.created_at)})}),l.sort((n,c)=>c.createdAt.getTime()-n.createdAt.getTime()).slice(0,8)},[u,o,t,i,p]);return s!=null&&s.id?e.jsxs(ie,{className:"border-0 shadow-card bg-card/80 backdrop-blur-sm h-full",children:[e.jsx(oe,{className:"pb-2 pt-5 px-5",children:e.jsxs(Ie,{className:"text-sm font-semibold flex items-center gap-2",children:[e.jsx("div",{className:"w-6 h-6 rounded-md bg-accent/10 flex items-center justify-center",children:e.jsx(Ke,{className:"h-3.5 w-3.5 text-accent"})}),u?"My Activity":"Recent Activity"]})}),e.jsx(ce,{className:"px-5 pb-5",children:e.jsx("div",{className:"space-y-3",children:f.length===0?e.jsx("p",{className:"text-sm text-muted-foreground text-center py-6",children:"No recent activity"}):f.map(l=>{const n=lt[l.type]||be;return e.jsxs("div",{className:"flex items-start gap-3 group",children:[e.jsx("div",{className:y("w-8 h-8 rounded-lg flex items-center justify-center flex-shrink-0 transition-transform group-hover:scale-105",dt[l.type]||"bg-muted text-muted-foreground"),children:e.jsx(n,{className:"w-3.5 h-3.5"})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium text-foreground leading-tight truncate",children:l.title}),e.jsx("p",{className:"text-caption text-muted-foreground truncate mt-0.5",children:l.description})]}),e.jsx("span",{className:"text-micro text-muted-foreground/70 whitespace-nowrap mt-0.5",children:l.time})]},l.id)})})})]}):e.jsxs(ie,{className:"border-0 shadow-card bg-card/80 backdrop-blur-sm",children:[e.jsx(oe,{className:"pt-5 px-5 pb-3",children:e.jsx(C,{className:"h-5 w-32"})}),e.jsx(ce,{className:"px-5 pb-5 space-y-4",children:[1,2,3].map(l=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(C,{className:"w-8 h-8 rounded-lg"}),e.jsxs("div",{className:"flex-1",children:[e.jsx(C,{className:"h-4 w-40 mb-1"}),e.jsx(C,{className:"h-3 w-28"})]})]},l))})]})}),ye=k.forwardRef(function({agentId:d},a){const{data:h=[]}=Z();$();const s=new Date,u=_(s,"yyyy-MM-dd"),o=k.useMemo(()=>h.filter(t=>{if(t.status==="cancelled"||!t.check_in||d&&t.assigned_to!==d)return!1;const i=v(t.check_in),p=xe(i,s);return p>=0&&p<=7}).sort((t,i)=>(t.check_in||"").localeCompare(i.check_in||"")).slice(0,5),[h,u,d]);return o.length===0?e.jsxs("div",{className:"flex flex-col items-center justify-center h-full text-center py-10",children:[e.jsx("div",{className:"w-12 h-12 rounded-2xl bg-muted/50 flex items-center justify-center mb-3",children:e.jsx(F,{className:"h-6 w-6 text-muted-foreground/40"})}),e.jsx("p",{className:"text-sm font-medium text-muted-foreground",children:"No upcoming bookings"}),e.jsx("p",{className:"text-xs text-muted-foreground/60 mt-0.5",children:"This week is clear"})]}):e.jsx("div",{className:"space-y-2",children:o.map(t=>{const i=t.check_in===u,p=t.check_out===u,f=t.check_in?xe(v(t.check_in),s):0,l=t.tenant?Q(t.tenant):"Guest";return e.jsxs("div",{className:y("flex items-center gap-3 p-3 rounded-xl cursor-pointer hover:bg-muted/40 transition-all duration-200 group",i&&"bg-success/5"),onClick:()=>{t.booking_number&&(window.location.href=`/app/bookings/${t.booking_number}`)},children:[e.jsx("div",{className:y("w-9 h-9 rounded-lg flex items-center justify-center shrink-0 transition-transform group-hover:scale-105",i?"bg-success/15":p?"bg-warning/15":"bg-muted/60"),children:p?e.jsx(ee,{className:"w-4 h-4 text-warning"}):e.jsx(F,{className:y("w-4 h-4",i?"text-success":"text-muted-foreground")})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate leading-tight",children:l}),t.property&&e.jsxs("p",{className:"text-micro text-muted-foreground flex items-center gap-1 mt-0.5",children:[e.jsx(J,{className:"w-2.5 h-2.5"}),t.property.name]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[i?e.jsx(we,{className:"bg-success/15 text-success border-0 text-micro font-semibold h-5 px-2",children:"Today"}):e.jsxs("span",{className:"text-caption text-muted-foreground flex items-center gap-1 font-medium",children:[e.jsx(_e,{className:"w-3 h-3"}),f,"d"]}
21),e.jsx("p",{className:"text-micro text-muted-foreground/60 mt-0.5",children:t.check_in&&_(v(t.check_in),"MMM d")})]})]},t.id)})})});function je({agentId:r}={}){const d=$(),{workspace:a}=G(),{data:h=[]}=Z(),{data:s=[]}=Ce(),u=_(new Date,"yyyy-MM-dd"),o=_(ke(new Date,2),"yyyy-MM-dd"),t=r?h.filter(n=>n.assigned_to===r):h,i=r?s.filter(n=>n.assigned_to===r):s,p=t.map(n=>n.id),{data:f=0}=I({queryKey:["action-overdue-payments",a==null?void 0:a.id,r,p.length],queryFn:async()=>{if(!(a!=null&&a.id))return 0;let n=S.from("payments").select("id",{count:"exact",head:!0}).eq("workspace_id",a.id).eq("status","pending").lt("due_date",u);if(r){if(p.length===0)return 0;n=n.in("booking_id",p.slice(0,200))}const{count:c}=await n;return c||0},enabled:!!(a!=null&&a.id)&&(!r||p.length>0)}),l=k.useMemo(()=>{const n=[];f>0&&n.push({id:"overdue-payments",icon:Xe,label:"Overdue payments",count:f,color:"text-destructive",bgColor:"from-destructive/15 to-destructive/5",href:"/app/finance",urgency:"critical"});const c=t.filter(g=>g.status==="to_complete").length;c>0&&n.push({id:"to-complete",icon:Me,label:"Bookings to complete",count:c,color:"text-warning",bgColor:"from-warning/15 to-warning/5",href:"/app/bookings?status=to_complete",urgency:"warning"});const j=t.filter(g=>g.check_in&&g.check_in>=u&&g.check_in<=o&&!g.assigned_to&&g.status!=="cancelled"&&g.status!=="closed").length;j>0&&n.push({id:"unassigned-checkins",icon:ct,label:"Unassigned check-ins (48h)",count:j,color:"text-warning",bgColor:"from-warning/15 to-warning/5",href:"/app/bookings",urgency:"warning"});const N=i.filter(g=>g.priority==="urgent"&&(g.status==="todo"||g.status==="in_progress")).length;N>0&&n.push({id:"urgent-tickets",icon:U,label:"Urgent tickets",count:N,color:"text-destructive",bgColor:"from-destructive/15 to-destructive/5",href:"/app/tickets",urgency:"critical"});const b=i.filter(g=>g.status!=="in_progress"||!g.updated_at?!1:Math.floor((Date.now()-new Date(g.updated_at).getTime())/(1e3*60*60*24))>7).length;return b>0&&n.push({id:"stale-tickets",icon:_e,label:"Stale tickets (>7d)",count:b,color:"text-muted-foreground",bgColor:"from-muted-foreground/15 to-muted-foreground/5",href:"/app/tickets",urgency:"info"}),n.sort((g,D)=>{const A={critical:0,warning:1,info:2};return A[g.urgency]-A[D.urgency]})},[f,t,i,u,o]);return l.length===0?null:e.jsx("div",{className:"space-y-1.5",children:l.map(n=>e.jsxs(H,{variant:"ghost",onClick:()=>d(n.href),className:"w-full flex gap-3 p-3 rounded-xl group text-left h-auto",children:[e.jsx("div",{className:y("w-9 h-9 rounded-xl bg-gradient-to-br flex items-center justify-center shrink-0","group-hover:scale-110 transition-transform shadow-soft",n.bgColor),children:e.jsx(n.icon,{className:y("h-4 w-4",n.color)})}),e.jsx("div",{className:"flex-1 min-w-0",children:e.jsx("p",{className:"text-sm font-medium",children:n.label})}),e.jsx(we,{variant:"outline",className:y("text-micro font-bold h-5 px-2 shrink-0",n.urgency==="critical"&&"border-destructive/40 text-destructive bg-destructive/5",n.urgency==="warning"&&"border-warning/40 text-warning bg-warning/5",n.urgency==="info"&&"border-border text-muted-foreground"),children:n.count}),e.jsx(O,{className:"h-3.5 w-3.5 text-muted-foreground opacity-0 group-hover:opacity-100 transition-opacity shrink-0"})]},n.id))})}function M({children:r,className:d}){return e.jsx("div",{className:y("rounded-2xl bg-card p-5","shadow-card hover:shadow-medium transition-shadow duration-500",d),children:r})}function mt({progress:r}){const a=2*Math.PI*20,h=a-r/100*a;return e.jsxs("div",{className:"relative w-12 h-12 shrink-0",children:[e.jsxs("svg",{className:"w-full h-full -rotate-90",viewBox:"0 0 48 48",children:[e.jsx("circle",{cx:"24",cy:"24",r:20,fill:"none",stroke:"hsl(var(--border))",strokeWidth:4,opacity:.3}),e.jsx("circle",{cx:"24",cy:"24",r:20,fill:"none",stroke:"hsl(var(--success))",strokeWidth:4,strokeDasharray:a,strokeDashoffset:h,strokeLinecap:"round",className:"transition-all duration-1000 ease-out"})]}),e.jsx("div",{className:"absolute inset-0 flex items-center justify-center",children:e.jsxs("span",{className:"text-micro font-bold tabular-nums",children:[Math.round(r),"%"]})})]})}function ut(){const{workspace:r}=G(),d=k.useMemo(()=>{const a=new Date;return a.setDate(a.getDate()-1),a.setHours(18,0,0,0),a.toISOString()},[]);return I({queryKey:["overnight-briefing",r==null?void 0:r.id,d],queryFn:async()=>{const a={inquiries:0,messages:0,newBookings:0,toConfirm:0,tickets:0,newBookingsList:[],toConfirmList:[]};if(!(r!=null&&r.id))return a;
21const h="id, booking_number, check_in, check_out, status, platform, property:properties(id, name, internal_reference, cover_photo, photos), tenant:tenants(id, first_name, last_name)",[s,u,o,t,i]=await Promise.all([S.from("public_inquiries").select("id",{count:"exact",head:!0}).eq("workspace_id",r.id).gte("created_at",d).eq("status","new"),S.from("booking_messages").select("id",{count:"exact",head:!0}).eq("workspace_id",r.id).gte("created_at",d).eq("sender_type","guest"),S.from("bookings").select(h,{count:"exact"}).eq("workspace_id",r.id).gte("created_at",d).in("status",["to_complete","option"]).order("created_at",{ascending:!1}).limit(20),S.from("bookings").select(h,{count:"exact"}).eq("workspace_id",r.id).eq("status","to_complete").order("check_in",{ascending:!0}).limit(20),S.from("tickets").select("id",{count:"exact",head:!0}).eq("workspace_id",r.id).gte("created_at",d)]);return{inquiries:s.count||0,messages:u.count||0,newBookings:o.count||0,toConfirm:t.count||0,tickets:i.count||0,newBookingsList:o.data||[],toConfirmList:t.data||[]}},enabled:!!(r!=null&&r.id),refetchInterval:6e4})}function Ne(r){if(!r)return"—";try{return _(v(r),"d MMM")}catch{return"—"}}function pt(r){var s,u,o,t;const d=((u=(s=r.tenant)==null?void 0:s.first_name)==null?void 0:u.trim())||"",a=((t=(o=r.tenant)==null?void 0:o.last_name)==null?void 0:t.trim())||"";return`${d} ${a}`.trim()||"Guest"}function xt(){const r=$(),{data:d,isLoading:a}=ut(),{getPlatformHex:h}=Ye(),[s,u]=k.useState({});if(a)return e.jsx("div",{className:"space-y-1",children:[1,2,3].map(i=>e.jsx(C,{className:"h-11 rounded-xl"},i))});const o=d||{inquiries:0,messages:0,newBookings:0,toConfirm:0,tickets:0,newBookingsList:[],toConfirmList:[]},t=[];return o.inquiries>0&&t.push({id:"inq",icon:Pe,label:"New inquiries",count:o.inquiries,href:"/app/inbox",color:"text-primary"}),o.messages>0&&t.push({id:"msg",icon:Qe,label:"New guest messages",count:o.messages,href:"/app/inbox",color:"text-accent"}),o.newBookings>0&&t.push({id:"newb",icon:Me,label:"New bookings",count:o.newBookings,href:"/app/bookings",color:"text-info",expandable:!0,items:o.newBookingsList}),o.toConfirm>0&&t.push({id:"tc",icon:ot,label:"To complete",count:o.toConfirm,href:"/app/bookings?status=to_complete",color:"text-warning",expandable:!0,items:o.toConfirmList}),o.tickets>0&&t.push({id:"tk",icon:U,label:"Tickets opened",count:o.tickets,href:"/app/tickets",color:"text-destructive"}),t.length===0?e.jsxs("div",{className:"flex items-center gap-3 py-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-success/10 flex items-center justify-center shrink-0",children:e.jsx(Se,{className:"h-4 w-4 text-success"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"All quiet overnight"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Nothing to triage"})]})]}):e.jsx("div",{className:"-mx-1",children:t.map(i=>{var l,n;const p=!!s[i.id],f=i.expandable&&(((l=i.items)==null?void 0:l.length)??0)>0;return e.jsxs("div",{children:[e.jsxs("button",{onClick:()=>f?u(c=>({...c,[i.id]:!c[i.id]})):r(i.href),className:y("w-full flex items-center gap-3 px-3 py-2.5 rounded-xl group text-left","hover:bg-muted/50 transition-colors"),children:[e.jsx(i.icon,{className:y("h-4 w-4 shrink-0",i.color),strokeWidth:2.25}),e.jsx("p",{className:"text-sm font-medium flex-1 truncate",children:i.label}),e.jsx("span",{className:y("text-sm font-semibold tabular-nums",i.color),children:i.count}),f?e.jsx(Oe,{className:y("h-3.5 w-3.5 text-muted-foreground/60 shrink-0 transition-transform",p&&"rotate-180")}):e.jsx(O,{className:"h-3.5 w-3.5 text-muted-foreground/50 group-hover:text-muted-foreground transition-colors shrink-0"})]}),f&&p&&e.jsxs("div",{className:"ml-10 mr-1 mb-1 mt-1 space-y-0.5 border-l border-border/60 pl-3",children:[i.items.map(c=>{var g,D,A,q,T;const j=((g=c.property)==null?void 0:g.name)||((D=c.property)==null?void 0:D.internal_reference)||"Property",N=((A=c.property)==null?void 0:A.cover_photo)||((T=(q=c.property)==null?void 0:q.photos)==null?void 0:T[0]),b=c.platform?h(c.platform):null;return e.jsxs("button",{onClick:P=>{P.stopPropagation(),r(`/app/bookings/${c.booking_number||c.id}`)},className:"w-full flex items-center gap-2.5 px-2 py-1.5 rounded-lg hover:bg-muted/50 transition-colors text-left",children:[e.jsxs("div",{className:"relative h-10 w-12 rounded-lg bg-muted overflow-hidden shrink-0",children:[N?e.jsx("img",{src:N,alt:j,className:"h-full w-full object-cover"}):e.jsx("div",{className:"h-full w-full flex items-center justify-center text-muted-foreground
21/60",children:e.jsx(E,{className:"h-3.5 w-3.5"})}),b&&e.jsx("span",{className:"absolute bottom-0.5 right-0.5 h-2 w-2 rounded-full ring-1 ring-background",style:{backgroundColor:b},"aria-label":c.platform||""})]}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-xs font-semibold truncate leading-tight",children:j}),e.jsxs("p",{className:"text-[11px] text-muted-foreground truncate leading-tight mt-0.5",children:[pt(c),c.booking_number?` · #${c.booking_number}`:""]}),e.jsxs("p",{className:"text-[11px] text-muted-foreground tabular-nums leading-tight mt-0.5 flex items-center gap-1.5",children:[e.jsxs("span",{children:[Ne(c.check_in)," → ",Ne(c.check_out)]}),c.platform&&e.jsxs(e.Fragment,{children:[e.jsx("span",{className:"text-muted-foreground/40",children:"·"}),e.jsx("span",{className:"capitalize",style:{color:b||void 0},children:c.platform})]})]})]}),e.jsx(O,{className:"h-3.5 w-3.5 text-muted-foreground/50 shrink-0"})]},c.id)}),i.count>(((n=i.items)==null?void 0:n.length)??0)&&e.jsxs("button",{onClick:c=>{c.stopPropagation(),r(i.href)},className:"w-full text-left text-[11px] text-muted-foreground hover:text-foreground px-2 py-1",children:["View all ",i.count," →"]})]})]},i.id)})})}function ht({checkIns:r,checkOuts:d,interventions:a,events:h}){const s=$(),u=[{id:"ci",icon:F,label:"Check-ins",count:r,color:"text-success",href:"/app/planning"},{id:"co",icon:ee,label:"Check-outs",count:d,color:"text-warning",href:"/app/planning"},{id:"iv",icon:K,label:"Interventions",count:a,color:"text-info",href:"/app/planning"},{id:"ev",icon:E,label:"Events",count:h,color:"text-primary",href:"/app/planning"}];return e.jsx("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-px bg-border/40 rounded-2xl overflow-hidden",children:u.map(o=>e.jsxs("button",{onClick:()=>s(o.href),className:"group flex flex-col items-start gap-1.5 p-4 bg-card hover:bg-muted/40 transition-colors text-left",children:[e.jsx(o.icon,{className:y("h-4 w-4",o.color),strokeWidth:2.25}),e.jsx("p",{className:"text-2xl font-semibold leading-none tabular-nums tracking-tight",children:o.count}),e.jsx("p",{className:"text-micro text-muted-foreground truncate",children:o.label})]},o.id))})}const gt={"check-in":{icon:F,color:"text-success"},"check-out":{icon:ee,color:"text-warning"},intervention:{icon:K,color:"text-info"},event:{icon:E,color:"text-primary"}};function ft({items:r}){const d=$();return r.length===0?e.jsxs("div",{className:"flex items-center gap-3 py-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-success/10 flex items-center justify-center shrink-0",children:e.jsx(Se,{className:"h-4 w-4 text-success"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"Nothing on your plate"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Enjoy the calm 🌿"})]})]}):e.jsx("div",{className:"-mx-1 space-y-0.5",children:r.map(a=>{const h=gt[a.type],s=h.icon,u=a.status==="completed",o=a.status==="in-progress";return e.jsxs("button",{onClick:()=>a.href&&d(a.href),className:y("relative w-full flex items-center gap-3 px-3 py-2.5 rounded-xl text-left","hover:bg-muted/50 transition-colors",u&&"opacity-50"),children:[e.jsx("div",{className:"w-11 shrink-0 text-right",children:e.jsx("span",{className:y("text-caption font-mono tabular-nums font-semibold",o?"text-warning":"text-muted-foreground"),children:a.time||"—"})}),u?e.jsx(Je,{className:"h-4 w-4 text-success shrink-0",strokeWidth:2.25}):e.jsx(s,{className:y("h-4 w-4 shrink-0",h.color),strokeWidth:2.25}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:y("text-sm font-medium leading-tight truncate",u&&"line-through"),children:a.title}),a.property&&e.jsxs("p",{className:"text-micro text-muted-foreground flex items-center gap-1 mt-0.5 truncate",children:[e.jsx(J,{className:"w-2.5 h-2.5 shrink-0"}),e.jsx("span",{className:"truncate",children:a.property})]})]}),o&&e.jsx("span",{className:"text-micro font-bold text-warning uppercase tracking-wider shrink-0",children:"Now"})]},a.id)})})}
21const yt=["photo","shoot","meeting","rendez","rdv","visit","plomb","tech","personal","perso"],jt=r=>{const d=(r||"").toLowerCase();return d.includes("photo")?tt:d.includes("meet")||d.includes("rdv")||d.includes("rendez")?Re:d.includes("plomb")||d.includes("tech")||d.includes("repair")?K:E};function Nt({agentId:r}){const d=$(),a=ve(new Date),h=qe(ke(a,1)),{data:s,isLoading:u}=Te({agentId:r,startDate:a.toISOString(),endDate:h.toISOString()}),o=k.useMemo(()=>s?s.filter(t=>{var p,f;if(!t.booking_id)return!0;const i=((f=(p=t.event_type)==null?void 0:p.name)==null?void 0:f.toLowerCase())||"";return yt.some(l=>i.includes(l))}).sort((t,i)=>(t.start_date||"").localeCompare(i.start_date||"")):[],[s]);return u?e.jsx("div",{className:"space-y-1.5",children:[1,2].map(t=>e.jsx(C,{className:"h-12 rounded-xl"},t))}):e.jsxs("div",{children:[o.length===0?e.jsxs("div",{className:"flex items-center gap-3 py-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted/50 flex items-center justify-center shrink-0",children:e.jsx(E,{className:"h-4 w-4 text-muted-foreground/60"})}),e.jsxs("div",{children:[e.jsx("p",{className:"text-sm font-semibold",children:"No appointments"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Today & tomorrow are open"})]})]}):e.jsx("div",{className:"-mx-1 space-y-0.5",children:o.map(t=>{var c,j,N,b;const i=jt((c=t.event_type)==null?void 0:c.name),p=t.start_date?v(t.start_date):null,f=p?st(p)?"Today":nt(p)?"Tomorrow":_(p,"MMM d"):"",l=p&&!t.all_day?_(p,"HH:mm"):null,n=(j=t.event_type)==null?void 0:j.color;return e.jsxs("button",{onClick:()=>d("/app/planning"),className:y("w-full flex items-center gap-3 px-3 py-2.5 rounded-xl","hover:bg-muted/50 transition-colors group text-left"),children:[e.jsx(i,{className:"h-4 w-4 shrink-0 text-muted-foreground",style:{color:n||void 0},strokeWidth:2.25}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsx("p",{className:"text-sm font-medium leading-tight truncate",children:t.title||((N=t.event_type)==null?void 0:N.name)||"Appointment"}),((b=t.property)==null?void 0:b.name)&&e.jsxs("p",{className:"text-micro text-muted-foreground flex items-center gap-1 mt-0.5 truncate",children:[e.jsx(J,{className:"w-2.5 h-2.5 shrink-0"}),e.jsx("span",{className:"truncate",children:t.property.name})]})]}),e.jsxs("div",{className:"text-right shrink-0",children:[l&&e.jsx("p",{className:"text-caption font-mono font-semibold tabular-nums",children:l}),e.jsx("p",{className:"text-micro text-muted-foreground/60",children:f})]})]},t.id)})}),e.jsxs(H,{variant:"ghost",size:"sm",onClick:()=>d("/app/planning"),className:"w-full mt-2 h-9 text-xs gap-1.5 rounded-xl text-muted-foreground hover:text-foreground",children:[e.jsx(et,{className:"h-3.5 w-3.5"}),"Add appointment"]})]})}function kt(){const[r,d]=k.useState(()=>new Date);return k.useEffect(()=>{const a=setInterval(()=>d(new Date),1e3);return()=>clearInterval(a)},[]),e.jsx("span",{className:"text-sm font-mono tabular-nums",children:_(r,"HH:mm")})}function L({title:r,subtitle:d,icon:a,action:h}){return e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xs uppercase tracking-wide text-muted-foreground font-semibold",children:r}),d&&e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-0.5",children:d})]}),h??(a?e.jsx(a,{className:"h-4 w-4 text-muted-foreground"}):null)]})}function Cs(){var ne,ae;const r=$(),{checkInTime:d,checkOutTime:a}=Ue(),h=new Date,s=_(h,"yyyy-MM-dd"),{data:u}=ze();G();const{user:o}=We(),t=u==null?void 0:u.id,i=!!t,[p,f]=k.useState(()=>{if(typeof window>"u")return"global";const x=window.localStorage.getItem("dashboard.tab");return x==="personal"||x==="global"?x:"global"});k.useEffect(()=>{!i&&p==="personal"&&f("global")},[i,p]),k.useEffect(()=>{window.localStorage.setItem("dashboard.tab",p)},[p]);const{data:l,isLoading:n}=Z(),{data:c,isLoading:j}=Ce(),{data:N,isLoading:b}=Ze({}),{data:g,isLoading:D}=Te({startDate:ve(h).toISOString(),endDate:qe(h).toISOString()});k.useMemo(()=>(l==null?void 0:l.filter(x=>x.assigned_to===t).map(x=>x.id))||[],[l,t]);const A=n||j||b||D,q=x=>x?x.slice(0,10):"",T=k.useMemo(()=>(l==null?void 0:l.filter(x=>q(x.check_out)>=s&&q(x.check_in)<=s))||[],[l,s]),P=(T==null?void 0:T.filter(x=>
21q(x.check_in)===s&&x.status!=="cancelled"))||[],V=(T==null?void 0:T.filter(x=>q(x.check_out)===s&&x.status!=="cancelled"))||[],X=(N==null?void 0:N.filter(x=>q(x.scheduled_date)===s))||[],Y=(g==null?void 0:g.filter(x=>x.start_date&&_(v(x.start_date),"yyyy-MM-dd")===s))||[],B=k.useMemo(()=>{if(!t)return[];const x=P.filter(m=>m.assigned_to===t),Ae=V.filter(m=>m.assigned_to===t),Be=X.filter(m=>m.agent_id===t),$e=Y.filter(m=>m.agent_id===t);return[...x.map(m=>{var w;return{id:`aci-${m.id}`,type:"check-in",time:d,title:`Check-in — ${m.tenant?Q(m.tenant):"Guest"}`,property:(w=m.property)==null?void 0:w.name,status:m.status==="in_progress"?"completed":"pending",href:m.booking_number?`/app/bookings/${m.booking_number}`:void 0}}),...Ae.map(m=>{var w;return{id:`aco-${m.id}`,type:"check-out",time:a,title:`Check-out — ${m.tenant?Q(m.tenant):"Guest"}`,property:(w=m.property)==null?void 0:w.name,status:m.status==="closed"?"completed":"pending",href:m.booking_number?`/app/bookings/${m.booking_number}`:void 0}}),...Be.map(m=>{var w;return{id:`aiv-${m.id}`,type:"intervention",time:m.scheduled_time||void 0,title:m.title||"Intervention",property:(w=m.property)==null?void 0:w.name,status:m.status==="completed"?"completed":m.status==="in_progress"?"in-progress":"pending",href:"/app/planning"}}),...$e.map(m=>{var w,re;return{id:`aev-${m.id}`,type:"event",time:m.start_date?_(v(m.start_date),"HH:mm"):void 0,title:m.title||((w=m.event_type)==null?void 0:w.name)||"Event",property:(re=m.property)==null?void 0:re.name,status:m.status==="completed"?"completed":m.status==="in_progress"?"in-progress":"pending",href:"/app/planning"}})].sort((m,w)=>m.time?w.time?m.time.localeCompare(w.time):-1:1)},[P,V,X,Y,t,d,a]),te=B.filter(x=>x.status==="completed").length,se=B.length>0?te/B.length*100:0,Le=((ne=u==null?void 0:u.name)==null?void 0:ne.split(" ")[0])||((ae=o==null?void 0:o.email)==null?void 0:ae.split("@")[0])||"",R=h.getHours(),De=R<12?at:R<18?rt:it;return A?e.jsx(me,{title:"Dashboard",activeRoute:"/app/dashboard",children:e.jsxs("div",{className:"page-container-wide page-section",children:[e.jsx(C,{className:"h-[120px] rounded-3xl"}),e.jsx(C,{className:"h-12 w-64 rounded-xl"}),e.jsx("div",{className:"grid grid-cols-2 lg:grid-cols-4 gap-3",children:[1,2,3,4].map(x=>e.jsx(C,{className:"h-24 rounded-2xl"},x))}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsx(C,{className:"h-80 rounded-2xl"}),e.jsx(C,{className:"h-80 rounded-2xl"})]})]})}):e.jsx(me,{title:"",activeRoute:"/app/dashboard",children:e.jsxs("div",{className:"page-container-wide page-section",children:[e.jsxs("header",{className:"flex items-end justify-between gap-4 pt-1",children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm text-muted-foreground font-medium",children:R<12?"Good morning":R<18?"Good afternoon":"Good evening"}),e.jsx("h1",{className:"text-3xl sm:text-4xl font-bold tracking-tight truncate",children:Le}),e.jsx("p",{className:"text-xs text-muted-foreground/70 mt-1",children:_(h,"EEEE, MMMM d")})]}),e.jsxs("div",{className:"flex items-center gap-1.5 text-muted-foreground shrink-0",children:[e.jsx(De,{className:"h-4 w-4"}),e.jsx(kt,{})]})]}),e.jsxs(He,{value:p,onValueChange:x=>f(x),className:"w-full",children:[e.jsxs(Fe,{className:"h-10",children:[e.jsxs(le,{value:"global",className:"gap-1.5",children:[e.jsx(he,{className:"h-3.5 w-3.5"})," Global"]}),e.jsxs(le,{value:"personal",className:"gap-1.5",disabled:!i,children:[e.jsx(ge,{className:"h-3.5 w-3.5"})," Personal"]})]}),e.jsxs(de,{value:"global",className:"page-section mt-4",children:[e.jsx(ht,{checkIns:P.length,checkOuts:V.length,interventions:X.length,events:Y.length}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"Overnight briefing",subtitle:"Since yesterday 6 PM",icon:Ge}),e.jsx(xt,{})]}),e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"Action required",subtitle:"Workspace-wide",icon:U}),e.jsx(je,{})]})]}),e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"Upcoming",subtitle:"Next 7 days",action:e.jsxs(H,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1 -mr-2",onClick:()=>r("/app/bookings"),children:["All ",e.jsx(O,{className:"h-3 w-3"})]})}),e.jsx(ye,{})]}),e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"Recent activity",subtitle:"Workspace"}),e.jsx(fe,{})]})]}),e.jsx(de,{value:"personal",className:"page-section mt-4",children:i?e.jsxs(e.Fragment,{children:[e.jsxs(M,{className:"p-5",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-base font-semibold tracking-tight",children:"My day"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:B.length===0?"N
21othing scheduled":`${te} of ${B.length} done`})]}),B.length>0&&e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(mt,{progress:se}),e.jsxs("p",{className:"text-sm font-semibold tabular-nums text-muted-foreground",children:[Math.round(se),"%"]})]})]}),e.jsx("div",{className:"mt-4",children:e.jsx(ft,{items:B})})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-4",children:[e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"My appointments",subtitle:"Today & tomorrow",icon:he}),e.jsx(Nt,{agentId:t})]}),e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"My action required",subtitle:"Yours only",icon:U}),e.jsx(je,{agentId:t})]})]}),e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"My upcoming bookings",subtitle:"Next 7 days",action:e.jsxs(H,{variant:"ghost",size:"sm",className:"h-7 text-xs gap-1 -mr-2",onClick:()=>r("/app/bookings"),children:["All ",e.jsx(O,{className:"h-3 w-3"})]})}),e.jsx(ye,{agentId:t})]}),e.jsxs(M,{className:"p-5",children:[e.jsx(L,{title:"My recent activity"}),e.jsx(fe,{agentId:t,userId:o==null?void 0:o.id})]})]}):e.jsxs(M,{className:"p-8 text-center",children:[e.jsx(ge,{className:"h-8 w-8 text-muted-foreground/50 mx-auto mb-3"}),e.jsx("p",{className:"text-sm font-semibold",children:"No agent linked"}),e.jsx("p",{className:"text-xs text-muted-foreground mt-1",children:"Link your account to an agent to see your personal day."})]})})]})]})})}export{Cs 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.