PageSourceSearch

https://www.resida.app/_next/static/chunks/3514.fb01f86eef816bef.js

js resida.app collected 2026-10-02 01:15:42 UTC 36,770 bytes, 1 lines download raw bytes

1"use strict";(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[3514,9559],{18085:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(71847).A)("Send",[["path",{d:"M14.536 21.686a.5.5 0 0 0 .937-.024l6.5-19a.496.496 0 0 0-.635-.635l-19 6.5a.5.5 0 0 0-.024.937l7.93 3.18a2 2 0 0 1 1.112 1.11z",key:"1ffxy3"}],["path",{d:"m21.854 2.147-10.94 10.939",key:"12cjpa"}]])},37107:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(71847).A)("Hash",[["line",{x1:"4",x2:"20",y1:"9",y2:"9",key:"4lhtct"}],["line",{x1:"4",x2:"20",y1:"15",y2:"15",key:"vyu0kd"}],["line",{x1:"10",x2:"8",y1:"3",y2:"21",key:"1ggp8o"}],["line",{x1:"16",x2:"14",y1:"3",y2:"21",key:"weycgp"}]])},43514:(e,t,s)=>{s.r(t),s.d(t,{default:()=>K});var a=s(95155),l=s(12115),r=s(35626),n=s(42529),i=s(35299),c=s(71360),d=s(71847);let o=(0,d.A)("ImagePlus",[["path",{d:"M16 5h6",key:"1vod17"}],["path",{d:"M19 2v6",key:"4bpg5p"}],["path",{d:"M21 11.5V19a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V5a2 2 0 0 1 2-2h7.5",key:"1ue2ih"}],["path",{d:"m21 15-3.086-3.086a2 2 0 0 0-2.828 0L6 21",key:"1xmnt7"}],["circle",{cx:"9",cy:"9",r:"2",key:"af1f0g"}]]);var x=s(6132),m=s(53842),u=s(6191),h=s(52056),p=s(21873),g=s(16485),y=s(37107),f=s(39347),b=s(69141);let j=(0,d.A)("Hammer",[["path",{d:"m15 12-8.373 8.373a1 1 0 1 1-3-3L12 9",key:"eefl8a"}],["path",{d:"m18 15 4-4",key:"16gjal"}],["path",{d:"m21.5 11.5-1.914-1.914A2 2 0 0 1 19 8.172V7l-2.26-2.26a6 6 0 0 0-4.202-1.756L9 2.96l.92.82A6.18 6.18 0 0 1 12 8.4V10l2 2h1.172a2 2 0 0 1 1.414.586L18.5 14.5",key:"b7pghm"}]]);var v=s(27937),N=s(5917);let w=(0,d.A)("Bookmark",[["path",{d:"m19 21-7-4-7 4V5a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2v16z",key:"1fy3hk"}]]);var k=s(86651),F=s(20508),_=s(95740),A=s(89559),C=s(18085),S=s(65229),E=s(24546),q=s(24924),T=s(5218),R=s(13255);let I={LOW:"bg-gray-100 text-gray-600",MEDIUM:"bg-clay-50 text-clay-700",HIGH:"bg-orange-50 text-orange-700",CRITICAL:"bg-rose-50 text-rose-700"},D=e=>(0,R.t)(Number(e)||0),M={OPEN:{bg:"bg-clay-50",text:"text-clay-700",label:"Open"},ACCEPTED:{bg:"bg-[#EBF1FF]",text:"text-[#0039B5]",label:"Accepted"},IN_PROGRESS:{bg:"bg-violet-50",text:"text-violet-700",label:"In progress"},RESOLVED:{bg:"bg-sage-50",text:"text-sage-700",label:"Resolved"},DECLINED:{bg:"bg-rose-50",text:"text-rose-600",label:"Declined"}},P=["Plumbing","Electrical","AC Repair","Carpentry","Painting","Cleaning","Masonry","Appliance Repair"];function B(e){var t;let{status:s}=e,l=null!=(t=M[(null!=s?s:"").toUpperCase()])?t:M.OPEN;return(0,a.jsx)("span",{className:"shrink-0 px-2 py-0.5 rounded-full text-[10px] font-bold uppercase tracking-wider ".concat(l.bg," ").concat(l.text),children:l.label})}function L(e){var t,s,d,u,h;let{presetHandyman:p,prefill:g,onBack:y,onCreated:f}=e,[b,j]=(0,l.useState)([]),[v,N]=(0,l.useState)(!0),[w,k]=(0,l.useState)(null!=(s=null==g?void 0:g.unitId)?s:""),[F,_]=(0,l.useState)(null!=(d=null==g?void 0:g.title)?d:""),[A,C]=(0,l.useState)(null!=(u=null==g?void 0:g.desc)?u:""),[S,E]=(0,l.useState)(""),[T,R]=(0,l.useState)("TENANT"),[I,D]=(0,l.useState)([]),[M,P]=(0,l.useState)(!1),[B,L]=(0,l.useState)(!1),[U,H]=(0,l.useState)(""),[O,V]=(0,l.useState)(!1);async function z(e){var t,s,a,l,r;let n=Array.from(null!=(t=e.target.files)?t:[]).slice(0,5-I.length);if(n.length){P(!0),H("");try{for(let e of n){let t=new FormData;t.append("file",e),t.append("folder","service_requests");let n=await (0,q.QMY)(t),i=null!=(r=null==n||null==(a=n.data)||null==(s=a.data)?void 0:s.url)?r:null==n||null==(l=n.data)?void 0:l.url;i&&D(e=>[...e,i])}}catch(e){H("Photo upload failed. Please try again.")}finally{P(!1),e.target.value=""}}}async function W(e){if(e.preventDefault(),!w)return void H("Please select the unit this request is for.");if(!F.trim())return void H("Please add a short title.");if(!A.trim())return void H("Please describe the issue.");L(!0),H("");try{await (0,q.vhb)({unit_id:w,handyman_id:null==p?void 0:p.user_id,title:F.trim(),description:A.trim(),scheduled_date:S?new Date("".concat(S,"T10:00")).toISOString():void 0,images:I,payer:T}),V(!0),null==f||f()}catch(n){var t,s,a,l,r;let e=null==n||null==(s=n.response)||null==(t=s.data)?void 0:t.detail;H("string"==typeof e?e:null!=(r=null==n||null==(l=n.response)||null==(a=l.data)?void 0:a.message)?r:"Could not create the request. Please try again.")}finally{L(!1)}}return((0,l.useEffect)(()=>{(0,q.Sfq)({page:1,limit:50}).then(e=>{var t,s;let a=null!=(t=null==e?void 0:e.data)?t:[],l=new Set,r=[];for(let e of a)e.unit_id&&!l.has(e.unit_id)&&(l.add(e.unit_id),r.push({unit_id:e.unit_id,label:"".concat(null!=(s=e.property_name)?s:"Property").concat(e.unit_number?" \xb7 Unit ".concat(e.unit_number):"")}));j(r),1===r.length&&k(r[0].unit_id)}).catch(()=>j([])).finally(()=>N(!1))},[]),O)?(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-5 border-b border-gray-100 shrink-0",children:[(0,a.jsx)("button",{onClick:y,className:"p-1.5 hover:bg-gray-100 rounded-full transition-colors",children:(0,a.jsx)(r.A,{className:"w-4 h-4 text-gray-600"})}),(0,a.jsx)("h2",{className:"font-bold text-gray-900",children:"New Request"})]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6 space-y-4",children:[(0,a.jsx)("div",{className:"w-16 h-16 bg-sage-50 rounded-full flex items-center justify-center border border-sage-100",children:(0,a.jsx)(n.A,{className:"w-8 h-8 text-sage-600"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("h3",{className:"text-lg font-bold text-gray-900",children:"Request submitted"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1 max-w-xs",children:"A handyman will review your request and reach out to agree a price and schedule."})]}),(0,a.jsx)("button",{onClick:y,className:"px-5 py-2.5 bg-[#0052FF] hover:bg-[#0039B5] text-white text-sm font-semibold rounded-full transition-colors",children:"View my requests"})]})]}):(0,a.jsxs)("div",{className:"flex flex-col h-full",children:[(0,a.jsxs)("div",{className:"flex items-center gap-3 p-5 border-b border-gray-100 shrink-0",children:[(0,a.jsx)("button",{onClick:y,className:"p-1.5 hover:bg-gray-100 rounded-full transition-colors",children:(0,a.jsx)(r.A,{className:"w-4 h-4 text-gray-600"})}),(0,a.jsx)("h2",{className:"font-bold text-gray-900",children:"New Request"})]}),(0,a.jsxs)("form",{onSubmit:W,className:"flex-1 overflow-y-auto p-5 space-y-5",children:[p&&(0,a.jsxs)("div",{className:"flex items-center gap-3 bg-[#EBF1FF]/60 border border-[#CCE0FF] rounded-xl p-3",children:[(0,a.jsx)("div",{className:"w-9 h-9 bg-[#CCE0FF] rounded-full flex items-center justify-center text-[#0039B5] font-bold text-sm shrink-0",children:(null!=(h=null==(t=p.full_name)?void 0:t[0])?h:"?").toUpperCase()}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-widest text-[#0039B5]",children:"Requesting"}),(0,a.jsx)("p",{className:"text-sm font-semibold text-gray-900 truncate",children:p.full_name})]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-xs font-semibold text-gray-900 mb-1.5",children:["Unit ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),v?(0,a.jsxs)("div",{className:"flex items-center gap-2 text-gray-400 text-sm py-2",children:[(0,a.jsx)(i.A,{className:"w-4 h-4 animate-spin"})," Loading your units…"]}):0===b.length?(0,a.jsx)("p",{className:"text-sm text-gray-500 bg-gray-50 border border-gray-100 rounded-xl p-3",children:"You don't have any rented units yet. Maintenance requests are for units you rent through Resida."}):(0,a.jsxs)("select",{value:w,onChange:e=>k(e.target.value),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm text-gray-900 outline-none focus:border-[#0052FF] transition-colors",children:[(0,a.jsx)("option",{value:"",children:"Select a unit"}),b.map(e=>(0,a.jsx)("option",{value:e.unit_id,children:e.label},e.unit_id))]})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-xs font-semibold text-gray-900 mb-1.5",children:["Title ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("input",{type:"text",value:F,onChange:e=>_(e.target.value),maxLength:120,placeholder:"e.g. Leaking kitchen tap",className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm text-gray-900 placeholder-gray-400 outline-none focus:border-[#0052FF] transition-colors"})]}),(0,a.jsxs)("div",{children:[(0,a.jsxs)("label",{className:"block text-xs font-semibold text-gray-900 mb-1.5",children:["Describe the issue ",(0,a.jsx)("span",{className:"text-red-500",children:"*"})]}),(0,a.jsx)("textarea",{value:A,onChange:e=>C(e.target.value),rows:4,placeholder:"Tell the handyman what's wrong, where it is, and anything they should know…",className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm text-gray-900 placeholder-gray-400 outline-none focus:border-[#0052FF] transition-colors resize-none"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-semibold text-gray-900 mb-1.5",children:"Preferred date (optional)"}),(0,a.jsx)("input",{type:"date",value:S,min:new Date().toISOString().split("T")[0],onChange:e=>E(e.target.value),className:"w-full px-4 py-3 bg-gray-50 border border-gray-200 rounded-xl text-sm text-gray-900 outline-none focus:border-[#0052FF] transition-colors"})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-semibold text-gray-900 mb-1.5",children:"Who pays for this repair?"}),(0,a.jsx)("div",{className:"grid grid-cols-2 gap-2",children:[["TENANT","I'll pay"],["OWNER","Request landlord"]].map(e=>{let[t,s]=e;return(0,a.jsx)("button",{type:"button",onClick:()=>R(t),className:"py-2.5 rounded-xl border text-sm font-semibold transition-colors ".concat(T===t?"bg-[#0052FF] border-[#0052FF] text-white":"bg-white border-gray-200 text-gray-700 hover:border-gray-400"),children:s},t)})}),(0,a.jsx)("p",{className:"text-[11px] text-gray-400 mt-1.5",children:"OWNER"===T?"The landlord will be asked to approve the quoted price and pay from their wallet.":"The agreed price will be charged from your wallet once the job is resolved."})]}),(0,a.jsxs)("div",{children:[(0,a.jsx)("label",{className:"block text-xs font-semibold text-gray-900 mb-1.5",children:"Photos (optional)"}),(0,a.jsxs)("div",{className:"flex flex-wrap gap-2",children:[I.map((e,t)=>(0,a.jsxs)("div",{className:"relative w-16 h-16 rounded-lg overflow-hidden border border-gray-200",children:[(0,a.jsx)("img",{src:e,alt:"",className:"w-full h-full object-cover"}),(0,a.jsx)("button",{type:"button",onClick:()=>D(e=>e.filter((e,s)=>s!==t)),className:"absolute top-0.5 right-0.5 w-5 h-5 bg-black/30 rounded-full flex items-center justify-center",children:(0,a.jsx)(c.A,{className:"w-3 h-3 text-white"})})]},e)),I.length<5&&(0,a.jsxs)("label",{className:"w-16 h-16 rounded-lg border-2 border-dashed border-gray-200 flex items-center justify-center cursor-pointer hover:border-[#99C0FF] hover:bg-[#
1EBF1FF]/40 transition-colors",children:[M?(0,a.jsx)(i.A,{className:"w-4 h-4 text-gray-400 animate-spin"}):(0,a.jsx)(o,{className:"w-5 h-5 text-gray-300"}),(0,a.jsx)("input",{type:"file",accept:"image/*",multiple:!0,className:"hidden",onChange:z,disabled:M})]})]}),(0,a.jsx)("p",{className:"text-[11px] text-gray-400 mt-1.5",children:"Up to 5 photos of the issue — helps the handyman come prepared."})]}),U&&(0,a.jsxs)("div",{className:"flex items-start gap-2 bg-red-50 border border-red-100 rounded-xl p-3",children:[(0,a.jsx)(x.A,{className:"w-4 h-4 text-red-500 shrink-0 mt-0.5"}),(0,a.jsx)("p",{className:"text-sm text-red-700",children:U})]}),(0,a.jsxs)("button",{type:"submit",disabled:B||0===b.length,className:"w-full bg-[#0052FF] hover:bg-[#0039B5] text-white font-semibold py-3.5 rounded-xl transition-colors disabled:opacity-50 disabled:cursor-not-allowed flex items-center justify-center gap-2",children:[B?(0,a.jsx)(i.A,{className:"w-4 h-4 animate-spin"}):(0,a.jsx)(m.A,{className:"w-4 h-4"}),"Submit request"]})]})]})}function U(e){let{onNew:t}=e,[s,r]=(0,l.useState)([]),[c,d]=(0,l.useState)(!0),[o,x]=(0,l.useState)(null);function j(){(0,q.EqQ)({page:1,limit:50}).then(e=>{var t;return r(null!=(t=null==e?void 0:e.data)?t:[])}).catch(()=>r([])).finally(()=>d(!1))}async function v(e){x(e);try{await (0,q.Kb0)(e),j()}catch(e){}finally{x(null)}}return(0,l.useEffect)(()=>{j()},[]),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto",children:(0,a.jsxs)("div",{className:"p-5",children:[(0,a.jsxs)("button",{onClick:t,className:"w-full flex items-center justify-center gap-2 bg-[#0052FF] hover:bg-[#0039B5] text-white font-semibold py-3 rounded-xl transition-colors mb-4",children:[(0,a.jsx)(u.A,{className:"w-4 h-4"})," New maintenance request"]}),c?(0,a.jsxs)("div",{className:"flex flex-col items-center py-16 text-gray-400",children:[(0,a.jsx)(i.A,{className:"w-6 h-6 animate-spin mb-3"}),(0,a.jsx)("p",{className:"text-sm",children:"Loading…"})]}):0===s.length?(0,a.jsxs)("div",{className:"flex flex-col items-center py-16 text-center text-gray-400",children:[(0,a.jsx)("div",{className:"w-14 h-14 bg-[#F1F3F4] rounded-full flex items-center justify-center mb-3",children:(0,a.jsx)(m.A,{className:"w-7 h-7 text-gray-200"})}),(0,a.jsx)("p",{className:"text-sm font-semibold text-gray-700 mb-1",children:"No requests yet"}),(0,a.jsx)("p",{className:"text-xs text-gray-400",children:"Report a repair or maintenance issue for your unit."})]}):(0,a.jsx)("div",{className:"space-y-3",children:s.map(e=>{var t,s,l,r,c,d;let x="OWNER"===(null!=(l=e.payer)?l:"TENANT").toUpperCase(),m=e.agreed_price>0&&!e.price_accepted_at&&"RESOLVED"!==(null!=(r=e.status)?r:"").toUpperCase(),u=m&&!x;return(0,a.jsxs)("div",{className:"bg-white ring-1 ring-black/5 rounded-[28px] p-4",children:[(0,a.jsxs)("div",{className:"flex items-start justify-between gap-2",children:[(0,a.jsx)("p",{className:"text-sm font-bold text-gray-900",children:e.title}),(0,a.jsx)(B,{status:e.status})]}),(e.ai_category||e.ai_urgency||e.ai_safety_risk)&&(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-1.5 mt-1.5",children:[e.ai_category&&(0,a.jsx)("span",{className:"text-[10px] font-semibold px-2 py-0.5 bg-gray-100 text-gray-600 rounded-full",children:e.ai_category}),e.ai_urgency&&(0,a.jsx)("span",{className:"text-[10px] font-bold uppercase px-2 py-0.5 rounded-full ".concat(null!=(c=I[e.ai_urgency.toUpperCase()])?c:"bg-gray-100 text-gray-600"),children:e.ai_urgency}),e.ai_safety_risk&&(0,a.jsxs)("span",{className:"text-[10px] font-bold px-2 py-0.5 bg-rose-50 text-rose-700 rounded-full flex items-center gap-0.5",children:[(0,a.jsx)(h.A,{className:"w-2.5 h-2.5"}
1),"Safety"]})]}),e.description&&(0,a.jsx)("p",{className:"text-xs text-gray-500 mt-1.5 line-clamp-2",children:e.description}),(null==(t=e.images)?void 0:t.length)>0&&(0,a.jsx)("div",{className:"flex gap-1.5 mt-2 overflow-x-auto no-scrollbar",children:e.images.slice(0,5).map((e,t)=>(0,a.jsx)("img",{src:e,alt:"",className:"w-12 h-12 rounded-lg object-cover shrink-0 border border-gray-100"},t))}),(0,a.jsxs)("div",{className:"flex flex-wrap items-center gap-x-3 gap-y-1 mt-2 text-[11px] text-gray-400",children:[(e.property_name||e.unit_number)&&(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(p.A,{className:"w-3 h-3"}),[e.property_name,e.unit_number&&"Unit ".concat(e.unit_number)].filter(Boolean).join(" \xb7 ")]}),e.scheduled_date&&(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(g.A,{className:"w-3 h-3"}),(d=e.scheduled_date)?new Date(d).toLocaleDateString("en-NG",{day:"numeric",month:"short",year:"numeric"}):null]}),(0,a.jsxs)("span",{className:"flex items-center gap-1",children:[(0,a.jsx)(y.A,{className:"w-3 h-3"}),String(e.id).slice(0,8).toUpperCase()]}),(0,a.jsx)("span",{className:"px-1.5 py-0.5 rounded-full font-semibold ".concat(x?"bg-violet-50 text-violet-700":"bg-gray-100 text-gray-600"),children:x?"Landlord pays":"You pay"})]}),(e.handyman_name||e.agreed_price)&&(0,a.jsxs)("div",{className:"flex items-center justify-between mt-3 pt-3 border-t border-gray-100",children:[e.handyman_name?(0,a.jsxs)("div",{className:"flex items-center gap-2 min-w-0",children:[(0,a.jsx)("div",{className:"w-7 h-7 bg-[#CCE0FF] rounded-full flex items-center justify-center text-[#0039B5] font-bold text-[11px] shrink-0",children:null==(s=e.handyman_name[0])?void 0:s.toUpperCase()}),(0,a.jsxs)("div",{className:"min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-semibold text-gray-900 truncate",children:e.handyman_name}),e.handyman_rating>0&&(0,a.jsxs)("p",{className:"text-[10px] text-gray-400 flex items-center gap-0.5",children:[(0,a.jsx)(f.A,{className:"w-2.5 h-2.5 fill-clay-400 text-clay-400"}),Number(e.handyman_rating).toFixed(1)]})]})]}):(0,a.jsx)("span",{className:"text-[11px] text-gray-400",children:"Awaiting handyman"}),(0,a.jsxs)("div",{className:"flex items-center gap-2 shrink-0",children:[e.agreed_price>0&&(0,a.jsxs)("span",{className:"text-xs font-bold text-gray-900",children:[D(e.agreed_price),e.price_accepted_at&&(0,a.jsx)("span",{className:"text-[10px] text-sage-600 ml-1",children:"accepted"})]}),e.handyman_phone&&(0,a.jsx)("a",{href:"tel:".concat(e.handyman_phone),className:"w-7 h-7 bg-sage-50 hover:bg-sage-100 rounded-full flex items-center justify-center transition-colors",children:(0,a.jsx)(b.A,{className:"w-3.5 h-3.5 text-sage-600"})})]})]}),u&&(0,a.jsxs)("div",{className:"mt-3 bg-clay-50/70 border border-clay-100 rounded-xl p-3",children:[(0,a.jsxs)("p",{className:"text-[11px] text-clay-800 mb-2",children:["The handyman quoted ",(0,a.jsx)("strong",{children:D(e.agreed_price)})," for this job. It will be charged from your wallet once the job is marked resolved."]}),(0,a.jsxs)("button",{onClick:()=>v(e.id),disabled:o===e.id,className:"w-full flex items-center justify-center gap-1.5 bg-[#0052FF] hover:bg-[#0039B5] text-white text-xs font-semibold py-2 rounded-lg transition-colors disabled:opacity-50",children:[o===e.id?(0,a.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,a.jsx)(n.A,{className:"w-3.5 h-3.5"}),"Accept ",D(e.agreed_price)]})]}),m&&x&&(0,a.jsx)("div",{className:"mt-3 bg-violet-50/70 border border-violet-100 rounded-xl p-3",children:(0,a.jsxs)("p",{className:"text-[11px] text-violet-800",children:["The handyman quoted ",(0,a.jsx)("strong",{children:D(e.agreed_price)}),". Waiting for the landlord to approve and cover the cost."]})})]},e.id)})})]})})}function H(){let[e,t]=(0,l.useState)(!1),[s,r]=(0,l.useState)(""),[n,c]=(0,l.useState)(!1),[d,o]=(0,l.useState)(!1),[x,m]=(0,l.useState)(""),u=async e=>{if(e.preventDefault(),s.trim()){c(!0),m("");try{await (0,q.uoc)({referred_email:s.trim(),referral_type:"handyman"}),o(!0),r(""),setTimeout(()=>o(!1),4e3)}catch(e){var t,a;m((null==e||null==(a=e.response)||null==(t=a.data)?void 0:t.detail)||"Could not send the invite. Please try again.")}finally{c(!1)}}};return(0,a.jsxs)("div",{className:"mt-4 bg-gray-50 rounded-[28px] ring-1 ring-black/5 overflow-hidden",children:[(0,a.jsxs)("button",{type:"button",onClick:()=>t(e=>!e),className:"w-full flex items-center gap-3 px-4 py-3 text-left",children:[(0,a.jsx)("div",{className:"w-8 h-8 bg-[#EBF1FF] rounded-xl flex items-center justify-center shrink-0",children:(0,a.jsx)(j,{className:"w-4 h-4 text-[#0052FF]"})}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsx)("p",{className:"text-xs font-bold text-gray-900",children:"Can't find your trusted technician?"}),(0,a.jsx)("p",{className:"text-[10px] text-gray-500",children:"Invite them to Re
1sida — earn a wallet reward on their first job."})]}),(0,a.jsx)(v.A,{className:"w-4 h-4 text-gray-400 shrink-0 transition-transform ".concat(e?"rotate-90":"")})]}),e&&(0,a.jsxs)("form",{onSubmit:u,className:"px-4 pb-4 flex items-center gap-2",children:[(0,a.jsx)("input",{type:"email",required:!0,placeholder:"[email protected]",value:s,onChange:e=>r(e.target.value),className:"flex-1 border border-gray-200 rounded-xl px-3 py-2.5 text-xs outline-none focus:border-[#0052FF] bg-white"}),(0,a.jsxs)("button",{type:"submit",disabled:n||d,className:"shrink-0 flex items-center gap-1.5 bg-gray-900 text-white text-xs font-semibold px-4 py-2.5 rounded-xl hover:opacity-90 transition-opacity disabled:opacity-60",children:[n?(0,a.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"}):d?(0,a.jsx)(N.A,{className:"w-3.5 h-3.5 text-sage-400"}):null,d?"Invited!":"Invite"]})]}),e&&x&&(0,a.jsx)("p",{className:"px-4 pb-3 text-[10px] text-rose-600",children:x})]})}function O(e){var t,s,l,r;let{h:c,preferred:d,onTogglePreferred:o,onRequest:x,toggling:u}=e,h=d.has(String(c.user_id));return(0,a.jsxs)("div",{className:"border rounded-2xl p-4 transition-colors ".concat(h?"border-[#CCE0FF] bg-[#EBF1FF]/30":"border-gray-100"),children:[(0,a.jsxs)("div",{className:"flex items-start gap-3",children:[(0,a.jsx)("div",{className:"w-11 h-11 rounded-full bg-[#CCE0FF] flex items-center justify-center text-[#0039B5] font-bold shrink-0 overflow-hidden",children:c.profile_image_url?(0,a.jsx)("img",{src:c.profile_image_url,alt:c.full_name,className:"w-full h-full object-cover"}):(null!=(l=null==(t=c.full_name)?void 0:t[0])?l:"?").toUpperCase()}),(0,a.jsxs)("div",{className:"flex-1 min-w-0",children:[(0,a.jsxs)("div",{className:"flex items-center gap-1.5",children:[(0,a.jsx)("p",{className:"text-sm font-bold text-gray-900 truncate",children:null!=(r=c.full_name)?r:"Handyman"}),c.id_verified&&(0,a.jsx)(n.A,{className:"w-3.5 h-3.5 text-[#0052FF]/80 shrink-0"}),h&&(0,a.jsx)("span",{className:"shrink-0 text-[9px] font-bold px-1.5 py-px rounded-full bg-[#CCE0FF] text-[#0039B5]",children:"Preferred"})]}),(0,a.jsxs)("div",{className:"flex items-center gap-2 text-[11px] text-gray-400 mt-0.5",children:[c.rating>0&&(0,a.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(f.A,{className:"w-3 h-3 fill-clay-400 text-clay-400"}),Number(c.rating).toFixed(1)]}),c.completed_jobs>0&&(0,a.jsxs)("span",{children:[c.completed_jobs," job",1!==c.completed_jobs?"s":""]}),c.location&&(0,a.jsxs)("span",{className:"flex items-center gap-0.5",children:[(0,a.jsx)(p.A,{className:"w-3 h-3"}),c.location]})]})]}),(0,a.jsxs)("div",{className:"flex flex-col items-end gap-1 shrink-0",children:[c.base_charge>0&&(0,a.jsxs)("div",{className:"text-right",children:[(0,a.jsx)("p",{className:"text-sm font-bold text-gray-900",children:D(c.base_charge)}),(0,a.jsx)("p",{className:"text-[10px] text-gray-400",children:"base"})]}),(0,a.jsx)("button",{onClick:()=>o(c),disabled:u===String(c.user_id),className:"p-1.5 rounded-full transition-colors disabled:opacity-50 ".concat(h?"text-[#0052FF] hover:bg-[#CCE0FF]":"text-gray-300 hover:text-[#0052FF]/80 hover:bg-[#CCE0FF]/40"),title:h?"Remove from preferred":"Add to preferred",children:u===String(c.user_id)?(0,a.jsx)(i.A,{className:"w-4 h-4 animate-spin"}):(0,a.jsx)(w,{className:"w-4 h-4 ".concat(h?"fill-blue-600":"")})})]})]}),(null==(s=c.skills)?void 0:s.length)>0&&(0,a.jsx)("div",{className:"flex flex-wrap gap-1 mt-2.5",children:c.skills.slice(0,4).map(e=>(0,a.jsx)("span",{className:"text-[10px] font-medium px-2 py-0.5 bg-gray-100 text-gray-600 rounded-full",children:e},e))}),(0,a.jsxs)("button",{onClick:()=>x(c),className:"w-full mt-3 flex items-center justify-center gap-1.5 border border-[#CCE0FF] bg-[#EBF1FF] hover:bg-[#CCE0FF] text-[#0039B5] text-xs font-semibold py-2 rounded-lg transition-colors",children:[(0,a.jsx)(m.A,{className:"w-3.5 h-3.5"})," Request this handyman ",(0,a.jsx)(v.A,{className:"w-3.5 h-3.5"})]})]})}function V(e){let{onRequest:t}=e,[s,r]=(0,l.useState)([]),[n,c]=(0,l.useState)(!0),[d,o]=(0,l.useState)(""),[x,m]=(0,l.useState)(""),[u,h]=(0,l.useState)(new Set),[p,g]=(0,l.useState)(null);async function y(e){let t=String(e.user_id);g(t);try{u.has(t)?(await (0,q.ijo)(t),h(e=>{let s=new Set(e);return s.delete(t),s})):(await (0,q.XxU)(t),h(e=>new Set([...e,t])))}catch(e){}finally{g(null)}}(0,l.useEffect)(()=>{(0,q.iwy)().then(e=>{var t;return h(new Set((null!=(t=null==e?void 0:e.data)?t:[]).map(e=>String(e.user_id))))}).catch(()=>{})},[]),(0,l.useEffect)(()=>{c(!0);let e=setTimeout(()=>{(0,q.ZAf)({search:d||void 0,skill:x||void 0,is_available:!0,page:1,limit:30}).then(e=>{var t;return r(null!=(t=null==e?void 0:e.data)?t:[])}).catch(()=>r([])).finally(()=>c(!1))},300);return()=>clearTimeout(e)},[d,x]);let f=s.filter(e=>u.has(String(e.user_id))),b=s.filter(e=>!u.has(String(e.user_id)));return(0,a.jsxs)("div",{className:"flex-1 overflow-y-auto flex flex-col",children:[(0,a.jsxs)("div",{className:"p-5 pb-3 shrink-0 space-y-3",children:[(0,a.jsxs)("div",{className:"relative",children:[(0,a.jsx)(k.A,{className:"absolute left-3 top-1/2 -translate-y-1/2 w-4 h-4 text-gray-400"}),(0,a.jsx)("input",{value:d,onChange:e=>o(e.target.value),placeholder:"Search by name…",className:"w-full pl-9 pr-4 py-2.5 bg-gray-50 border border-gray-200 rounded-xl text-sm outline-none focus:border-[#0052FF] transition-colors"})]}),(0,a.jsxs)("div",{className:"flex gap-1.5 overflow-x-auto no-scrollbar -mx-1 px-1",children:[(0,a.jsx)("button",{onClick:()=>m(""),className:"shrink-0 px-3 py-1.5 rounded-full text-xs font-semibold border transition-colors ".concat(""===x?"bg-[#0052FF] border-[#0052FF] text-white":"bg-white border-gray-200 text-gray-600 hover:border-gray-300"),children:"All"}),P.map(e=>(0,a.jsx)("button",{onClick:()=>m(x===e?"":e),className:"shrink-0 px-3 py-1.5 rounded-full text-xs font-semibold border transition-colors ".concat(x===e?"bg-[#0052FF] border-[#0052FF] text-white":"bg-white border-gray-200 text-gray-600 hover:border-gray-300"),children:e},e))]})]}),(0,a.jsxs)("div",{className:"px-5 pb-5 space-y-5",children:[n?(0,a.jsxs)("div",{className:"flex flex-col items-center py-16 text-gray-400",children:[(0,a.jsx)(i.A,{className:"w-6 h-6 animate-spin mb
1-3"}),(0,a.jsx)("p",{className:"text-sm",children:"Loading…"})]}):0===s.length?(0,a.jsxs)("div",{className:"flex flex-col items-center py-16 text-center text-gray-400",children:[(0,a.jsx)("div",{className:"w-14 h-14 bg-[#F1F3F4] rounded-full flex items-center justify-center mb-3",children:(0,a.jsx)(F.A,{className:"w-7 h-7 text-gray-200"})}),(0,a.jsx)("p",{className:"text-sm font-semibold text-gray-700 mb-1",children:"No handymen found"}),(0,a.jsx)("p",{className:"text-xs text-gray-400",children:"Try a different skill or search term."})]}):(0,a.jsxs)(a.Fragment,{children:[f.length>0&&(0,a.jsxs)("div",{children:[(0,a.jsxs)("p",{className:"text-[10px] font-bold uppercase tracking-widest text-[#0052FF] mb-2 flex items-center gap-1.5",children:[(0,a.jsx)(w,{className:"w-3 h-3 fill-blue-600"})," Your Preferred"]}),(0,a.jsx)("div",{className:"space-y-3",children:f.map(e=>(0,a.jsx)(O,{h:e,preferred:u,onTogglePreferred:y,onRequest:t,toggling:p},e.id))})]}),b.length>0&&(0,a.jsxs)("div",{children:[f.length>0&&(0,a.jsx)("p",{className:"text-[10px] font-bold uppercase tracking-widest text-gray-400 mb-2",children:"All Handymen"}),(0,a.jsx)("div",{className:"space-y-3",children:b.map(e=>(0,a.jsx)(O,{h:e,preferred:u,onTogglePreferred:y,onRequest:t,toggling:p},e.id))})]})]}),(0,a.jsx)(H,{})]})]})}let z=["My tap is leaking","There's no power in my flat","The AC is not cooling","Toilet is blocked","There's a crack in the ceiling","Door lock is broken"];function W(e){let{onDispatch:t}=e,[s,r]=(0,l.useState)([]),[n,c]=(0,l.useState)([]),[d,o]=(0,l.useState)(""),[x,m]=(0,l.useState)(""),[u,h]=(0,l.useState)(!1),[p,g]=(0,l.useState)([]),[y,f]=(0,l.useState)(""),b=(0,l.useRef)(null),j=(0,l.useRef)(null);(0,l.useEffect)(()=>{var e;null==(e=b.current)||e.scrollIntoView({behavior:"smooth"})},[s,u]),(0,l.useEffect)(()=>{(0,q.Sfq)({page:1,limit:50}).then(e=>{var t,s;let a=null!=(t=null==e?void 0:e.data)?t:[],l=new Set,r=[];for(let e of a)e.unit_id&&!l.has(e.unit_id)&&(l.add(e.unit_id),r.push({unit_id:e.unit_id,label:"".concat(null!=(s=e.property_name)?s:"Property").concat(e.unit_number?" \xb7 Unit ".concat(e.unit_number):"")}));g(r),1===r.length&&f(r[0].unit_id)}).catch(()=>{})},[]);let v=async e=>{var s,a,l,i,p;let g=(null!=e?e:d).trim();if(!g||u)return;o("");let f=x||g;x||m(g);let b=[...n,{role:"user",content:g}];c(b),r(e=>[...e,{role:"user",content:g,id:Date.now()}]),h(!0);try{let e=await (0,q.Itd)({issue:f,history:n,unit_id:y||void 0}),s=null!=(a=null==e?void 0:e.data)?a:e,d=null!=(l=null==s?void 0:s.action)?l:"dispatch",o=null!=(i=null==s?void 0:s.message)?i:"I'll log this for a technician.",x=null!=(p=null==s?void 0:s.steps)?p:[],m=o;"self_fix"===d&&x.length&&(m=o+"\n\n"+x.map((e,t)=>"".concat(t+1,". ").concat(e)).join("\n"));let u=[...b,{role:"assistant",content:o}];c(u),r(e=>[...e,{role:"assistant",content:m,id:Date.now()+1,action:d}]),"dispatch"===d&&setTimeout(()=>{var e;null==t||t({prefill:{title:(null==s||null==(e=s.classification)?void 0:e.summary)||f,desc:f,unitId:y||void 0},handymanId:null==s?void 0:s.suggested_handyman_id})},1200)}catch(e){r(e=>[...e,{role:"assistant",content:"Sorry, I'm having trouble right now. Please try again.",id:Date.now()+1,error:!0}])}h(!1),null==(s=j.current)||s.focus()},N=0===s.length;return(0,a.jsxs)("div",{className:"flex-1 flex flex-col overflow-hidden",children:[p.length>1&&(0,a.jsx)("div",{className:"px-5 pt-3 shrink-0",children:(0,a.jsxs)("select",{value:y,onChange:e=>f(e.target.value),className:"w-full px-3 py-2 bg-gray-50 border border-gray-200 rounded-xl text-xs text-gray-700 outline-none focus:border-[#0052FF] transition-colors",children:[(0,a.jsx)("option",{value:"",children:"Select a unit (optional)"}),p.map(e=>(0,a.jsx)("option",{value:e.unit_id,children:e.label},e.unit_id))]})}),(0,a.jsx)("div",{className:"flex-1 overflow-y-auto px-4 py-4",children:N?(0,a.jsxs)("div",{className:"flex flex-col items-center text-center gap-5 pt-6",children:[(0,a.jsx)("div",{className:"w-14 h-14 rounded-2xl bg-gradient-to-br from-violet-500 to-blue-600 flex items-center justify-center shadow-lg",children:(0,a.jsx)(_.A,{className:"w-7 h-7 text-white"})}),(0,a.jsxs)("div",{children:[(0,a.jsx)("p",{className:"text-base font-bold text-gray-900",children:"AI Maintenance Assistant"}),(0,a.jsx)("p",{className:"text-sm text-gray-500 mt-1 max-w-[260px] leading-relaxed",children:"Describe your issue. I'll try to help you fix it — or log a work order and assign a technician automatically."})]}),(0,a.jsx)("div",{className:"w-full space-y-2",children:z.map(e=>(0,a.jsx)("button",{onClick:()=>v(e),className:"w-full text-left text-xs font-medium text-gray-700 bg-gray-50 hover:bg-gray-100 border border-gray-200 rounded-xl px-4 py-2.5 transition-colors",children:e},e))})]}):(0,a.jsxs)("div",{className:"space-y-3",children:[s.map(e=>(0,a.jsxs)("div",{className:"flex ".concat("user"===e.role?"justify-end":"justify-start"),children:["assistant"===e.role&&(0,a.jsx)("div",{className:"w-6 h-6 rounded-full bg-gradient-to-br from-violet-500 to-blue-600 flex items-center justify-center shrink-0 mr-2 mt-1",children:(0,a.jsx)(_.A,{className:"w-3 h-3 text-white"})}),(0,a.jsxs)("div",{className:"max-w-[82%] px-3.5 py-2.5 rounded-2xl text-sm leading-relaxed ".concat("user"===e.role?"bg-[#0052FF] text-white rounded-br-sm":e.error?"bg-rose-50 text-rose-700 rounded-bl-sm border border-rose-100":"dispatch"===e.action?"bg-vi
1olet-50 text-violet-900 rounded-bl-sm border border-violet-100":"bg-gray-100 text-gray-900 rounded-bl-sm"),children:[(0,a.jsx)("span",{className:"whitespace-pre-wrap",children:e.content}),"dispatch"===e.action&&(0,a.jsx)("p",{className:"text-[10px] text-violet-500 mt-1.5 font-semibold",children:"Opening request form…"})]})]},e.id)),u&&(0,a.jsxs)("div",{className:"flex justify-start",children:[(0,a.jsx)("div",{className:"w-6 h-6 rounded-full bg-gradient-to-br from-violet-500 to-blue-600 flex items-center justify-center shrink-0 mr-2 mt-1",children:(0,a.jsx)(_.A,{className:"w-3 h-3 text-white"})}),(0,a.jsxs)("div",{className:"bg-gray-100 rounded-2xl rounded-bl-sm px-4 py-3 flex items-center gap-1.5",children:[(0,a.jsx)("span",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full animate-bounce [animation-delay:0ms]"}),(0,a.jsx)("span",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full animate-bounce [animation-delay:150ms]"}),(0,a.jsx)("span",{className:"w-1.5 h-1.5 bg-gray-400 rounded-full animate-bounce [animation-delay:300ms]"})]})]}),(0,a.jsx)("div",{ref:b})]})}),(0,a.jsxs)("div",{className:"px-4 py-3 border-t border-gray-100 shrink-0",children:[!N&&(0,a.jsxs)("button",{onClick:()=>{r([]),c([]),m("")},className:"flex items-center gap-1 text-[10px] text-gray-400 hover:text-gray-600 mb-2 transition-colors",children:[(0,a.jsx)(A.A,{className:"w-3 h-3"})," Start over"]}),(0,a.jsxs)("div",{className:"flex items-end gap-2 bg-gray-50 rounded-2xl px-3 py-2",children:[(0,a.jsx)("textarea",{ref:j,rows:1,value:d,onChange:e=>o(e.target.value),onKeyDown:e=>{"Enter"!==e.key||e.shiftKey||(e.preventDefault(),v())},placeholder:"Describe the issue…",className:"flex-1 bg-transparent text-sm text-gray-900 placeholder-gray-400 outline-none resize-none max-h-24"}),(0,a.jsx)("button",{onClick:()=>v(),disabled:!d.trim()||u,className:"w-8 h-8 rounded-full bg-violet-600 hover:bg-violet-700 disabled:opacity-40 text-white flex items-center justify-center shrink-0 transition-colors",children:u?(0,a.jsx)(i.A,{className:"w-3.5 h-3.5 animate-spin"}):(0,a.jsx)(C.A,{className:"w-3.5 h-3.5"})})]}),(0,a.jsx)("p",{className:"text-[10px] text-gray-400 text-center mt-2",children:"AI may make mistakes. A technician will review the work order."})]})]})}function K(e){let{open:t,onClose:s}=e;(0,T.K)(t);let{isAuthenticated:r}=(0,E.useAuthStore)(),[n,i]=(0,l.useState)("triage"),[c,d]=(0,l.useState)(null);return((0,l.useEffect)(()=>{t||(i("triage"),d(null))},[t]),t)?(0,a.jsxs)("div",{className:"fixed inset-0 z-[90] flex",children:[(0,a.jsx)("div",{className:"absolute inset-0 bg-black/30",onClick:s}),(0,a.jsx)("div",{className:"relative ml-auto w-full max-w-lg bg-[#F0F4F9] h-full flex flex-col gw-panel-right",children:r?c?(0,a.jsx)(L,{presetHandyman:c.presetHandyman,prefill:c.prefill,onBack:()=>{d(null),i("triage")},onCreated:()=>{}}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"shrink-0 border-b border-gray-100",children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-5 pb-3",children:[(0,a.jsx)("h2",{className:"font-bold text-gray-900",children:"Maintenance"}),(0,a.jsx)("button",{onClick:s,className:"p-2 hover:bg-gray-100 rounded-full transition-colors",children:(0,a.jsx)(S.A,{className:"w-4 h-4 text-gray-500"})})]}),(0,a.jsx)("div",{className:"flex px-5 gap-1",children:[["triage","✦ AI Triage"],["requests","My Requests"],["directory","Directory"]].map(e=>{let[t,s]=e;return(0,a.jsx)("button",{onClick:()=>i(t),className:"px-3 py-2.5 text-sm font-semibold border-b-2 -mb-px transition-colors ".concat(n===t?"border-violet-600 text-violet-600":"border-transparent text-gray-500 hover:text-gray-700"),children:s},t)})})]}),"triage"===n?(0,a.jsx)(W,{onDispatch:e=>{let{prefill:t,handymanId:s}=e;d({presetHandyman:null,prefill:t,handymanId:s})}}):"requests"===n?(0,a.jsx)(U,{onNew:()=>d({presetHandyman:null})}):(0,a.jsx)(V,{onRequest:e=>d({presetHandyman:e})})]}):(0,a.jsxs)(a.Fragment,{children:[(0,a.jsxs)("div",{className:"flex items-center justify-between p-5 border-b border-gray-100 shrink-0",children:[(0,a.jsx)("h2",{className:"font-bold text-gray-900",children:"Maintenance"}),(0,a.jsx)("button",{onClick:s,className:"p-2 hover:bg-gray-100 rounded-full transition-colors",children:(0,a.jsx)(S.A,{className:"w-4 h-4 text-gray-500"})})]}),(0,a.jsxs)("div",{className:"flex-1 flex flex-col items-center justify-center text-center px-6 text-gray-400",children:[(0,a.jsx)(m.A,{className:"w-10 h-10 text-gray-200 mb-3"}),(0,a.jsx)("p",{className:"text-sm font-semibold text-gray-700",children:"Sign in to manage maintenance"}),(0,a.jsx)("p",{className:"text-xs text-gray-400 mt-1",children:"Report repairs and browse verified handymen."})]})]})})]}):null}},52056:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(71847).A)("TriangleAlert",[["path",{d:"m21.73 18-8-14a2 2 0 0 0-3.48 0l-8 14A2 2 0 0 0 4 21h16a2 2 0 0 0 1.73-3",key:"wmoenq"}],["path",{d:"M12 9v4",key:"juzpu7"}],["path",{d:"M12 17h.01",key:"p32p05"}]])},71360:(e,t,s)=>{s.d(t,{A:()=>a});
1let a=(0,s(71847).A)("Trash2",[["path",{d:"M3 6h18",key:"d0wm0j"}],["path",{d:"M19 6v14c0 1-1 2-2 2H7c-1 0-2-1-2-2V6",key:"4alrt4"}],["path",{d:"M8 6V4c0-1 1-2 2-2h4c1 0 2 1 2 2v2",key:"v07s0e"}],["line",{x1:"10",x2:"10",y1:"11",y2:"17",key:"1uufr5"}],["line",{x1:"14",x2:"14",y1:"11",y2:"17",key:"xtxkd"}]])},89559:(e,t,s)=>{s.d(t,{A:()=>a});let a=(0,s(71847).A)("RefreshCw",[["path",{d:"M3 12a9 9 0 0 1 9-9 9.75 9.75 0 0 1 6.74 2.74L21 8",key:"v9h5vc"}],["path",{d:"M21 3v5h-5",key:"1q7to0"}],["path",{d:"M21 12a9 9 0 0 1-9 9 9.75 9.75 0 0 1-6.74-2.74L3 16",key:"3uifl3"}],["path",{d:"M8 16H3v5",key:"1cv678"}]])}}]);

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.