PageSourceSearch

https://zesyn.com/assets/Users-k8HSB6k-.js

js zesyn.com collected 2026-10-05 06:34:04 UTC 5,663 bytes, 4 lines download raw bytes

1import{u as f,r as p,j as e,H as k,a as u}from"./app-oX4QP5ax.js";import{C as w,a as j,T as h,B as b}from"./ConsoleLayout-DLjWPZbw.js";import{S as g}from"./Select-Cm9VNKb-.js";import{R as y}from"./RolesEditor-BoNjiB12.js";/* empty css            */import"./Popover-cz4MumCG.js";import"./DateField-BaBuvly0.js";import"./Confirm-C_aoRp_J.js";function L({people:x=[],roles:n=[],catalogue:m,urls:c}){var o,a;const{props:s}=f(),[t,i]=p.useState("people");return e.jsxs(w,{title:"Users & roles",groups:(o=s.console)==null?void 0:o.groups,user:(a=s.console)==null?void 0:a.user,lead:"Who can sign in, and what each of them may do. Accounts are created here — there is no sign-up.",breadcrumb:[{label:"System"},{label:"Users & roles"}],children:[e.jsx(k,{title:"Users & roles"}),e.jsx("div",{className:"mb-3 flex gap-1.5",children:["people","roles"].map(l=>e.jsxs("button",{onClick:()=>i(l),className:`rounded-full border px-3.5 py-[5px] text-[12px] font-[580] capitalize
2                        ${t===l?"border-brand bg-brand text-white":"border-line-2 bg-paper text-ink-3 hover:border-brand-2 hover:text-brand"}`,children:[l," ",l==="people"?x.length:n.length]},l))}),t==="people"?e.jsx(S,{people:x,roles:n,save:c.saveUser,invite:c.invite}):e.jsx(y,{roles:n,catalogue:m,save:c.saveRole})]})}function S({people:x,roles:n,save:m,invite:c}){const[s,t]=p.useState(null),[i,o]=p.useState(""),[a,l]=p.useState({}),v=()=>{u.post(m,{...s,password:i||null},{preserveScroll:!0,onSuccess:()=>{t(null),o(""),l({})},onError:r=>l(r)})};return e.jsxs("div",{className:"grid items-start gap-3 xl:grid-cols-[minmax(0,1fr)_340px]",children:[e.jsx(j,{className:"overflow-hidden",children:e.jsxs("table",{className:"w-full border-collapse text-[13px]",children:[e.jsx("thead",{children:e.jsx("tr",{children:["Person","Role","Two-factor","Last active",""].map((r,d)=>e.jsx("th",{className:`whitespace-nowrap border-b border-line pb-[10px] pr-[14px] text-left
3                              font-mono text-[9.5px] font-medium uppercase tracking-[.12em] text-ink-4
4                              ${d===0?"pl-5":""} ${d===4?"pr-5 text-right":""}`,children:r},r||d))})}),e.jsx("tbody",{children:x.map(r=>e.jsxs("tr",{className:"transition-colors hover:bg-paper-2",children:[e.jsxs("td",{className:"border-b border-line py-3 pl-5 pr-[14px]",children:[e.jsx("div",{className:"font-[620] text-ink",children:r.name}),e.jsx("div",{className:"mt-0.5 font-mono text-[10.5px] text-ink-4",children:r.email})]}),e.jsxs("td",{className:"border-b border-line py-3 pr-[14px]",children:[r.role??e.jsx("span",{className:"text-amber",children:"No role"}),!r.active&&e.jsx("div",{className:"mt-1",children:e.jsx(h,{tone:"warn",children:"Deactivated"})})]}),e.jsx("td",{className:"border-b border-line py-3 pr-[14px]",children:r.twoFactor?e.jsx(h,{tone:"published",children:"On"}):e.jsx(h,{tone:"warn",children:"Not set up"})}),e.jsx("td",{className:"border-b border-line py-3 pr-[14px] text-ink-3",children:r.lastActive??"Never"}),e.jsxs("td",{className:"whitespace-nowrap border-b border-line py-3 pr-5 text-right",children:[r.active&&e.jsx(b,{small:!0,variant:"ghost",onClick:()=>u.post(c.replace("__id__",String(r.id)),{},{preserveScroll:!0}),children:"Send password link"}),e.jsx(b,{small:!0,variant:"ghost",onClick:()=>{t(r),o("")},children:"Edit"})]})]},r.id))})]})}),e.jsxs(j,{className:"xl:sticky xl:top-[68px]",children:[e.jsxs("div",{className:"flex items-center gap-2 border-b border-line px-4 py-3.5",children:[e.jsx("h2",{children:s!=null&&s.id?"Edit person":"Add someone"}),(s==null?void 0:s.id)&&e.jsx("button",{onClick:()=>t(null),className:"ml-auto text-[12px] text-ink-4 hover:text-ink",children:"New instead"})]}),e.jsxs("div",{className:"grid gap-3.5 px-4 py-4",children:[[["name","Name"],["email","Email"]].map(([r,d])=>e.jsxs("div",{children:[e.jsx("label",{className:"mb-[7px] block text-[12.5px] font-[620] text-ink-2",children:d}),e.jsx("input",{className:"zc-inp",value:String((s==null?void 0:s[r])??""),onChange:N=>t({...s,[r]:N.target.value})}),a[r]&&e.jsx("p",{className:"mt-1.5 text-[11.5px] text-red",children:a[r]})]},r)),e.jsxs("div",{children:[e.jsx("label",{className:"mb-[7px] block text-[12.5px] font-[620] text-ink-2",children:"Role"}),e.jsx(g,{value:(s==null?void 0:s.roleId)??"",options:n.map(r=>({value:String(r.id),label:r.name})),placeholder:"Choose a role",onChange:r=>t({...s,roleId:Number(r)})}),a.role_id&&e.jsx("p",{className:"mt-1.5 text-[11.5px] text-red",children:a.role_id})]}),e.jsxs("div",{children:[e.jsx("label",{className:"mb-[7px] block text-[12.5px] font-[620] text-ink-2",children:s!=null&&s.id?"New password":"Password"}),e.jsx("input",{className:"zc-inp",type:"password",value:i,onChange:r=>o(r.target.value),placeholder:s!=null&&s.id?"Leave blank to keep the current one":"Leave blank and we email them a link"}),a.password&&e.jsx("p",{className:"mt-1.5 text-[11.5px] text-red",children:a.password}),!(s!=null&&s.id)&&!i&&e.jsx("p",{className:"mt-1.5 text-[11.5px] leading-[1.5] text-ink-4",children:"They get a link to choose their own, good for three days. Nobody — including you — ever sees it."})]}),e.jsxs("label",{className:"flex cursor-pointer items-center gap-2 text-[12.5px] text-ink-2",children:[e.jsx("input",{type:"checkbox",className:"h-4 w-4 accent-brand",checked:(s==null?void 0:s.active)??!0,onChange:r=>t({...s,active:r.target.checked})}),"Can sign in"]}),e.jsx(b,{onClick:v,children:s!=null&&s.id?"Save":"Add person"}),e.jsx("p",{className:"text-[11.5px] leading-[1.5] text-ink-4",children:"Two-factor is set up by the person themselves on first sign-in, and cannot be skipped in production."})]})]})]})}export{L 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.