PageSourceSearch

https://propvault.com/assets/settings.workspace-CYpGCNWu.js

js propvault.com collected 2026-10-09 22:59:06 UTC 12,380 bytes, 1 lines download raw bytes

1import{b as E,e as H,s as D,j as e,F as b,H as j,J as v,u as K,a as Y,a1 as X,c as g,r as h,bG as Z,f as ee,L as f,I as A,a9 as W,aa as P,ab as C,ac as F,ad as m,B as y,a0 as l,a3 as _}from"./index-BfBkqBNq.js";import{R as ae}from"./RouteAccessGate-C0VIE1N9.js";import{u as re}from"./use-org-settings-CJSsrHta.js";import{D as L}from"./DashboardLayout-CA1yfd_w.js";import{u as se,b as te}from"./use-tolerances-BCt2J6U3.js";import{T as ne}from"./TolerancesEditor-BX2zzY-Z.js";import"./lock-S7ewUMH1.js";import"./useMutation-uz6_FsvD.js";import"./report-xlsx-0elmp6kq.js";import"./triangle-alert-eBrbmV7z.js";import"./x-mOM0OqM8.js";import"./printer--topBers.js";import"./index-Du5FxyQ2.js";import"./PropVaultLogo-CExv2j-M.js";import"./building-2-BMaXS4Y1.js";import"./invites.functions-BP_ptYw7.js";import"./property-types-C5jQJUds.js";function oe(){const{data:n}=E();return H({queryKey:["org-usage",n?.id],enabled:!!n?.id,queryFn:async()=>{const[s,c]=await Promise.all([D.from("organization_usage").select("*").eq("organization_id",n.id).maybeSingle(),D.from("organizations").select("plan, seat_limit, property_limit, statement_limit_monthly").eq("id",n.id).maybeSingle()]);if(s.error)throw s.error;if(c.error)throw c.error;return!s.data||!c.data?null:{member_count:Number(s.data.member_count??0),active_property_count:Number(s.data.active_property_count??0),statements_this_month:Number(s.data.statements_this_month??0),seat_limit:c.data.seat_limit,property_limit:c.data.property_limit,statement_limit_monthly:c.data.statement_limit_monthly,plan:c.data.plan}}})}function ce(){const{data:n}=E(),s=n?.role==="owner",c=n?.role==="bookkeeper",t=s||c,u=se(),i=te();return e.jsxs("section",{className:"rounded-lg border border-border p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Tolerance defaults"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Values outside these min/max ranges are highlighted in red on reports. Leave blank to skip a field. These apply across every property unless a property defines its own override."})]}),e.jsx(ne,{rows:u.data??[],readOnly:!t,onSave:k=>i.mutateAsync(k),emptyHint:"No defaults set yet — fill in any field below to start flagging out-of-range values."})]})}const le=b({method:"GET"}).middleware([j]).handler(v("74391b3e33687588ed59ce948837a71053dd48310d3f9e3d165803307e75a0c9")),ie=b({method:"POST"}).middleware([j]).handler(v("34cfc187a55081a458c6aeb19a2519211c2682bbd47e44f5189a3493f18f1ad2")),de=b({method:"POST"}).middleware([j]).handler(v("c2a5404e769461a4f522977429cc49dfa4b025c742a7edaceae34fed2de6626f")),me=b({method:"GET"}).middleware([j]).handler(v("2ac17bf80454c279b36f512c238318742bc57c51873124c2a74807a7987eca78")),ue=b({method:"POST"}).middleware([j]).handler(v("78efd4df3f0b1234cbe82c2b89a9991a1f6413d9df7f50f3a23788a80758b801"));function Fe(){return e.jsx(ae,{path:"/settings/workspace",children:e.jsx(he,{})})}const pe=["January","February","March","April","May","June","July","August","September","October","November","December"];function O(n,s){return s==null?`${n}`:s===0?`${n} (unlimited)`:`${n} / ${s}`}function he(){const{user:n,loading:s}=K(),c=Y(),{data:t}=E(),u=re(),i=oe(),k=X(),d=t?.role==="owner",R=g(le),U=g(ie),q=g(de),I=g(me),B=g(ue),[S,G]=h.useState(null),[M,Q]=h.useState(null),[N,x]=h.useState(null),w=async()=>{if(t?.id)try{const[a,o]=await Promise.all([R({data:{organizationId:t.id}}),I({data:{organizationId:t.id}})]);G(a),Q(o)}catch(a){l.error(_(a,"We couldn't load workspace memory."))}};h.useEffect(()=>{t?.id&&w()},[t?.id]);const V=async a=>{x(a);try{await U({data:{id:a}}),l.success("Approved — now a workspace-wide convention."),await w()}catch(o){l.error(_(o,"We couldn't approve that memory."))}finally{x(null)}},z=async a=>{x(a);try{await q({data:{id:a}}),l.success("Removed."),await w()}catch(o){l.error(_(o,"We couldn't remove that memory."))}finally{x(null)}},J=async a=>{x(a);try{await B({data:{id:a}}),l.success("Removed."),await w()}catch(o){l.error(_(o,"We couldn't remove that preference."))}finally{x(null)}},[r,p]=h.useState({workspace_name:"",report_brand_name:"",report_accent_color:"",currency:"USD",fiscal_year_start_month:1,default_noi_convention:""});h.useEffect(()=>{!s&&!n&&c({to:"/login"})},[s,n,c]),h.useEffect(()=>{const a=u.data;a&&p(o=>({...o,report_brand_name:a.report_brand_name??"",report_accent_color:a.report_accent_color??"",currency:a.currency,fiscal_year_start_month:a.fiscal_year_start_month,default_noi_convention:a.default_noi_convention??""}))},[u.data]),h.useEffect(()=>{t?.name&&p(a=>({...a,workspace_name:t.name}))},[t?.name]);const $=async()=>{try{const a=r.workspace_name.trim();if(!a){l.error("Workspace name can't be empty");return}if(a.length>80){l.error("Workspace name must be 80 characters or fewer");return}if(t&&a!==t.name){const{error:o}=await D.from("organizations").update({name:a}).eq("id",t.id);if(o)throw o}await u.update.mutateAsync({report_brand_name:r.report_brand_name||null,report_accent_color:r.report_accent_color||null,currency:r.currency,fiscal_year_start_month:r.fiscal_year_start_month,default_noi_convention:r.default_noi_convention||null}),await k.invalidateQueries({queryKey:["memberships"]}
1),l.success("Workspace settings saved")}catch(a){l.error(_(a,"We couldn't save your workspace settings. Try again in a moment."))}};return s||u.isLoading?e.jsx(L,{children:e.jsx("p",{className:"text-muted-foreground",children:"Loading…"})}):e.jsx(L,{children:e.jsxs("div",{className:"mx-auto max-w-3xl space-y-8",children:[e.jsxs("div",{className:"flex items-baseline justify-between",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold",children:"Workspace"}),e.jsxs("p",{className:"text-sm text-muted-foreground",children:[t?.name??"Your workspace",Z(t?.role)&&e.jsxs(e.Fragment,{children:[" · plan ",e.jsx("span",{className:"capitalize",children:i.data?.plan??"—"})]})]})]}),e.jsx(ee,{to:"/settings/team",className:"text-sm text-primary hover:underline",children:"Manage team →"})]}),e.jsxs("section",{className:"grid gap-3 sm:grid-cols-3",children:[e.jsx(T,{label:"Members",value:O(i.data?.member_count??0,i.data?.seat_limit)}),e.jsx(T,{label:"Active properties",value:O(i.data?.active_property_count??0,i.data?.property_limit)}),e.jsx(T,{label:"Statements this month",value:O(i.data?.statements_this_month??0,i.data?.statement_limit_monthly)})]}),e.jsxs("section",{className:"rounded-lg border border-border p-4 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Workspace"}),e.jsxs("div",{className:"space-y-1 sm:max-w-md",children:[e.jsx(f,{htmlFor:"workspace-name",children:"Workspace name"}),e.jsx(A,{id:"workspace-name",value:r.workspace_name,onChange:a=>p({...r,workspace_name:a.target.value}),placeholder:"e.g. South Peak Group",maxLength:80,disabled:!d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown in the sidebar and workspace switcher."})]})]}),e.jsxs("section",{className:"rounded-lg border border-border p-4 space-y-4",children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Branding & report defaults"}),e.jsxs("div",{className:"grid gap-4 sm:grid-cols-2",children:[e.jsxs("div",{className:"space-y-1",children:[e.jsx(f,{htmlFor:"brand-name",children:"Report brand name"}),e.jsx(A,{id:"brand-name",value:r.report_brand_name,onChange:a=>p({...r,report_brand_name:a.target.value}),placeholder:t?.name??"",disabled:!d}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Shown at the top of generated reports."})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(f,{htmlFor:"accent",children:"Accent color"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(A,{id:"accent",value:r.report_accent_color,onChange:a=>p({...r,report_accent_color:a.target.value}),placeholder:"#0ea5e9",disabled:!d}),r.report_accent_color&&e.jsx("div",{className:"h-9 w-9 rounded border border-border",style:{background:r.report_accent_color}})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(f,{children:"Currency"}),e.jsxs(W,{value:r.currency,onValueChange:a=>p({...r,currency:a}),disabled:!d,children:[e.jsx(P,{children:e.jsx(C,{})}),e.jsxs(F,{children:[e.jsx(m,{value:"USD",children:"USD — US Dollar"}),e.jsx(m,{value:"EUR",children:"EUR — Euro"}),e.jsx(m,{value:"GBP",children:"GBP — British Pound"}),e.jsx(m,{value:"CAD",children:"CAD — Canadian Dollar"}),e.jsx(m,{value:"AUD",children:"AUD — Australian Dollar"})]})]})]}),e.jsxs("div",{className:"space-y-1",children:[e.jsx(f,{children:"Fiscal year starts"}),e.jsxs(W,{value:String(r.fiscal_year_start_month),onValueChange:a=>p({...r,fiscal_year_start_month:Number(a)}),disabled:!d,children:[e.jsx(P,{children:e.jsx(C,{})}),e.jsx(F,{children:pe.map((a,o)=>e.jsx(m,{value:String(o+1),children:a},o))})]})]}),e.jsxs("div",{className:"space-y-1 sm:col-span-2",children:[e.jsx(f,{children:"Default NOI convention"}),e.jsxs(W,{value:r.default_noi_convention||"_none",onValueChange:a=>p({...r,default_noi_convention:a==="_none"?"":a}),disabled:!d,children:[e.jsx(P,{children:e.jsx(C,{placeholder:"Per-property"})}),e.jsxs(F,{children:[e.jsx(m,{value:"_none",children:"Per-property (no default)"}),e.jsx(m,{value:"recoverable_only",children:"Recoverable expenses only"}),e.jsx(m,{value:"all_opex",children:"All operating expenses"})]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Falls back to whatever's set on each property if left blank."})]})]}),d&&e.jsx("div",{className:"flex justify-end",children:e.jsx(y,{onClick:$,disabled:u.update.isPending,children:u.update.isPending?"Saving…":"Save"})}),!d&&e.jsx("p",{className:"text-xs text-muted-foreground",children:"Only workspace owners can change these settings."})]}),e.jsx(ce,{}),e.jsxs("section",{className:"rounded-lg border border-border p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"Worksp
1ace memory"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Advisory notes the AI assistant has recorded about this workspace — conventions and quirks it uses to shape how it talks, never a source of numbers."})]}),S===null?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):S.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing recorded yet."}):e.jsx("ul",{className:"space-y-3",children:S.map(a=>e.jsxs("li",{className:"rounded-md border border-border p-3 space-y-2",children:[e.jsx("p",{className:"text-sm",children:a.content}),e.jsxs("p",{className:"text-xs text-muted-foreground",children:["Told by ",a.created_by_name??"a workspace member"," (",a.created_by_role,") ·"," ",a.created_at.slice(0,10)," ·"," ",a.status==="confirmed"?"confirmed":"pending approval"]}),e.jsxs("div",{className:"flex gap-2",children:[a.status==="proposed"&&d&&e.jsx(y,{size:"sm",variant:"outline",disabled:N===a.id,onClick:()=>V(a.id),children:"Approve"}),a.status==="proposed"?e.jsx(y,{size:"sm",variant:"ghost",disabled:N===a.id,onClick:()=>z(a.id),children:"Dismiss"}):e.jsx(y,{size:"sm",variant:"ghost",disabled:N===a.id,onClick:()=>z(a.id),children:"Forget"})]})]},a.id))})]}),e.jsxs("section",{className:"rounded-lg border border-border p-4 space-y-4",children:[e.jsxs("div",{children:[e.jsx("h2",{className:"text-sm font-semibold",children:"My preferences"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Personal preferences the AI assistant has recorded for just you — visible only to you."})]}),M===null?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Loading…"}):M.length===0?e.jsx("p",{className:"text-sm text-muted-foreground",children:"Nothing recorded yet."}):e.jsx("ul",{className:"space-y-3",children:M.map(a=>e.jsxs("li",{className:"rounded-md border border-border p-3 space-y-2",children:[e.jsx("p",{className:"text-sm",children:a.content}),e.jsx("p",{className:"text-xs text-muted-foreground",children:a.created_at.slice(0,10)}),e.jsx(y,{size:"sm",variant:"ghost",disabled:N===a.id,onClick:()=>J(a.id),children:"Forget"})]},a.id))})]})]})})}function T({label:n,value:s}){return e.jsxs("div",{className:"rounded-lg border border-border p-3",children:[e.jsx("p",{className:"text-xs uppercase tracking-wide text-muted-foreground",children:n}),e.jsx("p",{className:"mt-1 text-xl font-semibold",children:s})]})}export{Fe as component};

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.