1import{m as V,r as d,j as e,ck as E,cl as W,cm as J,cn as C,bR as k,G as X,ag as Y,aD as j,aq as v,ap as b,B as p,co as Z,C as M,d as ee,bK as ae,ci as te,ar as se,O as re,D as N,n as y,o as w,p as S,y as A,E as I,L as P,aw as f,I as g}from"./index-C8Ua44hE.js";const F=V("UsersRound",[["path",{d:"M18 21a8 8 0 0 0-16 0",key:"3ypg7q"}],["circle",{cx:"10",cy:"8",r:"5",key:"o932ke"}],["path",{d:"M22 20c0-3.37-2-6.5-4-8a5 5 0 0 0-.45-8.3",key:"10s06x"}]]);var L="Avatar",[ne]=W(L),[ie,D]=ne(L),$=d.forwardRef((t,r)=>{const{__scopeAvatar:n,...i}=t,[o,s]=d.useState("idle");return e.jsx(ie,{scope:n,imageLoadingStatus:o,onImageLoadingStatusChange:s,children:e.jsx(E.span,{...i,ref:r})})});$.displayName=L;var q="AvatarImage",_=d.forwardRef((t,r)=>{const{__scopeAvatar:n,src:i,onLoadingStatusChange:o=()=>{},...s}=t,m=D(q,n),l=de(i,s),c=J(u=>{o(u),m.onImageLoadingStatusChange(u)});return C(()=>{l!=="idle"&&c(l)},[l,c]),l==="loaded"?e.jsx(E.img,{...s,ref:r,src:i}):null});_.displayName=q;var K="AvatarFallback",O=d.forwardRef((t,r)=>{const{__scopeAvatar:n,delayMs:i,...o}=t,s=D(K,n),[m,l]=d.useState(i===void 0);return d.useEffect(()=>{if(i!==void 0){const c=window.setTimeout(()=>l(!0),i);return()=>window.clearTimeout(c)}},[i]),m&&s.imageLoadingStatus!=="loaded"?e.jsx(E.span,{...o,ref:r}):null});O.displayName=K;function T(t,r){return t?r?(t.src!==r&&(t.src=r),t.complete&&t.naturalWidth>0?"loaded":"loading"):"error":"idle"}function de(t,{referrerPolicy:r,crossOrigin:n}){const i=oe(),o=d.useRef(null),s=i?(o.current||(o.current=new window.Image),o.current):null,[m,l]=d.useState(()=>T(s,t));return C(()=>{l(T(s,t))},[s,t]),C(()=>{const c=h=>()=>{l(h)};if(!s)return;const u=c("loaded"),x=c("error");return s.addEventListener("load",u),s.addEventListener("error",x),r&&(s.referrerPolicy=r),typeof n=="string"&&(s.crossOrigin=n),()=>{s.removeEventListener("load",u),s.removeEventListener("error",x)}},[s,n,r]),m}function le(){return()=>{}}function oe(){return d.useSyncExternalStore(le,()=>!0,()=>!1)}var B=$,U=_,z=O;const H=d.forwardRef(({className:t,...r},n)=>e.jsx(B,{ref:n,className:k(` 2 after:content-[''] after:block after:absolute after:inset-0 after:rounded-full after:pointer-events-none after:border after:border-black/10 dark:after:border-white/10 3 relative flex h-10 w-10 shrink-0 overflow-hidden rounded-full`,t),...r}));H.displayName=B.displayName;const me=d.forwardRef(({className:t,...r},n)=>e.jsx(U,{ref:n,className:k("aspect-square h-full w-full",t),...r}));me.displayName=U.displayName;const Q=d.forwardRef(({className:t,...r},n)=>e.jsx(z,{ref:n,className:k("flex h-full w-full items-center justify-center rounded-full bg-muted",t),...r}));Q.displayName=z.displayName;function ce(t){return t.split(" ").map(r=>r[0]).filter(Boolean).slice(0,2).join("").toUpperCase()}function R({initial:t,onSubmit:r,isPending:n}){const[i,o]=d.useState(t?.name||""),[s,m]=d.useState(t?.email||""),[l,c]=d.useState(t?.phone||""),[u,x]=d.useState(t?.role||""),h=a=>{a.preventDefault(),i.trim()&&r({name:i.trim(),email:s,phone:l,role:u})};return e.jsxs("form",{onSubmit:h,className:"space-y-4",children:[e.jsxs("div",{children:[e.jsx(f,{htmlFor:"member-name",children:"Name *"}),e.jsx(g,{id:"member-name",value:i,onChange:a=>o(a.target.value),placeholder:"Team member name",required:!0,"data-testid":"input-member-name"})]}),e.jsxs("div",{children:[e.jsx(f,{htmlFor:"member-email",children:"Email"}),e.jsx(g,{id:"member-email",type:"email",value:s,onChange:a=>m(a.target.value),placeholder:"[email protected]","data-testid":"input-member-email"})]}),e.jsxs("div",{children:[e.jsx(f,{htmlFor:"member-phone",children:"Phone"}),e.jsx(g,{id:"member-phone",value:l,onChange:a=>c(a.target.value),placeholder:"(503) 555-0100","data-testid":"input-member-phone"})]}),e.jsxs("div",{children:[e.jsx(f,{htmlFor:"member-role",children:"Role"}),e.jsx(g,{id:"member-role",value:u,onChange:a=>x(a.target.value),placeholder:"e.g. Installer, Estimator","data-testid":"input-member-role"})]}),e.jsx(I,{children:e.jsxs(p,{type:"submit",disabled:n||!i.trim(),"data-testid":"button-save-member",children:[n&&e.jsx(P,{className:"w-4 h-4 animate-spin mr-2"}),"Save"]})})]})}function ue(){const{toast:t}
3=X(),[r,n]=d.useState(!1),[i,o]=d.useState(null),[s,m]=d.useState(null),{data:l=[],isLoading:c}=Y({queryKey:["/api/team-members"]}),u=j({mutationFn:async a=>{await b("POST","/api/team-members",a)},onSuccess:()=>{v.invalidateQueries({queryKey:["/api/team-members"]}),t({title:"Team member added"}),n(!1)},onError:a=>{t({title:"Error",description:a.message,variant:"destructive"})}}),x=j({mutationFn:async({id:a,data:G})=>{await b("PATCH",`/api/team-members/${a}`,G)},onSuccess:()=>{v.invalidateQueries({queryKey:["/api/team-members"]}),t({title:"Team member updated"}),o(null)},onError:a=>{t({title:"Error",description:a.message,variant:"destructive"})}}),h=j({mutationFn:async a=>{await b("DELETE",`/api/team-members/${a}`)},onSuccess:()=>{v.invalidateQueries({queryKey:["/api/team-members"]}),t({title:"Team member deleted"}),m(null)},onError:a=>{t({title:"Error",description:a.message,variant:"destructive"})}});return e.jsxs(e.Fragment,{children:[e.jsxs("div",{className:"space-y-3",children:[e.jsxs("div",{className:"flex items-center justify-between gap-2 flex-wrap",children:[e.jsxs("h2",{className:"text-sm font-semibold text-muted-foreground uppercase tracking-wide","data-testid":"text-team-header",children:["Team Members (",l.length,")"]}),e.jsxs(p,{size:"sm",onClick:()=>n(!0),"data-testid":"button-add-member",children:[e.jsx(Z,{className:"w-4 h-4 mr-2"}),"Add Member"]})]}),c?e.jsx("div",{className:"space-y-3",children:[1,2,3].map(a=>e.jsx(M,{className:"p-4 animate-pulse",children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"w-10 h-10 rounded-full bg-muted"}),e.jsxs("div",{className:"flex-1",children:[e.jsx("div",{className:"h-4 bg-muted rounded w-1/3 mb-2"}),e.jsx("div",{className:"h-3 bg-muted rounded w-1/2"})]})]})},a))}):l.length===0?e.jsxs("div",{className:"text-center py-8",children:[e.jsx(F,{className:"w-10 h-10 mx-auto text-muted-foreground mb-3"}),e.jsx("p",{className:"text-muted-foreground text-sm mb-1",children:"No team members yet"}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Add your first team member to get started."})]}):e.jsx("div",{className:"space-y-3",children:l.map(a=>e.jsx(M,{className:"p-4","data-testid":`card-member-${a.id}`,children:e.jsxs("div",{className:"flex items-start gap-3",children:[e.jsx(H,{className:"w-10 h-10 shrink-0","data-testid":`avatar-member-${a.id}`,children:e.jsx(Q,{children:ce(a.name)})}),e.jsxs("div",{className:"flex-1 min-w-0",children:[e.jsxs("div",{className:"flex items-center gap-2 flex-wrap",children:[e.jsx("p",{className:"font-semibold text-sm truncate","data-testid":`text-member-name-${a.id}`,children:a.name}),a.role&&e.jsx(ee,{variant:"secondary",className:"text-xs","data-testid":`badge-member-role-${a.id}`,children:a.role})]}),a.email&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-1 text-xs text-muted-foreground",children:[e.jsx(ae,{className:"w-3.5 h-3.5 shrink-0"}),e.jsx("span",{className:"truncate","data-testid":`text-member-email-${a.id}`,children:a.email})]}),a.phone&&e.jsxs("div",{className:"flex items-center gap-1.5 mt-0.5 text-xs text-muted-foreground",children:[e.jsx(te,{className:"w-3.5 h-3.5 shrink-0"}),e.jsx("span",{"data-testid":`text-member-phone-${a.id}`,children:a.phone})]})]}),e.jsxs("div",{className:"flex items-center gap-1 shrink-0",children:[e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>o(a),"data-testid":`button-edit-member-${a.id}`,children:e.jsx(se,{className:"w-4 h-4"})}),e.jsx(p,{size:"icon",variant:"ghost",onClick:()=>m(a),"data-testid":`button-delete-member-${a.id}`,children:e.jsx(re,{className:"w-4 h-4"})})]})]})},a.id))})]}),e.jsx(N,{open:r,onOpenChange:n,children:e.jsxs(y,{children:[e.jsxs(w,{children:[e.jsx(S,{children:"Add Team Member"}),e.jsx(A,{children:"Add a new member to your team."})]}),e.jsx(R,{onSubmit:a=>u.mutate(a),isPending:u.isPending})]})}),e.jsx(N,{open:i!==null,onOpenChange:a=>{a||o(null)},children:e.jsxs(y,{children:[e.jsxs(w,{children:[e.jsx(S,{children:"Edit Team Member"}),e.jsx(A,{children:"Update team member information."})]}),i&&e.jsx(R,{initial:i,onSubmit:a=>x.mutate({id:i.id,data:a}),isPending:x.isPending},i.id)]})}),e.jsx(N,{open:s!==null,onOpenChange:a=>{a||m(null)},children:e.jsxs(y,{children:[e.jsxs(w,{children:[e.jsx(S,{children:"Delete Team Member"}),e.jsxs(A,{children:["Are you sure you want to delete ",s?.name,"? This action cannot be undone."]})]}),e.jsxs(I,{className:"gap-2",children:[e.jsx(p,{variant:"outline",onClick:()=>m(null),"data-testid":"button-cancel-delete-member",children:"Cancel"}),e.jsxs(p,{variant:"destructive",onClick:()=>s&&h.mutate(s.id),disabled:h.isPending,"data-testid":"button-confirm-delete-member",children:[h.isPending&&e.jsx(P,{className:"w-4 h-4 animate-spin mr-2"}),"Delete"]})]})]})})]})}function he(){return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsx("header",{className:"sticky top-0 z-50 border-b bg-primary text-primary-foreground",children:e.jsxs("div",{className:"max-w-2xl mx-auto flex items-center gap-2 px-4 py-3",children:[e.jsx(F,{className:"w-5 h-5"}),e.jsx("h1",{className:"text-lg font-semibold tracking-tight","data-testid":"text-team-title",children:"Team Members"})]})}),e.jsx("main",{className:"max-w-2xl mx-auto px-4 pb-24 pt-4",children:e.jsx(ue,{})})]})}export{ue as TeamMembersSection,he 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.