1import{j as e}from"./vendor-query-CniT1WJL.js";import{f as w,u as C,r as A,L as d}from"./vendor-react-69GsFwrV.js";import{u as S,V as s,F as L,P,at as I,G as E}from"./index-KjAD5lCC.js";import{k as z,l as T,L as R,f as p,N as m,g as x,h as Y,E as $}from"./shared-DMAcxp5i.js";import{ab as F,g as V,K as B,j as M,h as O}from"./vendor-ui-Ad3ANzF6.js";import"./vendor-forms-q6h4WU-p.js";const u={accepted:{title:"Invitation already accepted",body:"This invitation has been used. Sign in to reach your supplier portal."},revoked:{title:"Invitation revoked",body:"This invitation is no longer active. Contact our sourcing team if you think that is a mistake."},expired:{title:"Invitation expired",body:"This invitation link has expired. Ask our sourcing team to send a fresh one."}};function W(){const{token:a}=w(),[,h]=C(),{isAuthenticated:r,isLoading:j,user:o,logout:g}=S(),{data:t,isPending:f,isError:v,error:k}=z(a),n=T(a??""),[N,c]=A.useState(null),l=`/suppliers/invite/${encodeURIComponent(a??"")}`;if(f||j)return e.jsx(R,{label:"Loading your invitation..."});if(v||!t)return e.jsxs(p,{children:[e.jsx(m,{title:"Invitation not found",body:x(k,"This invitation link is not valid.")}),e.jsx(s,{asChild:!0,className:"mt-6",children:e.jsx(d,{href:"/suppliers",children:"Supplier program"})})]});if(t.state!=="pending"){const i=u[t.state]??u.revoked;return e.jsxs(p,{children:[e.jsx(m,{title:i.title,body:i.body}),e.jsx(s,{asChild:!0,className:"mt-6",children:e.jsx(d,{href:t.state==="accepted"?"/suppliers/portal":"/suppliers",children:t.state==="accepted"?"Supplier sign in":"Supplier program"})})]})}const y=r&&o?.email?.trim().toLowerCase()===t.email.trim().toLowerCase(),b=async()=>{c(null);try{await n.mutateAsync(),h("/suppliers/portal")}catch(i){c(x(i,"We could not accept this invitation."))}};return e.jsx(L,{className:"py-8 md:py-12",children:e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsxs("div",{className:"text-center",children:[e.jsxs(P,{variant:"mint",children:[e.jsx(F,{className:"mr-1 inline size-3.5"}),"Supplier portal invitation"]}),e.jsx(I,{as:"h1",center:!0,className:"mt-4",title:t.supplierName?`Portal access for ${t.supplierName}`:"Your supplier portal invitation",sub:"Accepting links your VidaPeps account to your company record. From the portal you manage contacts, upload price lists, and track every product line you have offered us."}),e.jsxs("p",{className:"mt-2 text-caption text-ink-3 dark:text-white/55",children:["Invitation for"," ",e.jsx("span",{className:"font-semibold text-ink dark:text-white",children:t.email}),t.expiresAt?` · expires ${Y(t.expiresAt)}`:""]})]}),e.jsxs(E,{className:"mt-8",children:[e.jsx($,{message:N}),y?e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-body text-ink-2 dark:text-white/70",children:["You are signed in as"," ",e.jsx("span",{className:"font-semibold text-ink dark:text-white",children:t.email}),". Accept to open your supplier portal."]}),e.jsx(s,{className:"mt-5 w-full",disabled:n.isPending,onClick:b,children:n.isPending?e.jsxs(e.Fragment,{children:[e.jsx(V,{className:"size-4 animate-spin"})," Accepting..."]}):e.jsxs(e.Fragment,{children:[e.jsx(B,{className:"size-4"})," Accept invitation"]})})]}):r?e.jsxs("div",{className:"text-center",children:[e.jsxs("p",{className:"text-body text-ink-2 dark:text-white/70",children:["You are signed in as"," ",e.jsx("span",{className:"font-semibold text-ink dark:text-white",children:o?.email}),", but this invitation is for"," ",e.jsx("span",{className:"font-semibold text-ink dark:text-white",children:t.email}),". Sign out and sign back in with the invited address to accept."]}),e.jsxs(s,{variant:"ghost",className:"mt-5",onClick:()=>g(),children:[e.jsx(M,{className:"size-4"})," Sign out"]})]}):e.jsxs("div",{className:"text-center",children:[e.jsx("span",{className:"mx-auto flex size-12 items-center justify-center rounded-full bg-vida-mint-soft text-vida-green-700",children:e.jsx(O,{className:"size-5"})}),e.jsxs("p",{className:"mt-4 text-body text-ink-2 dark:text-white/70",children:["Sign in to accept. Your VidaPeps account email must match"," ",e.jsx("span",{className:"font-semibold text-ink dark:text-white",children:t.email}),", since that address is what binds your login to your company record."]}),e.jsxs("div",{className:"mt-5 flex flex-col gap-2 sm:flex-row sm:justify-center",children:[e.jsx(s,{asChild:!0,children:e.jsx("a",{href:`/login?redirect=${encodeURIComponent(l)}`,children:"Sign in to accept"})}),!t.hasAccount&&e.jsx(s,{asChild:!0,variant:"ghost",children:e.jsx("a",{href:`/register?redirect=${encodeURIComponent(l)}`,children:"Create an account"})})]}),t.hasAccount&&e.jsx("p",{className:"mt-3 text-caption text-ink-3 dark:text-white/55",children:"An account already exists for this address."})]})]}),e.jsx("p",{className:"mt-6 text-center text-caption text-ink-3 dark:text-white/55",children:"Portal access is per person. Ask us for another inv
1itation if a colleague also needs to sign in."})]})})}export{W 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.