115 lines
2.8 KiB
TypeScript
115 lines
2.8 KiB
TypeScript
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
|
|
}
|
|
}
|
|
|
|
// Define the Doctor data interface
|
|
export interface DoctorFormData {
|
|
id?: number;
|
|
nome: string;
|
|
nomeSocial?: string;
|
|
cpf: string;
|
|
rg: string;
|
|
crm: string;
|
|
crmUf: string;
|
|
especialidade: string;
|
|
email: string;
|
|
celular: string;
|
|
dataNascimento: string;
|
|
sexo: string;
|
|
cep: string;
|
|
logradouro: string;
|
|
numero: string;
|
|
complemento?: string;
|
|
bairro: string;
|
|
cidade: string;
|
|
estado: string;
|
|
observacoes?: string;
|
|
photo?: File | null;
|
|
}
|
|
|
|
|
|
// Mock data for doctors
|
|
const medicosMock: DoctorFormData[] = [
|
|
{
|
|
id: 1,
|
|
nome: "Dr. João da Silva",
|
|
nomeSocial: "",
|
|
cpf: "111.111.111-11",
|
|
rg: "11.111.111-1",
|
|
crm: "12345",
|
|
crmUf: "SP",
|
|
especialidade: "Cardiologia",
|
|
email: "joao.silva@example.com",
|
|
celular: "(11) 99999-1234",
|
|
dataNascimento: "1980-01-15",
|
|
sexo: "masculino",
|
|
cep: "01001-000",
|
|
logradouro: "Praça da Sé",
|
|
numero: "1",
|
|
bairro: "Sé",
|
|
cidade: "São Paulo",
|
|
estado: "SP",
|
|
},
|
|
{
|
|
id: 2,
|
|
nome: "Dra. Maria Oliveira",
|
|
nomeSocial: "Dra. Maria",
|
|
cpf: "222.222.222-22",
|
|
rg: "22.222.222-2",
|
|
crm: "54321",
|
|
crmUf: "RJ",
|
|
especialidade: "Dermatologia",
|
|
email: "maria.oliveira@example.com",
|
|
celular: "(21) 98888-5678",
|
|
dataNascimento: "1985-05-20",
|
|
sexo: "feminino",
|
|
cep: "20031-050",
|
|
logradouro: "Av. Pres. Wilson",
|
|
numero: "231",
|
|
bairro: "Centro",
|
|
cidade: "Rio de Janeiro",
|
|
estado: "RJ",
|
|
},
|
|
];
|
|
|
|
export async function getMedicos(): Promise<DoctorFormData[]> {
|
|
return new Promise(resolve => {
|
|
setTimeout(() => {
|
|
resolve(medicosMock);
|
|
}, 500);
|
|
});
|
|
}
|
|
|
|
export async function getMedicoById(id: number): Promise<DoctorFormData | undefined> {
|
|
return new Promise(resolve => {
|
|
setTimeout(() => {
|
|
const medico = medicosMock.find(m => m.id === id);
|
|
resolve(medico);
|
|
}, 300);
|
|
});
|
|
}
|
|
|
|
|
|
export async function salvarMedico(formData: DoctorFormData) {
|
|
try {
|
|
const response = await axios.post("https://mock.apidog.com/m1/1053378-0-default/medicos", formData,
|
|
{ headers: { "Content-Type": "application/json" } }
|
|
);
|
|
console.log("Médico salvo com sucesso:", response.data);
|
|
return response.data;
|
|
} catch (error) {
|
|
console.error('Erro ao salvar médico:', error);
|
|
throw error;
|
|
}
|
|
}
|