- Added isomorphic-dompurify for improved XSS protection - Refactored token storage to use in-memory management for access tokens - Implemented server-side route handlers for OAuth token management - Introduced security headers in next.config.js - Removed client-side exposure of client_secret and sensitive tokens - Updated API interceptors to handle token refresh logic - Cleaned up cookie management for refresh tokens
106 lines
2.8 KiB
JavaScript
106 lines
2.8 KiB
JavaScript
import { useState } from "react";
|
|
import HeadTab from "../content/HeadTab";
|
|
import { request } from "@/services/response";
|
|
import { setNewData } from "./function";
|
|
|
|
// 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 { removeAdditionalKeysDashboard } from "@/helper";
|
|
import { toast } from "react-toastify";
|
|
import LoadingComponent from "@/app/component/LoadingComponent";
|
|
|
|
function DetailUser({ user, isTurnsDetails, setIsTurnsDetails }) {
|
|
const [tab, setTab] = useState(0);
|
|
const [information, setInformation] = useState();
|
|
|
|
const [loading, setLoading] = useState(false);
|
|
|
|
const listTab = [
|
|
"اطلاعات عمومی",
|
|
"بیماریها",
|
|
"آلرژیها",
|
|
"داروهای مصرفی",
|
|
"جراحیها",
|
|
"سابقه خانوادگی بیماری",
|
|
"بستگان",
|
|
];
|
|
|
|
const handleChange = (_, newValue) => setTab(newValue);
|
|
const updateData = () => {
|
|
const usedKays = removeAdditionalKeysDashboard(information);
|
|
setLoading(true);
|
|
request
|
|
.patchUserProfile(usedKays, information?.uuid)
|
|
.then(() => {
|
|
setLoading(false);
|
|
toast.success("اطلاعات با موفقیت ثبت شد");
|
|
})
|
|
.catch(() => {
|
|
setLoading(false);
|
|
});
|
|
};
|
|
const changeData = (action, name, id, payload) =>
|
|
setNewData(action, name, id, payload, information, setInformation);
|
|
|
|
const components = [
|
|
<Information information={information} setInformation={setInformation} />,
|
|
<Disease
|
|
data={information}
|
|
setData={setInformation}
|
|
loading={loading}
|
|
updateData={updateData}
|
|
/>,
|
|
<Allergies
|
|
data={information}
|
|
loading={loading}
|
|
changeData={changeData}
|
|
updateData={updateData}
|
|
/>,
|
|
<Medications
|
|
data={information}
|
|
loading={loading}
|
|
changeData={changeData}
|
|
updateData={updateData}
|
|
/>,
|
|
<Surgeries
|
|
data={information}
|
|
loading={loading}
|
|
changeData={changeData}
|
|
updateData={updateData}
|
|
/>,
|
|
<FamilyHistory
|
|
data={information}
|
|
loading={loading}
|
|
changeData={changeData}
|
|
updateData={updateData}
|
|
/>,
|
|
<Relatives
|
|
data={information}
|
|
loading={loading}
|
|
changeData={changeData}
|
|
updateData={updateData}
|
|
/>,
|
|
];
|
|
|
|
return (
|
|
<HeadTab
|
|
tab={tab}
|
|
user={user}
|
|
listTab={listTab}
|
|
components={components}
|
|
handleChange={handleChange}
|
|
isTurnsDetails={isTurnsDetails}
|
|
setIsTurnsDetails={setIsTurnsDetails}
|
|
inactives={information?.prev_data ? [] : [1, 2, 3, 4, 5, 6]}
|
|
/>
|
|
);
|
|
}
|
|
|
|
export default DetailUser;
|