feat:change background color and add required fields to patient registration
This commit is contained in:
parent
a44e9bcf81
commit
43c97fadd0
@ -6,7 +6,7 @@
|
||||
:root {
|
||||
--background: #ffffff;
|
||||
--foreground: #475569;
|
||||
--card: #f8fafc;
|
||||
--card: #ffffff;
|
||||
--card-foreground: #334155;
|
||||
--popover: #ffffff;
|
||||
--popover-foreground: #475569;
|
||||
|
||||
@ -321,6 +321,19 @@ export function PatientRegistrationForm({
|
||||
const validateForm = () => {
|
||||
const newErrors: Record<string, string> = {}
|
||||
|
||||
//Campos obrigatórios
|
||||
if (!formData.cpf.trim()) newErrors.cpf = "CPF é obrigatório"
|
||||
if (!formData.rg.trim()) newErrors.rg = "RG é obrigatório"
|
||||
if (!formData.sexo.trim()) newErrors.sexo = "Sexo é obrigatório"
|
||||
if (!formData.nomeMae.trim()) newErrors.nomeMae = "Nome da mãe é obrigatório"
|
||||
if (!formData.nomeResponsavel.trim()) newErrors.nomeResponsavel = "Nome do responsável é obrigatório"
|
||||
if (!formData.celular.trim()) newErrors.celular = "Celular é obrigatório"
|
||||
if (!formData.cep.trim()) newErrors.cep = "CEP é obrigatório"
|
||||
if (!formData.numero.trim()) newErrors.numero = "Número é obrigatório"
|
||||
if (!formData.bairro.trim()) newErrors.bairro = "Bairro é obrigatório"
|
||||
if (!formData.cidade.trim()) newErrors.cidade = "Cidade é obrigatório"
|
||||
if (!formData.estado.trim()) newErrors.estado = "Estado é obrigatório"
|
||||
|
||||
// Required fields
|
||||
if (!formData.nome.trim()) {
|
||||
newErrors.nome = "Nome é obrigatório"
|
||||
@ -330,6 +343,9 @@ export function PatientRegistrationForm({
|
||||
if (formData.cpf && !validateCPF(formData.cpf)) {
|
||||
newErrors.cpf = "CPF inválido"
|
||||
}
|
||||
if (formData.cpfResponsavel && !validateCPF(formData.cpfResponsavel)) {
|
||||
newErrors.cpfResponsavel = "CPF do responsável inválido"
|
||||
}
|
||||
|
||||
// Email validation
|
||||
if (formData.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
|
||||
@ -434,7 +450,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.dadosPessoais} onOpenChange={() => toggleSection("dadosPessoais")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<User className="h-4 w-4" />
|
||||
@ -769,7 +785,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.observacoes} onOpenChange={() => toggleSection("observacoes")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<FileText className="h-4 w-4" />
|
||||
@ -833,7 +849,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.contato} onOpenChange={() => toggleSection("contato")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<Phone className="h-4 w-4" />
|
||||
@ -901,7 +917,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.endereco} onOpenChange={() => toggleSection("endereco")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<MapPin className="h-4 w-4" />
|
||||
@ -1014,21 +1030,21 @@ export function PatientRegistrationForm({
|
||||
</Collapsible>
|
||||
|
||||
{/* Botões de Ação */}
|
||||
<div className="flex justify-end gap-4 pt-6 border-t">
|
||||
<Button
|
||||
<div className="flex justify-end gap-4 pt-6 border-t">
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
onClick={handleCancel}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
>
|
||||
<XCircle className="mr-2 h-4 w-4" />
|
||||
Cancelar
|
||||
</Button>
|
||||
<Button
|
||||
</Button>
|
||||
<Button
|
||||
type="submit"
|
||||
className="bg-primary hover:bg-primary/90"
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
>
|
||||
{isSubmitting ? (
|
||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||
) : (
|
||||
@ -1037,10 +1053,10 @@ export function PatientRegistrationForm({
|
||||
{isSubmitting
|
||||
? "Salvando..."
|
||||
: mode === "create"
|
||||
? "Salvar Paciente"
|
||||
: "Atualizar Paciente"}
|
||||
</Button>
|
||||
</div>
|
||||
? "Salvar Paciente"
|
||||
: "Atualizar Paciente"}
|
||||
</Button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
)
|
||||
@ -1068,7 +1084,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.dadosPessoais} onOpenChange={() => toggleSection("dadosPessoais")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<User className="h-4 w-4" />
|
||||
@ -1403,7 +1419,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.observacoes} onOpenChange={() => toggleSection("observacoes")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<FileText className="h-4 w-4" />
|
||||
@ -1467,7 +1483,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.contato} onOpenChange={() => toggleSection("contato")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<Phone className="h-4 w-4" />
|
||||
@ -1535,7 +1551,7 @@ export function PatientRegistrationForm({
|
||||
<Collapsible open={expandedSections.endereco} onOpenChange={() => toggleSection("endereco")}>
|
||||
<Card>
|
||||
<CollapsibleTrigger asChild>
|
||||
<CardHeader className="cursor-pointer hover:bg-muted/50 transition-colors">
|
||||
<CardHeader className="cursor-pointer transition-colors">
|
||||
<CardTitle className="flex items-center justify-between">
|
||||
<span className="flex items-center gap-2">
|
||||
<MapPin className="h-4 w-4" />
|
||||
@ -1649,7 +1665,6 @@ export function PatientRegistrationForm({
|
||||
|
||||
{/* Botões de Ação */}
|
||||
<div className="flex justify-end gap-4 pt-6 border-t">
|
||||
<<<<<<< HEAD
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
@ -1658,9 +1673,6 @@ export function PatientRegistrationForm({
|
||||
}}
|
||||
disabled={isSubmitting}
|
||||
>
|
||||
=======
|
||||
<Button type="button" variant="outline" onClick={() => onOpenChange?.(false)} disabled={isSubmitting}>
|
||||
>>>>>>> 3cce8a9774ff469e9a525f42607dcfa5b09c84b8
|
||||
<XCircle className="mr-2 h-4 w-4" />
|
||||
Cancelar
|
||||
</Button>
|
||||
|
||||
13
susconecta/lib/api.ts
Normal file
13
susconecta/lib/api.ts
Normal file
@ -0,0 +1,13 @@
|
||||
import axios from "axios";
|
||||
|
||||
export async function salvarPaciente(formData: Record<string, any>) {
|
||||
try {
|
||||
const response = await axios.post("https://mock.apidog.com/m1/1053378-0-default/pacientes", formData,
|
||||
{ headers: { "Content-Type": "application/json" } }
|
||||
);
|
||||
return response.data;
|
||||
} catch (error) {
|
||||
console.log('error', error);
|
||||
throw error
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user