PageSourceSearch

https://app.koras.ai/assets/MemberProjectsPage-CEAJw48f.js

js koras.ai collected 2026-10-05 12:54:21 UTC 6,832 bytes, 1 lines download raw bytes

1import{q as B,r as x,j as e,S as F,L as T,U as $,aj as u,p as L,z as b}from"./index-B6m3Aicq.js";import{C as v}from"./Card-wylR0N6D.js";import{B as N}from"./Button-B9aTxEp6.js";import{S as U}from"./Select-Byl2_d5L.js";import{B as q}from"./Badge-Spt5QFtK.js";import{F as D}from"./ArrowLeftIcon-DMiZTu1b.js";import{F as J}from"./ChevronUpIcon-CSBP4WnS.js";import"./constants-CCUmzW3U.js";const m=[{key:"overview",label:"Overview"},{key:"icp",label:"ICP"},{key:"search_intents",label:"Search Intents"},{key:"search_jobs",label:"Search Jobs"},{key:"contacts",label:"Contacts"},{key:"templates",label:"Templates"},{key:"workflows",label:"Workflows"},{key:"inbox",label:"Inbox"},{key:"campaigns",label:"Campaigns"},{key:"social_calendar",label:"Social Calendar"},{key:"seo",label:"SEO"},{key:"competitors",label:"Competitors"},{key:"crm",label:"CRM"},{key:"crm_leads",label:"Leads",parent:"crm"},{key:"crm_accounts",label:"Accounts",parent:"crm"},{key:"crm_deals",label:"Deals",parent:"crm"},{key:"crm_activities",label:"Activities",parent:"crm"},{key:"crm_settings",label:"Settings",parent:"crm"},{key:"esign",label:"E-Sign"},{key:"meetings",label:"Meetings"},{key:"accounts",label:"Accounts"},{key:"prospect_sources",label:"Prospect Sources",parent:"accounts"},{key:"amazon_brand",label:"Amazon Brands"},{key:"account_nurturing",label:"Account Nurturing"},{key:"knowledge_base",label:"Knowledge Base"}],K=[{value:"viewer",label:"Viewer"},{value:"editor",label:"Editor"},{value:"admin",label:"Admin"},{value:"custom",label:"Custom"}],w={viewer:Object.fromEntries(m.map(r=>[r.key,"view"])),editor:Object.fromEntries(m.map(r=>[r.key,"full"])),admin:Object.fromEntries(m.map(r=>[r.key,"full"])),custom:Object.fromEntries(m.map(r=>[r.key,"none"]))};function S(){return Object.fromEntries(m.map(r=>[r.key,"none"]))}function I(){const{id:r}
1=B(),[d,P]=x.useState(null),[y,A]=x.useState([]),[p,h]=x.useState({}),[C,E]=x.useState(!0);x.useEffect(()=>{if(!r)return;async function s(){try{const[a,t,c]=await Promise.all([u.listMembers(),L.list({limit:100}),u.getMemberProjects(r)]),i=a.find(l=>l.id===r)||null;P(i),A(t.items);const n={};for(const l of c)n[l.projectId]=l;const g={};for(const l of t.items){const f=n[l.id];if(f){const j={};for(const k of m)j[k.key]=f.permissions[k.key]||"none";g[l.id]={hasAccess:!0,expanded:!1,preset:f.rolePreset||"custom",permissions:j,saving:!1}}else g[l.id]={hasAccess:!1,expanded:!1,preset:"viewer",permissions:S(),saving:!1}}h(g)}catch{b.error("Failed to load data")}finally{E(!1)}}s()},[r]);function o(s,a){h(t=>({...t,[s]:{...t[s],...a}}))}function _(s){const a=p[s];if(!a)return;const t=!a.hasAccess;o(s,{hasAccess:t,expanded:t,preset:"viewer",permissions:t?{...w.viewer}:S()})}function M(s,a){if(a==="custom"){o(s,{preset:"custom"});return}o(s,{preset:a,permissions:{...w[a]}})}function O(s,a,t){const c=p[s];if(!c)return;const i={...c.permissions,[a]:t};o(s,{permissions:i,preset:"custom"})}async function R(s){var t,c,i;if(!r)return;const a=p[s];if(a){o(s,{saving:!0});try{a.hasAccess?(await u.setProjectAccess(r,s,{rolePreset:a.preset,permissions:a.permissions}),b.success("Access saved")):(await u.removeProjectAccess(r,s),b.success("Access removed"))}catch(n){b.error(((i=(c=(t=n==null?void 0:n.response)==null?void 0:t.data)==null?void 0:c.error)==null?void 0:i.message)||"Failed to save access")}finally{o(s,{saving:!1})}}}if(C)return e.jsx("div",{className:"flex h-64 items-center justify-center",children:e.jsx(F,{size:"lg"})});const z=d?`${d.firstName} ${d.lastName}`:"Member";return e.jsxs("div",{className:"space-y-6",children:[e.jsx("div",{className:"flex items-center gap-4",children:e.jsxs(T,{to:"/settings/team",className:"flex items-center gap-1 text-sm text-gray-500 hover:text-gray-700",children:[e.jsx(D,{className:"h-4 w-4"}),"Back to Team"]})}),e.jsxs("div",{children:[e.jsxs("h2",{className:"text-xl font-bold text-gray-900",children:["Project Access — ",z]}),d&&e.jsxs("p",{className:"mt-1 text-sm text-gray-500",children:[d.email," ·"," ",e.jsx(q,{color:"bg-gray-100 text-gray-700",children:d.role})]})]}),y.length===0?e.jsx(v,{children:e.jsx("p",{className:"py-8 text-center text-sm text-gray-500",children:"No projects found."})}):e.jsx("div",{className:"space-y-4",children:y.map(s=>{const a=p[s.id];return a?e.jsxs(v,{padding:"none",children:[e.jsxs("div",{className:"flex items-center justify-between px-6 py-4",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsx("input",{type:"checkbox",checked:a.hasAccess,onChange:()=>_(s.id),className:"h-4 w-4 rounded border-gray-300 text-brand-600 focus:ring-brand-500"}),e.jsxs("div",{children:[e.jsx("p",{className:"font-medium text-gray-900",children:s.name}),s.description&&e.jsx("p",{className:"text-xs text-gray-500",children:s.description})]})]}),e.jsxs("div",{className:"flex items-center gap-3",children:[a.hasAccess&&e.jsx(N,{variant:"ghost",size:"sm",icon:a.expanded?e.jsx(J,{className:"h-4 w-4"}):e.jsx($,{className:"h-4 w-4"}),onClick:()=>o(s.id,{expanded:!a.expanded}),children:a.expanded?"Collapse":"Configure"}),e.jsx(N,{size:"sm",loading:a.saving,onClick:()=>R(s.id),children:"Save"})]})]}),a.hasAccess&&a.expanded&&e.jsxs("div",{className:"border-t border-gray-100 px-6 pb-6 pt-4",children:[e.jsx("div",{className:"mb-4 w-48",children:e.jsx(U,{label:"Preset",value:a.preset,onChange:t=>M(s.id,t.target.value),options:K})}),e.jsx("div",{className:"overflow-hidden rounded-lg border border-gray-200",children:e.jsxs("table",{className:"min-w-full divide-y divide-gray-200",children:[e.jsx("thead",{className:"bg-gray-50",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-4 py-2 text-left text-xs font-semibold uppercase tracking-wider text-gray-500",children:"Menu Item"}),["none","view","full"].map(t=>e.jsx("th",{className:"px-4 py-2 text-center text-xs font-semibold uppercase tracking-wider text-gray-500",children:t.charAt(0).toUpperCase()+t.slice(1)},t))]})}),e.jsx("tbody",{className:"divide-y divide-gray-100 bg-white",children:m.map(t=>{const c=a.permissions[t.key]||"none",i=!!t.parent;return e.jsxs("tr",{className:`hover:bg-gray-50 ${i?"bg-gray-50/50":""}`,children:[e.jsx("td",{className:"px-4 py-2 text-sm font-medium text-gray-700",children:i?e.jsxs("span",{className:"flex items-center gap-1 pl-5 text-gray-500",children:[e.jsx("span",{className:"text-gray-300",children:"↳"}),t.label]}):t.label}),["none","view","full"].map(n=>e.jsx("td",{className:"px-4 py-2 text-center",children:e.jsx("button",{onClick:()=>O(s.id,t.key,n),className:`rounded-md px-3 py-1 text-xs font-medium transition-colors ${c===n?n==="none"?"bg-gray-200 text-gray-800":n==="view"?"bg-blue-100 text-blue-700":"bg-green-100 text-green-700":"text-gray-400 hover:bg-gray-100"}`,children:n.charAt(0).toUpperCase()+n.slice(1)})}
1,n))]},t.key)})})]})})]})]},s.id):null})})]})}export{I 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.