Merge feature/mudança-vissual into develop
This commit is contained in:
commit
50119c7bf6
@ -16,6 +16,8 @@ export default function FinanceiroPage() {
|
|||||||
const pathname = usePathname();
|
const pathname = usePathname();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
const [bloqueio, setBloqueio] = useState(false);
|
const [bloqueio, setBloqueio] = useState(false);
|
||||||
|
const [formaTipo, setFormaTipo] = useState("");
|
||||||
|
const [parcelas, setParcelas] = useState("1");
|
||||||
|
|
||||||
const isAg = pathname?.startsWith("/agendamento");
|
const isAg = pathname?.startsWith("/agendamento");
|
||||||
const isPr = pathname?.startsWith("/procedimento");
|
const isPr = pathname?.startsWith("/procedimento");
|
||||||
@ -90,7 +92,7 @@ export default function FinanceiroPage() {
|
|||||||
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
<div className="grid grid-cols-1 md:grid-cols-3 gap-4">
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label className="text-xs text-muted-foreground">Tipo</Label>
|
<Label className="text-xs text-muted-foreground">Tipo</Label>
|
||||||
<select className="h-10 w-full rounded-md border border-gray-300 dark:border-input bg-background text-foreground pr-8 pl-3 text-[13px] appearance-none transition-colors hover:bg-muted/30 hover:border-gray-400">
|
<select value={formaTipo} onChange={(e) => setFormaTipo(e.target.value)} className="h-10 w-full rounded-md border border-gray-300 dark:border-input bg-background text-foreground pr-8 pl-3 text-[13px] appearance-none transition-colors hover:bg-muted/30 hover:border-gray-400">
|
||||||
<option value="">Selecionar</option>
|
<option value="">Selecionar</option>
|
||||||
<option value="dinheiro">Dinheiro</option>
|
<option value="dinheiro">Dinheiro</option>
|
||||||
<option value="cartao">Cartão</option>
|
<option value="cartao">Cartão</option>
|
||||||
|
|||||||
@ -368,7 +368,18 @@ const payload: MedicoInput = {
|
|||||||
neighborhood: form.bairro || undefined,
|
neighborhood: form.bairro || undefined,
|
||||||
city: form.cidade || "",
|
city: form.cidade || "",
|
||||||
state: form.estado || "",
|
state: form.estado || "",
|
||||||
birth_date: form.data_nascimento || null,
|
// converte dd/MM/yyyy para ISO
|
||||||
|
birth_date: (() => {
|
||||||
|
try {
|
||||||
|
const parts = String(form.data_nascimento).split(/\D+/).filter(Boolean);
|
||||||
|
if (parts.length === 3) {
|
||||||
|
const [d, m, y] = parts;
|
||||||
|
const date = new Date(Number(y), Number(m) - 1, Number(d));
|
||||||
|
if (!isNaN(date.getTime())) return date.toISOString().slice(0, 10);
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
return null;
|
||||||
|
})(),
|
||||||
rg: form.rg || null,
|
rg: form.rg || null,
|
||||||
active: true,
|
active: true,
|
||||||
created_by: null,
|
created_by: null,
|
||||||
@ -653,7 +664,22 @@ if (missingFields.length > 0) {
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label>Data de Nascimento</Label>
|
<Label>Data de Nascimento</Label>
|
||||||
<Input type="date" value={form.data_nascimento} onChange={(e) => setField("data_nascimento", e.target.value)} />
|
<Input
|
||||||
|
placeholder="dd/mm/aaaa"
|
||||||
|
value={form.data_nascimento}
|
||||||
|
onChange={(e) => {
|
||||||
|
const v = e.target.value.replace(/[^0-9\/]/g, "").slice(0, 10);
|
||||||
|
setField("data_nascimento", v);
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
const raw = form.data_nascimento;
|
||||||
|
const parts = raw.split(/\D+/).filter(Boolean);
|
||||||
|
if (parts.length === 3) {
|
||||||
|
const d = `${parts[0].padStart(2,'0')}/${parts[1].padStart(2,'0')}/${parts[2].padStart(4,'0')}`;
|
||||||
|
setField("data_nascimento", d);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
@ -2,6 +2,7 @@
|
|||||||
"use client";
|
"use client";
|
||||||
|
|
||||||
import { useEffect, useMemo, useState } from "react";
|
import { useEffect, useMemo, useState } from "react";
|
||||||
|
import { format, parse, isValid, parseISO } from "date-fns";
|
||||||
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";
|
||||||
@ -130,7 +131,9 @@ export function PatientRegistrationForm({
|
|||||||
cpf: p.cpf || "",
|
cpf: p.cpf || "",
|
||||||
rg: p.rg || "",
|
rg: p.rg || "",
|
||||||
sexo: p.sex || "",
|
sexo: p.sex || "",
|
||||||
birth_date: p.birth_date || "", // 👈 trocar data_nascimento → birth_date
|
birth_date: p.birth_date ? (() => {
|
||||||
|
try { return format(parseISO(String(p.birth_date)), 'dd/MM/yyyy'); } catch { return String(p.birth_date); }
|
||||||
|
})() : "",
|
||||||
telefone: p.phone_mobile || "",
|
telefone: p.phone_mobile || "",
|
||||||
email: p.email || "",
|
email: p.email || "",
|
||||||
cep: p.cep || "",
|
cep: p.cep || "",
|
||||||
@ -199,13 +202,26 @@ export function PatientRegistrationForm({
|
|||||||
}
|
}
|
||||||
|
|
||||||
function toPayload(): PacienteInput {
|
function toPayload(): PacienteInput {
|
||||||
|
// converte dd/MM/yyyy para ISO (yyyy-MM-dd) se possível
|
||||||
|
let isoDate: string | null = null;
|
||||||
|
try {
|
||||||
|
const parts = String(form.birth_date).split(/\D+/).filter(Boolean);
|
||||||
|
if (parts.length === 3) {
|
||||||
|
const [d, m, y] = parts;
|
||||||
|
const date = new Date(Number(y), Number(m) - 1, Number(d));
|
||||||
|
if (!isNaN(date.getTime())) {
|
||||||
|
isoDate = date.toISOString().slice(0, 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch {}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
full_name: form.nome, // 👈 troca 'nome' por 'full_name'
|
full_name: form.nome, // 👈 troca 'nome' por 'full_name'
|
||||||
social_name: form.nome_social || null,
|
social_name: form.nome_social || null,
|
||||||
cpf: form.cpf,
|
cpf: form.cpf,
|
||||||
rg: form.rg || null,
|
rg: form.rg || null,
|
||||||
sex: form.sexo || null,
|
sex: form.sexo || null,
|
||||||
birth_date: form.birth_date || null, // 👈 troca data_nascimento → birth_date
|
birth_date: isoDate, // enviar ISO ou null
|
||||||
phone_mobile: form.telefone || null,
|
phone_mobile: form.telefone || null,
|
||||||
email: form.email || null,
|
email: form.email || null,
|
||||||
cep: form.cep || null,
|
cep: form.cep || null,
|
||||||
@ -504,8 +520,24 @@ export function PatientRegistrationForm({
|
|||||||
</div>
|
</div>
|
||||||
<div className="space-y-2">
|
<div className="space-y-2">
|
||||||
<Label>Data de Nascimento</Label>
|
<Label>Data de Nascimento</Label>
|
||||||
<Input type="date" value={form.birth_date} onChange={(e) => setField("birth_date", e.target.value)} />
|
<Input
|
||||||
|
placeholder="dd/mm/aaaa"
|
||||||
|
value={form.birth_date}
|
||||||
|
onChange={(e) => {
|
||||||
|
// permita apenas números e '/'
|
||||||
|
const v = e.target.value.replace(/[^0-9\/]/g, "").slice(0, 10);
|
||||||
|
setField("birth_date", v);
|
||||||
|
}}
|
||||||
|
onBlur={() => {
|
||||||
|
// tenta formatar automaticamente se for uma data válida
|
||||||
|
const raw = form.birth_date;
|
||||||
|
const parts = raw.split(/\D+/).filter(Boolean);
|
||||||
|
if (parts.length === 3) {
|
||||||
|
const d = `${parts[0].padStart(2,'0')}/${parts[1].padStart(2,'0')}/${parts[2].padStart(4,'0')}`;
|
||||||
|
setField("birth_date", d);
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
/>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</CardContent>
|
</CardContent>
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user