handle change data and update data in dashboard page for all tabs
This commit is contained in:
@@ -17,7 +17,7 @@ function AutoSelector({
|
|||||||
disablePortal
|
disablePortal
|
||||||
options={list}
|
options={list}
|
||||||
disabled={disabled}
|
disabled={disabled}
|
||||||
defaultValue={value || ""}
|
value={value || ""}
|
||||||
ListboxProps={listboxProps}
|
ListboxProps={listboxProps}
|
||||||
getOptionLabel={(option) => {
|
getOptionLabel={(option) => {
|
||||||
if (typeof option === "string") return option;
|
if (typeof option === "string") return option;
|
||||||
|
|||||||
@@ -867,3 +867,13 @@ html {
|
|||||||
.MuiButton-loading .MuiButton-loadingIndicator {
|
.MuiButton-loading .MuiButton-loadingIndicator {
|
||||||
color: #ffffff !important;
|
color: #ffffff !important;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@keyframes spin {
|
||||||
|
to {
|
||||||
|
transform: rotate(90deg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
.spin {
|
||||||
|
animation: spin 1s linear infinite;
|
||||||
|
}
|
||||||
|
|||||||
@@ -1,16 +1,30 @@
|
|||||||
import UpdateList from "@/components/icons/UpdateList";
|
import UpdateList from "@/components/icons/UpdateList";
|
||||||
import { Button } from "@mui/material";
|
import { Button, CircularProgress } from "@mui/material";
|
||||||
|
|
||||||
function UpdateBtn({ updateData }) {
|
function UpdateBtn({ updateData, loading }) {
|
||||||
return (
|
return (
|
||||||
<Button
|
<Button
|
||||||
variant="outlined"
|
variant="outlined"
|
||||||
onClick={updateData}
|
onClick={updateData}
|
||||||
className="!border-[#5559CE] !border-[2px] !flex !items-center !justify-center !gap-2 !text-[14px] !font-medium
|
disabled={loading}
|
||||||
!py-[6px] md:!py-2 lg:!py-[9px] !px-[16px] sm:!px-[23px] md:!px-[29px] lg:!px-[36px] !mr-0 md:!mr-4"
|
className={`
|
||||||
|
!border-[#5559CE] !border-[2px] !relative
|
||||||
|
!py-[6px] md:!py-2 lg:!py-[9px] !px-[8px] sm:!px-[15px] md:!px-[21px] lg:!px-[28px] !mr-0 md:!mr-4
|
||||||
|
`}
|
||||||
|
>
|
||||||
|
{loading && (
|
||||||
|
<CircularProgress
|
||||||
|
className="!absolute !right-[45%] !top-[25%]"
|
||||||
|
size={20}
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
<div
|
||||||
|
className={`!flex !items-center !justify-center !gap-2 !text-[14px] !font-medium
|
||||||
|
${loading ? "opacity-0" : "opacity-100"}`}
|
||||||
>
|
>
|
||||||
<UpdateList />
|
<UpdateList />
|
||||||
آپدیت کردن
|
آپدیت کردن
|
||||||
|
</div>
|
||||||
</Button>
|
</Button>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,15 +51,15 @@ function ModalEditItem({
|
|||||||
<Button
|
<Button
|
||||||
variant="contained"
|
variant="contained"
|
||||||
onClick={() => {
|
onClick={() => {
|
||||||
const changedKey = {
|
// const changedKey = {
|
||||||
name: data.name,
|
// name: data.name,
|
||||||
relation: data.relation,
|
// relation: data.relation,
|
||||||
contact: {
|
// contact: {
|
||||||
phone: data.phone,
|
// phone: data.phone,
|
||||||
address: data.address,
|
// address: data.address,
|
||||||
},
|
// },
|
||||||
};
|
// };
|
||||||
changeData("update", name, id, changedKey);
|
changeData("update", name, id, data);
|
||||||
handleClose();
|
handleClose();
|
||||||
}}
|
}}
|
||||||
className="!py-[4px] md:!py-[6px] !min-h-[32px] md:!min-h-[39px] lg:!min-h-[46px] lg:!py-[8px] !px-[10px] md:!px-[14px] lg:!px-[18px] !rounded-[4px] !text-[#EFEFEF] !text-[12px] md:!text-[14px] lg:!text-[16px] !font-medium"
|
className="!py-[4px] md:!py-[6px] !min-h-[32px] md:!min-h-[39px] lg:!min-h-[46px] lg:!py-[8px] !px-[10px] md:!px-[14px] lg:!px-[18px] !rounded-[4px] !text-[#EFEFEF] !text-[12px] md:!text-[14px] lg:!text-[16px] !font-medium"
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import TextLoading from "@/app/component/loading/Text";
|
|||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
function ItemAllergie({ row, idx, changeData }) {
|
function ItemAllergie({ row, idx, changeData }) {
|
||||||
const contentData = {
|
const contentData = {
|
||||||
@@ -11,9 +11,18 @@ function ItemAllergie({ row, idx, changeData }) {
|
|||||||
reaction: row.reaction,
|
reaction: row.reaction,
|
||||||
severity: row.severity,
|
severity: row.severity,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [data, setData] = useState(contentData);
|
const [data, setData] = useState(contentData);
|
||||||
const resetData = () => setData(contentData);
|
const resetData = () => setData(contentData);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setData({
|
||||||
|
substance: row.substance,
|
||||||
|
reaction: row.reaction,
|
||||||
|
severity: row.severity,
|
||||||
|
});
|
||||||
|
}, [row]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow className="!border-0 !border-b !border-[#DBDBDB] dark:!border-transparent">
|
<TableRow className="!border-0 !border-b !border-[#DBDBDB] dark:!border-transparent">
|
||||||
<TableCell
|
<TableCell
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { useState } from "react";
|
|||||||
import ItemAllergie from "./ItemAllergie";
|
import ItemAllergie from "./ItemAllergie";
|
||||||
import ModalAddAlergie from "./modal";
|
import ModalAddAlergie from "./modal";
|
||||||
|
|
||||||
function Allergies({ data, changeData }) {
|
function Allergies({ data, changeData, updateData, loading }) {
|
||||||
|
const { other } = data;
|
||||||
|
const { allergies } = other && other[0];
|
||||||
const tableHead = ["ردیف", "ماده آلرژیزا", "واکنش", "شدت", ""];
|
const tableHead = ["ردیف", "ماده آلرژیزا", "واکنش", "شدت", ""];
|
||||||
const centerTable = [0];
|
const centerTable = [0];
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -15,16 +17,18 @@ function Allergies({ data, changeData }) {
|
|||||||
<ModalAddAlergie
|
<ModalAddAlergie
|
||||||
open={open}
|
open={open}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
|
loading={loading}
|
||||||
|
updateData={updateData}
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
{data.allergies.length ? (
|
{allergies.length ? (
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
tableHead={tableHead}
|
tableHead={tableHead}
|
||||||
centerTable={centerTable}
|
centerTable={centerTable}
|
||||||
>
|
>
|
||||||
{data.allergies.map((row, idx) => (
|
{allergies.map((row, idx) => (
|
||||||
<ItemAllergie
|
<ItemAllergie
|
||||||
key={idx}
|
key={idx}
|
||||||
row={row}
|
row={row}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Content from "./Content";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import CloseModalD from "@/components/icons/CloseModalD";
|
import CloseModalD from "@/components/icons/CloseModalD";
|
||||||
|
|
||||||
function ModalAddAlergie({ open, setOpen, changeData }) {
|
function ModalAddAlergie({ open, setOpen, loading, changeData, updateData }) {
|
||||||
const contentItem = {
|
const contentItem = {
|
||||||
substance: "",
|
substance: "",
|
||||||
reaction: "",
|
reaction: "",
|
||||||
@@ -30,7 +30,7 @@ function ModalAddAlergie({ open, setOpen, changeData }) {
|
|||||||
<>
|
<>
|
||||||
{/* Button Modal */}
|
{/* Button Modal */}
|
||||||
<>
|
<>
|
||||||
<UpdateBtn />
|
<UpdateBtn updateData={updateData} loading={loading} />
|
||||||
<AddBtn handleOpen={handleOpen} />
|
<AddBtn handleOpen={handleOpen} />
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ import { Switch, TableCell, TableRow } from "@mui/material";
|
|||||||
import Head from "@/components/dashboard/userAccount/components/Head";
|
import Head from "@/components/dashboard/userAccount/components/Head";
|
||||||
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
import UpdateBtn from "@/components/dashboard/userAccount/components/UpdateBtn";
|
||||||
|
|
||||||
function Disease({ data, setData, updateData }) {
|
function Disease({ data, setData, updateData, loading }) {
|
||||||
const { other } = data;
|
const { other } = data;
|
||||||
const { disease } = other && other[0];
|
const { disease } = other && other[0];
|
||||||
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
const tableHead = ["ردیف", "اسم", "وضعیت", ""];
|
||||||
@@ -31,7 +31,7 @@ function Disease({ data, setData, updateData }) {
|
|||||||
return (
|
return (
|
||||||
<div className="opacity-page">
|
<div className="opacity-page">
|
||||||
<Head text="لیست بیماری ها" add={false}>
|
<Head text="لیست بیماری ها" add={false}>
|
||||||
<UpdateBtn updateData={updateData} />
|
<UpdateBtn updateData={updateData} loading={loading} />
|
||||||
</Head>
|
</Head>
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import TextLoading from "@/app/component/loading/Text";
|
|||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
function ItemHistory({ row, idx, changeData }) {
|
function ItemHistory({ row, idx, changeData }) {
|
||||||
const contentData = {
|
const contentData = {
|
||||||
@@ -12,6 +12,12 @@ function ItemHistory({ row, idx, changeData }) {
|
|||||||
};
|
};
|
||||||
const [data, setData] = useState(contentData);
|
const [data, setData] = useState(contentData);
|
||||||
const resetData = () => setData(contentData);
|
const resetData = () => setData(contentData);
|
||||||
|
useEffect(() => {
|
||||||
|
setData({
|
||||||
|
relation: row.relation,
|
||||||
|
disease: row.disease,
|
||||||
|
});
|
||||||
|
}, [row]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
@@ -49,10 +55,10 @@ function ItemHistory({ row, idx, changeData }) {
|
|||||||
<ModalEditItem
|
<ModalEditItem
|
||||||
id={idx}
|
id={idx}
|
||||||
data={data}
|
data={data}
|
||||||
title="سابقه خانوادگی"
|
|
||||||
name="family_history"
|
name="family_history"
|
||||||
resetData={resetData}
|
resetData={resetData}
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
|
title="سابقه خانوادگی"
|
||||||
>
|
>
|
||||||
<Content data={data} setData={setData} />
|
<Content data={data} setData={setData} />
|
||||||
</ModalEditItem>
|
</ModalEditItem>
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { useState } from "react";
|
|||||||
import ModalAddHistory from "./modal";
|
import ModalAddHistory from "./modal";
|
||||||
import ItemHistory from "./ItemHistory";
|
import ItemHistory from "./ItemHistory";
|
||||||
|
|
||||||
function FamilyHistory({ data, changeData }) {
|
function FamilyHistory({ data, changeData, loading, updateData }) {
|
||||||
|
const { other } = data;
|
||||||
|
const { family_history } = other && other[0];
|
||||||
const tableHead = ["ردیف", "بیماری", "نسبت خانوادگی", ""];
|
const tableHead = ["ردیف", "بیماری", "نسبت خانوادگی", ""];
|
||||||
const centerTable = [0];
|
const centerTable = [0];
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -15,16 +17,18 @@ function FamilyHistory({ data, changeData }) {
|
|||||||
<ModalAddHistory
|
<ModalAddHistory
|
||||||
open={open}
|
open={open}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
|
loading={loading}
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
{data.medications.length ? (
|
{family_history.length ? (
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
tableHead={tableHead}
|
tableHead={tableHead}
|
||||||
centerTable={centerTable}
|
centerTable={centerTable}
|
||||||
>
|
>
|
||||||
{data.family_history.map((row, idx) => (
|
{family_history.map((row, idx) => (
|
||||||
<ItemHistory
|
<ItemHistory
|
||||||
key={idx}
|
key={idx}
|
||||||
row={row}
|
row={row}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Content from "./Content";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import CloseModalD from "@/components/icons/CloseModalD";
|
import CloseModalD from "@/components/icons/CloseModalD";
|
||||||
|
|
||||||
function ModalAddHistory({ open, setOpen, changeData }) {
|
function ModalAddHistory({ open, setOpen, changeData, loading, updateData }) {
|
||||||
const contentItem = {
|
const contentItem = {
|
||||||
relation: "",
|
relation: "",
|
||||||
disease: "",
|
disease: "",
|
||||||
@@ -24,7 +24,7 @@ function ModalAddHistory({ open, setOpen, changeData }) {
|
|||||||
<>
|
<>
|
||||||
{/* Button Modal */}
|
{/* Button Modal */}
|
||||||
<>
|
<>
|
||||||
<UpdateBtn />
|
<UpdateBtn loading={loading} updateData={updateData} />
|
||||||
<AddBtn handleOpen={handleOpen} />
|
<AddBtn handleOpen={handleOpen} />
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|||||||
@@ -1,20 +1,20 @@
|
|||||||
export const changeData = (action, name, id, payload) => {
|
export const setNewData = (action, name, id, payload, data, setData) => {
|
||||||
const newData = {
|
const newData = {
|
||||||
...data,
|
...data,
|
||||||
[name]: [...data[name]],
|
// [name]: [...data[name]],
|
||||||
};
|
};
|
||||||
|
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case "update":
|
case "update":
|
||||||
newData[name][id] = payload;
|
newData.other[0][name][id] = payload;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "add":
|
case "add":
|
||||||
newData[name].push(payload);
|
newData.other[0][name].push(payload);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case "delete":
|
case "delete":
|
||||||
newData[name].splice(id, 1);
|
newData.other[0][name].splice(id, 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import HeadTab from "../content/HeadTab";
|
import HeadTab from "../content/HeadTab";
|
||||||
import profileData from "@/data/profile_other.json";
|
import { request } from "@/services/response";
|
||||||
|
import { setNewData } from "./function";
|
||||||
|
|
||||||
// Tabs
|
// Tabs
|
||||||
import Medications from "./medications";
|
import Medications from "./medications";
|
||||||
@@ -10,8 +11,6 @@ import Allergies from "./allergies";
|
|||||||
import Surgeries from "./surgeries";
|
import Surgeries from "./surgeries";
|
||||||
import FamilyHistory from "./familyHistory";
|
import FamilyHistory from "./familyHistory";
|
||||||
import Relatives from "./relatives";
|
import Relatives from "./relatives";
|
||||||
import { request } from "@/services/response";
|
|
||||||
import { changeData } from "./function";
|
|
||||||
|
|
||||||
function DetailUser({
|
function DetailUser({
|
||||||
user,
|
user,
|
||||||
@@ -20,50 +19,28 @@ function DetailUser({
|
|||||||
isTurnsDetails,
|
isTurnsDetails,
|
||||||
setIsTurnsDetails,
|
setIsTurnsDetails,
|
||||||
}) {
|
}) {
|
||||||
const [tab, setTab] = useState(0);
|
const [tab, setTab] = useState(5);
|
||||||
const {
|
const initialData = {
|
||||||
name,
|
name: dataUser?.name,
|
||||||
description,
|
description: dataUser?.description,
|
||||||
birthday,
|
birthday: dataUser?.birthday,
|
||||||
insurance_id,
|
basic_insurance: [dataUser?.basic_insurance?.id],
|
||||||
basic_insurance,
|
blood_type: dataUser?.blood_type,
|
||||||
blood_type,
|
education: dataUser?.education,
|
||||||
education,
|
fathers_name: dataUser?.fathers_name,
|
||||||
fathers_name,
|
gender: dataUser?.gender,
|
||||||
gender,
|
home_phone: dataUser?.home_phone,
|
||||||
home_phone,
|
job: dataUser?.job,
|
||||||
job,
|
marital_status: dataUser?.marital_status,
|
||||||
marital_status,
|
supplementary_insurance: dataUser?.supplementary_insurance,
|
||||||
national_code,
|
work_phone: dataUser?.work_phone,
|
||||||
national_code_approved,
|
address: dataUser?.address,
|
||||||
supplementary_insurance,
|
other: dataUser?.other,
|
||||||
work_phone,
|
national_code: dataUser?.national_code,
|
||||||
address,
|
};
|
||||||
other,
|
|
||||||
} = dataUser;
|
const [data, setData] = useState(initialData);
|
||||||
const [data, setData] = useState({
|
const [loading, setLoading] = useState(false);
|
||||||
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 listTab = [
|
||||||
"اطلاعات عمومی",
|
"اطلاعات عمومی",
|
||||||
@@ -77,11 +54,18 @@ function DetailUser({
|
|||||||
|
|
||||||
const handleChange = (_, newValue) => setTab(newValue);
|
const handleChange = (_, newValue) => setTab(newValue);
|
||||||
const updateData = () => {
|
const updateData = () => {
|
||||||
|
setLoading(true);
|
||||||
request
|
request
|
||||||
.patchUserProfile(data, data.uuid)
|
.patchUserProfile(data, dataUser.uuid)
|
||||||
.then((res) => {})
|
.then((res) => {
|
||||||
.catch((err) => {});
|
setLoading(false);
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
setLoading(false);
|
||||||
|
});
|
||||||
};
|
};
|
||||||
|
const changeData = (action, name, id, payload) =>
|
||||||
|
setNewData(action, name, id, payload, data, setData);
|
||||||
|
|
||||||
const components = [
|
const components = [
|
||||||
<Information
|
<Information
|
||||||
@@ -93,12 +77,42 @@ function DetailUser({
|
|||||||
isTurnsDetails={isTurnsDetails}
|
isTurnsDetails={isTurnsDetails}
|
||||||
setIsTurnsDetails={setIsTurnsDetails}
|
setIsTurnsDetails={setIsTurnsDetails}
|
||||||
/>,
|
/>,
|
||||||
<Disease data={data} setData={setData} updateData={updateData} />,
|
<Disease
|
||||||
<Allergies data={data} changeData={changeData} />,
|
data={data}
|
||||||
<Medications data={data} changeData={changeData} />,
|
setData={setData}
|
||||||
<Surgeries data={data} changeData={changeData} />,
|
loading={loading}
|
||||||
<FamilyHistory data={data} changeData={changeData} />,
|
updateData={updateData}
|
||||||
<Relatives data={data} changeData={changeData} />,
|
/>,
|
||||||
|
<Allergies
|
||||||
|
data={data}
|
||||||
|
loading={loading}
|
||||||
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
|
/>,
|
||||||
|
<Medications
|
||||||
|
data={data}
|
||||||
|
loading={loading}
|
||||||
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
|
/>,
|
||||||
|
<Surgeries
|
||||||
|
data={data}
|
||||||
|
loading={loading}
|
||||||
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
|
/>,
|
||||||
|
<FamilyHistory
|
||||||
|
data={data}
|
||||||
|
loading={loading}
|
||||||
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
|
/>,
|
||||||
|
<Relatives
|
||||||
|
data={data}
|
||||||
|
loading={loading}
|
||||||
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
|
/>,
|
||||||
];
|
];
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function DateBirthday({ data, changeData }) {
|
|||||||
<DatePicker
|
<DatePicker
|
||||||
locale="fa"
|
locale="fa"
|
||||||
onChange={(e) => {
|
onChange={(e) => {
|
||||||
changeData(convertToJalali(e._d), "value", "date_of_birth");
|
changeData(convertToJalali(e._d), "value", "birthday");
|
||||||
handleClose();
|
handleClose();
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -11,8 +11,11 @@ import {
|
|||||||
import AutoSelector from "@/app/component/element/AutoSelector";
|
import AutoSelector from "@/app/component/element/AutoSelector";
|
||||||
|
|
||||||
function Form({ data, userInfo, insurance, changeData, prevData }) {
|
function Form({ data, userInfo, insurance, changeData, prevData }) {
|
||||||
const findVal = (list, name) =>
|
const findVal = (list, name, arr) =>
|
||||||
data && list && list.length && list.find((g) => g.id === data[name]);
|
data &&
|
||||||
|
list &&
|
||||||
|
list.length &&
|
||||||
|
list.find((g) => g.id === (arr ? data[name][0] : data[name]));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="grid grid-cols-1 lg:grid-cols-2 gap-[24px]">
|
<div className="grid grid-cols-1 lg:grid-cols-2 gap-[24px]">
|
||||||
@@ -78,7 +81,7 @@ function Form({ data, userInfo, insurance, changeData, prevData }) {
|
|||||||
updateData={(name, val) => {
|
updateData={(name, val) => {
|
||||||
changeData([Number(val.id)], "value", name);
|
changeData([Number(val.id)], "value", name);
|
||||||
}}
|
}}
|
||||||
value={findVal(insurance, "basic_insurance")}
|
value={findVal(insurance, "basic_insurance", true)?.name}
|
||||||
label="نوع بیمه"
|
label="نوع بیمه"
|
||||||
name="basic_insurance"
|
name="basic_insurance"
|
||||||
list={insurance}
|
list={insurance}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ function Information({ user, data, setData, userInfo, dataUser }) {
|
|||||||
setLoading(true);
|
setLoading(true);
|
||||||
request[dataUser ? "patchUserProfile" : "postUserProfile"](
|
request[dataUser ? "patchUserProfile" : "postUserProfile"](
|
||||||
data,
|
data,
|
||||||
Cookies.get("uuid")
|
dataUser ? dataUser.uuid : Cookies.get("uuid")
|
||||||
)
|
)
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import TextLoading from "@/app/component/loading/Text";
|
|||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
function ItemMedication({ row, idx, changeData }) {
|
function ItemMedication({ row, idx, changeData }) {
|
||||||
const contentData = {
|
const contentData = {
|
||||||
@@ -14,6 +14,14 @@ function ItemMedication({ row, idx, changeData }) {
|
|||||||
const [data, setData] = useState(contentData);
|
const [data, setData] = useState(contentData);
|
||||||
const resetData = () => setData(contentData);
|
const resetData = () => setData(contentData);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setData({
|
||||||
|
name: row.name,
|
||||||
|
dose: row.dose,
|
||||||
|
frequency: row.frequency,
|
||||||
|
});
|
||||||
|
}, [row]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={idx}
|
key={idx}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { useState } from "react";
|
|||||||
import ItemMedication from "./ItemMedication";
|
import ItemMedication from "./ItemMedication";
|
||||||
import ModalAddMedications from "./modal";
|
import ModalAddMedications from "./modal";
|
||||||
|
|
||||||
function Medications({ data, changeData }) {
|
function Medications({ data, changeData, updateData, loading }) {
|
||||||
|
const { other } = data;
|
||||||
|
const { medications } = other && other[0];
|
||||||
const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""];
|
const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""];
|
||||||
const centerTable = [0];
|
const centerTable = [0];
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -15,16 +17,18 @@ function Medications({ data, changeData }) {
|
|||||||
<ModalAddMedications
|
<ModalAddMedications
|
||||||
open={open}
|
open={open}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
|
loading={loading}
|
||||||
|
updateData={updateData}
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
{data.medications.length ? (
|
{medications.length ? (
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
tableHead={tableHead}
|
tableHead={tableHead}
|
||||||
centerTable={centerTable}
|
centerTable={centerTable}
|
||||||
>
|
>
|
||||||
{data.medications.map((row, idx) => (
|
{medications.map((row, idx) => (
|
||||||
<ItemMedication
|
<ItemMedication
|
||||||
key={idx}
|
key={idx}
|
||||||
row={row}
|
row={row}
|
||||||
|
|||||||
@@ -6,7 +6,13 @@ import { useState } from "react";
|
|||||||
import Content from "./Content";
|
import Content from "./Content";
|
||||||
import CloseModalD from "@/components/icons/CloseModalD";
|
import CloseModalD from "@/components/icons/CloseModalD";
|
||||||
|
|
||||||
function ModalAddMedications({ open, setOpen, changeData }) {
|
function ModalAddMedications({
|
||||||
|
open,
|
||||||
|
setOpen,
|
||||||
|
loading,
|
||||||
|
changeData,
|
||||||
|
updateData,
|
||||||
|
}) {
|
||||||
const contentItem = {
|
const contentItem = {
|
||||||
name: "",
|
name: "",
|
||||||
dose: "",
|
dose: "",
|
||||||
@@ -26,7 +32,7 @@ function ModalAddMedications({ open, setOpen, changeData }) {
|
|||||||
<>
|
<>
|
||||||
{/* Button Modal */}
|
{/* Button Modal */}
|
||||||
<>
|
<>
|
||||||
<UpdateBtn />
|
<UpdateBtn updateData={updateData} loading={loading} />
|
||||||
<AddBtn handleOpen={handleOpen} />
|
<AddBtn handleOpen={handleOpen} />
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import TextLoading from "@/app/component/loading/Text";
|
|||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
function ItemRelatives({ row, idx, changeData }) {
|
function ItemRelatives({ row, idx, changeData }) {
|
||||||
const contentData = {
|
const contentData = {
|
||||||
@@ -12,9 +12,19 @@ function ItemRelatives({ row, idx, changeData }) {
|
|||||||
phone: row.contact.phone,
|
phone: row.contact.phone,
|
||||||
address: row.contact.address,
|
address: row.contact.address,
|
||||||
};
|
};
|
||||||
|
|
||||||
const [data, setData] = useState(contentData);
|
const [data, setData] = useState(contentData);
|
||||||
const resetData = () => setData(contentData);
|
const resetData = () => setData(contentData);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setData({
|
||||||
|
name: row.name,
|
||||||
|
relation: row.relation,
|
||||||
|
phone: row.contact.phone,
|
||||||
|
address: row.contact.address,
|
||||||
|
});
|
||||||
|
}, [row]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={idx}
|
key={idx}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import Head from "@/components/dashboard/userAccount/components/Head";
|
|||||||
import ModalAddRelatives from "./modal";
|
import ModalAddRelatives from "./modal";
|
||||||
import ItemRelatives from "./ItemRelatives";
|
import ItemRelatives from "./ItemRelatives";
|
||||||
|
|
||||||
function Relatives({ data, changeData }) {
|
function Relatives({ data, changeData, loading, updateData }) {
|
||||||
|
const { other } = data;
|
||||||
|
const { relatives } = other && other[0];
|
||||||
const tableHead = ["ردیف", "نام", "نسبت", "شماره تماس", "آدرس", ""];
|
const tableHead = ["ردیف", "نام", "نسبت", "شماره تماس", "آدرس", ""];
|
||||||
const centerTable = [0];
|
const centerTable = [0];
|
||||||
const [open, setOpen] = useState(false);
|
const [open, setOpen] = useState(false);
|
||||||
@@ -14,17 +16,19 @@ function Relatives({ data, changeData }) {
|
|||||||
<Head text="لیست بستگان">
|
<Head text="لیست بستگان">
|
||||||
<ModalAddRelatives
|
<ModalAddRelatives
|
||||||
open={open}
|
open={open}
|
||||||
|
loading={loading}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
|
updateData={updateData}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
{data.medications.length ? (
|
{relatives.length ? (
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
tableHead={tableHead}
|
tableHead={tableHead}
|
||||||
centerTable={centerTable}
|
centerTable={centerTable}
|
||||||
>
|
>
|
||||||
{data.relatives.map((row, idx) => (
|
{relatives.map((row, idx) => (
|
||||||
<ItemRelatives
|
<ItemRelatives
|
||||||
key={idx}
|
key={idx}
|
||||||
row={row}
|
row={row}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Content from "./Content";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import CloseModalD from "@/components/icons/CloseModalD";
|
import CloseModalD from "@/components/icons/CloseModalD";
|
||||||
|
|
||||||
function ModalAddRelatives({ open, setOpen, changeData }) {
|
function ModalAddRelatives({ open, setOpen, changeData, loading, updateData }) {
|
||||||
const contentItem = {
|
const contentItem = {
|
||||||
name: "",
|
name: "",
|
||||||
relation: "",
|
relation: "",
|
||||||
@@ -36,7 +36,7 @@ function ModalAddRelatives({ open, setOpen, changeData }) {
|
|||||||
<>
|
<>
|
||||||
{/* Button Modal */}
|
{/* Button Modal */}
|
||||||
<>
|
<>
|
||||||
<UpdateBtn />
|
<UpdateBtn updateData={updateData} loading={loading} />
|
||||||
<AddBtn handleOpen={handleOpen} />
|
<AddBtn handleOpen={handleOpen} />
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|||||||
@@ -3,7 +3,7 @@ import TextLoading from "@/app/component/loading/Text";
|
|||||||
import { TableCell, TableRow } from "@mui/material";
|
import { TableCell, TableRow } from "@mui/material";
|
||||||
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
import ModalEditItem from "@/components/dashboard/userAccount/components/modal/ModalEditItem";
|
||||||
import Content from "./modal/Content";
|
import Content from "./modal/Content";
|
||||||
import { useState } from "react";
|
import { useEffect, useState } from "react";
|
||||||
|
|
||||||
function ItemSurgeries({ row, idx, changeData }) {
|
function ItemSurgeries({ row, idx, changeData }) {
|
||||||
const contentData = {
|
const contentData = {
|
||||||
@@ -14,6 +14,14 @@ function ItemSurgeries({ row, idx, changeData }) {
|
|||||||
const [data, setData] = useState(contentData);
|
const [data, setData] = useState(contentData);
|
||||||
const resetData = () => setData(contentData);
|
const resetData = () => setData(contentData);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
setData({
|
||||||
|
type: row.type,
|
||||||
|
year: row.year,
|
||||||
|
hospital: row.hospital,
|
||||||
|
});
|
||||||
|
}, [row]);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<TableRow
|
<TableRow
|
||||||
key={idx}
|
key={idx}
|
||||||
|
|||||||
@@ -4,7 +4,9 @@ import { useState } from "react";
|
|||||||
import ItemSurgeries from "./ItemSurgeries";
|
import ItemSurgeries from "./ItemSurgeries";
|
||||||
import ModalAddSurgeries from "./modal";
|
import ModalAddSurgeries from "./modal";
|
||||||
|
|
||||||
function Surgeries({ data, changeData }) {
|
function Surgeries({ data, changeData, loading, updateData }) {
|
||||||
|
const { other } = data;
|
||||||
|
const { surgeries } = other && other[0];
|
||||||
const tableHead = [
|
const tableHead = [
|
||||||
"ردیف",
|
"ردیف",
|
||||||
"نوع جراحی",
|
"نوع جراحی",
|
||||||
@@ -21,16 +23,18 @@ function Surgeries({ data, changeData }) {
|
|||||||
<ModalAddSurgeries
|
<ModalAddSurgeries
|
||||||
open={open}
|
open={open}
|
||||||
setOpen={setOpen}
|
setOpen={setOpen}
|
||||||
|
loading={loading}
|
||||||
|
updateData={updateData}
|
||||||
changeData={changeData}
|
changeData={changeData}
|
||||||
/>
|
/>
|
||||||
</Head>
|
</Head>
|
||||||
{data.surgeries.length ? (
|
{surgeries.length ? (
|
||||||
<CustomTable
|
<CustomTable
|
||||||
zeroRadius={true}
|
zeroRadius={true}
|
||||||
tableHead={tableHead}
|
tableHead={tableHead}
|
||||||
centerTable={centerTable}
|
centerTable={centerTable}
|
||||||
>
|
>
|
||||||
{data.surgeries.map((row, idx) => (
|
{surgeries.map((row, idx) => (
|
||||||
<ItemSurgeries
|
<ItemSurgeries
|
||||||
key={idx}
|
key={idx}
|
||||||
row={row}
|
row={row}
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import Content from "./Content";
|
|||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import CloseModalD from "@/components/icons/CloseModalD";
|
import CloseModalD from "@/components/icons/CloseModalD";
|
||||||
|
|
||||||
function ModalAddSurgeries({ open, setOpen, changeData }) {
|
function ModalAddSurgeries({ open, setOpen, updateData, loading, changeData }) {
|
||||||
const contentItem = {
|
const contentItem = {
|
||||||
type: "",
|
type: "",
|
||||||
year: "",
|
year: "",
|
||||||
@@ -26,7 +26,7 @@ function ModalAddSurgeries({ open, setOpen, changeData }) {
|
|||||||
<>
|
<>
|
||||||
{/* Button Modal */}
|
{/* Button Modal */}
|
||||||
<>
|
<>
|
||||||
<UpdateBtn />
|
<UpdateBtn loading={loading} updateData={updateData} />
|
||||||
<AddBtn handleOpen={handleOpen} />
|
<AddBtn handleOpen={handleOpen} />
|
||||||
</>
|
</>
|
||||||
|
|
||||||
|
|||||||
@@ -12,6 +12,15 @@ module.exports = {
|
|||||||
"gradient-conic":
|
"gradient-conic":
|
||||||
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
"conic-gradient(from 180deg at 50% 50%, var(--tw-gradient-stops))",
|
||||||
},
|
},
|
||||||
|
keyframes: {
|
||||||
|
spinCounter: {
|
||||||
|
from: { transform: "rotate(0deg)" },
|
||||||
|
to: { transform: "rotate(-360deg)" },
|
||||||
|
},
|
||||||
|
},
|
||||||
|
animation: {
|
||||||
|
spinCounter: "spinCounter 1s linear infinite",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
plugins: [],
|
plugins: [],
|
||||||
|
|||||||
Reference in New Issue
Block a user