PageSourceSearch

https://ecobot.com/assets/invite-DGrJ8rVh.js

js ecobot.com collected 2026-10-02 14:34:24 UTC 8,880 bytes, 1 lines download raw bytes

1import{X as V,u as $,i,k as C,j as e,C as D,P as k,f as S}from"./index-k9Hj-c9V.js";import{S as G}from"./Section-CIF52LJu.js";import{i as q,P as M}from"./PasswordChecklist-CGL3Dorz.js";import"./check-CA2GioPW.js";const R="https://api.ecobot.com/v1.7";async function Y(n){try{const r=await fetch(`${R}/invites/validate?id=${encodeURIComponent(n)}`,{method:"GET",headers:{Accept:"application/json"}});let a=null;try{a=await r.json()}catch{a=null}if(!r.ok)return{ok:!1,message:`Request failed (${r.status})`};const s=a;return s&&s.valid===!0&&typeof s.companyName=="string"?{ok:!0,valid:!0,companyName:s.companyName}:s&&s.valid===!1?{ok:!0,valid:!1,reason:s.reason??"notfound"}:{ok:!1,message:"Unexpected response from server"}}catch{return{ok:!1,message:"Network error. Check your connection and try again."}}}async function W(n){try{const r=await fetch(`${R}/invites/accept`,{method:"POST",headers:{"Content-Type":"application/json",Accept:"application/json"},body:JSON.stringify(n)});let a=null;try{a=await r.json()}catch{a=null}return r.ok?{ok:!0}:{ok:!1,message:a?.errors?.[0]?.message||a?.error?.message||a?.detail||a?.message||"Something went wrong. Please try again."}}catch{return{ok:!1,message:"Network error. Check your connection and try again."}}}const H="ecobot:signup-complete",J=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i,B=["Sole Proprietor/Contractor","Field Scientist","Project Manager","IT/GIS","Owner/Business Unit Leader"];function ae(){const{id:n}=V.useSearch(),r=$(),[a,s]=i.useState({kind:"loading"}),[N,m]=i.useState(0);return i.useEffect(()=>{if(!n||!J.test(n)){s({kind:"invalid",reason:"malformed"});return}let u=!1;return s({kind:"loading"}),Y(n).then(l=>{if(!u){if(!l.ok){s({kind:"network-error"});return}if(l.valid)s({kind:"valid",companyName:l.companyName}),C("Invite Valid",{companyName:l.companyName});else{const v=l.reason==="expired"?"expired":"notfound";s({kind:"invalid",reason:v}),C("Invite Invalid",{reason:v})}}}),()=>{u=!0}},[n,N]),e.jsx("div",{className:"flex min-h-screen flex-col bg-bg-light",children:e.jsx("main",{className:"flex-1",children:e.jsx(G,{variant:"topo-white",size:"xl",className:"!pt-32 md:!pt-40",children:e.jsxs(D,{children:[a.kind==="loading"&&e.jsx(X,{}),a.kind==="network-error"&&e.jsx(A,{eyebrow:"Couldn't reach Ecobot",title:"We had trouble checking your invite",body:"This might be a temporary connection issue.",cta:e.jsx(k,{onClick:()=>m(u=>u+1),size:"lg",children:"Try again"})}),a.kind==="invalid"&&e.jsx(A,{eyebrow:"Invite unavailable",title:a.reason==="expired"?"This invite has expired":"This invite is no longer valid",body:"Ask an Ecobot admin at your company to send you a new invite, or talk to our team.",cta:e.jsxs("div",{className:"flex flex-wrap justify-center gap-3",children:[e.jsx(k,{to:"/request-invite",size:"lg",children:"Request a new invite"}),e.jsx(k,{to:"/",size:"lg",variant:"ghost-light",children:"Back to home"})]})}),a.kind==="valid"&&n&&e.jsx(K,{companyName:a.companyName,inviteUID:n,onSuccess:()=>{try{window.sessionStorage.setItem(H,String(Date.now()))}catch{}r({to:"/welcome",replace:!0})}})]})})})})}function X(){return e.jsx("div",{className:"mx-auto max-w-xl",children:e.jsxs("div",{className:"rounded-3xl border border-border-light bg-white p-10 text-center shadow-[0_24px_60px_-32px_rgba(17,25,36,0.2)]",children:[e.jsx("div",{className:"mx-auto h-6 w-6 animate-spin rounded-full border-2 border-ink/15 border-t-brand-start"}),e.jsx("p",{className:"mt-4 text-sm text-ink/60",children:"Checking your invite…"})]})})}function A({eyebrow:n,title:r,body:a,cta:s}){return e.jsxs("div",{className:"mx-auto max-w-2xl text-center",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-brand-start",children:n}),e.jsx("h1",{className:"mt-3 font-display text-4xl md:text-5xl font-bold tracking-tight text-ink",children:r}),e.jsx("p",{className:"mx-auto mt-5 max-w-xl text-lg text-ink/70",children:a}),e.jsx("div",{className:"mt-8 flex justify-center",children:s})]})}function K({companyName:n,inviteUID:r,onSuccess:a}){const[s,N]=i.useState(""),[m,u]=i.useState(""),[l,v]=i.useState(B[0]),[d,U]=i.useState(""),[j,F]=i.useState(""),[y,L]=i.useState(!1),[h,w]=i.useState({firstName:!1,lastName:!1,position:!1,password:!1,confirm:!1,terms:!1}),[c,I]=i.useState(!1),[P,E]=i.useState(null),T=d.length>0&&d===j,z=q(d),_=s.trim().length>0&&m.trim().length>0&&l.trim().length>0&&z&&T&&y&&!c,f=t=>w(o=>o[t]?o:{...o,[t]:!0}),x=t=>w(o=>o[t]?{...o,[t]:!1}:o);async function O(t){if(t.preventDefault(),w({firstName:!0,lastName:!0,position:!0,password:!0,confirm:!0,terms:!0}),!_)return;E(null),I(!0);const o=await W({firstname:s.trim(),lastname:m.trim(),position:l,password:d,inviteUID:r});if(o.ok){C("Invite Accepted",{companyName:n}),a();return}I(!1),E(o.message)}return e.jsxs("div",{className:"mx-auto max-w-2xl",children:[e.jsxs("div",{className:"text-center",children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-[0.18em] text-brand-start",children:"You're invited"}),e.jsx("h1",{className:"mt-3 font-display text-4xl md:text-5xl font-bold tracking-tight text-ink",children:"Welcome to the team!"}),e.jsxs("p",{className:"mx-auto mt-4 max-w-xl text-lg text-ink/70",children:["You've been invited to join"," ",e.jsx("span",{className:"font-semibold text-ink",children:n})," on Ecobot. Complete your account information below to get started."]})]}),e.jsxs("form",{noValidate:!0,onSubmit:O,className:"mt-8 flex flex-col gap-4 roun
1ded-3xl border border-border-light bg-white p-6 shadow-[0_24px_60px_-32px_rgba(17,25,36,0.2)] md:p-10",children:[e.jsxs("div",{className:"grid grid-cols-1 gap-4 sm:grid-cols-2",children:[e.jsxs(b,{label:"First name",children:[e.jsx("input",{autoComplete:"given-name",value:s,onChange:t=>{N(t.target.value),x("firstName")},onBlur:()=>f("firstName"),className:g,disabled:c}),h.firstName&&!s.trim()&&e.jsx(p,{children:"Enter your first name"})]}),e.jsxs(b,{label:"Last name",children:[e.jsx("input",{autoComplete:"family-name",value:m,onChange:t=>{u(t.target.value),x("lastName")},onBlur:()=>f("lastName"),className:g,disabled:c}),h.lastName&&!m.trim()&&e.jsx(p,{children:"Enter your last name"})]})]}),e.jsx(b,{label:"Your role",children:e.jsx("select",{autoComplete:"organization-title",value:l,onChange:t=>{v(t.target.value),x("position")},onBlur:()=>f("position"),className:g,disabled:c,children:B.map(t=>e.jsx("option",{value:t,children:t},t))})}),e.jsxs(b,{label:"Password",children:[e.jsx("input",{type:"password",autoComplete:"new-password",value:d,onChange:t=>{U(t.target.value),x("password")},onBlur:()=>f("password"),className:g,disabled:c}),e.jsx(M,{password:d}),h.password&&!d&&e.jsx(p,{children:"Create a password"})]}),e.jsxs(b,{label:"Confirm password",children:[e.jsx("input",{type:"password",autoComplete:"new-password",value:j,onChange:t=>{F(t.target.value),x("confirm")},onBlur:()=>f("confirm"),className:g,disabled:c}),j.length>0&&!T&&e.jsx(p,{children:"Passwords don't match"}),h.confirm&&!j&&e.jsx(p,{children:"Re-enter your password"})]}),e.jsxs("label",{className:"flex items-start gap-2 text-sm text-ink/75",children:[e.jsx("input",{type:"checkbox",checked:y,onChange:t=>{L(t.target.checked),t.target.checked&&x("terms")},className:"mt-1 h-4 w-4 rounded border-ink/25 text-brand-start focus:ring-brand-start",disabled:c}),e.jsxs("span",{children:["I agree to Ecobot's"," ",e.jsx(S,{to:"/terms-and-conditions",target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-ink underline decoration-ink/30 underline-offset-4 hover:decoration-ink",children:"Terms and Conditions"})," ","and"," ",e.jsx(S,{to:"/privacy-policy",target:"_blank",rel:"noopener noreferrer",className:"font-semibold text-ink underline decoration-ink/30 underline-offset-4 hover:decoration-ink",children:"Privacy Policy"}),"."]})]}),h.terms&&!y&&e.jsx(p,{children:"Please accept the terms to continue"}),P&&e.jsx("p",{role:"alert",className:"text-[13px] text-red-600",children:P}),e.jsx("div",{className:"mt-2",children:e.jsx(k,{type:"submit",size:"lg",variant:"primary",className:"w-full justify-center",disabled:!_,children:c?"Creating account…":"Create account"})})]}),e.jsxs("p",{className:"mt-6 text-center text-sm text-ink/55",children:["Not you?"," ",e.jsx(S,{to:"/",className:"underline underline-offset-4 hover:text-ink",children:"Back to home"})]})]})}const g="mt-2 block h-11 w-full rounded-xl border border-ink/15 bg-white px-3.5 text-[15px] text-ink outline-none focus:border-brand-start focus:ring-2 focus:ring-brand-start/20 disabled:opacity-60";function b({label:n,children:r}){return e.jsxs("label",{className:"block",children:[e.jsx("span",{className:"text-[11px] font-display font-bold uppercase tracking-[0.18em] text-ink/55",children:n}),r]})}function p({children:n}){return e.jsx("p",{className:"mt-1 text-xs text-red-600",children:n})}export{ae as component};

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.