fix-patient-appoiment
This commit is contained in:
parent
2c39f404d8
commit
edb717050b
@ -4,7 +4,7 @@ import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { CalendarRegistrationForm } from "@/components/forms/calendar-registration-form";
|
||||
import HeaderAgenda from "@/components/agenda/HeaderAgenda";
|
||||
import FooterAgenda from "@/components/agenda/FooterAgenda";
|
||||
import { useState } from "react";
|
||||
import { useState, useEffect } from "react";
|
||||
import { criarAgendamento } from '@/lib/api';
|
||||
import { toast } from '@/hooks/use-toast';
|
||||
|
||||
@ -40,6 +40,26 @@ export default function NovoAgendamentoPage() {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const [formData, setFormData] = useState<FormData>({});
|
||||
// Prefill from search params if provided (origin=consultas)
|
||||
useEffect(() => {
|
||||
try {
|
||||
const origin = searchParams?.get?.('origin')
|
||||
if (!origin) return
|
||||
const next: FormData = { ...formData }
|
||||
const pId = searchParams.get('patientId')
|
||||
const tipo = searchParams.get('tipo')
|
||||
const especialidade = searchParams.get('especialidade')
|
||||
const local = searchParams.get('local')
|
||||
if (pId) next.patientId = pId
|
||||
if (tipo) next.appointmentType = tipo
|
||||
if (especialidade) next.chief_complaint = `Especialidade: ${especialidade}`
|
||||
if (local) next.unit = local
|
||||
setFormData(next)
|
||||
} catch (e) {
|
||||
// ignore
|
||||
}
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [])
|
||||
|
||||
const handleFormChange = (data: FormData) => {
|
||||
setFormData(data);
|
||||
|
||||
@ -333,7 +333,9 @@ export default function PacientePage() {
|
||||
especialidade,
|
||||
local: localizacao
|
||||
})
|
||||
router.push(`/resultados?${params.toString()}`)
|
||||
// if we have a linked patient id, include it so the agenda page can prefill
|
||||
try { if (patientId) params.append('patientId', String(patientId)) } catch(e){}
|
||||
router.push(`/agenda?origin=consultas&${params.toString()}`)
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
31
susconecta/dev_user_info.json
Normal file
31
susconecta/dev_user_info.json
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"user": {
|
||||
"id": "8c02cbac-16f8-4437-b362-342f5a6ea6df",
|
||||
"email": "yinohos278@nrlord.com",
|
||||
"email_confirmed_at": "2025-10-22T21:14:13.540678Z",
|
||||
"created_at": "2025-10-22T21:14:13.536407Z",
|
||||
"last_sign_in_at": "2025-10-23T19:35:45.222772Z"
|
||||
},
|
||||
"profile": {
|
||||
"id": "8c02cbac-16f8-4437-b362-342f5a6ea6df",
|
||||
"full_name": "João Gustavo",
|
||||
"avatar_url": null,
|
||||
"created_at": "2025-10-22T21:14:13.536083+00:00",
|
||||
"updated_at": "2025-10-22T21:14:13.581474+00:00",
|
||||
"email": "yinohos278@nrlord.com",
|
||||
"disabled": false,
|
||||
"phone": "(79) 99161-9988"
|
||||
},
|
||||
"roles": [
|
||||
"paciente"
|
||||
],
|
||||
"permissions": {
|
||||
"isAdmin": false,
|
||||
"isManager": false,
|
||||
"isDoctor": false,
|
||||
"isSecretary": false,
|
||||
"isPatient": true,
|
||||
"canManageUsers": false,
|
||||
"isAdminOrManager": false
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user