PageSourceSearch

https://smartmanageai.ai/assets/PlatformOrganizations-Bhlcrmdh.js

js smartmanageai.ai collected 2026-10-05 15:07:12 UTC 7,845 bytes, 1 lines download raw bytes

1import{r as s,j as e}from"./vendor-react-DKbe1Umz.js";import{a as U,u as W}from"./vendor-data-CjSe2wkl.js";import{y as Y,u as K,r as F,B as m,C as Q,s as X,I as c,S as D,g as z,h as G,i as M,j as T,v as Z,aG as J,l as g,D as ee,c as ae,d as se,e as te,L as o,n as re,q as ne,o as le}from"./index-DZ74KeH3.js";import{T as ie,a as ce,b as y,c as r,d as oe,e as t}from"./table-CAeITjOT.js";import{cr as de,b3 as me,a8 as he,bz as xe,$ as ue,E as ge}from"./vendor-ui-DMaW9-Ov.js";import{a as je}from"./vendor-dates-5UNeOyFW.js";import"./vendor-charts-DWX9qznF.js";import"./vendor-forms-C2vWC2ab.js";function Ee(){const{user:n,logout:pe,organizationName:Ne}=Y(),{toast:O}=K(),[j,B]=s.useState(""),[p,q]=s.useState("all"),[H,h]=s.useState(!1),[d,w]=s.useState(""),[x,N]=s.useState(""),[S,E]=s.useState("GENERAL_CONTRACTOR"),[R,b]=s.useState(""),[A,L]=s.useState(""),[I,P]=s.useState(""),f=a=>a.trim().toLowerCase().replace(/[^a-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,""),C=U({mutationFn:async a=>await(await le("POST","/api/platform/organizations",a)).json(),onSuccess:()=>{ne.invalidateQueries({queryKey:["/api/platform/organizations"]}),h(!1),w(""),N(""),E("GENERAL_CONTRACTOR"),b(""),L(""),P(""),O({title:"Organization created",description:"The new organization has been created successfully."})},onError:a=>{O({title:"Failed to create organization",description:a.message,variant:"destructive"})}}),{data:l,isLoading:V}=W({queryKey:["/api/platform/organizations"]});n&&`${n.firstName}${n.lastName}`,n!=null&&n.role;const v={GENERAL_CONTRACTOR:"General Contractor",ROOFING:"Roofing",ELECTRICAL:"Electrical",PLUMBING:"Plumbing",HVAC:"HVAC",CONCRETE:"Concrete",CARPENTRY:"Carpentry",MASONRY:"Masonry",DRYWALL:"Drywall",PAINTING:"Painting",FLOORING:"Flooring",LANDSCAPING:"Landscaping",EXCAVATION:"Excavation",DEMOLITION:"Demolition",STEEL_ERECTION:"Steel Erection",GLAZING:"Glazing",INSULATION:"Insulation",FIRE_PROTECTION:"Fire Protection",WATERPROOFING:"Waterproofing",OTHER:"Other"},i=l==null?void 0:l.filter(a=>{const u=a.name.toLowerCase().includes(j.toLowerCase())||a.slug.toLowerCase().includes(j.toLowerCase()),k=p==="all"||a.tradeType===p;return u&&k}),_=Array.from(new Set((l==null?void 0:l.map(a=>a.tradeType))||[])),$=a=>{switch(a){case"COMPLETED":return e.jsx(g,{variant:"default",children:"Active"});case"IN_PROGRESS":return e.jsx(g,{variant:"secondary",children:"Onboarding"});default:return e.jsx(g,{variant:"outline",children:"Not Started"})}};return e.jsxs("div",{className:"min-h-screen bg-background",children:[e.jsxs("main",{className:"px-3 sm:px-6 py-4 sm:py-6 space-y-6",children:[e.jsxs("div",{className:"flex flex-col sm:flex-row sm:items-center gap-3 sm:gap-4",children:[e.jsx(F,{href:"/admin",children:e.jsxs(m,{variant:"ghost",size:"sm",children:[e.jsx(de,{className:"h-4 w-4 mr-1"}),"Back"]})}),e.jsxs("div",{className:"flex-1",children:[e.jsx("h1",{className:"text-xl sm:text-2xl font-bold","data-testid":"text-organizations-title",children:"Organizations"}),e.jsx("p",{className:"text-muted-foreground text-sm",children:"Manage all contractor companies on the platform"})]}),e.jsxs(m,{onClick:()=>h(!0),className:"w-full sm:w-auto","data-testid":"button-create-org",children:[e.jsx(me,{className:"h-4 w-4 mr-2"}),"Create Organization"]})]}),e.jsxs(Q,{children:[e.jsx(X,{children:e.jsxs("div",{className:"flex flex-col md:flex-row gap-4 justify-between",children:[e.jsxs("div",{className:"relative flex-1 max-w-sm",children:[e.jsx(he,{className:"absolute left-3 top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground"}),e.jsx(c,{placeholder:"Search organizations...",value:j,onChange:a=>B(a.target.value),className:"pl-9","data-testid":"input-search-orgs"})]}),e.jsxs(D,{value:p,onValueChange:q,children:[e.jsx(z,{className:"w-full sm:w-[200px]","data-testid":"select-trade-filter",children:e.jsx(G,{placeholder:"Filter by trade"})}),e.jsxs(M,{children:[e.jsx(T,{value:"all",children:"All Trades"}),_.map(a=>e.jsx(T,{value:a,children:v[a]||a},a))]})]})]})}),e.jsx(Z,{children:V?e.jsx("div",{className:"space-y-4",children:[1,2,3,4,5].map(a=>e.jsx(J,{className:"h-16 w-full"},a))}):e.jsx("div",{className:"overflow-x-auto -mx-3 sm:-mx-6 px-3 sm:px-6",children:e.jsxs(ie,{children:[e.jsx(ce,{children:e.jsxs(y,{children:[e.jsx(r,{children:"Organization"}),e.jsx(r,{children:"Trade"}),e.jsx(r,{children:"Users"}),e.jsx(r,{children:"Status"}),e.jsx(r,{children:"Region"}),e.jsx(r,{children:"Created"}),e.jsx(r,{})]})}),e.jsxs(oe,{children:[i==null?void 0:i.map(a=>e.jsxs(y,{"data-testid":`row-org-${a.id}`,children:[e.jsx(t,{children:e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("div",{className:"h-10 w-10 rounded-md bg-primary/10 flex items-center justify-center",children:e.jsx(xe,{className:"h-5 w-5 text-primary"})}),e.jsxs("div",{children:[e.jsx("div",{className:"font-medium",children:a.name}),e.jsx("div",{className:"text-sm text-muted-foreground",children:a.slug})]})]})}),e.jsx(t,{children:e.jsx(g,{variant:"outline",children:v[a.tradeType]||a.tradeType})}),e.jsx(t,{children:e.jsxs("div",{className:"flex items-center gap-1",children:[e.jsx(ue,{className:"h-4 w-4 text-muted-foreground"}),e.jsx("span",{children:a.userCount})]})}),e.jsx(t,{children:$(a.onboardingStatus)}),e.jsx(t,{children:a.region||"-"}),e.jsx(t,{children:je(new Date(a.createdAt),"MMM d, yyyy")}),e.jsx(t,{children:e.jsx(F,{href:`/admin/organizations/${a.id}`,children:e.jsxs(m,{variant:"ghost",size:"sm","data-testid":`button-view-org-${a.id}`,children:["View ",e.jsx(ge,{className:"ml-1 h-3 w-3"})]})})})]},a.id)),(i==null?void 0:i.length)===0&&e.jsx(y,{children:e.jsx(t,{colSpan:7,className:"text-center py-8 text-muted-foreground",children:"No organizations foun
1d"})})]})]})})})]})]}),e.jsx(ee,{open:H,onOpenChange:h,children:e.jsxs(ae,{className:"sm:max-w-md",children:[e.jsx(se,{children:e.jsx(te,{children:"Create Organization"})}),e.jsxs("form",{onSubmit:a=>{a.preventDefault(),C.mutate({name:d,slug:x||f(d),tradeType:S,region:R,email:A,phone:I})},className:"space-y-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"org-name",children:"Name *"}),e.jsx(c,{id:"org-name",value:d,onChange:a=>{w(a.target.value),(!x||x===f(d))&&N(f(a.target.value))},placeholder:"Acme Construction",required:!0,"data-testid":"input-org-name"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"org-slug",children:"Slug"}),e.jsx(c,{id:"org-slug",value:x,onChange:a=>N(a.target.value),placeholder:"acme-construction","data-testid":"input-org-slug"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"org-trade",children:"Trade Type"}),e.jsxs(D,{value:S,onValueChange:E,children:[e.jsx(z,{"data-testid":"select-org-trade",children:e.jsx(G,{placeholder:"Select trade type"})}),e.jsx(M,{children:Object.entries(v).map(([a,u])=>e.jsx(T,{value:a,children:u},a))})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"org-region",children:"Region"}),e.jsx(c,{id:"org-region",value:R,onChange:a=>b(a.target.value),placeholder:"Northeast US","data-testid":"input-org-region"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"org-email",children:"Email"}),e.jsx(c,{id:"org-email",type:"email",value:A,onChange:a=>L(a.target.value),placeholder:"[email protected]","data-testid":"input-org-email"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(o,{htmlFor:"org-phone",children:"Phone"}),e.jsx(c,{id:"org-phone",value:I,onChange:a=>P(a.target.value),placeholder:"(555) 123-4567","data-testid":"input-org-phone"})]}),e.jsxs(re,{children:[e.jsx(m,{type:"button",variant:"outline",onClick:()=>h(!1),"data-testid":"button-cancel-create-org",children:"Cancel"}),e.jsx(m,{type:"submit",disabled:!d.trim()||C.isPending,"data-testid":"button-submit-create-org",children:C.isPending?"Creating...":"Create"})]})]})]})})]})}export{Ee 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.