develop #83
@ -13,6 +13,7 @@ import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"
|
|||||||
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
import { Collapsible, CollapsibleContent, CollapsibleTrigger } from "@/components/ui/collapsible"
|
||||||
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"
|
import { Dialog, DialogContent, DialogHeader, DialogTitle } from "@/components/ui/dialog"
|
||||||
import { Alert, AlertDescription } from "@/components/ui/alert"
|
import { Alert, AlertDescription } from "@/components/ui/alert"
|
||||||
|
import { salvarPaciente } from "@/lib/api";
|
||||||
import {
|
import {
|
||||||
Upload,
|
Upload,
|
||||||
ChevronDown,
|
ChevronDown,
|
||||||
@ -29,6 +30,7 @@ import {
|
|||||||
Loader2,
|
Loader2,
|
||||||
} from "lucide-react"
|
} from "lucide-react"
|
||||||
|
|
||||||
|
|
||||||
interface PatientFormData {
|
interface PatientFormData {
|
||||||
// Dados pessoais
|
// Dados pessoais
|
||||||
photo: File | null
|
photo: File | null
|
||||||
@ -378,7 +380,7 @@ export function PatientRegistrationForm({
|
|||||||
console.log("[v0] Patient ID:", patientId)
|
console.log("[v0] Patient ID:", patientId)
|
||||||
|
|
||||||
// Simulate network delay
|
// Simulate network delay
|
||||||
await new Promise((resolve) => setTimeout(resolve, 1000))
|
await salvarPaciente(formData)
|
||||||
|
|
||||||
// TODO: Implement actual API call
|
// TODO: Implement actual API call
|
||||||
// const response = await fetch('/api/patients', {
|
// const response = await fetch('/api/patients', {
|
||||||
@ -1012,16 +1014,33 @@ 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 type="button" variant="outline" onClick={handleCancel} disabled={isSubmitting}>
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
onClick={handleCancel}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
<XCircle className="mr-2 h-4 w-4" />
|
<XCircle className="mr-2 h-4 w-4" />
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
<Button type="submit" className="bg-primary hover:bg-primary/90" disabled={isSubmitting}>
|
<Button
|
||||||
{isSubmitting ? <Loader2 className="mr-2 h-4 w-4 animate-spin" /> : <Save className="mr-2 h-4 w-4" />}
|
type="submit"
|
||||||
{isSubmitting ? "Salvando..." : mode === "create" ? "Salvar Paciente" : "Atualizar Paciente"}
|
className="bg-primary hover:bg-primary/90"
|
||||||
</Button>
|
disabled={isSubmitting}
|
||||||
</div>
|
>
|
||||||
|
{isSubmitting ? (
|
||||||
|
<Loader2 className="mr-2 h-4 w-4 animate-spin" />
|
||||||
|
) : (
|
||||||
|
<Save className="mr-2 h-4 w-4" />
|
||||||
|
)}
|
||||||
|
{isSubmitting
|
||||||
|
? "Salvando..."
|
||||||
|
: mode === "create"
|
||||||
|
? "Salvar Paciente"
|
||||||
|
: "Atualizar Paciente"}
|
||||||
|
</Button>
|
||||||
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
)
|
)
|
||||||
@ -1630,7 +1649,14 @@ 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">
|
||||||
<Button type="button" variant="outline" onClick={() => onOpenChange(false)} disabled={isSubmitting}>
|
<Button
|
||||||
|
type="button"
|
||||||
|
variant="outline"
|
||||||
|
onClick={() => {
|
||||||
|
if (onOpenChange) onOpenChange(false)
|
||||||
|
}}
|
||||||
|
disabled={isSubmitting}
|
||||||
|
>
|
||||||
<XCircle className="mr-2 h-4 w-4" />
|
<XCircle className="mr-2 h-4 w-4" />
|
||||||
Cancelar
|
Cancelar
|
||||||
</Button>
|
</Button>
|
||||||
|
|||||||
23
susconecta/lib/api.js
Normal file
23
susconecta/lib/api.js
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export async function salvarPaciente(formData) {
|
||||||
|
var myHeaders = new Headers();
|
||||||
|
myHeaders.append("Content-Type", "application/json");
|
||||||
|
|
||||||
|
var raw = JSON.stringify(formData);
|
||||||
|
|
||||||
|
var requestOptions = {
|
||||||
|
method: 'POST',
|
||||||
|
headers: myHeaders,
|
||||||
|
body: raw,
|
||||||
|
redirect: 'follow'
|
||||||
|
};
|
||||||
|
|
||||||
|
try {
|
||||||
|
const response = await fetch("https://mock.apidog.com/m1/1053378-0-default/pacientes", requestOptions);
|
||||||
|
const result = await response.json();
|
||||||
|
return result;
|
||||||
|
} catch (error) {
|
||||||
|
console.log('error', error);
|
||||||
|
throw error;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user