PageSourceSearch

https://endo-health-chi.vercel.app/assets/NutriCheckInPatientPage-CdFeLuG9.js

js endo-health-chi.vercel.app collected 2026-10-03 06:54:13 UTC 4,641 bytes, 1 lines download raw bytes

1import{a as n,j as e}from"./vendor-framer-motion-DgxRQIHL.js";import{I as P}from"./vendor-firebase-U95O8hiF.js";import{bc as I,B as G}from"./index-9GEQNrq5.js";import{n as O,a as F}from"./nutriCheckInService-8-7Tq9tK.js";import"./vendor-editor-D77TyNkE.js";import"./vendor-pdf-DqDRg8pW.js";import"./vendor-charts-IsSz2KDH.js";const y=/^[a-f0-9]{48}$/;function w(a,l){if(a instanceof P){if(a.code==="functions/not-found")return"Este link não está disponível. Solicite um novo ao consultório.";if(a.code==="functions/invalid-argument")return"Verifique os dados e tente novamente."}return l}const H=()=>{const{token:a}=I(),[l,g]=n.useState(!0),[b,d]=n.useState(null),[o,j]=n.useState(null),[u,E]=n.useState(""),[m,S]=n.useState(""),[x,v]=n.useState({}),[N,f]=n.useState(!1),[C,z]=n.useState(!1),[k,p]=n.useState(null);n.useEffect(()=>{const t=a?.trim()||"";if(!y.test(t)){d("Link inválido."),g(!1);return}let r=!1;return(async()=>{try{const s=await O(t);if(!r){j(s);const c={};s.suggestedGoalLabels.forEach(h=>{c[h]=!1}),v(c),d(null)}}catch(s){r||(d(w(s,"Não foi possível abrir o registro.")),j(null))}finally{r||g(!1)}})(),()=>{r=!0}},[a]);const L=n.useCallback(async t=>{t.preventDefault();const r=a?.trim()||"";if(!(!y.test(r)||!o)){f(!0),p(null);try{let s;const c=u.replace(",",".").trim();if(c.length>0){const i=Number(c);if(!Number.isFinite(i)||i<2||i>400){p("Peso inválido (use um número entre 2 e 400 kg ou deixe em branco)."),f(!1);return}s=i}const h=Object.entries(x).filter(([,i])=>i).map(([i])=>i);await F({token:r,weightKg:s,note:m.trim()||void 0,completedGoalLabels:h}),z(!0)}catch(s){p(w(s,"Não foi possível enviar. Tente novamente."))}finally{f(!1)}}},[a,o,u,m,x]);return l?e.jsx("div",{className:"min-h-screen flex items-center justify-center bg-zinc-50 dark:bg-zinc-950 px-4",children:e.jsx("p",{className:"text-sm text-muted",children:"Carregando…"})}):b||!o?e.jsx("div",{className:"min-h-screen flex flex-col items-center justify-center bg-zinc-50 dark:bg-zinc-950 px-4 text-center",children:e.jsx("p",{className:"text-sm text-foreground max-w-md",children:b||"Indisponível."})}):C?e.jsxs("div",{className:"min-h-screen flex flex-col items-center justify-center bg-zinc-50 dark:bg-zinc-950 px-4 text-center",children:[e.jsx("p",{className:"text-lg font-semibold text-foreground",children:"Registro enviado"}),e.jsx("p",{className:"text-sm text-muted mt-2 max-w-md",children:"Obrigado. Seu nutricionista verá este check-in na consulta."})]}):e.jsx("div",{className:"min-h-screen bg-zinc-50 dark:bg-zinc-950 py-10 px-4",children:e.jsxs("div",{className:"max-w-lg mx-auto rounded-2xl border border-subtle bg-surface shadow-sm p-6 space-y-6",children:[e.jsxs("header",{children:[e.jsx("p",{className:"text-xs font-semibold uppercase tracking-wide text-muted",children:o.clinicName}),e.jsx("h1",{className:"text-xl font-bold text-foreground mt-1",children:"Check-in"}),e.jsxs("p",{className:"text-sm text-muted mt-1",children:["Olá, ",o.patientHint,". Registre peso e marque metas cumpridas, se aplicável."]})]}),e.jsxs("form",{onSubmit:L,className:"space-y-5",children:[e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-bold text-muted uppercase",htmlFor:"weight-kg",children:"Peso (kg) — opcional"}),e.jsx("input",{id:"weight-kg",type:"text",inputMode:"decimal",value:u,onChange:t=>E(t.target.value),placeholder:"Ex.: 72,5",className:"mt-1 w-full rounded-xl border border-subtle bg-surface px-3 py-2 text-sm text-foreground",autoComplete:"off"})]}),o.suggestedGoalLabels.length>0&&e.jsxs("fieldset",{children:[e.jsx("legend",{className:"text-xs font-bold text-muted uppercase mb-2",children:"Metas sugeridas"}),e.jsx("ul",{className:"space-y-2",children:o.suggestedGoalLabels.map(t=>e.jsx("li",{children:e.jsxs("label",{className:"flex items-start gap-2 text-sm text-foreground cursor-pointer",children:[e.jsx("input",{type:"checkbox",checked:!!x[t],onChange:r=>v(s=>({...s,[t]:r.target.checked})),className:"mt-0.5 rounded border-subtle"}),e.jsx("span",{children:t})]})},t))})]}),e.jsxs("div",{children:[e.jsx("label",{className:"text-xs font-bold text-muted uppercase",htmlFor:"checkin-note",children:"Observação — opcional"}),e.jsx("textarea",{id:"checkin-note",value:m,onChange:t=>
1S(t.target.value),maxLength:2e3,rows:3,placeholder:"Como foi a semana, dúvidas…",className:"mt-1 w-full rounded-xl border border-subtle bg-surface px-3 py-2 text-sm text-foreground resize-y"})]}),k&&e.jsx("p",{className:"text-sm text-red-600 dark:text-red-400",children:k}),e.jsx(G,{type:"submit",disabled:N,className:"w-full",children:N?"Enviando…":"Enviar check-in"})]})]})})};export{H 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.