119 lines
2.9 KiB
JavaScript
119 lines
2.9 KiB
JavaScript
import { useState } from "react";
|
|
import HeadTab from "../content/HeadTab";
|
|
import profileData from "@/data/profile_other.json";
|
|
|
|
// Tabs
|
|
import Medications from "./medications";
|
|
import Information from "./information";
|
|
import Disease from "./disease";
|
|
import Allergies from "./allergies";
|
|
import Surgeries from "./surgeries";
|
|
import FamilyHistory from "./familyHistory";
|
|
import Relatives from "./relatives";
|
|
import { request } from "@/services/response";
|
|
import { changeData } from "./function";
|
|
|
|
function DetailUser({
|
|
user,
|
|
dataUser,
|
|
userInfo,
|
|
isTurnsDetails,
|
|
setIsTurnsDetails,
|
|
}) {
|
|
const [tab, setTab] = useState(0);
|
|
const {
|
|
name,
|
|
description,
|
|
birthday,
|
|
insurance_id,
|
|
basic_insurance,
|
|
blood_type,
|
|
education,
|
|
fathers_name,
|
|
gender,
|
|
home_phone,
|
|
job,
|
|
marital_status,
|
|
national_code,
|
|
national_code_approved,
|
|
supplementary_insurance,
|
|
work_phone,
|
|
address,
|
|
other,
|
|
} = dataUser;
|
|
const [data, setData] = useState({
|
|
name: name,
|
|
description: description,
|
|
birthday: birthday,
|
|
insurance_id: insurance_id,
|
|
basic_insurance: basic_insurance,
|
|
blood_type: blood_type,
|
|
education: education,
|
|
fathers_name: fathers_name,
|
|
gender: gender,
|
|
home_phone: home_phone,
|
|
job: job,
|
|
marital_status: marital_status,
|
|
national_code: national_code,
|
|
national_code_approved: national_code_approved,
|
|
supplementary_insurance: supplementary_insurance,
|
|
work_phone: work_phone,
|
|
address: address,
|
|
other: other,
|
|
});
|
|
console.log(data);
|
|
console.log(dataUser);
|
|
console.log(userInfo);
|
|
|
|
const listTab = [
|
|
"اطلاعات عمومی",
|
|
"بیماریها",
|
|
"آلرژیها",
|
|
"داروهای مصرفی",
|
|
"جراحیها",
|
|
"سابقه خانوادگی بیماری",
|
|
"بستگان",
|
|
];
|
|
|
|
const handleChange = (_, newValue) => setTab(newValue);
|
|
const updateData = () => {
|
|
request
|
|
.patchUserProfile(data, data.uuid)
|
|
.then((res) => {})
|
|
.catch((err) => {});
|
|
};
|
|
|
|
const components = [
|
|
<Information
|
|
user={user}
|
|
data={data}
|
|
setData={setData}
|
|
userInfo={userInfo}
|
|
dataUser={dataUser}
|
|
isTurnsDetails={isTurnsDetails}
|
|
setIsTurnsDetails={setIsTurnsDetails}
|
|
/>,
|
|
<Disease data={data} setData={setData} updateData={updateData} />,
|
|
<Allergies data={data} changeData={changeData} />,
|
|
<Medications data={data} changeData={changeData} />,
|
|
<Surgeries data={data} changeData={changeData} />,
|
|
<FamilyHistory data={data} changeData={changeData} />,
|
|
<Relatives data={data} changeData={changeData} />,
|
|
];
|
|
|
|
return (
|
|
<HeadTab
|
|
tab={tab}
|
|
user={user}
|
|
listTab={listTab}
|
|
components={components}
|
|
handleChange={handleChange}
|
|
isTurnsDetails={isTurnsDetails}
|
|
setIsTurnsDetails={setIsTurnsDetails}
|
|
inactives={dataUser ? [] : [1, 2, 3, 4, 5, 6]}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default DetailUser;
|