PageSourceSearch

https://sentinel-365-c9d4f.web.app/assets/ConnectInboxPage-CaenTYBh.js

js sentinel-365-c9d4f.web.app collected 2026-10-03 12:35:59 UTC 8,063 bytes, 1 lines download raw bytes

1import{j as e,r as d}from"./react-vendor-pafHdoJx.js";import{b as k,d as u,u as y,l as b}from"./index-Db0fDLGN.js";import{C}from"./shared-DWiYwVXx.js";import{a0 as w,bs as A,o as D,ak as S,l as E,L as j,ae as F,aE as z,bc as B,a as L,M as P}from"./ui-vendor-DLXJn6s3.js";import{L as I,E as O,b as _}from"./shared-DHvo53EK.js";import"./map-vendor-Dr8zbd0c.js";import"./firebase-vendor-D3UzkAhn.js";function H({dispatchId:a,onDone:l}){const{toast:s}=y(),[t,o]=d.useState(""),[n,i]=d.useState(""),[m,g]=d.useState(""),[x,c]=d.useState(!1),[p,v]=d.useState(null),N=async()=>{c(!0);try{const r=await u.createTripGrant({dispatchId:a,cpf:n,phone:m,name:t});v(r.whatsappUrl),s({title:"Convite criado — envie pelo WhatsApp.",kind:"success"}),b("connect_trip_grant_created",{})}catch(r){s({title:(r==null?void 0:r.message)||"Falha ao criar convite",kind:"error"})}finally{c(!1)}},h={borderColor:"var(--border-primary)",color:"var(--page-text)",background:"transparent"};return e.jsx("div",{className:"mt-3 pt-3 border-t",style:{borderColor:"var(--border-primary)"},children:p?e.jsxs("div",{className:"flex flex-wrap items-center gap-3",children:[e.jsxs("a",{href:p,target:"_blank",rel:"noreferrer",className:"px-4 py-2 rounded-lg text-sm font-semibold flex items-center gap-2",style:{background:"#25D36620",color:"#25D366"},children:[e.jsx(P,{size:16})," Enviar convite no WhatsApp"]}),e.jsx("p",{className:"text-xs",style:{color:"var(--page-text-secondary)"},children:"O motorista entra com o celular (código SMS) e a viagem já aparece pra ele. Sem senha, sem cadastro."}),e.jsx("button",{onClick:l,className:"text-xs px-2 py-1 rounded",style:{color:"var(--page-text-secondary)"},children:"Fechar"})]}):e.jsxs("div",{className:"flex flex-wrap gap-2 items-center",children:[e.jsx("input",{value:t,onChange:r=>o(r.target.value),placeholder:"Nome do motorista",className:"px-3 py-2 rounded-lg border text-sm flex-1 min-w-[160px]",style:h}),e.jsx("input",{value:n,onChange:r=>i(r.target.value),placeholder:"CPF",className:"px-3 py-2 rounded-lg border text-sm w-36",style:h}),e.jsx("input",{value:m,onChange:r=>g(r.target.value),placeholder:"Celular (DDD + nº)",className:"px-3 py-2 rounded-lg border text-sm w-44",style:h}),e.jsxs("button",{onClick:N,disabled:x||!n||!m,className:"px-4 py-2 rounded-lg text-sm font-medium flex items-center gap-1.5 disabled:opacity-50",style:{background:"#10B981",color:"#fff"},children:[x?e.jsx(j,{size:15,className:"animate-spin"}):e.jsx(L,{size:15})," Convidar"]})]})})}function M({trip:a,onRefresh:l,showAccept:s}){const{toast:t}=y(),[o,n]=d.useState(!1),[i,m]=d.useState(!1),g=async()=>{n(!0);try{await u.acceptDispatch(a.id),t({title:"Coleta aceita — aponte o motorista na fila abaixo.",kind:"success"}),b("connect_dispatch_accept",{}),l()}catch(c){t({title:(c==null?void 0:c.message)||"Falha ao aceitar",kind:"error"})}finally{n(!1)}},x=async()=>{const c=window.prompt("Motivo da recusa (mín. 3 caracteres):");if(!(!c||c.trim().length<3)){n(!0);try{await u.rejectDispatch(a.id,c.trim()),t({title:"Coleta recusada — o embarcador foi notificado.",kind:"info"}),l()}catch(p){t({title:(p==null?void 0:p.message)||"Falha ao recusar",kind:"error"})}finally{n(!1)}}};return e.jsxs("div",{className:"rounded-xl border p-3.5",style:{borderColor:a.pickupLate?"#EF444450":"var(--border-primary)",background:"var(--surface-secondary)"},children:[e.jsxs("div",{className:"flex flex-wrap items-start justify-between gap-3",children:[e.jsxs("div",{className:"min-w-0 flex-1",children:[e.jsxs("p",{className:"text-sm font-bold truncate",style:{color:"var(--page-text)"},children:[a.origin," → ",a.destination]}),e.jsxs("p",{className:"text-xs mt-0.5",style:{color:"var(--page-text-secondary)"},children:[a.shipperName||"Embarcador",a.nfeNumber?` · NF-e ${a.nfeNumber}`:"",a.cargo?` · ${a.cargo}`:""]}),e.jsxs("div",{className:"flex flex-wrap items-center gap-2 mt-2",children:[e.jsxs("span",{className:"text-[11px] px-2 py-1 rounded font-medium flex items-center gap-1",style:{background:a.pickupLate?"#EF444418":"var(--surface-primary)",border:"1px solid var(--border-primary)",color:a.pickupLate?"#EF4444":"var(--page-text-secondary)"},children:[e.jsx(D,{size:11})," Coleta ",_(a.scheduledPickupAt),a.pickupLate?" · ATRASADA":a.pickupInHours!=null&&a.pickupInHours>=0?` · em ${a.pickupInHours}h`:""]}),a.scheduledDate&&e.jsxs("span",{className:"text-[11px] px-2 py-1 rounded font-medium flex items-center gap-1",style:{background:"var(--surface-primary)",border:"1px solid var(--border-primary)",color:"var(--page-text-secondary)"},children:[e.jsx(S,{size:11})," Entrega ",new Date(a.scheduledDate).toLocaleDateString("pt-BR")]}),a.needsDriver?e.jsxs("span",{className:"text-[11px] px-2 py-1 rounded font-semibold flex items-center gap-1",style:{background:"#F59E0B18",color:"#F59E0B"},children:[e.jsx(E,{size:11})," sem motorista"]}):e.jsxs("span",{className:"text-[11px] px-2 py-1 rounded font-medium",style:{background:"#10B98118",color:"#10B981"},children:[a.driverName,a.vehiclePlate?` · ${a.vehiclePlate}`:""]})]})]}),e.jsxs("div",{className:"flex items-center gap-2 shrink-0",children:[s&&e.jsxs(e.Fragment,{children:[e.jsxs("button",{onClick:g,disabled:o,className:"text-xs px-3 py-2 rounded-lg font-semibold flex items-center gap-1.5 disabled:opacity-50",style:{background:"#10B981",color:"#fff"},children:[o?e.jsx(j,{size:13,className:"animate-spin"}):e.jsx(F,{size:13})," Aceitar"]}),e.jsxs("button",{onClick:x,disabled:o,className:"text-xs px-2.5 py-2 rounded-lg flex items-center gap-1",style:{color:"#EF4444"},children:[e.jsx(z,{size:13})," Recusar"]})]}),!s&&a.needsDriver&&e.jsxs("button",{onClick:()=>m(!i),className:"text-xs px-3 py-2 rounded-lg font-semibold flex items-center gap-1.5",style:{background:"#10B98118",color:"#10B981"},children:[e.jsx(B,{size:13})," Apontar motorista"]})]})]}),i&&e.jsx(H,{dispatchId:a.id,onDone:()=>{m(!1),l()}}),a.waitingHours>=2&&s&&e.jsxs("p",{className:"text-[11px] mt-2",style:{color:"#F59E0B"},children:["O embarcador está esperando resposta há ",a.waitingHours,"h — isso conta no seu tempo de aceite."]})]})}function f({title:a,hint:l,trips:s,onRefresh:t,showAccept:o,empty:n}
1){return e.jsxs("div",{children:[e.jsxs("div",{className:"flex items-baseline gap-2 mb-2",children:[e.jsx("h2",{className:"text-sm font-bold",style:{color:"var(--page-text)"},children:a}),e.jsx("span",{className:"text-xs tabular-nums px-1.5 py-0.5 rounded font-semibold",style:{background:"var(--surface-secondary)",color:"var(--page-text-secondary)"},children:s.length}),e.jsx("span",{className:"text-[11px]",style:{color:"var(--page-text-secondary)"},children:l})]}),s.length===0?e.jsx(O,{text:n}):e.jsx("div",{className:"space-y-2",children:s.map(i=>e.jsx(M,{trip:i,onRefresh:t,showAccept:o},i.id))})]})}function X(){var t,o;const a=k(()=>u.connectInbox(),[]),l=((t=a.data)==null?void 0:t.aguardandoAceite)||[],s=((o=a.data)==null?void 0:o.aguardandoColeta)||[];return e.jsx(C,{icon:w,title:"Inbox de coletas",subtitle:"O que os embarcadores mandaram — aceite, aponte o motorista e o resto é automático",right:e.jsx("button",{onClick:()=>a.refetch(),className:"p-2 rounded-lg hover-surface","aria-label":"Atualizar",children:e.jsx(A,{size:15,style:{color:"var(--page-text-secondary)"}})}),children:a.loading&&!a.data?e.jsx(I,{}):e.jsxs("div",{className:"space-y-6",children:[e.jsx(f,{title:"Aguardando seu aceite",hint:"o embarcador está esperando resposta",trips:l,onRefresh:()=>a.refetch(),showAccept:!0,empty:"Nenhuma coleta esperando resposta. 🎯"}),e.jsx(f,{title:"Aceitas — aguardando coleta",hint:"precisam de motorista e embarque",trips:s,onRefresh:()=>a.refetch(),showAccept:!1,empty:"Nenhuma coleta pendente de embarque."}),e.jsx("p",{className:"text-[11px]",style:{color:"var(--page-text-secondary)"},children:"Ao aceitar, a viagem já aparece na torre do embarcador. O motorista entra pelo link de WhatsApp com código SMS — a partir daí posição, telemetria e comprovante fluem sozinhos, e a telemetria desliga quando a viagem encerra."})]})})}export{X 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.