PageSourceSearch

https://deliverimates-production.up.railway.app/assets/DriverForm-C-vtD7vZ.js

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

1import{bC as Z,r as a,j as e,a8 as ee}from"./index-Db4qfLtJ.js";import{u as te,a as se,b as ne}from"./use-driver-form-CSfacMeT.js";const ae="You may have the right to workers' compensation benefits, including medical care and lost wages. You have the right to see a doctor of your choosing. You will receive a copy of this report via text message after submitting. Completing this form does not waive any of your rights.",le="Puede tener derecho a beneficios de compensación laboral, incluyendo atención médica y salario perdido. Tiene derecho a ver a un médico de su elección. Recibirá una copia de este informe por mensaje de texto después de enviarlo. Completar este formulario no renuncia a ninguno de sus derechos.",I="By completing this form, you agree that your electronic confirmation has the same legal effect as a written signature.",ie=[{id:"head",en:"Head",es:"Cabeza"},{id:"neck_shoulder",en:"Neck/Shoulder",es:"Cuello/Hombro"},{id:"back",en:"Back",es:"Espalda"},{id:"arm_hand",en:"Arm/Hand",es:"Brazo/Mano"},{id:"leg_knee",en:"Leg/Knee",es:"Pierna/Rodilla"},{id:"foot_ankle",en:"Foot/Ankle",es:"Pie/Tobillo"}];function me(){const{token:c}=Z(),{data:i,isLoading:B,error:C}=te(c),h=se(),R=ne(),[d,l]=a.useState(0),[g,D]=a.useState("en"),[x,L]=a.useState([]),[p,$]=a.useState(""),[b,O]=a.useState(""),[f,F]=a.useState(""),[m,Y]=a.useState(""),[j,U]=a.useState(""),[w,W]=a.useState(!1),[y,q]=a.useState(""),[H,M]=a.useState(!1),[N,z]=a.useState(null),[r,S]=a.useState([]),[P,k]=a.useState(!1),E=a.useRef(null);if(a.useEffect(()=>{navigator.geolocation&&navigator.geolocation.getCurrentPosition(s=>z({lat:s.coords.latitude,lng:s.coords.longitude,accuracy:s.coords.accuracy}),()=>{})},[]),B)return e.jsx(oe,{});if(C||!i)return e.jsx(re,{message:C?.message||"This link is invalid or has expired."});if(H)return e.jsx(ce,{});const t=g==="es",v=i.incident.incident_type==="injury",T=new Date,A=`I, ${y||"____"}, confirm I provided the above information on ${T.toLocaleDateString()} at ${T.toLocaleTimeString()}. I understand this report will be shared with my employer. This acknowledgment does not waive my right to workers' compensation benefits or to seek medical treatment.`,G=s=>new Promise((n,o)=>{const u=new FileReader;u.onload=()=>{const X=u.result;n(X.split(",")[1]??"")},u.onerror=o,u.readAsDataURL(s)}),V=s=>{if(!s)return;const n=Array.from(s).slice(0,5-r.length).map(o=>({file:o,preview:URL.createObjectURL(o)}));S(o=>[...o,...n].slice(0,5))},Q=s=>{S(n=>(n[s]&&URL.revokeObjectURL(n[s].preview),n.filter((o,u)=>u!==s)))},J=async()=>{if(!c||r.length===0)return;const s=ee;for(const{file:n}of r){const o=await G(n);await fetch(`${s}/api/driver-form/${c}/photos`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({file_base64:o,file_name:n.name,mime_type:n.type})})}},K=async()=>{if(!(!c||!w||!y.trim()))try{r.length>0&&(k(!0),await J(),k(!1)),await h.mutateAsync({token:c,data:{description:p,body_part_affected:v&&x.length>0?x.join(","):null,medical_decision:m,medical_facility_name:j||null,gps_lat:N?.lat||null,gps_lng:N?.lng||null,gps_accuracy_meters:N?.accuracy||null,gps_captured_at:N?new Date().toISOString():null,language_used:g,driver_confirmed:!0,esign_consent_shown:!0,rights_notice_shown:!0,confirmation_text:A,witnesses:b||f?[{name:b||null,phone:f||null}]:[]}}),M(!0)}catch{k(!1)}},_=s=>{Y(s),s==="yes_received"&&c&&R.mutate(c)};return e.jsx("div",{className:"min-h-screen bg-white",children:e.jsxs("div",{className:"max-w-md mx-auto px-4 py-6",children:[e.jsx("div",{className:"flex justify-end mb-4",children:e.jsx("button",{onClick:()=>D(g==="en"?"es":"en"),className:"text-sm text-blue-600 border border-blue-200 rounded px-3 py-1",children:g==="en"?"Español":"English"})}),e.jsx("div",{className:"flex gap-1 mb-6",children:[0,1,2,3,4,5,6,7].map(s=>e.jsx("div",{className:`h-1 flex-1 rounded ${s<=d?"bg-blue-600":"bg-slate-200"}`},s))}),d===0&&e.jsxs("div",{className:"space-y-6",children:[e.jsx("h2",{className:"text-lg font-bold",children:t?"Sus Derechos":"Your Rights"}),e.jsx("div",{className:"bg-blue-50 border border-blue-200 rounded-lg p-4 text-sm",children:t?le:ae}),e.jsx("div",{className:"bg-slate-50 border border-slate-200 rounded-lg p-4 text-sm text-slate-700",children:I}),e.jsx("button",{onClick:()=>l(1),className:"w-full bg-blue-600 text-white rounded-lg py-3 font-medium text-lg",children:t?"Continuar al informe":"Continue to report"})]}),d===1&&e.jsxs("div",{className:"space-y-6",children:[e.jsxs("button",{onClick:()=>l(0),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsx("h2",{className:"text-lg font-bold",children:t?`Hola ${i.driver.name}, ¿eres tú?`:`Hi ${i.driver.name}, is this you?`}),e.jsx("button",{onClick:()=>l(2),className:"w-full bg-blue-600 text-white rounded-lg py-4 font-medium text-lg",children:t?"Sí, continuar":"Yes, continue"}),e.jsx("button",{className:"w-full border border-slate-300 rounded-lg py-4 text-sm text-slate-600",children:t?"Este no soy yo":"This isn't me — call my dispatcher"})]}),d===2&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>l(1),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsx("h2",{className:"text-lg font-bold",children:t?"¿Qué pasó?":"What happened?"}),e.jsxs("p",{className:"text-sm text-slate-500 capitalize",children:[i.incident.incident_type," incident",i.incident.injury_subtype?` — ${i.incident.injury_subtype.replace("_"," ")}`:"",i.incident.vehicle_subtype?` — ${i.incident.vehicle_subtype.replace("_"," ")}`:""]}),e.jsx("button",{onClick:()=>l(v?3:4),className:"w-full bg-blue-600 text-white rounded-lg py-3 font-medium",children:t?"Continuar":"Continue"})]}),d===3&&v&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>l(2),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsx("h2",{className:"text-lg font-bold",children:t?"Parte(s) del cuerpo afectada(s)":"Body part(s) affected"}),e.jsx("p",{className:"text-sm text-slate-500",children:t?"Seleccione todas las que apliquen":"Select all that apply"}),e.jsx("div",{className:"grid grid-cols-2 gap-2",children:ie.map(s=>
1{const n=x.includes(s.id);return e.jsxs("button",{onClick:()=>L(o=>n?o.filter(u=>u!==s.id):[...o,s.id]),className:`py-3 px-4 rounded-lg border text-sm font-medium ${n?"bg-blue-600 text-white border-blue-600":"bg-white border-slate-300 text-slate-700"}`,children:[n&&"✓ ",t?s.es:s.en]},s.id)})}),e.jsxs("div",{className:"flex gap-2",children:[e.jsx("button",{onClick:()=>l(4),className:"flex-1 border border-slate-300 rounded-lg py-2 text-sm",children:t?"Omitir":"Skip"}),e.jsx("button",{onClick:()=>l(4),className:"flex-1 bg-blue-600 text-white rounded-lg py-2 font-medium",children:t?"Continuar":"Continue"})]})]}),d===4&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>l(v?3:2),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsx("h2",{className:"text-lg font-bold",children:t?"¿Qué pasó?":"What happened?"}),e.jsx("p",{className:"text-xs text-slate-500",children:t?"Solo tus palabras — no incluyas nada que tu despachador te haya dicho":"Your words only — do not include anything your dispatcher told you"}),e.jsx("textarea",{value:p,onChange:s=>$(s.target.value),maxLength:500,rows:4,className:"w-full border border-slate-300 rounded-lg p-3 text-sm",placeholder:t?"En 2-3 oraciones: ¿dónde estabas, qué pasó?":"In 2-3 sentences: where were you, what happened?"}),e.jsxs("p",{className:"text-xs text-right text-slate-400",children:[p.length,"/500"]}),e.jsxs("div",{className:"border-t pt-4",children:[e.jsxs("p",{className:"text-sm font-medium mb-2",children:[t?"¿Alguien más vio lo que pasó?":"Did anyone else see what happened?"," (",t?"opcional":"optional",")"]}),e.jsx("input",{value:b,onChange:s=>O(s.target.value),className:"w-full border border-slate-300 rounded-lg p-2 text-sm mb-2",placeholder:t?"Nombre del testigo":"Witness name"}),e.jsx("input",{value:f,onChange:s=>F(s.target.value),className:"w-full border border-slate-300 rounded-lg p-2 text-sm",placeholder:t?"Número de teléfono":"Phone number",type:"tel"})]}),e.jsx("button",{onClick:()=>l(5),disabled:!p.trim(),className:"w-full bg-blue-600 text-white rounded-lg py-3 font-medium disabled:opacity-50",children:t?"Continuar":"Continue"})]}),d===5&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>l(4),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsxs("h2",{className:"text-lg font-bold",children:[t?"Fotos / Video":"Photos / Video"," (",t?"opcional":"optional",")"]}),e.jsx("p",{className:"text-sm text-slate-500",children:t?"Agrega fotos o video de la lesión, escena, vehículo o animal (máx. 5, 10 MB cada uno)":"Add photos or video of the injury, scene, vehicle, or animal (max 5, 10 MB each)"}),r.length>0&&e.jsx("div",{className:"grid grid-cols-3 gap-2",children:r.map((s,n)=>e.jsxs("div",{className:"relative",children:[s.file.type.startsWith("video/")?e.jsx("video",{src:s.preview,className:"w-full h-24 object-cover rounded-lg bg-black"}):e.jsx("img",{src:s.preview,alt:"",className:"w-full h-24 object-cover rounded-lg"}),e.jsx("button",{onClick:()=>Q(n),className:"absolute -top-2 -right-2 bg-rose-500 text-white rounded-full w-6 h-6 text-xs flex items-center justify-center",children:"✕"})]},n))}),e.jsx("input",{ref:E,type:"file",accept:"image/*,video/*",multiple:!0,capture:"environment",onChange:s=>V(s.target.files),className:"hidden"}),r.length<5&&e.jsx("div",{className:"flex gap-2",children:e.jsx("button",{onClick:()=>E.current?.click(),className:"flex-1 border-2 border-dashed border-blue-300 rounded-lg py-4 text-sm text-blue-600 font-medium",children:t?"📷 Tomar foto o elegir archivo":"📷 Take photo or choose file"})}),e.jsxs("p",{className:"text-xs text-slate-400 text-center",children:[r.length,"/5 ",t?"archivos":"files"]}),e.jsx("button",{onClick:()=>l(6),className:"w-full bg-blue-600 text-white rounded-lg py-3 font-medium",children:r.length>0?t?"Continuar":"Continue":t?"Omitir":"Skip"})]}),d===6&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>l(5),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsx("h2",{className:"text-lg font-bold",children:t?"¿Estás recibiendo atención médica?":"Are you getting or planning to get medical care?"}),e.jsx("button",{onClick:()=>
1_("yes_received"),className:`w-full text-left py-4 px-4 rounded-lg border text-sm ${m==="yes_received"?"bg-blue-600 text-white border-blue-600":"bg-white border-slate-300"}`,children:t?"Sí — voy o he ido a una clínica u hospital":"Yes — I'm going or have gone to a clinic or hospital"}),m==="yes_received"&&e.jsx("input",{value:j,onChange:s=>U(s.target.value),className:"w-full border border-slate-300 rounded-lg p-2 text-sm",placeholder:t?"¿Dónde? (opcional)":"Where? (optional)"}),e.jsxs("button",{onClick:()=>_("not_right_now"),className:`w-full text-left py-4 px-4 rounded-lg border text-sm ${m==="not_right_now"?"bg-blue-600 text-white border-blue-600":"bg-white border-slate-300"}`,children:[e.jsx("span",{children:t?"No ahora mismo":"Not right now"}),e.jsx("span",{className:"block text-xs mt-1 opacity-75",children:t?"pero sé que puedo ver a un médico más tarde si lo necesito":"but I know I can still see a doctor later if needed"})]}),e.jsx("button",{onClick:()=>_("not_sure"),className:`w-full text-left py-4 px-4 rounded-lg border text-sm ${m==="not_sure"?"bg-blue-600 text-white border-blue-600":"bg-white border-slate-300"}`,children:t?"No estoy seguro/a todavía":"I'm not sure yet"}),e.jsx("button",{onClick:()=>l(7),disabled:!m,className:"w-full bg-blue-600 text-white rounded-lg py-3 font-medium disabled:opacity-50",children:t?"Continuar":"Continue"})]}),d===7&&e.jsxs("div",{className:"space-y-4",children:[e.jsxs("button",{onClick:()=>l(6),className:"text-sm text-blue-600",children:["← ",t?"Atrás":"Back"]}),e.jsx("h2",{className:"text-lg font-bold",children:t?"Revisar y enviar":"Review and submit"}),e.jsxs("div",{className:"bg-slate-50 rounded-lg p-4 text-sm space-y-2",children:[e.jsx("p",{className:"text-xs text-slate-500 font-medium mb-2",children:t?"Prellenado por su empleador:":"Pre-filled by your employer:"}),e.jsx("div",{children:i.driver.name}),e.jsx("div",{className:"capitalize",children:i.incident.incident_type}),i.incident.address&&e.jsx("div",{children:i.incident.address})]}),e.jsxs("div",{className:"bg-blue-50 rounded-lg p-4 text-sm space-y-2",children:[e.jsx("p",{className:"text-xs text-blue-600 font-medium mb-2",children:t?"Usted proporcionó:":"You provided:"}),e.jsxs("div",{children:[e.jsx("strong",{children:t?"Descripción:":"Description:"})," ",p]}),x.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:t?"Parte(s) del cuerpo:":"Body part(s):"})," ",x.map(s=>s.replace("_"," ")).join(", ")]}),e.jsxs("div",{children:[e.jsx("strong",{children:t?"Decisión médica:":"Medical:"})," ",m.replace("_"," ")]}),j&&e.jsxs("div",{children:[e.jsx("strong",{children:t?"Centro médico:":"Facility:"})," ",j]}),b&&e.jsxs("div",{children:[e.jsx("strong",{children:t?"Testigo:":"Witness:"})," ",b," ",f]}),r.length>0&&e.jsxs("div",{children:[e.jsx("strong",{children:t?"Fotos/Video:":"Photos/Video:"})," ",r.length," ",t?"archivo(s)":"file(s)"]})]}),e.jsxs("div",{className:"border border-slate-300 rounded-lg p-4 space-y-3",children:[e.jsx("p",{className:"text-xs font-medium text-slate-500 uppercase tracking-wide",children:t?"Firma electrónica":"Electronic Signature"}),e.jsx("p",{className:"text-xs text-slate-500",children:I}),e.jsx("p",{className:"text-sm text-slate-700",children:A}),e.jsxs("div",{children:[e.jsx("label",{className:"text-sm font-medium text-slate-600 block mb-1",children:t?"Escriba su nombre completo para firmar:":"Type your full name to sign:"}),e.jsx("input",{type:"text",value:y,onChange:s=>q(s.target.value),placeholder:i.driver?.name||(t?"Nombre completo":"Full name"),className:"w-full border border-slate-300 rounded-lg px-3 py-2 text-sm italic",autoComplete:"name"})]}),e.jsxs("label",{className:"flex items-center gap-2 cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:w,onChange:s=>W(s.target.checked)}),e.jsx("span",{className:"text-sm font-medium",children:t?"Confirmo que la información es precisa":"I confirm the information above is accurate"})]})]}),h.error&&e.jsx("div",{className:"bg-rose-50 border border-rose-200 rounded p-3 text-sm text-rose-700",children:h.error.message}),e.jsx("button",{onClick:K,disabled:!w||!y.trim()||h.isPending||P,className:"w-full bg-blue-600 text-white rounded-lg py-4 font-bold text-lg disabled:opacity-50",children:P?t?"Subiendo fotos...":"Uploading photos...":h.isPending?t?"Enviando...":"Submitting...":t?"Enviar informe":"Submit report"})]})]})})}function oe(){return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center",children:e.jsxs("div",{className:"text-center",children:[e.jsx("div",{className:"animate-spin h-8 w-8 border-2 border-blue-600 border-t-transparent roun
1ded-full mx-auto mb-4"}),e.jsx("p",{className:"text-sm text-slate-500",children:"Loading your incident report..."})]})})}function re({message:c}){return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"text-4xl mb-4",children:"⚠️"}),e.jsx("h1",{className:"text-lg font-bold mb-2",children:"Link Expired or Invalid"}),e.jsx("p",{className:"text-sm text-slate-500 mb-4",children:c}),e.jsx("p",{className:"text-sm text-slate-500",children:"Contact your dispatcher for a new link."})]})})}function ce(){return e.jsx("div",{className:"min-h-screen bg-white flex items-center justify-center p-4",children:e.jsxs("div",{className:"text-center max-w-sm",children:[e.jsx("div",{className:"text-4xl mb-4",children:"✅"}),e.jsx("h1",{className:"text-lg font-bold mb-2",children:"Report Submitted"}),e.jsx("p",{className:"text-sm text-slate-500",children:"You'll receive a text with a link to your copy. You have the right to workers' compensation benefits."})]})})}export{me 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.