PageSourceSearch

https://dealassist.replit.app/assets/dashboard-pLm8O9I9.js

js dealassist.replit.app collected 2026-10-03 03:49:15 UTC 18,171 bytes, 1 lines download raw bytes

1import{c as V,u as z,r as o,b as v,j as e,B as w,U as H,C as h,a as p,L as M,d as g,e as u,f as U,H as B,E as K,g as O,h as T}from"./index-ymGASxfw.js";import{H as _}from"./help-sidebar-D9Bn0ZmA.js";import{B as $}from"./badge-3CC9CLqT.js";import{S as f}from"./skeleton-q6F7ptfe.js";import{U as G}from"./user-4jTVcIjm.js";import{D as A}from"./dollar-sign-B3-8x30S.js";import{T as Z}from"./trending-up-CO7wnVmj.js";import{C as I}from"./circle-alert-DXLxRv-b.js";import{C as W}from"./clock-Ds05tUbz.js";import{C as J}from"./chevron-left-BjK6UCdQ.js";import{C as Q}from"./chevron-right-CdIo0__w.js";import{C as X,a as Y}from"./chevron-up-Xz_mYCrv.js";import{R as ee}from"./refresh-cw-DjrTL334.js";const F=V("Newspaper",[["path",{d:"M4 22h16a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2H8a2 2 0 0 0-2 2v16a2 2 0 0 1-2 2Zm0 0a2 2 0 0 1-2-2v-9c0-1.1.9-2 2-2h2",key:"7pis2x"}],["path",{d:"M18 14h-8",key:"sponae"}],["path",{d:"M15 18h-5",key:"95g1m2"}],["path",{d:"M10 6h8v4h-8V6Z",key:"smlsk5"}]]);function se(){return localStorage.getItem("dashboardView")==="brokerage"?"brokerage":"my"}function we(){const{user:n}=z(),[r,l]=o.useState(se);o.useEffect(()=>{localStorage.setItem("dashboardView",r)},[r]);const i=n?.partyId,a=r==="my"&&!!i,{data:c,isLoading:j}=v({queryKey:a?["/api/listings",{agentId:i}]:["/api/listings"],queryFn:async({queryKey:s})=>{const x=s[1],L=x?.agentId?`/api/listings?agentId=${x.agentId}`:"/api/listings";return(await T("GET",L)).json()}}),{data:N,isLoading:k}=v({queryKey:a?["/api/deals",{agentId:i}]:["/api/deals"],queryFn:async({queryKey:s})=>{const x=s[1],L=x?.agentId?`/api/deals?agentId=${x.agentId}`:"/api/deals";return(await T("GET",L)).json()}}),{data:b,isLoading:d}=v({queryKey:["/api/parties"]}),t=o.useMemo(()=>c||[],[c]),m=o.useMemo(()=>N||[],[N]),C=o.useMemo(()=>t.filter(s=>s.listingStatus==="ACTIVE"),[t]),E=o.useMemo(()=>m.filter(s=>s.status==="CLOSED"),[m]),P=o.useMemo(()=>E.reduce((s,x)=>s+Number(x.volume||0),0),[E]),R=o.useMemo(()=>m.filter(s=>["NEGOTIATION","LOI","EXECUTED","IN_ESCROW"].includes(s.status)),[m]),q=o.useMemo(()=>C.reduce((s,x)=>{const L=Number(x.listPrice||0),S=Number(x.commissionPercentage||0);return s+L*S/100},0),[C]),y=j||k||d;return e.jsxs("div",{className:"p-6 space-y-6 max-w-7xl mx-auto",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center justify-between gap-3",children:[e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("h1",{className:"text-2xl font-semibold tracking-tight","data-testid":"text-dashboard-title",children:"Dashboard"}),e.jsx(_,{path:"/"})]}),e.jsx("p",{className:"text-muted-foreground text-sm mt-1",children:r==="my"&&i?"Overview of your listings and deals":"Overview of all brokerage operations"})]}),e.jsxs("div",{className:"flex items-center gap-1 rounded-lg border p-1","data-testid":"dashboard-view-toggle",children:[e.jsxs(w,{variant:r==="my"?"default":"ghost",size:"sm",onClick:()=>l("my"),className:"gap-1.5","data-testid":"button-view-my",children:[e.jsx(G,{className:"h-3.5 w-3.5"}),"My View"]}),e.jsxs(w,{variant:r==="brokerage"?"default":"ghost",size:"sm",onClick:()=>l("brokerage"),className:"gap-1.5","data-testid":"button-view-brokerage",children:[e.jsx(H,{className:"h-3.5 w-3.5"}),"Brokerage"]})]})]}),r==="my"&&!i&&e.jsx(h,{className:"border-amber-200 bg-amber-50 dark:border-amber-800 dark:bg-amber-950/30",children:e.jsx(p,{className:"pt-4",children:e.jsx("p",{className:"text-sm text-amber-800 dark:text-amber-200",children:"Your account is not linked to a party record. An admin can link your account on the Admin page to enable the personal view. Showing all brokerage data instead."})})}),e.jsxs("div",{className:"grid gap-2 md:gap-3 lg:gap-4 grid-cols-2 md:grid-cols-5",children:[e.jsx(M,{href:"/listings",className:"block","data-testid":"link-active-listings-card",children:e.jsxs(h,{className:"overflow-hidden h-full cursor-pointer transition-shadow hover:shadow-md hover:border-primary/40",children:[e.jsxs(g,{className:"flex flex-row items-center justify-between gap-1 space-y-0 p-3 pb-1 md:p-4 md:pb-1 lg:p-6 lg:pb-2",children:[e.jsx(u,{className:"text-xs md:text-xs lg:text-sm font-medium truncate",children:"Active Listings"}),e.jsx(U,{className:"h-3 w-3 md:h-3.5 md:w-3.5 lg:h-4 lg:w-4 text-muted-foreground shrink-0"})]}),e.jsxs(p,{className:"p-3 pt-0 md:p-4 md:pt-0 lg:p-6 lg:pt-0",children:[y?e.jsx(f,{className:"h-6 lg:h-8 w-12 lg:w-16"}):e.jsx("div",{className:"text-lg md:text-xl lg:text-2xl font-bold truncate","data-testid":"text-active-listings-count",children:C.length}),e.jsx("p",{className:"text-[10px] md:text-[10px] lg:text-xs text-muted-foreground mt-0.5 lg:mt-1 truncate",children:"Currently on market"})]})]})}),e.jsx(M,{href:"/listings",className:"block","data-testid":"link-potential-commission-card",children:e.jsxs(h,{className:"overflow-hidden h-full cursor-pointer transition-shadow hover:shadow-md hover:border-primary/40",children:[e.jsxs(g,{className:"flex flex-row items-center justify-between gap-1 space-y-0 p-3 pb-1 md:p-4 md:pb-1 lg:p-6 lg:pb-2",children:[e.jsx(u,{className:"text-xs md:text-xs lg:text-sm font-medium truncate",children:"Potential Commission"}),e.jsx(A,{className:"h-3 w-3 md:h-3.5 md:w-3.5 lg:h-4 lg:w-4 text-muted-foreground shrink-0"})]}),e.jsxs(p,{className:"p-3 pt-0 md:p-4 md:pt-0 lg:p-6 lg:pt-0",children:[y?e.jsx(f,{className:"h-6 lg:h-8 w-16 lg:w-24"}):e.jsxs("div",{className:"text-lg md:text-xl lg:text-2xl font-bold truncate","data-testid":"text-potential-commission",children:["$",q.toLocaleStr
1ing(void 0,{maximumFractionDigits:0})]}),e.jsx("p",{className:"text-[10px] md:text-[10px] lg:text-xs text-muted-foreground mt-0.5 lg:mt-1 truncate",children:"Active listing commissions"})]})]})}),e.jsx(M,{href:"/current-deals",className:"block","data-testid":"link-pending-deals-card",children:e.jsxs(h,{className:"overflow-hidden h-full cursor-pointer transition-shadow hover:shadow-md hover:border-primary/40",children:[e.jsxs(g,{className:"flex flex-row items-center justify-between gap-1 space-y-0 p-3 pb-1 md:p-4 md:pb-1 lg:p-6 lg:pb-2",children:[e.jsx(u,{className:"text-xs md:text-xs lg:text-sm font-medium truncate",children:"Pending Deals"}),e.jsx(B,{className:"h-3 w-3 md:h-3.5 md:w-3.5 lg:h-4 lg:w-4 text-muted-foreground shrink-0"})]}),e.jsxs(p,{className:"p-3 pt-0 md:p-4 md:pt-0 lg:p-6 lg:pt-0",children:[y?e.jsx(f,{className:"h-6 lg:h-8 w-12 lg:w-16"}):e.jsx("div",{className:"text-lg md:text-xl lg:text-2xl font-bold truncate","data-testid":"text-pending-deals-count",children:R.length}),e.jsx("p",{className:"text-[10px] md:text-[10px] lg:text-xs text-muted-foreground mt-0.5 lg:mt-1 truncate",children:"In progress"})]})]})}),e.jsx(M,{href:"/deals",className:"block","data-testid":"link-closed-deals-card",children:e.jsxs(h,{className:"overflow-hidden h-full cursor-pointer transition-shadow hover:shadow-md hover:border-primary/40",children:[e.jsxs(g,{className:"flex flex-row items-center justify-between gap-1 space-y-0 p-3 pb-1 md:p-4 md:pb-1 lg:p-6 lg:pb-2",children:[e.jsx(u,{className:"text-xs md:text-xs lg:text-sm font-medium truncate",children:"Closed Deals"}),e.jsx(Z,{className:"h-3 w-3 md:h-3.5 md:w-3.5 lg:h-4 lg:w-4 text-muted-foreground shrink-0"})]}),e.jsxs(p,{className:"p-3 pt-0 md:p-4 md:pt-0 lg:p-6 lg:pt-0",children:[y?e.jsx(f,{className:"h-6 lg:h-8 w-12 lg:w-16"}):e.jsx("div",{className:"text-lg md:text-xl lg:text-2xl font-bold truncate","data-testid":"text-closed-deals-count",children:E.length}),e.jsx("p",{className:"text-[10px] md:text-[10px] lg:text-xs text-muted-foreground mt-0.5 lg:mt-1 truncate",children:"Total closed"})]})]})}),e.jsx(M,{href:"/reports",className:"block col-span-2 md:col-span-1","data-testid":"link-total-volume-card",children:e.jsxs(h,{className:"overflow-hidden h-full cursor-pointer transition-shadow hover:shadow-md hover:border-primary/40",children:[e.jsxs(g,{className:"flex flex-row items-center justify-between gap-1 space-y-0 p-3 pb-1 md:p-4 md:pb-1 lg:p-6 lg:pb-2",children:[e.jsx(u,{className:"text-xs md:text-xs lg:text-sm font-medium truncate",children:"Total Volume"}),e.jsx(A,{className:"h-3 w-3 md:h-3.5 md:w-3.5 lg:h-4 lg:w-4 text-muted-foreground shrink-0"})]}),e.jsxs(p,{className:"p-3 pt-0 md:p-4 md:pt-0 lg:p-6 lg:pt-0",children:[y?e.jsx(f,{className:"h-6 lg:h-8 w-16 lg:w-24"}):e.jsxs("div",{className:"text-lg md:text-xl lg:text-2xl font-bold truncate","data-testid":"text-total-volume",children:["$",P.toLocaleString(void 0,{maximumFractionDigits:0})]}),e.jsx("p",{className:"text-[10px] md:text-[10px] lg:text-xs text-muted-foreground mt-0.5 lg:mt-1 truncate",children:"Closed deal volume"})]})]})})]}),e.jsxs("div",{className:"grid gap-4 md:grid-cols-2",children:[e.jsxs(h,{children:[e.jsx(g,{children:e.jsx(u,{className:"text-base",children:"Recent Deals"})}),e.jsx(p,{children:y?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(s=>e.jsx(f,{className:"h-12 w-full"},s))}):m.length>0?e.jsx("div",{className:"space-y-3",children:m.slice(0,5).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-2 border-b last:border-0 cursor-pointer hover:bg-muted/50 rounded px-2 -mx-2",onClick:()=>window.location.href=`/deals/${s.id}`,"data-testid":`row-deal-${s.id}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.dealName}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["#",s.dealNumber]})]}),e.jsx($,{variant:s.status==="CLOSED"?"default":"secondary",children:s.status})]},s.id))}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(I,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No deals yet"})]})})]}),e.jsxs(h,{children:[e.jsx(g,{children:e.jsx(u,{className:"text-base",children:"Active Listings"})}),e.jsx(p,{children:y?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(s=>e.jsx(f,{className:"h-12 w-full"},s))}):C.length>0?e.jsx("div",{className:"space-y-3",children:C.slice(0,5).map(s=>e.jsxs("div",{className:"flex items-center justify-between gap-2 py-2 border-b last:border-0 cursor-pointer hover:bg-muted/50 rounded px-2 -mx-2",onClick:()=>window.location.href=`/listings/${s.id}`,"data-testid":`row-listing-${s.id}`,children:[e.jsxs("div",{className:"min-w-0",children:[e.jsx("p",{className:"text-sm font-medium truncate",children:s.propertyName}),e.jsx("p",{className:"text-xs text-muted-foreground truncate",children:s.address})]}),e.jsx($,{variant:"secondary",children:s.listingType.replace(/_/g," ")})]},s.id))}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(I,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No active listings"})]})})]})]}),e.jsx(te,{}),e.jsx(ne,{})]})}const D=10;function te(){const[n,r]=o.useState("major"),[l,i]=o.useState(0);o.useEffect(()=>{i(0)},[n]);const a=l*D,{data:c,isLoading:j}=v({queryKey:["/api/activity-logs/recent",{limit:D,offset:a,major:n==="major"}],queryFn:async()=>{const d=new URLSearchParams({limit:String(D),offset:String(a),...n==="major"?{major:"true"}:{}}),t=await fetch(`/api/activity-logs/recent?${d}`,{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch");return t.json()}}),N=c?.logs||[],k=c?.total||0,b=Math.ceil(k/D);return e.jsxs(h,{"data-testid":"card-recent-changes",children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center justify-between",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(W,{className:"h-5 w-5 text-muted-foreground"}
1),e.jsx(u,{className:"text-base",children:"Recent Changes"})]}),e.jsxs("div",{className:"flex items-center gap-1 bg-muted rounded-lg p-0.5",children:[e.jsx(w,{size:"sm",variant:n==="major"?"default":"ghost",className:"h-7 text-xs px-3",onClick:()=>r("major"),"data-testid":"button-filter-major",children:"Major"}),e.jsx(w,{size:"sm",variant:n==="all"?"default":"ghost",className:"h-7 text-xs px-3",onClick:()=>r("all"),"data-testid":"button-filter-all",children:"All"})]})]})}),e.jsxs(p,{children:[j?e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(d=>e.jsx(f,{className:"h-10 w-full"},d))}):N.length>0?e.jsx("div",{className:"space-y-1",children:N.map(d=>{const t=re(d);return e.jsxs("div",{className:"flex items-start gap-3 py-2 border-b last:border-0","data-testid":`row-change-${d.id}`,children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("p",{className:"text-sm",children:[e.jsx("span",{className:"font-medium",children:d.userName})," ",e.jsx("span",{className:"text-muted-foreground",children:d.action})," ",e.jsx("span",{className:"font-medium capitalize",children:d.entityType})," #",d.entityId]}),t&&e.jsx("p",{className:"text-xs text-muted-foreground mt-0.5 truncate","data-testid":`text-change-detail-${d.id}`,children:t})]}),e.jsx("span",{className:"text-xs text-muted-foreground whitespace-nowrap shrink-0","data-testid":`text-change-time-${d.id}`,children:ae(d.createdAt)})]},d.id)})}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(I,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:["No ",n==="major"?"major ":"","changes"]})]}),b>1&&e.jsxs("div",{className:"flex items-center justify-between mt-4 pt-3 border-t",children:[e.jsxs("span",{className:"text-xs text-muted-foreground","data-testid":"text-changes-page-info",children:["Page ",l+1," of ",b]}),e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(w,{size:"icon",variant:"outline",className:"h-7 w-7",disabled:l===0,onClick:()=>i(l-1),"data-testid":"button-changes-prev",children:e.jsx(J,{className:"h-3 w-3"})}),e.jsx(w,{size:"icon",variant:"outline",className:"h-7 w-7",disabled:l>=b-1,onClick:()=>i(l+1),"data-testid":"button-changes-next",children:e.jsx(Q,{className:"h-3 w-3"})})]})]})]})]})}function ae(n){const r=new Date(n),i=new Date().getTime()-r.getTime(),a=Math.floor(i/6e4),c=Math.floor(i/36e5),j=Math.floor(i/864e5);return a<1?"Just now":a<60?`${a}m ago`:c<24?`${c}h ago`:j<7?`${j}d ago`:O(r,{month:"short",day:"numeric"})}function re(n){try{const r=JSON.parse(n.changes);if(typeof r=="object"&&!Array.isArray(r)){const l=[];for(const[i,a]of Object.entries(r)){const c=i.replace(/([A-Z])/g," $1").replace(/_/g," ").toLowerCase().trim();a&&typeof a=="object"&&"from"in a&&"to"in a?l.push(`${c}: ${a.from||"empty"} → ${a.to||"empty"}`):l.push(`${c}: ${a}`)}return l.join(", ")}return n.changes}catch{return n.changes}}const le={Industrial:"bg-slate-100 text-slate-800 dark:bg-slate-900 dark:text-slate-200","Market Trends":"bg-blue-100 text-blue-800 dark:bg-blue-900 dark:text-blue-200",Transactions:"bg-green-100 text-green-800 dark:bg-green-900 dark:text-green-200",Development:"bg-purple-100 text-purple-800 dark:bg-purple-900 dark:text-purple-200",Policy:"bg-orange-100 text-orange-800 dark:bg-orange-900 dark:text-orange-200",Economy:"bg-yellow-100 text-yellow-800 dark:bg-yellow-900 dark:text-yellow-200"};function ne(){const[n,r]=o.useState(!1),{data:l,isLoading:i}=v({queryKey:["/api/news/san-diego-cre"],staleTime:1440*60*1e3,refetchOnWindowFocus:!1}),{data:a,isLoading:c,refetch:j,isFetched:N}=v({queryKey:["/api/news/san-diego-cre","extended"],queryFn:async()=>{const t=await fetch("/api/news/san-diego-cre?extended=true",{credentials:"include"});if(!t.ok)throw new Error("Failed to fetch");return t.json()},staleTime:1440*60*1e3,refetchOnWindowFocus:!1,enabled:!1}),k=n&&a?a:l,b=l?.length??0,d=b>=5&&!(N&&(a?.length??0)<=b);return e.jsxs(h,{"data-testid":"card-cre-news",children:[e.jsx(g,{children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx(F,{className:"h-5 w-5 text-muted-foreground"}),e.jsx(u,{className:"text-base",children:"San Diego County CRE News"})]})}),e.jsx(p,{children:i?e.jsx("div",{className:"space-y-3",children:[1,2,3,4,5].map(t=>e.jsx(f,{className:"h-14 w-full"},t))}):l&&l.length>0?e.jsxs("div",{children:[e.jsx("div",{className:"space-y-3",children:k?.map((t,m)=>e.jsx("div",{className:"py-2 border-b last:border-0","data-testid":`news-item-${m}`,children:e.jsxs("div",{className:"flex items-start gap-2",children:[e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 mb-0.5",children:[e.jsx("p",{className:"text-sm font-medium",children:t.headline}),t.isLead&&e.jsx($,{className:"bg-red-600 text-white text-[9px] px-1.5 py-0 shrink-0","data-testid":`news-lead-${m}`,children:"Lead"})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:t.summary}),e.jsxs("div",{className:"flex items-center gap-2 mt-1 flex-wrap",children:[t.url&&e.jsxs("a",{href:t.url,target:"_blank",rel:"noopener noreferrer",className:"inline-flex items-center gap-1 text-xs text-blue-600 hover:text-blue-800 dark:text-blue-400 dark:hover:text-blue-300","data-testid":`news-link-${m}`,children:[t.source||"Read article"," ",e.jsx(K,{className:"h-3 w-3"})]}),t.pubDate&&e.jsx("span",{className:"text-[10px] text-muted-foreground","data-testid":`news-date-${m}`,children:O(t.pubDate,{month:"short",day:"numeric",year:"numeric"})})]})]}),e.jsx($,{variant:"outline",className:`text-[10px] shrink-0 ${le[t.category]||""}`,children:t.category})]})},m))}),n?e.jsxs(w,{variant:"ghost",size:"sm",className:"w-full mt-3 text-xs text-muted-foreground",onClick:()=>r(!1),"data-testid":"button-show-less-news",children:["Show Less ",e.jsx(X,{className:"h-3 w-3 ml-1"})]}):d&&e.jsx(w,{variant:"ghost",size:"sm",className:"w-full mt-3 text-xs text-muted-foreground",disabled:c,onClick:()=>{N&&a?r(!0):j().then(()=>r(!0))},"data-testid":"button-show-more-news",children:c?e.jsxs(e.Fragment,{children:["Loading... ",e.jsx(ee,{className:"h-3 w-3 ml-1 animate-spin"})]}):e.jsxs(e.Fragment,{children:["Show More ",e.jsx(Y,{className:"h-3 w-3 ml-1"})]})})]}):e.jsxs("div",{className:"flex flex-col items-center justify-center py-8 text-center",children:[e.jsx(F,{className:"h-8 w-8 text-muted-foreground mb-2"}),e.jsx("p",{className:"text-sm text-muted-foreground",children:"No news available"})]})})]})}export{we 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.