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 {
|
:root {
|
||||||
--background: #ffffff;
|
--background: #ffffff;
|
||||||
--foreground: #475569;
|
--foreground: #475569;
|
||||||
--card: #f8fafc;
|
--card: #ffffff;
|
||||||
--card-foreground: #334155;
|
--card-foreground: #334155;
|
||||||
--popover: #ffffff;
|
--popover: #ffffff;
|
||||||
--popover-foreground: #475569;
|
--popover-foreground: #475569;
|
||||||
|
|||||||
@ -321,6 +321,19 @@ export function PatientRegistrationForm({
|
|||||||
const validateForm = () => {
|
const validateForm = () => {
|
||||||
const newErrors: Record<string, string> = {}
|
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
|
// Required fields
|
||||||
if (!formData.nome.trim()) {
|
if (!formData.nome.trim()) {
|
||||||
newErrors.nome = "Nome é obrigatório"
|
newErrors.nome = "Nome é obrigatório"
|
||||||
@ -330,6 +343,9 @@ export function PatientRegistrationForm({
|
|||||||
if (formData.cpf && !validateCPF(formData.cpf)) {
|
if (formData.cpf && !validateCPF(formData.cpf)) {
|
||||||
newErrors.cpf = "CPF inválido"
|
newErrors.cpf = "CPF inválido"
|
||||||
}
|
}
|
||||||
|
if (formData.cpfResponsavel && !validateCPF(formData.cpfResponsavel)) {
|
||||||
|
newErrors.cpfResponsavel = "CPF do responsável inválido"
|
||||||
|
}
|
||||||
|
|
||||||
// Email validation
|
// Email validation
|
||||||
if (formData.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
|
if (formData.email && !/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(formData.email)) {
|
||||||
@ -434,7 +450,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.dadosPessoais} onOpenChange={() => toggleSection("dadosPessoais")}>
|
<Collapsible open={expandedSections.dadosPessoais} onOpenChange={() => toggleSection("dadosPessoais")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<User className="h-4 w-4" />
|
<User className="h-4 w-4" />
|
||||||
@ -769,7 +785,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.observacoes} onOpenChange={() => toggleSection("observacoes")}>
|
<Collapsible open={expandedSections.observacoes} onOpenChange={() => toggleSection("observacoes")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<FileText className="h-4 w-4" />
|
<FileText className="h-4 w-4" />
|
||||||
@ -833,7 +849,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.contato} onOpenChange={() => toggleSection("contato")}>
|
<Collapsible open={expandedSections.contato} onOpenChange={() => toggleSection("contato")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<Phone className="h-4 w-4" />
|
<Phone className="h-4 w-4" />
|
||||||
@ -901,7 +917,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.endereco} onOpenChange={() => toggleSection("endereco")}>
|
<Collapsible open={expandedSections.endereco} onOpenChange={() => toggleSection("endereco")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<MapPin className="h-4 w-4" />
|
<MapPin className="h-4 w-4" />
|
||||||
@ -1014,21 +1030,21 @@ export function PatientRegistrationForm({
|
|||||||
</Collapsible>
|
</Collapsible>
|
||||||
|
|
||||||
{/* Botões de Ação */}
|
{/* Botões de Ação */}
|
||||||
<div className="flex justify-end gap-4 pt-6 border-t">
|
<div className="flex justify-end gap-4 pt-6 border-t">
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
onClick={handleCancel}
|
onClick={handleCancel}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
<XCircle className="mr-2 h-4 w-4" />
|
<XCircle className="mr-2 h-4 w-4" />
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
<Button
|
<Button
|
||||||
type="submit"
|
type="submit"
|
||||||
className="bg-primary hover:bg-primary/90"
|
className="bg-primary hover:bg-primary/90"
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
{isSubmitting ? (
|
{isSubmitting ? (
|
||||||
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
) : (
|
) : (
|
||||||
@ -1037,10 +1053,10 @@ export function PatientRegistrationForm({
|
|||||||
{isSubmitting
|
{isSubmitting
|
||||||
? "Salvando..."
|
? "Salvando..."
|
||||||
: mode === "create"
|
: mode === "create"
|
||||||
? "Salvar Paciente"
|
? "Salvar Paciente"
|
||||||
: "Atualizar Paciente"}
|
: "Atualizar Paciente"}
|
||||||
</Button>
|
</Button>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -1068,7 +1084,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.dadosPessoais} onOpenChange={() => toggleSection("dadosPessoais")}>
|
<Collapsible open={expandedSections.dadosPessoais} onOpenChange={() => toggleSection("dadosPessoais")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<User className="h-4 w-4" />
|
<User className="h-4 w-4" />
|
||||||
@ -1403,7 +1419,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.observacoes} onOpenChange={() => toggleSection("observacoes")}>
|
<Collapsible open={expandedSections.observacoes} onOpenChange={() => toggleSection("observacoes")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<FileText className="h-4 w-4" />
|
<FileText className="h-4 w-4" />
|
||||||
@ -1467,7 +1483,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.contato} onOpenChange={() => toggleSection("contato")}>
|
<Collapsible open={expandedSections.contato} onOpenChange={() => toggleSection("contato")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<Phone className="h-4 w-4" />
|
<Phone className="h-4 w-4" />
|
||||||
@ -1535,7 +1551,7 @@ export function PatientRegistrationForm({
|
|||||||
<Collapsible open={expandedSections.endereco} onOpenChange={() => toggleSection("endereco")}>
|
<Collapsible open={expandedSections.endereco} onOpenChange={() => toggleSection("endereco")}>
|
||||||
<Card>
|
<Card>
|
||||||
<CollapsibleTrigger asChild>
|
<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">
|
<CardTitle className="flex items-center justify-between">
|
||||||
<span className="flex items-center gap-2">
|
<span className="flex items-center gap-2">
|
||||||
<MapPin className="h-4 w-4" />
|
<MapPin className="h-4 w-4" />
|
||||||
@ -1649,7 +1665,6 @@ export function PatientRegistrationForm({
|
|||||||
|
|
||||||
{/* Botões de Ação */}
|
{/* Botões de Ação */}
|
||||||
<div className="flex justify-end gap-4 pt-6 border-t">
|
<div className="flex justify-end gap-4 pt-6 border-t">
|
||||||
<<<<<<< HEAD
|
|
||||||
<Button
|
<Button
|
||||||
type="button"
|
type="button"
|
||||||
variant="outline"
|
variant="outline"
|
||||||
@ -1658,9 +1673,6 @@ export function PatientRegistrationForm({
|
|||||||
}}
|
}}
|
||||||
disabled={isSubmitting}
|
disabled={isSubmitting}
|
||||||
>
|
>
|
||||||
=======
|
|
||||||
<Button type="button" variant="outline" onClick={() => onOpenChange?.(false)} disabled={isSubmitting}>
|
|
||||||
>>>>>>> 3cce8a9774ff469e9a525f42607dcfa5b09c84b8
|
|
||||||
<XCircle className="mr-2 h-4 w-4" />
|
<XCircle className="mr-2 h-4 w-4" />
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</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