PageSourceSearch

https://deliverimates-production.up.railway.app/assets/CompanyCreate-DRla-7Qq.js

js deliverimates-production.up.railway.app collected 2026-10-03 12:13:24 UTC 10,740 bytes, 1 lines download raw bytes

1import{aa as U,ax as B,q as k,p as q,j as e,n as w,a as N,u as $,l as M,r as g,C as y,d as _,i as F,e as v,b as C,aE as d,ac as r,B as c,b4 as f,A as I,ab as Q}from"./index-Db4qfLtJ.js";import{u as G}from"./use-plans-Dhay0JrA.js";import{C as H}from"./copy-DajIPwGS.js";function J(){const i=U();return B({mutationFn:l=>q("/api/superadmin/companies",{method:"POST",body:JSON.stringify(l)}),onSuccess:()=>{i.invalidateQueries({queryKey:k.admin.companies()}),i.invalidateQueries({queryKey:k.admin.metrics()})}})}const K=[{label:"Company Info"},{label:"Admin User"},{label:"Select Plan"}];function R({currentStep:i}){return e.jsx("div",{className:"flex items-center gap-2",children:K.map((l,t)=>e.jsxs("div",{className:"flex items-center",children:[e.jsxs("div",{className:"flex items-center gap-2",children:[e.jsx("div",{className:N("h-8 w-8 rounded-full flex items-center justify-center text-sm font-medium border-2 transition-colors",t<i?"bg-indigo-600 border-indigo-600 text-white":t===i?"border-indigo-600 text-indigo-600 bg-white":"border-slate-300 text-slate-400 bg-white"),children:t<i?e.jsx(w,{className:"h-4 w-4"}):t+1}),e.jsx("span",{className:N("text-sm font-medium hidden sm:block",t<=i?"text-slate-900":"text-slate-400"),children:l.label})]}),t<K.length-1&&e.jsx("div",{className:N("w-8 sm:w-12 h-0.5 mx-2",t<i?"bg-indigo-600":"bg-slate-200")})]},l.label))})}function Y({plan:i,selected:l,onSelect:t}){const h=i.price_cents>0?`$${(i.price_cents/100).toFixed(0)}/mo`:"Custom";return e.jsxs("button",{type:"button",onClick:()=>t(i.id),className:N("relative flex flex-col items-start p-5 rounded-lg border-2 text-left transition-all w-full",l?"border-indigo-600 bg-indigo-50 ring-1 ring-indigo-600":"border-slate-200 bg-white hover:border-slate-300"),children:[l&&e.jsx("div",{className:"absolute top-3 right-3 h-5 w-5 rounded-full bg-indigo-600 flex items-center justify-center",children:e.jsx(w,{className:"h-3 w-3 text-white"})}),e.jsx("h3",{className:"text-lg font-semibold",children:i.name}),e.jsx("p",{className:"text-2xl font-bold mt-1",children:h}),e.jsx("p",{className:"text-sm text-muted-foreground mt-1",children:i.da_limit?`Up to ${i.da_limit} Drivers`:"Unlimited Drivers"}),e.jsx("ul",{className:"mt-3 space-y-1 text-sm text-slate-600",children:Object.entries(i.features).filter(([,m])=>m).map(([m])=>e.jsxs("li",{className:"flex items-center gap-1.5",children:[e.jsx(w,{className:"h-3.5 w-3.5 text-emerald-600 shrink-0"}),m.replace(/_/g," ").replace(/\b\w/g,p=>p.toUpperCase())]},m))})]})}const D={name:"",short_code:"",station_codes:"",adp_company_code:"",timezone:"America/Los_Angeles",expected_da_count:"",admin_email:"",admin_name:"",admin_phone:"",admin_password:"",plan_id:"",trial_days:"14"};function Z({backPath:i="/admin/companies",companyPath:l=t=>`/admin/companies/${t}`}={}){const t=$(),{toast:h}=M(),{data:m}=G(),p=J(),[j,u]=g.useState(0),[s,A]=g.useState(D),[x,P]=g.useState(null),[S,L]=g.useState(!1),n=(a,o)=>A(b=>({...b,[a]:o})),z=s.name.trim()&&s.short_code.trim(),E=s.admin_email.trim()&&s.admin_password.trim()&&s.admin_password.length>=6,T=s.plan_id,O=async()=>{try{const a=s.station_codes.split(",").map(b=>b.trim()).filter(Boolean),o=await p.mutateAsync({name:s.name.trim(),short_code:s.short_code.trim().toUpperCase(),station_codes:a,adp_company_code:s.adp_company_code.trim()||void 0,timezone:s.timezone,expected_da_count:parseInt(s.expected_da_count)||0,admin_email:s.admin_email.trim(),admin_name:s.admin_name.trim()||void 0,admin_phone:s.admin_phone.trim()||void 0,admin_password:s.admin_password,plan_id:s.plan_id,trial_days:parseInt(s.trial_days)||void 0});h({title:"Company created",description:`${s.name} has been onboarded successfully.`}),P({id:o.company.id,name:o.company.name,apiKey:o.company.apiKey})}catch(a){h({title:"Error",description:a instanceof Error?a.message:"Failed to create company",variant:"destructive"})}};return x?e.jsx("div",{className:"max-w-2xl mx-auto space-y-6",children:e.jsxs(y,{children:[e.jsxs(_,{className:"text-center",children:[e.jsx("div",{className:"flex justify-center mb-2",children:e.jsx(F,{className:"h-10 w-10 text-emerald-500"})}),e.jsxs(v,{className:"text-2xl",children:[x.name," is live"]})]}),e.jsxs(C,{className:"space-y-6",children:[e.jsxs("p",{className:"text-sm text-muted-foreground text-center",children:["Sync schedules, branding, and a Chrome-extension API key were all provisioned. Pass the key below to the DSP — it's shown",e.
1jsx("strong",{children:" only once"}),"."]}),x.apiKey?e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{children:"Chrome extension API key"}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx(r,{value:x.apiKey,readOnly:!0,className:"font-mono text-xs",onFocus:a=>a.currentTarget.select()}),e.jsxs(c,{type:"button",variant:"outline",onClick:()=>{navigator.clipboard.writeText(x.apiKey),L(!0),h({title:"Copied"})},children:[S?e.jsx(F,{className:"h-4 w-4 mr-1 text-emerald-500"}):e.jsx(H,{className:"h-4 w-4 mr-1"}),S?"Copied":"Copy"]})]}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Have the DSP paste this into the extension's Settings → API Key field. If lost, generate a replacement under Settings → API Keys in their dashboard."})]}):e.jsx("div",{className:"rounded-md border border-amber-200 bg-amber-50 p-3 text-sm text-amber-800",children:"Company created, but the API key step failed. Generate one manually from the DSP's Settings → API Keys page."}),e.jsxs("div",{className:"flex justify-end gap-2 pt-2",children:[e.jsx(c,{variant:"outline",onClick:()=>{P(null),A(D),u(0)},children:"Onboard another"}),e.jsx(c,{onClick:()=>t(l(x.id)),children:"Go to company"})]})]})]})}):e.jsxs("div",{className:"max-w-2xl mx-auto space-y-6",children:[e.jsxs("div",{className:"flex items-center gap-3",children:[e.jsxs(c,{variant:"ghost",size:"sm",onClick:()=>t(i),children:[e.jsx(f,{className:"h-4 w-4 mr-1"}),"Back"]}),e.jsx("h1",{className:"text-2xl font-bold",children:"Onboard Company"})]}),e.jsx(R,{currentStep:j}),j===0&&e.jsxs(y,{children:[e.jsx(_,{children:e.jsx(v,{children:"Company Information"})}),e.jsxs(C,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"name",children:"Company Name *"}),e.jsx(r,{id:"name",value:s.name,onChange:a=>n("name",a.target.value),placeholder:"Acme Delivery LLC"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"short_code",children:"Short Code *"}),e.jsx(r,{id:"short_code",value:s.short_code,onChange:a=>n("short_code",a.target.value.toUpperCase()),placeholder:"ACME",maxLength:10})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"station_codes",children:"Station Codes"}),e.jsx(r,{id:"station_codes",value:s.station_codes,onChange:a=>n("station_codes",a.target.value),placeholder:"DLA1, DLA2 (comma-separated)"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"adp_company_code",children:"ADP Company Code"}),e.jsx(r,{id:"adp_company_code",value:s.adp_company_code,onChange:a=>n("adp_company_code",a.target.value),placeholder:"Optional"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"timezone",children:"Timezone"}),e.jsxs("select",{id:"timezone",value:s.timezone,onChange:a=>n("timezone",a.target.value),className:"h-10 w-full rounded-md border border-input bg-background px-3 text-sm",children:[e.jsx("option",{value:"America/Los_Angeles",children:"Pacific"}),e.jsx("option",{value:"America/Denver",children:"Mountain"}),e.jsx("option",{value:"America/Chicago",children:"Central"}),e.jsx("option",{value:"America/New_York",children:"Eastern"})]})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"expected_da_count",children:"Expected Driver Count"}),e.jsx(r,{id:"expected_da_count",type:"number",value:s.expected_da_count,onChange:a=>n("expected_da_count",a.target.value),placeholder:"0",min:0})]})]}),e.jsx("div",{className:"flex justify-end",children:e.jsxs(c,{onClick:()=>u(1),disabled:!z,children:["Next",e.jsx(I,{className:"h-4 w-4 ml-2"})]})})]})]}),j===1&&e.jsxs(y,{children:[e.jsx(_,{children:e.jsx(v,{children:"Admin User"})}),e.jsxs(C,{className:"space-y-4",children:[e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"admin_name",children:"Full Name"}),e.jsx(r,{id:"admin_name",value:s.admin_name,onChange:a=>n("admin_name",a.target.value),placeholder:"Jane Smith"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"admin_email",children:"Email *"}),e.jsx(r,{id:"admin_email",type:"email",value:s.admin_email,onChange:a=>n("admin_email",a.target.value),placeholder:"[email protected]"})]})]}),e.jsxs("div",{className:"grid grid-cols-1 sm:grid-cols-2 gap-4",children:[e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"admin_phone",children:"Phone"}),e.jsx(r,{id:"admin_phone",type:"tel",value:s.admin_phone,onChange:a=>n("admin_phone",a.target.value),placeholder:"+1 555-000-0000"})]}),e.jsxs("div",{className:"space-y-2",children:[e.jsx(d,{htmlFor:"admin_password",children:"Temporary Password *"}),e.jsx(r,{id:"admin_password",type:"text",value:s.admin_password,onChange:a=>n("admin_password",a.target.value),placeholder:"Min 6 characters"})]})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(c,{variant:"outline",onClick:()=>u(0),children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsxs(c,{onClick:()=>u(2),disabled:!E,children:["Next",e.jsx(I,{className:"h-4 w-4 ml-2"})]})]})]})]}),j===2&&e.jsxs(y,{children:[e.jsx(_,{children:e.jsx(v,{children:"Select Plan"})}),e.jsxs(C,{className:"space-y-4",children:[e.jsx("div",{className:"grid grid-cols-1 sm:grid-cols-3 gap-4",children:(m||[]).map(a=>e.jsx(Y,{plan:a,selected:s.plan_id===a.id,onSelect:o=>n("plan_id",o)},a.id))}),e.jsxs("div",{className:"max-w-xs space-y-2",children:[e.jsx(d,{htmlFor:"trial_days",children:"Trial Period (days)"}),e.jsx(r,{id:"trial_days",type:"number",value:s.trial_days,onChange:a=>n("trial_days",a.target.value),placeholder:"14",min:0,max:90}),e.jsx("p",{className:"text-xs text-muted-foreground",children:"Set to 0 for no trial (immediate active)"})]}),e.jsxs("div",{className:"flex justify-between",children:[e.jsxs(c,{variant:"outline",onClick:()=>u(1),children:[e.jsx(f,{className:"h-4 w-4 mr-2"}),"Back"]}),e.jsx(c,{onClick:O,disabled:!T||p.isPending,children:p.isPending?e.jsxs(e.Fragment,{children:[e.jsx(Q,{className:"h-4 w-4 mr-2 animate-spin"}),"Creating..."]}):"Create Company"})]})]})]})]})}export{Z 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.