diff --git a/src/app/(panels)/suite/patient/account/PatientForm.tsx b/src/app/(panels)/suite/patient/account/PatientForm.tsx deleted file mode 100644 index 04b0a7f..0000000 --- a/src/app/(panels)/suite/patient/account/PatientForm.tsx +++ /dev/null @@ -1,115 +0,0 @@ -"use client" - -import { useState } from "react" -import axios from "axios" - -import { Card, CardContent, CardFooter, CardHeader } from "@/components/ui/card" -import { Button } from "@/components/ui/button" -import { Input } from "@/components/ui/input" -import { Label } from "@/components/ui/label" - - -export function PersonForm({ person }: { person: { email: string, name: string, medications: any[], diagnoses: string[] } }) { - - const [medications, setMedications] = useState(person.medications || []) - - const [diagnoses, setDiagnoses] = useState(person.diagnoses || []) - - const handleDiagnosesChange = (event: React.ChangeEvent) => { - const value = event.target.value - setDiagnoses(value.split(',')) - } - - const handleAddMedication = () => { - setMedications([...medications, { name: '', dosage: '', frequency: '' }]) - } - - const handleMedicationsChange = (index: number, field: string, value: string) => { - const updatedMedications = [...medications] - updatedMedications[index][field] = value - setMedications(updatedMedications) - } - - const handleSave = async () => { - try { - await axios.put(`/api/patients?email=${person.email}`, { - medications, - medicalConditions: diagnoses, - }); - alert('Patient data updated successfully'); - } catch (error) { - console.error('Error updating patient data:', error); - alert('Failed to update patient data'); - } - }; - - - return ( - - -

Edit Patient: {person.name}

-
- -
- -
- {medications.map((medication: { name: string, dosage: string, frequency:string }, index: number) => ( -
- handleMedicationsChange(index, 'name', e.target.value)} - className="mb-2" - /> - handleMedicationsChange(index, 'dosage', e.target.value)} - className="mb-2" - /> - handleMedicationsChange(index, 'frequency', e.target.value)} - className="mb-2" - /> -
- ))} -
- - - - -
-
-
- - -
-
- - - -
- ) -} - diff --git a/src/app/(panels)/suite/patient/account/page.jsx b/src/app/(panels)/suite/patient/account/page.jsx index 7f8841e..7817b9a 100644 --- a/src/app/(panels)/suite/patient/account/page.jsx +++ b/src/app/(panels)/suite/patient/account/page.jsx @@ -15,9 +15,6 @@ const AccountPage = () => { if (user) { axios.get(`/api/user?userId=${user.id}`).then(response => { setUserData(response.data); - if (response.data.role === 'caregiver') { - axios.get('/api/patients').then(res => setPatients(res.data)); - } }); } }, [user]); @@ -35,7 +32,7 @@ const AccountPage = () => { setMedications([...medications, { name: '', dosage: '', frequency: '' }]); } - const [diagnoses, setDiagnoses] = useState(userData.diagnoses || []); + const [diagnoses, setDiagnoses] = useState([]); const handleDiagnosesChange = (e) => { setDiagnoses(e.target.value.split(',')); }