1import{c as q,r as a,j as e}from"./react-vendor-Cc_xor_U.js";import{a3 as U}from"./index-Dk7s5RkW.js";import"./ai-vendor-CzbGuKuh.js";import{L as F,X as G,Q as J,z as A,R as D,B as T,M as x,x as Q,g as W,W as X,w as H}from"./ui-vendor-FP6SsB9q.js";import{A as K,m as V}from"./motion-vendor-C5vbwT8_.js";import"./markdown-vendor-D21RDMMv.js";import"./shiki-vendor-KIjf0JMC.js";import"./sentry-vendor-BrGEXQI1.js";import"./pdf-vendor-BjoiBSc5.js";import"./stripe-vendor-BNM55ZSA.js";try{let r=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new r.Error().stack;o&&(r._sentryDebugIds=r._sentryDebugIds||{},r._sentryDebugIds[o]="41597d97-1ded-4fe0-a4bd-aa6e9396209a",r._sentryDebugIdIdentifier="sentry-dbid-41597d97-1ded-4fe0-a4bd-aa6e9396209a")}catch{}function ce(){const r=q(),[o,L]=a.useState([]),[B,y]=a.useState(!0),[j,b]=a.useState(!1),[p,h]=a.useState(!1),[M,N]=a.useState(null),[u,z]=a.useState("all"),[v,d]=a.useState(""),[i,_]=a.useState("single"),[c,w]=a.useState(""),[k,C]=a.useState(1),[g,S]=a.useState(""),[I,E]=a.useState(!0),[l,m]=a.useState("inventor"),f=a.useCallback(async()=>{y(!0),d("");try{const t=await U.listInvites({page:1,limit:50,status:u});L(t.invites)}catch(t){const s=t instanceof Error?t.message:"Unknown error";s.includes("401")||s.includes("Unauthorized")?r("/signin"):s.includes("403")||s.includes("Admin access required")?r("/dashboard"):d(s)}finally{y(!1)}},[u,r]);a.useEffect(()=>{f()},[f]);const O=async t=>{t.preventDefault(),b(!0),d("");try{await U.createInvite({type:i,maxUses:i==="group"?k:1,...i==="single"&&c?{email:c}:{},...g?{note:g}:{},sendEmail:i==="single"&&I,isLawyer:l==="lawyer",inviteFor:l}),await f(),h(!1),w(""),C(1),S(""),E(!0),m("inventor")}catch(s){const n=s instanceof Error?s.message:"Failed to create invite";d(n)}finally{b(!1)}},P=async(t,s)=>{await navigator.clipboard.writeText(t),N(s),setTimeout(()=>N(null),2e3)},R=t=>new Date(t).toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",hour:"2-digit",minute:"2-digit"}),$=t=>{const s=new Date,n=new Date(t.expiresAt)<s;return t.currentUses>=t.maxUses?e.jsx("span",{className:"px-2 py-1 text-xs rounded-full bg-blue-100 text-blue-700 font-montserrat",children:"Used"}):!t.isActive||n?e.jsx("span",{className:"px-2 py-1 text-xs rounded-full bg-red-100 text-red-700 font-montserrat",children:"Expired"}):e.jsx("span",{className:"px-2 py-1 text-xs rounded-full bg-green-100 text-green-700 font-montserrat",children:"Active"})};return B?e.jsx("div",{className:"h-full flex items-center justify-center",children:e.jsx(F,{className:"w-8 h-8 animate-spin text-hiply-teal"})}):e.jsx("div",{className:"h-full overflow-y-auto",children:e.jsxs("div",{className:"max-w-7xl mx-auto px-6 py-8",children:[e.jsxs("div",{className:"flex justify-between items-center mb-8",children:[e.jsxs("div",{children:[e.jsx("h1",{className:"text-2xl font-semibold text-hiply-dark font-montserrat",children:"Invite Management"}),e.jsx("p",{className:"mt-1 text-sm text-gray-600 font-montserrat",children:"Create and manage registration invites"})]}),e.jsx("button",{onClick:()=>h(!p),className:"flex items-center gap-2 px-4 py-2 bg-hiply-dark text-white rounded-lg hover:opacity-90 transition-opacity font-montserrat font-medium",children:p?e.jsxs(e.Fragment,{children:[e.jsx(G,{className:"w-4 h-4"}),"Cancel"]}):e.jsxs(e.Fragment,{children:[e.jsx(J,{className:"w-4 h-4"}),"Create Invite"]})})]}),v&&e.jsx("div",{className:"bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg text-sm font-montserrat mb-6",children:v}),e.jsx(K,{children:p&&e.jsx(V.div,{initial:{opacity:0,height:0},animate:{opacity:1,height:"auto"},exit:{opacity:0,height:0},transition:{duration:.2},className:"overflow-hidden",children:e.jsxs("div",{className:"bg-white rounded-lg shadow-md p-6 mb-8 border border-gray-200",children:[e.jsx("h2",{className:"text-lg font-semibold mb-4 font-montserrat text-hiply-dark",children:"Create New Invite"}),e.jsxs("form",{onSubmit:O,className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-2 gap-4",children:[e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 font-montserrat",children:"Invite Type"}),e.jsxs("select",{value:i,onChange:t=>_(t.target.value),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-hiply-teal font-montserrat",children:[e.jsx("option",{value:"single",children:"Single Use"}
1),e.jsx("option",{value:"group",children:"Group (Multi-use)"})]})]}),i==="single"?e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 font-montserrat",children:"Email (Optional)"}),e.jsx("input",{type:"email",value:c,onChange:t=>w(t.target.value),placeholder:"[email protected]",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-hiply-teal font-montserrat"})]}):e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 font-montserrat",children:"Max Uses"}),e.jsx("input",{type:"number",min:"1",max:"200",value:k,onChange:t=>C(parseInt(t.target.value)),className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-hiply-teal font-montserrat"})]})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 font-montserrat",children:"Note (Optional)"}),e.jsx("input",{type:"text",value:g,onChange:t=>S(t.target.value),placeholder:"Internal note about this invite",className:"w-full px-3 py-2 border border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-hiply-teal font-montserrat"})]}),e.jsxs("div",{children:[e.jsx("label",{className:"block text-sm font-medium text-gray-700 mb-1 font-montserrat",children:"Invite Purpose"}),e.jsxs("div",{className:"flex gap-3",children:[e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"inviteFor",value:"inventor",checked:l==="inventor",onChange:()=>m("inventor"),className:"text-hiply-teal focus:ring-hiply-teal"}),e.jsxs("span",{className:"flex items-center gap-1 text-sm text-gray-700 font-montserrat",children:[e.jsx(A,{className:"w-4 h-4"}),"Inventor"]})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"inviteFor",value:"lawyer",checked:l==="lawyer",onChange:()=>m("lawyer"),className:"text-hiply-teal focus:ring-hiply-teal"}),e.jsxs("span",{className:"flex items-center gap-1 text-sm text-gray-700 font-montserrat",children:[e.jsx(D,{className:"w-4 h-4"}),"Agent"]})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"radio",name:"inviteFor",value:"business",checked:l==="business",onChange:()=>m("business"),className:"text-hiply-teal focus:ring-hiply-teal"}),e.jsxs("span",{className:"flex items-center gap-1 text-sm text-gray-700 font-montserrat",children:[e.jsx(T,{className:"w-4 h-4"}),"Business"]})]})]}),e.jsxs("p",{className:"text-xs text-gray-500 mt-1 font-montserrat",children:[l==="inventor"&&"Inventor will be directed to create ideas and disclosures",l==="lawyer"&&"Agent will be directed to the agent dashboard",l==="business"&&"Business will complete business onboarding flow"]})]}),i==="single"&&c&&e.jsxs("div",{className:"flex items-center",children:[e.jsx("input",{type:"checkbox",id:"sendEmail",checked:I,onChange:t=>E(t.target.checked),className:"mr-2 rounded border-gray-300 text-hiply-teal focus:ring-hiply-teal"}),e.jsxs("label",{htmlFor:"sendEmail",className:"text-sm text-gray-700 flex items-center font-montserrat",children:[e.jsx(x,{className:"w-4 h-4 mr-1"}),"Send invitation email to ",c]})]}),e.jsxs("div",{className:"flex justify-end gap-3 pt-2",children:[e.jsx("button",{type:"button",onClick:()=>h(!1),className:"px-4 py-2 text-gray-700 border border-gray-300 rounded-lg hover:bg-gray-50 font-montserrat",children:"Cancel"}),e.jsx("button",{type:"submit",disabled:j,className:"px-4 py-2 bg-hiply-dark text-white rounded-lg hover:opacity-90 disabled:opacity-50 font-montserrat font-medium flex items-center gap-2",children:j?e.jsxs(e.Fragment,{children:[e.jsx(F,{className:"w-4 h-4 animate-spin"}),"Creating..."]}):"Create Invite"})]})]})]})})}),e.jsx("div",{className:"bg-white rounded-lg shadow-md mb-6 border border-gray-200",children:e.jsx("div",{className:"border-b border-gray-200",children:e.jsx("nav",{className:"flex -mb-px",children:["all","active","expired","used"].map(t=>e.jsx("button",{onClick:()=>z(t),className:`py-3 px-4 border-b-2 font-medium text-sm capitalize font-montserrat transition-colors ${u===t?"border-hiply-teal text-hiply-teal":"border-transparent text-gray-500 hover:text-gray-700 hover:border-gray-300"}`,children:t},t))})})}),e.jsx("div",{className:"bg-white rounded-lg shadow-md overflow-hidden border border-gray-200",children:e.jsx("div",{className:"overflow-x-auto",children:e.jsxs("table",{className:"w-full",children:[e.jsx("thead",{className:"bg-gray-50 border-b border-gray-200",children:e.jsxs("tr",{children:[e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Status"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Type"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Email"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Usage"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Expires"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Note"}),e.jsx("th",{className:"px-6 py-3 text-left text-xs font-medium text-gray-500 uppercase tracking-wider font-montserrat",children:"Actions"})]})}),e.jsx("tbody",{className:"divide-y divide-gray-200",children:o.length===0?e.jsx("tr",{children:e.jsx("td",{colSpan:7,className:"px-6 py-12 text-center text-gray-500 font-montserrat",children:"No invites found"})}):o.map(t=>e.jsxs("tr",{className:"hover:bg-gray-50",children:[e.jsx("td",{className:"px-6 py-4",children:$(t)}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[t.type==="single"?e.jsx(x,{className:"w-4 h-4 text-gray-400"}):e.jsx(Q,{className:"w-4 h-4 text-gray-400"}),e.jsx("span",{className:"text-sm text-gray-900 capitalize font-montserrat",children:t.type})]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("span",{className:"text-sm text-gray-900 font-montserrat",children:t.email||"-"})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("span",{className:"text-sm text-gray-900 font-montserrat",children:[t.currentUses," / ",t.maxUses]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-1 text-sm text-gray-900 font-montserrat",children:[e.jsx(W,{className:"w-3 h-3"}),R(t.expiresAt)]})}),e.jsx("td",{className:"px-6 py-4",children:e.jsx("div",{className:"text-sm text-gray-500 font-montserrat",children:(()=>{try{const s=JSON.parse(t.metadata||"{}
1"),n=s.inviteFor||(s.isLawyer?"lawyer":"inventor");return e.jsxs("div",{children:[e.jsxs("div",{className:`flex items-center gap-1 mb-1 ${n==="lawyer"?"text-purple-600":n==="business"?"text-teal-600":"text-blue-600"}`,children:[n==="lawyer"&&e.jsx(D,{className:"w-3 h-3"}),n==="business"&&e.jsx(T,{className:"w-3 h-3"}),n==="inventor"&&e.jsx(A,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs font-medium capitalize",children:n})]}),s.note&&e.jsx("div",{children:s.note}),s.emailSent===!0&&e.jsxs("div",{className:"flex items-center gap-1 text-green-600 mt-1",children:[e.jsx(x,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"Email sent"})]}),s.emailSent===!1&&s.emailError&&e.jsxs("div",{className:"flex items-center gap-1 text-red-600 mt-1",children:[e.jsx(x,{className:"w-3 h-3"}),e.jsx("span",{className:"text-xs",children:"Email failed"})]})]})}catch{return"-"}})()})}),e.jsx("td",{className:"px-6 py-4",children:e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("button",{onClick:()=>P(t.inviteUrl,t.id),className:"p-1 text-gray-400 hover:text-hiply-teal transition-colors",title:"Copy invite link",children:M===t.id?e.jsx("span",{className:"text-xs text-green-600 font-montserrat",children:"Copied!"}):e.jsx(X,{className:"w-4 h-4"})}),e.jsx("a",{href:t.inviteUrl,target:"_blank",rel:"noopener noreferrer",className:"p-1 text-gray-400 hover:text-hiply-teal transition-colors",title:"Open invite link",children:e.jsx(H,{className:"w-4 h-4"})})]})})]},t.id))})]})})})]})})}export{ce as Component}; 2//# sourceMappingURL=route-CrmIOMnR.js.map
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.