feat(doctor-form): add search doctor by ID button and logic to registration form
This commit is contained in:
parent
ea63a73b43
commit
a032465773
@ -1,6 +1,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { buscarPacientePorId } from "@/lib/api";
|
||||||
import { Button } from "@/components/ui/button";
|
import { Button } from "@/components/ui/button";
|
||||||
import { Input } from "@/components/ui/input";
|
import { Input } from "@/components/ui/input";
|
||||||
import { Label } from "@/components/ui/label";
|
import { Label } from "@/components/ui/label";
|
||||||
@ -154,7 +155,7 @@ export function DoctorRegistrationForm({
|
|||||||
let alive = true;
|
let alive = true;
|
||||||
async function load() {
|
async function load() {
|
||||||
if (mode === "edit" && doctorId) {
|
if (mode === "edit" && doctorId) {
|
||||||
const medico = await buscarMedicoPorId(doctorId);
|
const medico = await buscarMedicoPorId(String(doctorId));
|
||||||
if (!alive) return;
|
if (!alive) return;
|
||||||
setForm({
|
setForm({
|
||||||
photo: null,
|
photo: null,
|
||||||
@ -309,34 +310,27 @@ async function handleSubmit(ev: React.FormEvent) {
|
|||||||
setErrors((e) => ({ ...e, submit: "" }));
|
setErrors((e) => ({ ...e, submit: "" }));
|
||||||
|
|
||||||
const payload: MedicoInput = {
|
const payload: MedicoInput = {
|
||||||
full_name: form.full_name,
|
user_id: null, // ou o UUID real
|
||||||
nome_social: form.nome_social || null,
|
|
||||||
cpf: form.cpf || "",
|
|
||||||
rg: form.rg || null,
|
|
||||||
sexo: form.sexo || null,
|
|
||||||
data_nascimento: form.data_nascimento || null,
|
|
||||||
celular: form.celular || "",
|
|
||||||
email: form.email || undefined,
|
|
||||||
crm: form.crm,
|
crm: form.crm,
|
||||||
crm_uf: form.estado_crm || null,
|
crm_uf: form.estado_crm,
|
||||||
rqe: form.rqe || null,
|
specialty: form.especialidade,
|
||||||
formacao_academica: form.formacao_academica,
|
full_name: form.full_name,
|
||||||
especialidade: form.especialidade || "",
|
cpf: form.cpf,
|
||||||
observacoes: form.observacoes || null,
|
email: form.email,
|
||||||
tipo_vinculo: form.tipo_vinculo || null,
|
phone_mobile: form.celular,
|
||||||
dados_bancarios: form.dados_bancarios || null, // Remova se não for necessário
|
phone2: form.telefone || null,
|
||||||
valor_consulta: form.valor_consulta || null,
|
cep: form.cep,
|
||||||
|
street: form.logradouro,
|
||||||
|
number: form.numero,
|
||||||
|
complement: form.complemento,
|
||||||
|
neighborhood: form.bairro,
|
||||||
|
city: form.cidade,
|
||||||
|
state: form.estado,
|
||||||
|
birth_date: form.data_nascimento || null,
|
||||||
|
rg: form.rg || null,
|
||||||
active: true,
|
active: true,
|
||||||
cep: form.cep || null,
|
created_by: null, // ou o UUID real
|
||||||
city: form.cidade || null,
|
updated_by: null, // ou o UUID real
|
||||||
complement: form.complemento || null,
|
|
||||||
neighborhood: form.bairro || null,
|
|
||||||
number: form.numero || null,
|
|
||||||
phone2: form.telefone || null, // Ajustar conforme necessário
|
|
||||||
state: form.estado || null,
|
|
||||||
street: form.logradouro || null,
|
|
||||||
created_by: 'user_id',
|
|
||||||
updated_by: 'user_id',
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@ -121,47 +121,33 @@ export type Medico = {
|
|||||||
|
|
||||||
|
|
||||||
// ===== MÉDICOS =====
|
// ===== MÉDICOS =====
|
||||||
|
// ...existing code...
|
||||||
export type MedicoInput = {
|
export type MedicoInput = {
|
||||||
full_name: string;
|
|
||||||
nome_social?: string | null;
|
|
||||||
cpf: string;
|
|
||||||
rg?: string | null;
|
|
||||||
sexo?: string | null;
|
|
||||||
data_nascimento?: string | null;
|
|
||||||
telefone?: string;
|
|
||||||
celular?: string; // Este é o celular no seu código, mas talvez tenha que ser 'phone_mobile'
|
|
||||||
contato_emergencia?: string;
|
|
||||||
email?: string;
|
|
||||||
crm: string;
|
|
||||||
crm_uf?: string | null;
|
|
||||||
rqe?: string | null;
|
|
||||||
formacao_academica?: FormacaoAcademica[];
|
|
||||||
curriculo_url?: string | null;
|
|
||||||
especialidade: string;
|
|
||||||
observacoes?: string | null;
|
|
||||||
tipo_vinculo?: string | null;
|
|
||||||
dados_bancarios?: DadosBancarios | null;
|
|
||||||
agenda_horario?: string | null;
|
|
||||||
valor_consulta?: number | string | null;
|
|
||||||
active?: boolean;
|
|
||||||
cep?: string | null;
|
|
||||||
city?: string | null;
|
|
||||||
complement?: string | null;
|
|
||||||
neighborhood?: string | null;
|
|
||||||
number?: string | null;
|
|
||||||
phone2?: string | null; // Talvez seja o campo correto para o segundo telefone
|
|
||||||
state?: string | null;
|
|
||||||
street?: string | null;
|
|
||||||
created_at?: string;
|
|
||||||
created_by?: string | null;
|
|
||||||
updated_at?: string;
|
|
||||||
updated_by?: string | null;
|
|
||||||
user_id?: string | null;
|
user_id?: string | null;
|
||||||
|
crm: string;
|
||||||
|
crm_uf: string;
|
||||||
|
specialty: string;
|
||||||
|
full_name: string;
|
||||||
|
cpf: string;
|
||||||
|
email: string;
|
||||||
|
phone_mobile: string;
|
||||||
|
phone2?: string | null;
|
||||||
|
cep: string;
|
||||||
|
street: string;
|
||||||
|
number: string;
|
||||||
|
complement?: string;
|
||||||
|
neighborhood?: string;
|
||||||
|
city: string;
|
||||||
|
state: string;
|
||||||
|
birth_date: string | null;
|
||||||
|
rg?: string | null;
|
||||||
|
active?: boolean;
|
||||||
|
created_by?: string | null;
|
||||||
|
updated_by?: string | null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// ===== CONFIG =====
|
// ===== CONFIG =====
|
||||||
const API_BASE =
|
const API_BASE =
|
||||||
process.env.NEXT_PUBLIC_API_BASE ?? "https://yuanqfswhberkoevtmfr.supabase.co";
|
process.env.NEXT_PUBLIC_API_BASE ?? "https://yuanqfswhberkoevtmfr.supabase.co";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user