1import{j as e,r as D}from"./react-Bwt1xbxH.js";import{e as ve,L as I}from"./router-BNQw1M6O.js";import{a as ye}from"./useTenantApplications-ChYScKI_.js";import{C as j,a as S,b as k,c as f}from"./card-BRwga5uZ.js";import{B as L}from"./badge-sYAW1rF8.js";import{v as we,t as ee,D as xe,j as pe,k as he,l as ge,L as w,I as A,S as be,n as Ce,o as Se,p as ke,q as Ae,r as je,B as p,d as se,s as R,u as q,U as De,b as ne,a as fe,Q as Fe,V as Re,ah as Me,W as Ee,Y as Le,_ as Te,$ as qe,a0 as $e,a1 as Ie,a2 as Pe}from"./index-npYIF1Cu.js";import{S as W}from"./separator-CSCjbKjn.js";import{T as Ve,a as Ge,b as P,c as V}from"./tabs-BQYiXrXS.js";import{V as Oe,C as Be,b as Ue,O as ze,A as He}from"./CandidateAvailabilitySection-DMYonzRn.js";import{P as We}from"./progress-BHcrQScn.js";import{a as Je,c as Qe}from"./useApplications-C8vynHch.js";import{T as Ke}from"./target-l_Cq94Md.js";import{S as Xe}from"./star-l9bIqRyd.js";import{T as Y}from"./triangle-alert-h178_mHH.js";import{C as G}from"./circle-x-CIbeTxuC.js";import{C as Z}from"./circle-check-big-DJJQcaJP.js";import{T as Ye}from"./trending-up-CUWmCSRG.js";import"./scroll-area-D2MniAOt.js";import"./alert-DijtL8hC.js";import"./useEntityScope-CcGZG0YN.js";import"./EdlPdfGenerator-B8Yp7qkt.js";import"./switch-Bmt8G_nu.js";import"./jspdf-Bi_e3ESl.js";import"./EdlPreview-D6v7hTt1.js";import"./radio-group-C_gDYn6h.js";import{E as Ze}from"./EditCohabitantDialog-C_Rkc_wo.js";import{A as es}from"./arrow-left-DT35dPxo.js";import{B as ie}from"./building-2-Dn9H_Pz_.js";import{M as ss}from"./map-pin-BdQZNC2_.js";import{C as le}from"./clipboard-check-WiTj5Yt4.js";import{M as J}from"./message-square-DhmiklD2.js";import{U as Q}from"./user-Cl1aWP8N.js";import{E as ts}from"./euro-Dsa4ooPx.js";import{R as as}from"./ruler-BXMVQw9p.js";import{P as B}from"./pencil-BPy3aBfH.js";import{F as T}from"./file-text-5SCb-fAv.js";import{S as ce}from"./shield-check-DnLmvI_u.js";import{U as rs}from"./users-Bb-GG5bK.js";import{S as ns}from"./shield-DBcSbGqI.js";import{C as is}from"./calendar-Cum5cp15.js";import{E as ls}from"./eye-DY08Rkyz.js";import{T as cs}from"./trash-2-zDbTado7.js";import{f as de}from"./format-C8mPAXtC.js";import{f as oe}from"./fr-CVavktiw.js";import"./vendor-Cpj98o6Y.js";import"./useAdminViewMode-XzGjeUa8.js";import"./radix-i14q2oaY.js";import"./charts-BnGLdBFA.js";import"./plus-9Ubnrunu.js";import"./square-pen-a5Pg65Bg.js";import"./file-pen-line-C57KjvmK.js";import"./clipboard-list-BW9bPRoK.js";import"./user-check-DNjBNjf6.js";import"./slider-CxzVRd-V.js";import"./phone-DAlqf0HB.js";import"./calendar-clock-BVOxZmWf.js";import"./circle-alert-BGsHJ5cg.js";import"./send-08w7E-fS.js";import"./popover-BXemYjVA.js";import"./calendar-CKYnhXkt.js";import"./isSameDay-B5gaE2OA.js";import"./subDays-Bn-ISHJm.js";import"./addDays-DyhBVSPb.js";import"./startOfMonth-DJU6uKMb.js";import"./endOfMonth-DAPjuT7b.js";import"./differenceInCalendarMonths-CjogcJf2.js";import"./isSameMonth-BkiYgLmn.js";import"./endOfWeek-jrpt-7gU.js";import"./addYears-Ci1XJDYG.js";import"./chevron-left-BHZB_2Iz.js";import"./chevron-right-BkaZ9219.js";import"./calendar-check-DGvO5UzV.js";import"./parseISO-DO1riErf.js";import"./heic-ikFk6IhD.js";import"./jimoLetter-Deyg6FjC.js";import"./pdfjs-BJOR6ZAE.js";import"./refresh-cw-BQGolS8S.js";import"./circle-EfUJypic.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 ds=we("BedDouble",[["path",{d:"M2 20v-8a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v8",key:"1k78r4"}],["path",{d:"M4 10V6a2 2 0 0 1 2-2h12a2 2 0 0 1 2 2v4",key:"fb3tl2"}],["path",{d:"M12 4v6",key:"1dcgq2"}],["path",{d:"M2 18h20",key:"ajqnye"}]]);function os({scoreResult:o,monthlyRent:t,totalIncome:u=0,hasGuarantor:N=!1}){const{score:d,tier:v,reasons:m,breakdown:h}=o,n=Je(v),g=l=>l>=80?"text-green-600":l>=60?"text-yellow-600":l>=40?"text-orange-500":"text-red-500",r=(l=>l>=80?5:l>=60?4:l>=40?3:l>=20?2:1)(d),c=g(d),a=u>0?Math.floor(u*.33):0,x=u>0?Math.floor(u*.4):0,y=m.filter(l=>l.positive),M=m.filter(l=>!l.positive),z=[{label:"Revenus",value:h.income_ratio,max:35},{label:"Emploi",value:h.employment,max:25},{label:"Documents",value:h.documents,max:25},{label:"Garant",value:h.guarantor,max:15}];return e.jsxs("div",{className:"space-y-6",children:[e.jsxs(j,{className:"bg-gradient-to-br from-primary/5 to-primary/10 border-primary/20",children:[e.jsx(S,{className:"pb-2",children:e.jsxs(k,{className:"flex items-center gap-2 text-lg",children:[e.jsx(Ke,{className:"w-5 h-5 text-primary"}),"Score Hello JIMO détaillé"]})}),e.jsxs(f,{children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"flex items-center gap-1 mb-1",children:Array.from({length:5}).map((l,F)=>e.jsx(Xe,{className:`w-5 h-5 ${F<r?`${c}
6 fill-current`:"text-muted-foreground/30"}`},F))}),e.jsx("p",{className:`text-4xl font-bold ${c}`,children:d}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"/ 100"})]}),e.jsxs("div",{className:"flex-1 space-y-2",children:[e.jsxs("div",{className:"flex justify-between text-sm",children:[e.jsxs(L,{variant:"outline",className:`${n.badgeClass}`,children:[e.jsx("span",{className:"mr-1",children:n.icon}),n.label]}),e.jsxs("span",{className:"text-muted-foreground",children:[d,"%"]})]}),e.jsx(We,{value:d,className:`h-3 ${d>=70?"[&>div]:bg-green-500":d>=50?"[&>div]:bg-yellow-500":"[&>div]:bg-red-500"}`})]})]}),e.jsx("div",{className:"mt-4 grid grid-cols-2 sm:grid-cols-4 gap-2 text-xs",children:z.map(l=>e.jsxs("div",{className:"text-center p-2 bg-background/50 rounded-lg",children:[e.jsxs("p",{className:"font-semibold",children:[l.value,"/",l.max]}),e.jsx("p",{className:"text-muted-foreground",children:l.label})]},l.label))})]})]}),M.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-4 flex items-center gap-2 text-red-700",children:[e.jsx(Y,{className:"w-5 h-5"}),"Points de vigilance (",M.length,")"]}),e.jsx("div",{className:"space-y-3",children:M.map((l,F)=>{const _=l.label.includes("insuffisant")||l.label.includes("non renseigné")||l.label.includes("Aucun")||l.label.includes("Pas de");return e.jsxs("div",{className:`border rounded-lg p-4 flex items-start gap-3 ${_?"border-red-200 bg-red-50":"border-yellow-200 bg-yellow-50"}`,children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:_?e.jsx(G,{className:"w-5 h-5 text-red-600"}):e.jsx(Y,{className:"w-5 h-5 text-yellow-600"})}),e.jsx("p",{className:`text-sm font-medium ${_?"text-red-800":"text-yellow-800"}`,children:l.label})]},F)})})]}),y.length>0&&e.jsxs("div",{children:[e.jsxs("h3",{className:"font-semibold mb-4 flex items-center gap-2 text-green-700",children:[e.jsx(Z,{className:"w-5 h-5"}),"Points forts (",y.length,")"]}),e.jsx("div",{className:"space-y-3",children:y.map((l,F)=>e.jsxs("div",{className:"border rounded-lg p-4 flex items-start gap-3 border-green-200 bg-green-50",children:[e.jsx("div",{className:"shrink-0 mt-0.5",children:e.jsx(Z,{className:"w-5 h-5 text-green-600"})}),e.jsx("p",{className:"text-sm font-medium text-green-800",children:l.label})]},F))})]}),u>0&&e.jsx(j,{className:"bg-secondary/50 border-muted",children:e.jsx(f,{className:"p-4",children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(Ye,{className:"w-5 h-5 text-primary shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-foreground",children:"Loyer cible recommandé"}),e.jsxs("p",{className:"text-sm text-muted-foreground mt-1",children:["Avec des revenus de ",e.jsxs("strong",{children:[u.toLocaleString("fr-FR")," â¬/mois"]}),", le loyer max recommandé est de ",e.jsxs("strong",{children:[a.toLocaleString("fr-FR")," â¬"]}),N&&e.jsxs(e.Fragment,{children:[" (ou jusqu'à ",e.jsxs("strong",{children:[x.toLocaleString("fr-FR")," â¬"]})," avec garant)"]}),".",t&&e.jsxs("span",{className:t<=a?" text-green-700":" text-red-700",children:[" ","Loyer actuel : ",t.toLocaleString("fr-FR")," â¬",t<=a?" â":" â ï¸"]})]})]})]})})})]})}const ms=[{value:"cdi",label:"CDI"},{value:"cdd",label:"CDD"},{value:"freelance",label:"Indépendant / Freelance"},{value:"student",label:"Ãtudiant"},{value:"retired",label:"Retraité"},{value:"unemployed",label:"Sans emploi"},{value:"other",label:"Autre"}];function us({open:o,onOpenChange:t,applicationId:u,candidateId:N,initialData:d}){const v=ee(),[m,h]=D.useState(!1),[n,g]=D.useState({first_name:"",last_name:"",email:"",phone:"",employment_status:"",monthly_income:""});D.useEffect(()=>{o&&g({first_name:d.first_name||"",last_name:d.last_name||"",email:d.email||"",phone:d.phone||"",employment_status:d.employment_status||"",monthly_income:d.monthly_income?.toString()||""})},[o,d]);const i=async()=>{h(!0);try{if(N){const{error:c}=await R.from("candidate_profiles").update({first_name:n.first_name||null,last_name:n.last_name||null,email:n.email||null,phone:n.phone||null,employment_status:n.employment_status||null,monthly_income:n.monthly_income?parseFloat(n.monthly_income):null}).eq("id",N);if(c)throw c}const{error:r}=await R.from("applications").update({guest_first_name:n.first_name||null,guest_last_name:n.last_name||null,guest_email:n.email||null,guest_phone:n.phone||null,guest_employment_status:n.employment_status||null,guest_monthly_income:n.monthly_income?parseFloat(n.monthly_income):null}).eq("id",u);if(r)throw r;
6q.success("Informations mises à jour"),v.invalidateQueries({queryKey:["tenant-application",u]}),t(!1)}catch(r){q.error(r.message||"Erreur lors de la mise à jour")}finally{h(!1)}};return e.jsx(xe,{open:o,onOpenChange:t,children:e.jsxs(pe,{className:"sm:max-w-lg",children:[e.jsx(he,{children:e.jsx(ge,{children:"Modifier mes informations"})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"edit-fn",children:"Prénom"}),e.jsx(A,{id:"edit-fn",value:n.first_name,onChange:r=>g(c=>({...c,first_name:r.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"edit-ln",children:"Nom"}),e.jsx(A,{id:"edit-ln",value:n.last_name,onChange:r=>g(c=>({...c,last_name:r.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"edit-email",children:"Email"}),e.jsx(A,{id:"edit-email",type:"email",value:n.email,onChange:r=>g(c=>({...c,email:r.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"edit-phone",children:"Téléphone"}),e.jsx(A,{id:"edit-phone",value:n.phone,onChange:r=>g(c=>({...c,phone:r.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{children:"Situation professionnelle"}),e.jsxs(be,{value:n.employment_status,onValueChange:r=>g(c=>({...c,employment_status:r})),children:[e.jsx(Ce,{children:e.jsx(Se,{placeholder:"Sélectionner"})}),e.jsx(ke,{children:ms.map(r=>e.jsx(Ae,{value:r.value,children:r.label},r.value))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"edit-income",children:"Revenus mensuels (â¬)"}),e.jsx(A,{id:"edit-income",type:"number",value:n.monthly_income,onChange:r=>g(c=>({...c,monthly_income:r.target.value}))})]})]}),e.jsxs(je,{children:[e.jsx(p,{variant:"outline",onClick:()=>t(!1),children:"Annuler"}),e.jsxs(p,{onClick:i,disabled:m,children:[m&&e.jsx(se,{className:"w-4 h-4 mr-2 animate-spin"}),"Enregistrer"]})]})]})})}function me({open:o,onOpenChange:t,applicationId:u,candidateId:N,target:d,cohabitantId:v,initialData:m}){const h=ee(),[n,g]=D.useState(!1),[i,r]=D.useState({first_name:"",last_name:"",email:"",phone:"",income:""});D.useEffect(()=>{o&&r({first_name:m.guarantor_first_name||"",last_name:m.guarantor_last_name||"",email:m.guarantor_email||"",phone:m.guarantor_phone||"",income:m.guarantor_income?.toString()||""})},[o,m]);const c=async()=>{g(!0);try{if(d==="candidate"&&N){const{error:a}=await R.from("candidate_profiles").update({guarantor_first_name:i.first_name||null,guarantor_last_name:i.last_name||null,guarantor_email:i.email||null,guarantor_phone:i.phone||null,guarantor_income:i.income?parseFloat(i.income):null}).eq("id",N);if(a)throw a;const{error:x}=await R.from("applications").update({guest_guarantor_first_name:i.first_name||null,guest_guarantor_last_name:i.last_name||null,guest_guarantor_email:i.email||null,guest_guarantor_phone:i.phone||null,guest_guarantor_income:i.income?parseFloat(i.income):null}).eq("id",u);if(x)throw x}else if(d==="cohabitant"&&v){const{error:a}=await R.from("application_cohabitants").update({guarantor_first_name:i.first_name||null,guarantor_last_name:i.last_name||null,guarantor_email:i.email||null,guarantor_phone:i.phone||null,guarantor_income:i.income?parseFloat(i.income):null}).eq("id",v);if(a)throw a}q.success("Garant mis à jour"),h.invalidateQueries({queryKey:["tenant-application",u]}),t(!1)}catch(a){q.error(a.message||"Erreur lors de la mise à jour")}finally{g(!1)}};return e.jsx(xe,{open:o,onOpenChange:t,children:e.jsxs(pe,{className:"sm:max-w-lg",children:[e.jsx(he,{children:e.jsx(ge,{children:"Modifier le garant"})}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4 py-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"g-fn",children:"Prénom"}),e.jsx(A,{id:"g-fn",value:i.first_name,onChange:a=>r(x=>({...x,first_name:a.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"g-ln",children:"Nom"}),e.jsx(A,{id:"g-ln",value:i.last_name,onChange:a=>r(x=>({...x,last_name:a.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"g-email",children:"Email"}),e.jsx(A,{id:"g-email",type:"email",value:i.email,onChange:a=>r(x=>({...x,email:a.target.value}))})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(w,{htmlFor:"g-phone",children:"Téléphone"}),e.jsx(A,{id:"g-phone",value:i.phone,onChange:a=>r(x=>({...x,phone:a.target.value}))})]}),e.jsxs("div",{className:"space-y-2 sm:col-span-2",children:[e.jsx(w,{htmlFor:"g-income",children:"Revenus mensuels (â¬)"}),e.jsx(A,{id:"g-income",type:"number",value:i.income,onChange:a=>r(x=>({...x,income:a.target.value}))})]})]}),e.jsxs(je,{children:[e.jsx(p,{variant:"outline",onClick:()=>t(!1),children:"Annuler"}),e.jsxs(p,{onClick:c,disabled:n,children:[n&&e.jsx(se,{className:"w-4 h-4 mr-2 animate-spin"}),"Enregistrer"]})]})]})})}const K={received:"Reçue",under_review:"En cours d'étude",visit_scheduled:"Visite programmée",accepted:"Acceptée",rejected:"Non retenue",withdrawn:"Retir
6ée"},xs={received:"bg-blue-100 text-blue-800",under_review:"bg-yellow-100 text-yellow-800",visit_scheduled:"bg-purple-100 text-purple-800",accepted:"bg-green-100 text-green-800",rejected:"bg-red-100 text-red-800",withdrawn:"bg-gray-100 text-gray-800"},X={received:e.jsx(fe,{className:"w-5 h-5"}),under_review:e.jsx(T,{className:"w-5 h-5"}),visit_scheduled:e.jsx(is,{className:"w-5 h-5"}),accepted:e.jsx(Z,{className:"w-5 h-5 text-green-600"}),rejected:e.jsx(G,{className:"w-5 h-5 text-red-600"}),withdrawn:e.jsx(G,{className:"w-5 h-5 text-gray-600"})},_e={identity:"Pièce d'identité",proof_of_address:"Justificatif de domicile",employment_contract:"Contrat de travail",payslips:"Bulletins de salaire",tax_notice:"Avis d'imposition",guarantor_identity:"Pièce d'identité garant",guarantor_proof_of_address:"Justificatif domicile garant",guarantor_payslips:"Bulletins de salaire garant",guarantor_tax_notice:"Avis d'imposition garant",other:"Autre"},ue={cdi:"CDI",cdd:"CDD",freelance:"Indépendant / Freelance",student:"Ãtudiant",retired:"Retraité",unemployed:"Sans emploi",other:"Autre"},ps={spouse:"Conjoint(e) / Ãpoux(se)",partner:"Partenaire (PACS)",cohabitant:"Concubin(e)",roommate:"Colocataire",family:"Membre de la famille",other:"Autre"},hs={cohab_identity:"Pièce d'identité",cohab_proof_of_address:"Justificatif de domicile",cohab_employment_contract:"Contrat de travail",cohab_payslips:"Bulletins de salaire",cohab_tax_notice:"Avis d'imposition",cohab_guarantor_identity:"Pièce d'identité garant",cohab_guarantor_proof_of_address:"Justificatif domicile garant",cohab_guarantor_payslips:"Bulletins de salaire garant",cohab_guarantor_tax_notice:"Avis d'imposition garant"};function Gt(){const{id:o}=ve(),{data:t,isLoading:u}=ye(o||""),[N,d]=D.useState(!1),[v,m]=D.useState(!1),[h,n]=D.useState(null),[g,i]=D.useState(null);if(u)return e.jsx("div",{className:"flex items-center justify-center py-12",children:e.jsx(se,{className:"w-8 h-8 animate-spin text-primary"})});if(!t)return e.jsxs("div",{className:"text-center py-12",children:[e.jsx("p",{className:"text-muted-foreground mb-4",children:"Candidature non trouvée"}),e.jsx(p,{asChild:!0,children:e.jsx(I,{to:"/tenant/applications",children:"Retour aux candidatures"})})]});const r=t.unit,c=r?.properties,a=t.my_profile||t.candidate,x=(t.total_candidates||1)>1,y=t.cohabitants_list||[],M=t.all_application_documents||[],z=r?.monthly_rent||0,l=r?.charges||0,F=z+l,_=a?.monthly_income||0,$=_>0?F/_*100:0,H=t.required_documents||[],E=t.candidate_documents||[],O=a?.has_guarantor||!1,Ne=s=>E.some(b=>b.document_type===s),te=H.filter(s=>s.document_type.startsWith("guarantor_")).length>0;return e.jsxs("div",{className:"space-y-6",children:[e.jsx(p,{variant:"ghost",size:"sm",asChild:!0,children:e.jsxs(I,{to:"/tenant/applications",children:[e.jsx(es,{className:"w-4 h-4 mr-2"}),"Retour aux candidatures"]})}),e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-start justify-between gap-4",children:[e.jsxs("div",{className:"flex items-start gap-4",children:[e.jsx("div",{className:"w-14 h-14 rounded-xl bg-primary/10 flex items-center justify-center",children:e.jsx(ie,{className:"w-7 h-7 text-primary"})}),e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-display font-bold",children:r?.name||"Logement"}),e.jsxs("p",{className:"text-muted-foreground flex items-center gap-1",children:[e.jsx(ss,{className:"w-4 h-4"}),c?.address,", ",c?.postal_code," ",c?.city]})]})]}),e.jsxs(L,{className:`${xs[t.status]} text-sm px-4 py-2`,children:[X[t.status],e.jsx("span",{className:"ml-2",children:K[t.status]})]})]}),e.jsxs(Ve,{defaultValue:"overview",className:"space-y-6",children:[e.jsxs(Ge,{className:"grid w-full grid-cols-5 lg:w-auto lg:inline-flex",children:[e.jsx(P,{value:"overview",children:"Aperçu"}),e.jsxs(P,{value:"visit",children:[e.jsx(le,{className:"w-4 h-4 mr-1"}),"Visite"]}),e.jsx(P,{value:"dossier",children:"Mon dossier"}),e.jsxs(P,{value:"messages",children:[e.jsx(J,{className:"w-4 h-4 mr-1"}),"Messages"]}),e.jsx(P,{value:"history",children:"Historique"})]}),e.jsxs(V,{value:"overview",className:"space-y-6",children:[x&&e.jsxs("div",{className:"flex items-start gap-3 p-4 bg-blue-50 rounded-lg border border-blue-200",children:[e.jsx(Q,{className:"w-5 h-5 text-blue-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-medium text-blue-800",children:["Candidature groupée (",t.total_candidates," candidats)"]}),e.jsx("p",{className:"text-sm text-blue-700",children:"Vous faites partie d'une candidature groupée. Seules vos informations personnelles sont affichées ici. Chaque candidat doit compléter son propre profil."})]})]}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-3 gap-6",children:[e.jsxs(j,{className:"lg:col-span-2",children:[e.jsx(S,{children:e.jsx(k,{children:"Détails du logement"})}),e.jsxs(f,{children:[e.jsxs("div",{className:"grid grid-cols-2 sm:grid-cols-4 gap-4",children:[e.jsxs("div",{className:"text-center p-4 bg-secondary/50 rounded-lg",children:[e.jsx(ts,{className:"w-5 h-5 mx-auto mb-2 text-primary"}),e.jsxs("p",{className:"text-lg font-bold",children:[r?.monthly_rent?.toLocaleStr
6ing("fr-FR")," â¬"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Loyer/mois"})]}),e.jsxs("div",{className:"text-center p-4 bg-secondary/50 rounded-lg",children:[e.jsx(as,{className:"w-5 h-5 mx-auto mb-2 text-primary"}),e.jsxs("p",{className:"text-lg font-bold",children:[r?.surface_area," m²"]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Surface"})]}),e.jsxs("div",{className:"text-center p-4 bg-secondary/50 rounded-lg",children:[e.jsx(ds,{className:"w-5 h-5 mx-auto mb-2 text-primary"}),e.jsx("p",{className:"text-lg font-bold",children:r?.rooms||"-"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Pièces"})]}),e.jsxs("div",{className:"text-center p-4 bg-secondary/50 rounded-lg",children:[e.jsx(ie,{className:"w-5 h-5 mx-auto mb-2 text-primary"}),e.jsx("p",{className:"text-lg font-bold",children:r?.floor||"RDC"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Ãtage"})]})]}),r?.charges&&e.jsxs("p",{className:"mt-4 text-sm text-muted-foreground",children:["+ ",r.charges," ⬠de charges",r.furnished&&" ⢠Meublé"]})]})]}),e.jsxs(j,{children:[e.jsx(S,{children:e.jsx(k,{children:"Statut"})}),e.jsxs(f,{children:[e.jsxs("div",{className:"text-center py-4",children:[e.jsx("div",{className:`inline-flex items-center justify-center w-16 h-16 rounded-full mb-4 ${t.status==="accepted"?"bg-green-100":t.status==="rejected"?"bg-red-100":"bg-blue-100"}`,children:X[t.status]}),e.jsx("h3",{className:"font-semibold text-lg mb-2",children:K[t.status]}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t.status==="received"&&"Votre dossier a été reçu et sera examiné prochainement.",t.status==="under_review"&&"Votre dossier est en cours d'analyse.",t.status==="visit_scheduled"&&"Une visite a été programmée.",t.status==="accepted"&&"Félicitations ! Votre candidature a été acceptée.",t.status==="rejected"&&"Votre candidature n'a pas été retenue."]})]}),t.status==="accepted"&&e.jsxs(e.Fragment,{children:[e.jsx(W,{className:"my-4"}),e.jsx(p,{className:"w-full",asChild:!0,children:e.jsxs(I,{to:"/tenant/messages",children:[e.jsx(J,{className:"w-4 h-4 mr-2"}),"Contacter le propriétaire"]})})]})]})]})]})]}),e.jsxs(V,{value:"visit",className:"space-y-6",children:[e.jsx(Oe,{applicationId:t.id,applicationStatus:t.status,visitScheduledDate:t.visit_scheduled_date,visitScheduledTime:t.visit_scheduled_time,visitStatus:t.visit_status,propertyAddress:`${c?.address}, ${c?.postal_code} ${c?.city}`,variant:"tenant",managementMode:r?.management_mode,ownerContact:t.owner_profile?{firstName:t.owner_profile.first_name,lastName:t.owner_profile.last_name,phone:t.owner_profile.phone}:null}),e.jsx(Be,{applicationId:t.id,canEdit:!0}),["visit_scheduled","accepted","rejected","withdrawn"].includes(t.status)&&e.jsx(Ue,{applicationId:t.id,applicationStatus:t.status,variant:"tenant"}),["visit_scheduled","accepted","rejected","withdrawn"].includes(t.status)&&e.jsx(ze,{applicationId:t.id,applicationStatus:t.status,variant:"tenant",readonly:!0}),!["visit_scheduled","accepted","rejected","withdrawn"].includes(t.status)&&e.jsx(j,{children:e.jsxs(f,{className:"py-8 text-center",children:[e.jsx(le,{className:"w-12 h-12 mx-auto mb-4 text-muted-foreground/50"}),e.jsx("h3",{className:"font-medium mb-2",children:"Visite pas encore programmée"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Vous pourrez remplir votre compte-rendu de visite une fois la visite programmée."})]})})]}),e.jsxs(V,{value:"dossier",className:"space-y-6",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-xl font-display font-bold",children:"Mon dossier de candidature"}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:"Retrouvez toutes les informations et documents de votre dossier"})]}),e.jsxs(p,{className:"gap-2",onClick:()=>d(!0),children:[e.jsx(B,{className:"w-4 h-4"}),"Modifier le dossier"]})]}),e.jsx(j,{className:"border-l-4 border-l-primary",children:e.jsx(f,{className:"py-4",children:e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-4",children:[e.jsxs("div",{className:"flex items-center gap-6",children:[e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Loyer + charges"}),e.jsxs("p",{className:"text-lg font-bold",children:[F.toLocaleStr
6ing("fr-FR")," â¬/mois"]})]}),e.jsxs("div",{children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Revenus foyer"}),e.jsx("p",{className:"text-lg font-bold",children:_>0?`${_.toLocaleString("fr-FR")} â¬`:"Non renseigné"})]})]}),e.jsxs("div",{className:"text-right",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Taux d'effort"}),e.jsx("p",{className:`text-2xl font-bold ${$<=33?"text-green-600":$<=40?"text-yellow-600":"text-red-600"}`,children:_>0?`${$.toFixed(1)}%`:"N/A"}),_>0&&e.jsx("p",{className:"text-xs text-muted-foreground",children:$<=33?"â Optimal":$<=40?"â Acceptable":"â Ãlevé"})]})]})})}),e.jsxs(j,{children:[e.jsx(S,{className:"pb-4",children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs(k,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Q,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("span",{className:"text-lg",children:"Candidat principal"}),e.jsxs("p",{className:"text-sm font-normal text-muted-foreground",children:[a?.first_name," ",a?.last_name]})]})]}),e.jsxs(p,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>d(!0),children:[e.jsx(B,{className:"w-3.5 h-3.5"}),"Modifier"]})]})}),e.jsxs(f,{className:"space-y-6",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Email"}),e.jsx("p",{className:"font-medium text-sm",children:a?.email||"â"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Téléphone"}),e.jsx("p",{className:"font-medium text-sm",children:a?.phone||"â"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Situation professionnelle"}),e.jsx("p",{className:"font-medium text-sm",children:ue[a?.employment_status||""]||a?.employment_status||"Non renseigné"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Revenus mensuels"}),e.jsx("p",{className:"font-medium text-sm",children:_>0?`${_.toLocaleString("fr-FR")} â¬`:"Non renseigné"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Garant"}),e.jsx(L,{variant:O?"default":"secondary",className:"text-xs",children:O?"Oui":"Non"})]})]}),e.jsx(W,{}),e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h4",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(T,{className:"w-4 h-4 text-primary"}),"Mes documents"]}),e.jsx(p,{variant:"outline",size:"sm",asChild:!0,className:"gap-1.5",children:e.jsxs(I,{to:"/tenant/applications",children:[e.jsx(De,{className:"w-3.5 h-3.5"}),"Gérer"]})})]}),E.filter(s=>!s.document_type.startsWith("guarantor_")).length>0?e.jsx("div",{className:"space-y-2",children:E.filter(s=>!s.document_type.startsWith("guarantor_")).map(s=>e.jsx(U,{doc:s,applicationId:t.id},s.id))}):e.jsxs("div",{className:"text-center py-6 border rounded-lg border-dashed",children:[e.jsx(T,{className:"w-8 h-8 mx-auto mb-2 text-muted-foreground/40"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"Aucun document ajouté"}),e.jsx(p,{variant:"link",size:"sm",asChild:!0,children:e.jsx(I,{to:"/tenant/applications",children:"Ajouter des documents"})})]})]}),O&&e.jsxs(e.Fragment,{children:[e.jsx(W,{}),e.jsxs("div",{className:"p-4 rounded-lg border bg-accent/5",children:[e.jsxs("div",{className:"flex items-center justify-between mb-3",children:[e.jsxs("h4",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(ce,{className:"w-4 h-4 text-primary"}),"Mon garant"]}),e.jsxs(p,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>m(!0),children:[e.jsx(B,{className:"w-3.5 h-3.5"}),"Modifier"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-3 gap-4 mb-4",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Nom"}),e.jsx("p",{className:"font-medium text-sm",children:a?.guarantor_first_name||a?.guarantor_last_name?`${a?.guarantor_first_name||""} ${a?.guarantor_last_name||""}`.trim():"Non renseigné"})]}),a?.guarantor_email&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Email"}),e.jsx("p",{className:"font-medium text-sm",children:a.guarantor_email})]}),a?.guarantor_phone&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Téléphone"}),e.jsx("p",{className:"font-medium text-sm",children:a.guarantor_phone})]}),a?.guarantor_income&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Revenus mensuels"}),e.jsxs("p",{className:"font-medium text-sm",children:[a.guarantor_income.toLocaleStr
6ing("fr-FR")," â¬"]})]})]}),E.filter(s=>s.document_type.startsWith("guarantor_")).length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",children:"Documents du garant"}),e.jsx("div",{className:"space-y-2",children:E.filter(s=>s.document_type.startsWith("guarantor_")).map(s=>e.jsx(U,{doc:s,applicationId:t.id},s.id))})]})]})]})]})]}),y.length>0&&e.jsxs(j,{children:[e.jsx(S,{className:"pb-4",children:e.jsx("div",{className:"flex items-center justify-between",children:e.jsxs(k,{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-secondary/50 flex items-center justify-center",children:e.jsx(rs,{className:"w-5 h-5 text-primary"})}),e.jsxs("div",{children:[e.jsxs("span",{className:"text-lg",children:["Co-candidat",y.length>1?"s":""]}),e.jsxs("p",{className:"text-sm font-normal text-muted-foreground",children:[y.length," personne",y.length>1?"s":""]})]})]})})}),e.jsx(f,{className:"space-y-4",children:y.map((s,b)=>{const ae=M.filter(C=>C.document_type.startsWith("cohab_")&&!C.document_type.startsWith("cohab_guarantor_")),re=M.filter(C=>C.document_type.startsWith("cohab_guarantor_"));return e.jsxs("div",{className:"border rounded-lg p-4 space-y-4",children:[e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-9 h-9 rounded-full bg-primary/10 flex items-center justify-center",children:e.jsx(Q,{className:"w-4 h-4 text-primary"})}),e.jsxs("div",{children:[e.jsxs("p",{className:"font-semibold",children:[s.first_name," ",s.last_name]}),e.jsxs("div",{className:"flex items-center gap-2 mt-0.5",children:[s.relationship&&e.jsx(L,{variant:"secondary",className:"text-xs",children:ps[s.relationship]||s.relationship}),e.jsx(L,{variant:s.user_id?"default":"outline",className:"text-xs",children:s.user_id?"Compte lié":"En attente"})]})]})]}),e.jsxs(p,{variant:"outline",size:"sm",className:"gap-1.5",onClick:()=>n(s.id),children:[e.jsx(B,{className:"w-3.5 h-3.5"}),"Modifier"]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Email"}),e.jsx("p",{className:"font-medium text-sm",children:s.email||"â"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Téléphone"}),e.jsx("p",{className:"font-medium text-sm",children:s.phone||"â"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Situation"}),e.jsx("p",{className:"font-medium text-sm",children:ue[s.employment_status||""]||s.employment_status||"Non renseigné"})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Revenus"}),e.jsx("p",{className:"font-medium text-sm",children:s.monthly_income?`${s.monthly_income.toLocaleString("fr-FR")} â¬`:"Non renseigné"})]})]}),ae.length>0&&e.jsxs("div",{children:[e.jsxs("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",children:["Documents de ",s.first_name]}),e.jsx("div",{className:"space-y-2",children:ae.map(C=>e.jsx(U,{doc:C,applicationId:t.id},C.id))})]}),s.has_guarantor&&e.jsxs("div",{className:"p-3 rounded-lg border bg-accent/5 space-y-3",children:[e.jsxs("h5",{className:"font-semibold flex items-center gap-2 text-sm",children:[e.jsx(ce,{className:"w-4 h-4 text-primary"}),"Garant de ",s.first_name]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 lg:grid-cols-4 gap-3",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Nom"}),e.jsx("p",{className:"font-medium text-sm",children:s.guarantor_first_name||s.guarantor_last_name?`${s.guarantor_first_name||""} ${s.guarantor_last_name||""}`.trim():"â"})]}),s.guarantor_email&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Email"}),e.jsx("p",{className:"font-medium text-sm",children:s.guarantor_email})]}),s.guarantor_phone&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Téléphone"}),e.jsx("p",{className:"font-medium text-sm",children:s.guarantor_phone})]}),s.guarantor_income&&e.jsxs("div",{className:"space-y-1",children:[e.jsx("p",{className:"text-xs text-muted-foreground uppercase tracking-wide",children:"Revenus"}),e.jsxs("p",{className:"font-medium text-sm",children:[s.guarantor_income.toLocaleStr
6ing("fr-FR")," â¬"]})]})]}),re.length>0&&e.jsxs("div",{children:[e.jsx("p",{className:"text-xs font-medium text-muted-foreground uppercase tracking-wide mb-2",children:"Documents du garant"}),e.jsx("div",{className:"space-y-2",children:re.map(C=>e.jsx(U,{doc:C,applicationId:t.id},C.id))})]})]})]},s.id)})})]}),e.jsx(os,{scoreResult:Qe({candidate_profiles:{monthly_income:a?.monthly_income||null,employment_status:a?.employment_status||null,has_guarantor:a?.has_guarantor||!1},guest_monthly_income:null,guest_employment_status:null,guest_has_guarantor:!1,application_cohabitants:t.cohabitants||[],application_documents:E,units:{monthly_rent:r?.monthly_rent,marketplace_listings:null}}),monthlyRent:r?.monthly_rent,totalIncome:a?.monthly_income||0,hasGuarantor:a?.has_guarantor||!1}),e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[e.jsxs(j,{children:[e.jsx(S,{children:e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(ns,{className:"w-5 h-5"}),"Exigences du propriétaire"]})}),e.jsxs(f,{className:"space-y-3",children:[te?e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-yellow-50 rounded-lg border border-yellow-200",children:[e.jsx(Y,{className:"w-5 h-5 text-yellow-600 shrink-0 mt-0.5"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-yellow-800 text-sm",children:"Garant requis"}),e.jsx("p",{className:"text-xs text-yellow-700",children:"Le propriétaire demande un garant."})]})]}):e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-green-50 rounded-lg border border-green-200",children:[e.jsx(ne,{className:"w-5 h-5 text-green-600 shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsx("p",{className:"font-medium text-green-800 text-sm",children:"Pas de garant requis"})})]}),te&&!O&&e.jsxs("div",{className:"flex items-start gap-3 p-3 bg-red-50 rounded-lg border border-red-200",children:[e.jsx(G,{className:"w-5 h-5 text-red-600 shrink-0 mt-0.5"}),e.jsx("div",{children:e.jsx("p",{className:"font-medium text-red-800 text-sm",children:"Garant manquant dans votre dossier"})})]})]})]}),e.jsxs(j,{children:[e.jsx(S,{children:e.jsxs(k,{className:"flex items-center gap-2 text-base",children:[e.jsx(T,{className:"w-5 h-5"}),"Documents demandés"]})}),e.jsx(f,{children:H.length===0?e.jsx("p",{className:"text-muted-foreground text-sm",children:"Aucun document spécifique demandé."}):e.jsx("div",{className:"space-y-2",children:H.map(s=>{const b=Ne(s.document_type);return e.jsxs("div",{className:`flex items-center justify-between p-2.5 rounded-lg text-sm ${b?"bg-green-50":"bg-red-50"}`,children:[e.jsxs("div",{className:"flex items-center gap-2",children:[b?e.jsx(ne,{className:"w-4 h-4 text-green-600"}):e.jsx(G,{className:"w-4 h-4 text-red-600"}),e.jsx("span",{className:b?"text-green-800":"text-red-800",children:_e[s.document_type]||s.document_type})]}),s.is_mandatory&&e.jsx(L,{variant:"outline",className:"text-xs",children:"Obligatoire"})]},s.id)})})})]})]}),(t.message||t.owner_comment)&&e.jsxs("div",{className:"grid grid-cols-1 lg:grid-cols-2 gap-6",children:[t.message&&e.jsxs(j,{children:[e.jsx(S,{children:e.jsx(k,{className:"text-base",children:"Votre message"})}),e.jsx(f,{children:e.jsxs("p",{className:"text-muted-foreground italic text-sm whitespace-pre-wrap break-words",children:['"',t.message,'"']})})]}),t.owner_comment&&e.jsxs(j,{children:[e.jsx(S,{children:e.jsx(k,{className:"text-base",children:"Commentaire du propriétaire"})}),e.jsx(f,{children:e.jsx("p",{className:"text-sm",children:t.owner_comment})})]})]})]}),e.jsx(V,{value:"history",children:e.jsxs(j,{children:[e.jsx(S,{children:e.jsx(k,{children:"Historique"})}),e.jsx(f,{children:e.jsxs("div",{className:"space-y-4",children:[e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-blue-100 flex items-center justify-center shrink-0",children:e.jsx(T,{className:"w-4 h-4 text-blue-600"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:"Candidature soumise"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:de(new Date(t.submitted_at),"d MMMM yyyy 'à ' HH:mm",{locale:oe})})]})]}),t.actions?.map(s=>e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx("div",{className:"w-8 h-8 rounded-full bg-gray-100 flex items-center justify-center shrink-0",children:s.action_type==="status_change"?X[s.new_status]||e.jsx(fe,{className:"w-4 h-4"}):e.jsx(J,{className:"w-4 h-4"})}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium",children:s.action_type==="status_change"?`Statut: ${K[s.new_status]||s.new_status}`:s.description}),e.jsx("p",{className:"text-sm text-muted-foreground",children:de(new Date(s.created_at),"d MMMM yyyy 'à ' HH:mm",{locale:oe})})]})]},s.id))]})})]})}),e.jsx(V,{value:"messages",className:"space-y-6",children:e.jsx(He,{applicationId:t.id,variant:"tenant",candidateName:`${a?.first_name||""} ${a?.last_name||""}`})})]}),e.jsx(us,{open:N,onOpenChange:d,applicationId:t.id,candidateId:t.candidate_id||null,initialData:{first_name:a?.first_name,last_name:a?.last_name,email:a?.email,phone:a?.phone,employment_status:a?.employment_status,monthly_income:a?.monthly_income}}),e.jsx(me,{open:v,onOpenChange:m,applicationId:t.id,candidateId:t.candidate_id||null,target:"candidate",initialData:{guarantor_first_name:a?.guarantor_first_name,guarantor_last_name:a?.guarantor_last_name,guarantor_email:a?.guarantor_email,guarantor_phone:a?.guarantor_phone,guarantor_income:a?.guarantor_income}}),y.map(s=>e.jsx(Ze,{open:h===s.id,onOpenChange:b=>n(b?s.id:null),applicationId:t.id,cohabitantId:s.id,initialData:{first_name:s.first_name,last_name:s.last_name,email:s.email,phone:s.phone,employment_status:s.employment_status,monthly_income:s.monthly_income,relationship:s.relationship}},`edit-cohab-${s.id}`)),y.filter(s=>s.has_guarantor).map(s=>e.jsx(me,{open:g===s.id,onOpenChange:b=>i(b?s.id:null),applicationId:t.id,candidateId:null,target:"cohabitant",cohabitantId:s.id,initialData:{guarantor_first_name:s.guarantor_first_name,guarantor_last_name:s.guarantor_last_name,guarantor_email:s.guarantor_email,guarantor_phone:s.guarantor_phone,guarantor_income:s.guarantor_income}},`edit-cohab-g-${s.id}`))]})}function U({doc:o,applicationId:t}){const u=ee(),N=Fe({mutationFn:async()=>{const{error:m}
6=await R.from("application_documents").delete().eq("id",o.id);if(m)throw m},onSuccess:()=>{u.invalidateQueries({queryKey:["tenant-application",t]}),q.success("Document supprimé")},onError:()=>{q.error("Erreur lors de la suppression")}}),d=async()=>{const m=o.file_url.includes("/candidate-documents/")?o.file_url.split("/candidate-documents/").pop():o.file_url.includes("/application-documents/")?o.file_url.split("/application-documents/").pop():null;if(m){const{data:h}=await R.storage.from("candidate-documents").createSignedUrl(m,3600);if(h?.signedUrl){window.open(h.signedUrl,"_blank");return}}window.open(o.file_url,"_blank")},v=hs[o.document_type]||_e[o.document_type]||o.document_type;return e.jsxs("div",{className:"flex items-center justify-between p-2 rounded border text-sm",children:[e.jsxs("div",{className:"flex items-center gap-2 min-w-0",children:[e.jsx(T,{className:"w-4 h-4 text-primary flex-shrink-0"}),e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"font-medium truncate",children:v}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:o.file_name})]})]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(p,{variant:"ghost",size:"sm",onClick:d,children:e.jsx(ls,{className:"w-4 h-4"})}),e.jsxs(Re,{children:[e.jsx(Me,{asChild:!0,children:e.jsx(p,{variant:"ghost",size:"sm",className:"text-destructive hover:text-destructive",children:e.jsx(cs,{className:"w-4 h-4"})})}),e.jsxs(Ee,{children:[e.jsxs(Le,{children:[e.jsx(Te,{children:"Supprimer ce document ?"}),e.jsxs(qe,{children:["Le document « ",v," » sera supprimé définitivement."]})]}),e.jsxs($e,{children:[e.jsx(Ie,{children:"Annuler"}),e.jsx(Pe,{onClick:()=>N.mutate(),className:"bg-destructive text-destructive-foreground hover:bg-destructive/90",children:"Supprimer"})]})]})]})]})]})}export{Gt 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.