change response file & request get user-profile & change design dashboard page & handle limit page dashboard
This commit is contained in:
@@ -0,0 +1,82 @@
|
||||
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";
|
||||
|
||||
const listTab = [
|
||||
"اطلاعات عمومی",
|
||||
"بیماریها",
|
||||
"آلرژیها",
|
||||
"داروهای مصرفی",
|
||||
"جراحیها",
|
||||
"سابقه خانوادگی بیماری",
|
||||
"بستگان",
|
||||
];
|
||||
|
||||
function DetailUser({ user, isTurnsDetails, setIsTurnsDetails }) {
|
||||
const [tab, setTab] = useState(0);
|
||||
const [data, setData] = useState(profileData[0]);
|
||||
|
||||
const handleChange = (_, newValue) => setTab(newValue);
|
||||
const changeData = (action, name, id, payload) => {
|
||||
const newData = {
|
||||
...data,
|
||||
[name]: [...data[name]],
|
||||
};
|
||||
|
||||
switch (action) {
|
||||
case "update":
|
||||
newData[name][id] = payload;
|
||||
break;
|
||||
|
||||
case "add":
|
||||
newData[name].push(payload);
|
||||
break;
|
||||
|
||||
case "delete":
|
||||
newData[name].splice(id, 1);
|
||||
break;
|
||||
|
||||
default:
|
||||
console.warn(`Unknown action: ${action}`);
|
||||
return;
|
||||
}
|
||||
setData(newData);
|
||||
};
|
||||
|
||||
const components = [
|
||||
<Information
|
||||
user={user}
|
||||
isTurnsDetails={isTurnsDetails}
|
||||
setIsTurnsDetails={setIsTurnsDetails}
|
||||
/>,
|
||||
<Disease data={data} changeData={changeData} />,
|
||||
<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}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
export default DetailUser;
|
||||
Reference in New Issue
Block a user