PageSourceSearch

https://propflowmarket.lovable.app/assets/ChessboardGrid-BlMRQHyX-v7.js

js propflowmarket.lovable.app collected 2026-10-03 03:42:31 UTC 8,103 bytes, 1 lines download raw bytes

1import{k as G,r as n,j as e}from"./vendor-core-CGvFEvkV-v7.js";import{O as I,P,Q as A,R as E,V as N,b as x,x as H,B as Q}from"./App-_RKmcbZK-v7.js";import{S as q}from"./slider-LZwXqsPz-v7.js";import{S as J,a as K,b as W,c as Y,d as Z}from"./sheet-Dxwo2hmx-v7.js";import{B as ee}from"./badge-c903kYkT-v7.js";import{a as S}from"./currency-BazZlZuM-v7.js";import{C as re}from"./cuboid-DeTyaQuA-v7.js";import{E as se}from"./external-link-Bdg0JiJa-v7.js";import"./index-DNt0u3Q7-v7.js";import"./vendor-ui-DTRn_Kee-v7.js";import"./index-BFCvP2lz-v7.js";const F={available:{bg:"bg-success/15",border:"border-success/40",text:"text-success",label:"available"},reserved:{bg:"bg-warning/15",border:"border-warning/40",text:"text-warning",label:"reserved"},booking:{bg:"bg-warning/15",border:"border-warning/40",text:"text-warning",label:"reserved"},sold:{bg:"bg-destructive/15",border:"border-destructive/40",text:"text-destructive",label:"plotSold"}};function ue({units:d,onStatusChange:c,readOnly:R=!1,className:z}){const{t:l,i18n:f}=G(),[s,w]=n.useState(null),[p,O]=n.useState("all"),[h,T]=n.useState("all"),[m,k]=n.useState([0,0]),[_,B]=n.useState(!1),{floors:g,bedrooms:C,minPrice:j,maxPrice:b}=n.useMemo(()=>{const r=new Set,t=new Set;let a=1/0,o=0;return d.forEach(i=>{i.floor!=null&&r.add(i.floor),i.bedrooms!=null&&t.add(i.bedrooms),i.price!=null&&(i.price<a&&(a=i.price),i.price>o&&(o=i.price))}),a===1/0&&(a=0),{floors:Array.from(r).sort((i,u)=>u-i),bedrooms:Array.from(t).sort((i,u)=>i-u),minPrice:a,maxPrice:o}},[d]);!_&&b>0&&(k([j,b]),B(!0));const M=n.useMemo(()=>d.filter(r=>{var t,a;return!(p!=="all"&&((t=r.floor)==null?void 0:t.toString())!==p||h!=="all"&&((a=r.bedrooms)==null?void 0:a.toString())!==h||r.price!=null&&_&&(r.price<m[0]||r.price>m[1]))}),[d,p,h,m,_]),U=n.useMemo(()=>new Set(M.map(r=>r.id)),[M]),{gridFloors:V,maxAxisX:$}=n.useMemo(()=>{const r=g.length>
10?g:[1];let t=1;return d.forEach(a=>{a.axis_x!=null&&a.axis_x>t&&(t=a.axis_x)}),{gridFloors:r,maxAxisX:t}},[g,d]),L=n.useMemo(()=>{const r=new Map;return d.forEach(t=>{const a=t.floor??1,o=t.axis_x??1;r.set(`${a}-${o}`,t)}),r},[d]),v=r=>F[r]||F.available,X=n.useCallback((r,t)=>{c==null||c(r,t),w(a=>a?{...a,status:t}:null)},[c]),D=r=>r==null?"":r===0?"Ст":`${r}К`;return e.jsxs("div",{className:x("space-y-4",z),children:[e.jsxs("div",{className:"flex flex-wrap items-end gap-4 p-4 rounded-2xl border border-border/60 bg-card shadow-card",children:[e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:l("units.floor")}),e.jsxs(I,{value:p,onValueChange:O,children:[e.jsx(P,{className:"w-32 h-9",children:e.jsx(A,{})}),e.jsxs(E,{children:[e.jsx(N,{value:"all",children:l("units.allFloors")}),g.map(r=>e.jsxs(N,{value:r.toString(),children:[l("units.floor")," ",r]},r))]})]})]}),C.length>0&&e.jsxs("div",{className:"space-y-1.5",children:[e.jsx("label",{className:"text-xs font-medium text-muted-foreground",children:l("chessboard.rooms")}),e.jsxs(I,{value:h,onValueChange:T,children:[e.jsx(P,{className:"w-32 h-9",children:e.jsx(A,{})}),e.jsxs(E,{children:[e.jsx(N,{value:"all",children:l("chessboard.allRooms")}),C.map(r=>e.jsx(N,{value:r.toString(),children:r===0?l("chessboard.studio"):`${r} ${l("chessboard.rooms")}`},r))]})]})]}),b>j&&e.jsxs("div",{className:"space-y-1.5 flex-1 min-w-[200px]",children:[e.jsxs("label",{className:"text-xs font-medium text-muted-foreground",children:[l("chessboard.price"),": ",S(m[0],f.language)," - ",S(m[1],f.language)]}),e.jsx(q,{min:j,max:b,step:Math.max(1,Math.floor((b-j)/100)),value:m,onValueChange:r=>k(r),className:"py-2"})]}),e.jsx("div",{className:"flex gap-3 ml-auto",children:Object.entries(F).filter(([r])=>r!=="booking").map(([r,t])=>e.jsxs("div",{className:"flex items-center gap-1.5",children:[e.jsx("div",{className:x("h-3 w-3 rounded-sm border-2",t.border,t.bg)}),e.jsx("span",{className:"text-xs text-muted-foreground",children:l(`properties.${t.label}`)})]},r))})]}),e.jsx("div",{className:"overflow-x-auto rounded-2xl border border-border/60 bg-card shadow-card",children:e.jsx("div",{className:"inline-block min-w-full",children:e.jsxs("div",{className:"grid",style:{gridTemplateColumns:`48px repeat(${$}, minmax(100px, 1fr))`},children:[e.jsx("div",{className:"sticky left-0 z-10 bg-muted p-2 text-xs font-semibold text-muted-foreground border-b border-border flex items-center justify-center",children:l("units.floor")}),Array.from({length:$},(r,t)=>e.jsx("div",{className:"p-2 text-xs font-semibold text-center text-muted-foreground border-b border-l border-border bg-muted",children:t+1},t)),V.map(r=>e.jsxs(e.Fragment,{children:[e.jsx("div",{className:"sticky left-0 z-10 bg-muted/50 p-2 text-sm font-bold text-foreground border-b border-border flex items-center justify-center",children:r},`label-${r}`),Array.from({length:$},(t,a)=>{const o=L.get(`${r}-${a+1}`);if(!o)return e.jsx("div",{className:"border-b border-l border-border p-1 min-h-[80px]"},`empty-${r}-${a}`);const i=v(o.status),u=!U.has(o.id);return e.jsx("button",{onClick:()=>w(o),className:x("border-b border-l border-border p-2 min-h-[80px] transition-all duration-200 text-left",i.bg,i.border,"hover:brightness-110 hover:shadow-md cursor-pointer",u&&"opacity-20"),children:e.jsxs("div",{className:"flex flex-col gap-0.5",children:[e.jsx("span",{className:"text-xs font-bold text-foreground truncate",children:o.unit_number}),o.bedrooms!=null&&e.jsx("span",{className:x("text-[11px] font-semibold",i.text),children:D(o.bedrooms)}),o.area!=null&&e.jsxs("span",{className:"text-[10px] text-muted-foreground",children:[o.area," м²"]}),o.price!=null&&e.jsx("span",{className:"text-[11px] font-semibold text-foreground/80",children:S(o.price,f.language)})]})},o.id)})]}))]})})}),e.jsx(J,{open:!!s,onOpenChange:r=>!r&&w(null),children:e.jsx(K,{className:"overflow-y-auto",children:s&&e.jsxs(e.Fragment,{children:[e.jsxs(W,{children:[e.jsx(Y,{children:s.unit_number}),e.jsx(Z,{children:l("chessboard.unitDetails")})]}),e.jsxs("div",{className:"mt-6 space-y-5",children:[s.layout_image&&e.jsx("img",{src:H(s.layout_image),alt:`${s.unit_number} layout`,className:"w-full rounded-lg border border-border object-contain bg-muted p-2"}),e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs("span",{className:"text-sm text-muted-foreground",children:[l("properties.status"),":"]}),e.jsx(ee,{variant:"outline",className:x("text-xs",v(s.status).border,v(s.status).text),children:l(`properties.${v(s.status).label}`)})]}),e.jsxs("div",{className:"grid grid-cols-2 gap-3",children:[s.floor!=null&&e.jsx(y,{label:l("units.floor"),value:s.floor.toString()}),s.bedrooms!=null&&e.jsx(y,{label:l("chessboard.rooms"),value:s.bedrooms===0?l("chessboard.studio"):s.bedrooms.toString()}),s.area!=null&&e.jsx(y,{label:l("landing.area"),value:`${s.area} м²`}),s.price!=null&&e.jsx(y,{label:l("properties.price"),value:S(s.price,f.language)})]}),s.tour_3d_url&&e.jsxs("a",{href:s.tour_3d_url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-2 text-sm text-accent hover:underline",children:[e.jsx(re,{className:"h-4 w-4"}),l("landing.tour3d"),e.jsx(se,{className:"h-3.5 w-3.5"})]}),!R&&c&&e.jsxs("div",{className:"space-y-2 pt-4 border-t border-border",children:[e.jsx("label",{className:"text-sm font-medium",children:l("chessboard.changeStatus")}),e.jsx("div",{className:"flex gap-2",children:["available","reserved","sold"].map(r=>e.jsx(Q,{size:"sm",variant:s.status===r?"default":"outline",onClick:()=>X(s.id,r),className:x(s.status===r&&r==="available"&&"bg-emerald-600 hover:bg-emerald-700",s.status===r&&r==="reserved"&&"bg-amber-500 hover:bg-amber-600",
1s.status===r&&r==="sold"&&"bg-red-600 hover:bg-red-700"),children:l(`properties.${r==="sold"?"plotSold":r}`)},r))})]})]})]})})})]})}function y({label:d,value:c}){return e.jsxs("div",{className:"rounded-xl border border-border/60 p-3 bg-muted/30",children:[e.jsx("p",{className:"text-[11px] text-muted-foreground",children:d}),e.jsx("p",{className:"text-sm font-semibold text-foreground",children:c})]})}export{ue as ChessboardGrid};

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.