diff --git a/app/component/Field.js b/app/component/Field.js index 92470ca..d7f3cb5 100644 --- a/app/component/Field.js +++ b/app/component/Field.js @@ -1,16 +1,29 @@ import { TextField } from "@mui/material"; -function Field({ title, type, props, multiline, isPlaceHolder }) { +function Field({ + type, + name, + title, + props, + value, + multiline, + handleChange, + isPlaceHolder, +}) { return ( { + handleChange(name || "", e.target.value); + }} sx={{ "& .MuiFormLabel-root": { top: "-4px !important", diff --git a/app/component/element/AutoSelector.js b/app/component/element/AutoSelector.js new file mode 100644 index 0000000..50bfffc --- /dev/null +++ b/app/component/element/AutoSelector.js @@ -0,0 +1,96 @@ +import BottomSelect from "@/components/icons/BottomSelect"; +import { Autocomplete, Button, TextField } from "@mui/material"; +import { styleTextSelectRight } from "@/mui"; + +function AutoSelector({ + list, + value, + isError, + updateData, + label, + disabled = false, + listboxProps, + name, +}) { + return ( + { + if (typeof option === "string") return option; + return option?.name || option?.label || ""; + }} + className="!w-full !rounded-lg auto-complete-selector" + onChange={(e, newValue) => updateData(name, newValue?.label || "")} + sx={{ + ...styleTextSelectRight, + // Hide Icon Number + "& input::-webkit-outer-spin-button, & input::-webkit-inner-spin-button": + { + display: "none", + }, + "& input[type=number]": { + MozAppearance: "textfield", + }, + "& .MuiInputBase-input": { padding: "12.5px 14px !important" }, + "& .MuiInputBase-root": { + borderRadius: 2, + padding: "0 !important", + height: { + xs: "43px !important", + sm: "43px !important", + md: "46px !important", + lg: "48px !important", + }, + }, + "& .MuiOutlinedInput-notchedOutline": { + border: "1px solid #D7D7D7", + }, + "& .MuiInput-underline:hover:not(.Mui-disabled):before, .MuiOutlinedInput-notchedOutline": + { + borderColor: "#D7D7D7 !important", + }, + "& .muirtl-1kiro5a-MuiInputBase-root-MuiOutlinedInput-root.Mui-focused .MuiOutlinedInput-notchedOutline": + { + border: "1px solid #5559CE !important", + }, + "& .MuiOutlinedInput-notchedOutline": { + border: isError ? "1px solid red !important" : "", + }, + }} + renderOption={(props, option) => ( + + )} + renderInput={(params) => ( + + + + ), + }} + placeholder={label} + sx={{ + borderRadius: "8px", + }} + /> + )} + /> + ); +} + +export default AutoSelector; diff --git a/components/dashboard/userAccount/components/modal/ModalDeleteItem.js b/components/dashboard/userAccount/components/modal/ModalDeleteItem.js new file mode 100644 index 0000000..1b9febe --- /dev/null +++ b/components/dashboard/userAccount/components/modal/ModalDeleteItem.js @@ -0,0 +1,60 @@ +import CloseModalD from "@/components/icons/CloseModalD"; +import TrashB from "@/components/icons/TrashB"; +import { styleDefault } from "@/mui"; +import { Box, Button, Modal } from "@mui/material"; +import { useState } from "react"; + +function ModalDeleteItem({ changeData, name, id }) { + const [open, setOpen] = useState(false); + + const handleClose = () => setOpen(false); + const handleOpen = () => setOpen(true); + + return ( + <> + + + +
+

+ حذف +

+ +
+ +

+ آیا از حذف این آیتم مطمئن هستید؟ +

+
+ + +
+
+
+ + ); +} + +export default ModalDeleteItem; diff --git a/components/dashboard/userAccount/components/modal/ModalEditItem.js b/components/dashboard/userAccount/components/modal/ModalEditItem.js new file mode 100644 index 0000000..12f793f --- /dev/null +++ b/components/dashboard/userAccount/components/modal/ModalEditItem.js @@ -0,0 +1,76 @@ +import { useState } from "react"; +import EditB from "@/components/icons/EditB"; +import { styleDefault } from "@/mui"; +import { Box, Button, Modal } from "@mui/material"; +import CloseModalD from "@/components/icons/CloseModalD"; + +function ModalEditItem({ + data, + resetData, + name, + title, + id, + changeData, + children, +}) { + const [open, setOpen] = useState(false); + + const handleClose = () => setOpen(false); + const handleOpen = () => setOpen(true); + + return ( + <> + + + +
+

+ تغییر {title} +

+ +
+ {children} +
+ + +
+
+
+ + ); +} + +export default ModalEditItem; diff --git a/components/dashboard/userAccount/content/HeadTab.js b/components/dashboard/userAccount/content/HeadTab.js index 1766fd6..c769626 100644 --- a/components/dashboard/userAccount/content/HeadTab.js +++ b/components/dashboard/userAccount/content/HeadTab.js @@ -5,7 +5,6 @@ function HeadTab({ tab, user, listTab, - loading, handleChange, isTurnsDetails, setIsTurnsDetails, @@ -15,7 +14,6 @@ function HeadTab({ <> {isTurnsDetails ? ( diff --git a/components/dashboard/userAccount/content/index.js b/components/dashboard/userAccount/content/index.js index 9fc6edf..d29905e 100644 --- a/components/dashboard/userAccount/content/index.js +++ b/components/dashboard/userAccount/content/index.js @@ -32,27 +32,45 @@ function ContentTabs({ setValue, setIsOpenSide, }) { - const [loading, setLoading] = useState(true); const [tab, setTab] = useState(0); - const data = profileData[0]; + const [data, setData] = useState(profileData[0]); - const handleChange = (_, newValue) => { - setTab(newValue); + 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; + } + console.log(newData); + + setData(newData); }; - useEffect(() => { - setTimeout(() => { - setLoading(false); - }, 2000); - }, []); - const components = [ - , - , - , - , - , - , + , + , + , + , + , + , ]; return ( @@ -88,7 +106,6 @@ function ContentTabs({ tab={tab} user={user} listTab={listTab} - loading={loading} components={components} handleChange={handleChange} isTurnsDetails={isTurnsDetails} diff --git a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js index 87162c5..15aed02 100644 --- a/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js +++ b/components/dashboard/userAccount/sidebars/turns/isTurnsDetails/index.js @@ -2,16 +2,12 @@ import DetailLg from "./DetailLg"; import DetailSm from "./DetailSm"; import Head from "./Head"; -function IsTurnsDetails({ user, setIsTurnsDetails, loading }) { +function IsTurnsDetails({ user, setIsTurnsDetails }) { return (
- - - + + +
); } diff --git a/components/dashboard/userAccount/tabs/allergies/ItemAllergie.js b/components/dashboard/userAccount/tabs/allergies/ItemAllergie.js new file mode 100644 index 0000000..b66e37e --- /dev/null +++ b/components/dashboard/userAccount/tabs/allergies/ItemAllergie.js @@ -0,0 +1,64 @@ +import ModalDeleteItem from "../../components/modal/ModalDeleteItem"; +import TextLoading from "@/app/component/loading/Text"; +import { TableCell, TableRow } from "@mui/material"; +import ModalEditItem from "../../components/modal/ModalEditItem"; +import Content from "./modal/Content"; +import { useState } from "react"; + +function ItemAllergie({ row, idx, changeData }) { + const contentData = { + substance: row.substance, + reaction: row.reaction, + severity: row.severity, + }; + const [data, setData] = useState(contentData); + const resetData = () => setData(contentData); + + return ( + + + + {idx + 1} + + + + + {row.substance} + + + + + {row.reaction} + + + + + {row.severity} + + + +
+ + + + +
+
+
+ ); +} + +export default ItemAllergie; diff --git a/components/dashboard/userAccount/tabs/allergies/index.js b/components/dashboard/userAccount/tabs/allergies/index.js index 01a7c60..d8ea603 100644 --- a/components/dashboard/userAccount/tabs/allergies/index.js +++ b/components/dashboard/userAccount/tabs/allergies/index.js @@ -1,13 +1,10 @@ import CustomTable from "@/app/component/CustomTable"; -import TextLoading from "@/app/component/loading/Text"; -import EditB from "@/components/icons/EditB"; -import TrashB from "@/components/icons/TrashB"; -import { Button, TableCell, TableRow } from "@mui/material"; import Head from "../../components/Head"; import { useState } from "react"; import ModalAddAlergie from "./modal"; +import ItemAllergie from "./ItemAllergie"; -function Allergies({ data }) { +function Allergies({ data, changeData }) { const tableHead = ["ردیف", "ماده آلرژی‌زا", "واکنش", "شدت", ""]; const centerTable = [0]; const [open, setOpen] = useState(false); @@ -15,57 +12,32 @@ function Allergies({ data }) { return (
- + - - {data.allergies.map((row, idx) => ( - - - - {idx + 1} - - - - - {row.substance} - - - - - {row.reaction} - - - - - {row.severity} - - - -
- - -
-
-
- ))} -
+ {data.allergies.length ? ( + + {data.allergies.map((row, idx) => ( + + ))} + + ) : ( +

+ هیچ آلرژی‌ای وجود ندارد! +

+ )}
); } diff --git a/components/dashboard/userAccount/tabs/allergies/modal/Content.js b/components/dashboard/userAccount/tabs/allergies/modal/Content.js index e631088..67ca62f 100644 --- a/components/dashboard/userAccount/tabs/allergies/modal/Content.js +++ b/components/dashboard/userAccount/tabs/allergies/modal/Content.js @@ -1,24 +1,47 @@ import FieldLabel from "@/components/contactUs/FieldLabel"; import Field from "@/app/component/Field"; -import AutoCompleteSelect from "@/app/component/element/AutoCompleteSelect"; +import AutoSelector from "@/app/component/element/AutoSelector"; const listIntensity = [ - { label: "خفیف" }, - { label: "متوسط" }, { label: "شدید" }, + { label: "متوسط" }, + { label: "خفیف" }, ]; -function Content() { +function Content({ setData, data }) { + const handleChange = (name, value) => + setData((prev) => ({ ...prev, [name]: value })); + return (
- + - + - +
); diff --git a/components/dashboard/userAccount/tabs/allergies/modal/index.js b/components/dashboard/userAccount/tabs/allergies/modal/index.js index f4d663a..0fa2d82 100644 --- a/components/dashboard/userAccount/tabs/allergies/modal/index.js +++ b/components/dashboard/userAccount/tabs/allergies/modal/index.js @@ -3,10 +3,27 @@ import AddBtn from "../../../components/AddBtn"; import UpdateBtn from "../../../components/UpdateBtn"; import { Button, Modal } from "@mui/material"; import Content from "./Content"; +import { useState } from "react"; + +function ModalAddAlergie({ open, setOpen, changeData }) { + const contentItem = { + substance: "", + reaction: "", + severity: "", + }; -function ModalAddAlergie({ open, setOpen }) { const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const [newItem, setNewItem] = useState({ + substance: "", + reaction: "", + severity: "", + }); + const handleAddData = () => { + changeData("add", "allergies", null, newItem); + setNewItem(contentItem); + handleClose(); + }; return ( <> @@ -25,16 +42,19 @@ function ModalAddAlergie({ open, setOpen }) { >
-

اضافه کردن آلرژی

+

+ اضافه کردن آلرژی +

- +
diff --git a/components/dashboard/userAccount/tabs/disease/index.js b/components/dashboard/userAccount/tabs/disease/index.js index d8088eb..fa53d7b 100644 --- a/components/dashboard/userAccount/tabs/disease/index.js +++ b/components/dashboard/userAccount/tabs/disease/index.js @@ -4,7 +4,7 @@ import { Switch, TableCell, TableRow } from "@mui/material"; import Head from "../../components/Head"; import UpdateBtn from "../../components/UpdateBtn"; -function Disease({ data }) { +function Disease({ data, changeData }) { const tableHead = ["ردیف", "اسم", "وضعیت", ""]; const centerTable = [0]; @@ -38,7 +38,14 @@ function Disease({ data }) { - + { + const newData = row; + newData.status = JSON.stringify(e.target.checked); + changeData("update", "disease", idx, newData); + }} + /> diff --git a/components/dashboard/userAccount/tabs/familyHistory/ItemHistory.js b/components/dashboard/userAccount/tabs/familyHistory/ItemHistory.js new file mode 100644 index 0000000..e62357a --- /dev/null +++ b/components/dashboard/userAccount/tabs/familyHistory/ItemHistory.js @@ -0,0 +1,65 @@ +import ModalDeleteItem from "../../components/modal/ModalDeleteItem"; +import TextLoading from "@/app/component/loading/Text"; +import { TableCell, TableRow } from "@mui/material"; +import ModalEditItem from "../../components/modal/ModalEditItem"; +import Content from "./modal/Content"; +import { useState } from "react"; + +function ItemHistory({ row, idx, changeData }) { + const contentData = { + relation: row.relation, + disease: row.disease, + }; + const [data, setData] = useState(contentData); + const resetData = () => setData(contentData); + + return ( + + + + {idx + 1} + + + + + {row.relation} + + + + + {row.disease} + + + +
+ + + + +
+
+
+ ); +} + +export default ItemHistory; diff --git a/components/dashboard/userAccount/tabs/familyHistory/index.js b/components/dashboard/userAccount/tabs/familyHistory/index.js index 3e7d064..f623728 100644 --- a/components/dashboard/userAccount/tabs/familyHistory/index.js +++ b/components/dashboard/userAccount/tabs/familyHistory/index.js @@ -1,13 +1,10 @@ import CustomTable from "@/app/component/CustomTable"; -import TextLoading from "@/app/component/loading/Text"; -import EditB from "@/components/icons/EditB"; -import TrashB from "@/components/icons/TrashB"; -import { Button, TableCell, TableRow } from "@mui/material"; import Head from "../../components/Head"; import { useState } from "react"; import ModalAddHistory from "./modal"; +import ItemHistory from "./ItemHistory"; -function FamilyHistory({ data }) { +function FamilyHistory({ data, changeData }) { const tableHead = ["ردیف", "بیماری", "نسبت خانوادگی", ""]; const centerTable = [0]; const [open, setOpen] = useState(false); @@ -15,52 +12,32 @@ function FamilyHistory({ data }) { return (
- + - - {data.family_history.map((row, idx) => ( - - - - {idx + 1} - - - - - {row.disease} - - - - - {row.relation} - - - -
- - -
-
-
- ))} -
+ {data.medications.length ? ( + + {data.family_history.map((row, idx) => ( + + ))} + + ) : ( +

+ هیچ سابقه خانوادگی وجود ندارد! +

+ )}
); } diff --git a/components/dashboard/userAccount/tabs/familyHistory/modal/Content.js b/components/dashboard/userAccount/tabs/familyHistory/modal/Content.js new file mode 100644 index 0000000..106d193 --- /dev/null +++ b/components/dashboard/userAccount/tabs/familyHistory/modal/Content.js @@ -0,0 +1,34 @@ +import FieldLabel from "@/components/contactUs/FieldLabel"; +import Field from "@/app/component/Field"; + +function Content({ setData, data }) { + const handleChange = (name, value) => + setData((prev) => ({ ...prev, [name]: value })); + + return ( +
+ + + + + + +
+ ); +} + +export default Content; diff --git a/components/dashboard/userAccount/tabs/familyHistory/modal/index.js b/components/dashboard/userAccount/tabs/familyHistory/modal/index.js index 78ddb07..afb8504 100644 --- a/components/dashboard/userAccount/tabs/familyHistory/modal/index.js +++ b/components/dashboard/userAccount/tabs/familyHistory/modal/index.js @@ -2,10 +2,22 @@ import { styleDefault } from "@/mui"; import AddBtn from "../../../components/AddBtn"; import UpdateBtn from "../../../components/UpdateBtn"; import { Button, Modal } from "@mui/material"; +import Content from "./Content"; +import { useState } from "react"; -function ModalAddHistory({ open, setOpen }) { +function ModalAddHistory({ open, setOpen, changeData }) { + const contentItem = { + relation: "", + disease: "", + }; const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const [newItem, setNewItem] = useState(contentItem); + const handleAddData = () => { + changeData("add", "family_history", null, newItem); + setNewItem(contentItem); + handleClose(); + }; return ( <> @@ -24,16 +36,19 @@ function ModalAddHistory({ open, setOpen }) { >
-

اضافه کردن سابقه خانوادگی بیماری

+

+ اضافه کردن سابقه خانوادگی بیماری +

- {/* */} +
diff --git a/components/dashboard/userAccount/tabs/medications/ItemMedication.js b/components/dashboard/userAccount/tabs/medications/ItemMedication.js new file mode 100644 index 0000000..9783661 --- /dev/null +++ b/components/dashboard/userAccount/tabs/medications/ItemMedication.js @@ -0,0 +1,71 @@ +import ModalDeleteItem from "../../components/modal/ModalDeleteItem"; +import TextLoading from "@/app/component/loading/Text"; +import { TableCell, TableRow } from "@mui/material"; +import ModalEditItem from "../../components/modal/ModalEditItem"; +import Content from "./modal/Content"; +import { useState } from "react"; + +function ItemMedication({ row, idx, changeData }) { + const contentData = { + name: row.name, + dose: row.dose, + frequency: row.frequency, + }; + const [data, setData] = useState(contentData); + const resetData = () => setData(contentData); + + return ( + + + + {idx + 1} + + + + + {row.name} + + + + + {row.dose} + + + + + {row.frequency} + + + +
+ + + + +
+
+
+ ); +} + +export default ItemMedication; diff --git a/components/dashboard/userAccount/tabs/medications/index.js b/components/dashboard/userAccount/tabs/medications/index.js index c4c25d1..2d56809 100644 --- a/components/dashboard/userAccount/tabs/medications/index.js +++ b/components/dashboard/userAccount/tabs/medications/index.js @@ -1,13 +1,10 @@ import CustomTable from "@/app/component/CustomTable"; -import TextLoading from "@/app/component/loading/Text"; -import EditB from "@/components/icons/EditB"; -import TrashB from "@/components/icons/TrashB"; -import { Button, TableCell, TableRow } from "@mui/material"; import Head from "../../components/Head"; import ModalAddMedications from "./modal"; import { useState } from "react"; +import ItemMedication from "./ItemMedication"; -function Medications({ data }) { +function Medications({ data, changeData }) { const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""]; const centerTable = [0]; const [open, setOpen] = useState(false); @@ -15,57 +12,32 @@ function Medications({ data }) { return (
- + - - {data.medications.map((row, idx) => ( - - - - {idx + 1} - - - - - {row.name} - - - - - {row.dose} - - - - - {row.frequency} - - - -
- - -
-
-
- ))} -
+ {data.medications.length ? ( + + {data.medications.map((row, idx) => ( + + ))} + + ) : ( +

+ هیچ داروی مصرفی وجود ندارد! +

+ )}
); } diff --git a/components/dashboard/userAccount/tabs/medications/modal/Content.js b/components/dashboard/userAccount/tabs/medications/modal/Content.js new file mode 100644 index 0000000..584940e --- /dev/null +++ b/components/dashboard/userAccount/tabs/medications/modal/Content.js @@ -0,0 +1,44 @@ +import FieldLabel from "@/components/contactUs/FieldLabel"; +import Field from "@/app/component/Field"; + +function Content({ setData, data }) { + const handleChange = (name, value) => + setData((prev) => ({ ...prev, [name]: value })); + + return ( +
+ + + + + handleChange(name, `${value}mg`)} + /> + + + + +
+ ); +} + +export default Content; diff --git a/components/dashboard/userAccount/tabs/medications/modal/index.js b/components/dashboard/userAccount/tabs/medications/modal/index.js index acdd9b6..90aecca 100644 --- a/components/dashboard/userAccount/tabs/medications/modal/index.js +++ b/components/dashboard/userAccount/tabs/medications/modal/index.js @@ -2,10 +2,24 @@ import { styleDefault } from "@/mui"; import AddBtn from "../../../components/AddBtn"; import UpdateBtn from "../../../components/UpdateBtn"; import { Button, Modal } from "@mui/material"; +import { useState } from "react"; +import Content from "./Content"; + +function ModalAddMedications({ open, setOpen, changeData }) { + const contentItem = { + name: "", + dose: "", + frequency: "", + }; -function ModalAddMedications({ open, setOpen }) { const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const [newItem, setNewItem] = useState(contentItem); + const handleAddData = () => { + changeData("add", "medications", null, newItem); + setNewItem(contentItem); + handleClose(); + }; return ( <> @@ -24,16 +38,19 @@ function ModalAddMedications({ open, setOpen }) { >
-

اضافه کردن دارو های مصرفی

+

+ اضافه کردن دارو های مصرفی +

- {/* */} +
diff --git a/components/dashboard/userAccount/tabs/relatives/ItemRelatives.js b/components/dashboard/userAccount/tabs/relatives/ItemRelatives.js new file mode 100644 index 0000000..8420731 --- /dev/null +++ b/components/dashboard/userAccount/tabs/relatives/ItemRelatives.js @@ -0,0 +1,71 @@ +import ModalDeleteItem from "../../components/modal/ModalDeleteItem"; +import TextLoading from "@/app/component/loading/Text"; +import { TableCell, TableRow } from "@mui/material"; +import ModalEditItem from "../../components/modal/ModalEditItem"; +import Content from "./modal/Content"; +import { useState } from "react"; + +function ItemRelatives({ row, idx, changeData }) { + const contentData = { + name: row.name, + relation: row.relation, + phone: row.contact.phone, + address: row.contact.address, + }; + const [data, setData] = useState(contentData); + const resetData = () => setData(contentData); + + return ( + + + + {idx + 1} + + + + + {row.name} + + + + + {row.relation} + + + + + {`${row.contact.phone?.replace("+", "")}+`} + + + + {row.contact.address} + + +
+ + + + +
+
+
+ ); +} + +export default ItemRelatives; diff --git a/components/dashboard/userAccount/tabs/relatives/index.js b/components/dashboard/userAccount/tabs/relatives/index.js index 412b5ba..3878d84 100644 --- a/components/dashboard/userAccount/tabs/relatives/index.js +++ b/components/dashboard/userAccount/tabs/relatives/index.js @@ -1,13 +1,10 @@ import CustomTable from "@/app/component/CustomTable"; -import TextLoading from "@/app/component/loading/Text"; -import EditB from "@/components/icons/EditB"; -import TrashB from "@/components/icons/TrashB"; -import { Button, TableCell, TableRow, Tooltip } from "@mui/material"; import Head from "../../components/Head"; import ModalAddRelatives from "./modal"; import { useState } from "react"; +import ItemRelatives from "./ItemRelatives"; -function Relatives({ data }) { +function Relatives({ data, changeData }) { const tableHead = ["ردیف", "نام", "نسبت", "شماره تماس", "آدرس", ""]; const centerTable = [0]; const [open, setOpen] = useState(false); @@ -15,61 +12,32 @@ function Relatives({ data }) { return (
- + - - {data.relatives.map((row, idx) => ( - - - - {idx + 1} - - - - - {row.name} - - - - - {row.relation} - - - - - {`${row.contact.phone?.replace("+", "")}+`} - - - - {row.contact.address} - - - -
- - -
-
-
- ))} -
+ {data.medications.length ? ( + + {data.relatives.map((row, idx) => ( + + ))} + + ) : ( +

+ هیچ داروی مصرفی وجود ندارد! +

+ )}
); } diff --git a/components/dashboard/userAccount/tabs/relatives/modal/Content.js b/components/dashboard/userAccount/tabs/relatives/modal/Content.js new file mode 100644 index 0000000..06b4c27 --- /dev/null +++ b/components/dashboard/userAccount/tabs/relatives/modal/Content.js @@ -0,0 +1,55 @@ +import FieldLabel from "@/components/contactUs/FieldLabel"; +import Field from "@/app/component/Field"; + +function Content({ setData, data }) { + const handleChange = (name, value) => + setData((prev) => ({ ...prev, [name]: value })); + console.log(data); + + return ( +
+ + + + + + + + + + + + +
+ ); +} + +export default Content; diff --git a/components/dashboard/userAccount/tabs/relatives/modal/index.js b/components/dashboard/userAccount/tabs/relatives/modal/index.js index e2fc3f6..6411ff2 100644 --- a/components/dashboard/userAccount/tabs/relatives/modal/index.js +++ b/components/dashboard/userAccount/tabs/relatives/modal/index.js @@ -2,10 +2,34 @@ import { styleDefault } from "@/mui"; import AddBtn from "../../../components/AddBtn"; import UpdateBtn from "../../../components/UpdateBtn"; import { Button, Modal } from "@mui/material"; +import Content from "./Content"; +import { useState } from "react"; + +function ModalAddRelatives({ open, setOpen, changeData }) { + const contentItem = { + name: "", + relation: "", + phone: "", + address: "", + }; -function ModalAddRelatives({ open, setOpen }) { const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const [newItem, setNewItem] = useState(contentItem); + const handleAddData = () => { + const changedKey = { + name: newItem.name, + relation: newItem.relation, + contact: { + phone: newItem.phone, + address: newItem.address, + }, + }; + + changeData("add", "relatives", null, changedKey); + setNewItem(contentItem); + handleClose(); + }; return ( <> @@ -24,16 +48,24 @@ function ModalAddRelatives({ open, setOpen }) { >
-

اضافه کردن بستگان

+

+ اضافه کردن بستگان +

- {/* */} +
diff --git a/components/dashboard/userAccount/tabs/surgeries/ItemSurgeries.js b/components/dashboard/userAccount/tabs/surgeries/ItemSurgeries.js new file mode 100644 index 0000000..a8f1ceb --- /dev/null +++ b/components/dashboard/userAccount/tabs/surgeries/ItemSurgeries.js @@ -0,0 +1,70 @@ +import ModalDeleteItem from "../../components/modal/ModalDeleteItem"; +import TextLoading from "@/app/component/loading/Text"; +import { TableCell, TableRow } from "@mui/material"; +import ModalEditItem from "../../components/modal/ModalEditItem"; +import Content from "./modal/Content"; +import { useState } from "react"; + +function ItemSurgeries({ row, idx, changeData }) { + const contentData = { + type: row.type, + year: row.year, + hospital: row.hospital, + }; + const [data, setData] = useState(contentData); + const resetData = () => setData(contentData); + + return ( + + + + {idx + 1} + + + + + {row.type} + + + + + {row.hospital} + + + + + {row.year} + + + +
+ + + + +
+
+
+ ); +} + +export default ItemSurgeries; diff --git a/components/dashboard/userAccount/tabs/surgeries/index.js b/components/dashboard/userAccount/tabs/surgeries/index.js index 799e30e..2533e94 100644 --- a/components/dashboard/userAccount/tabs/surgeries/index.js +++ b/components/dashboard/userAccount/tabs/surgeries/index.js @@ -6,8 +6,9 @@ import { Button, TableCell, TableRow } from "@mui/material"; import Head from "../../components/Head"; import ModalAddSurgeries from "./modal"; import { useState } from "react"; +import ItemSurgeries from "./ItemSurgeries"; -function Surgeries({ data }) { +function Surgeries({ data, updateData, changeData }) { const tableHead = [ "ردیف", "نوع جراحی", @@ -21,60 +22,30 @@ function Surgeries({ data }) { return (
- + - - {data.surgeries.map((row, idx) => ( - - - - {idx + 1} - - - - - {row.type} - - - - - {row.hospital} - - - - - {row.year} - - - -
- - -
-
-
- ))} -
+ {data.surgeries.length ? ( + + {data.surgeries.map((row, idx) => ( + + ))} + + ) : ( +

هیچ جراحی وجود ندارد!

+ )}
); } diff --git a/components/dashboard/userAccount/tabs/surgeries/modal/Content.js b/components/dashboard/userAccount/tabs/surgeries/modal/Content.js new file mode 100644 index 0000000..8b59ba0 --- /dev/null +++ b/components/dashboard/userAccount/tabs/surgeries/modal/Content.js @@ -0,0 +1,50 @@ +import FieldLabel from "@/components/contactUs/FieldLabel"; +import Field from "@/app/component/Field"; + +const listIntensity = [ + { label: "شدید" }, + { label: "متوسط" }, + { label: "خفیف" }, +]; + +function Content({ setData, data }) { + const handleChange = (name, value) => + setData((prev) => ({ ...prev, [name]: value })); + + return ( +
+ + + + + + + + + +
+ ); +} + +export default Content; diff --git a/components/dashboard/userAccount/tabs/surgeries/modal/index.js b/components/dashboard/userAccount/tabs/surgeries/modal/index.js index 895fd01..50bbcac 100644 --- a/components/dashboard/userAccount/tabs/surgeries/modal/index.js +++ b/components/dashboard/userAccount/tabs/surgeries/modal/index.js @@ -2,10 +2,24 @@ import { styleDefault } from "@/mui"; import AddBtn from "../../../components/AddBtn"; import UpdateBtn from "../../../components/UpdateBtn"; import { Button, Modal } from "@mui/material"; +import Content from "./Content"; +import { useState } from "react"; + +function ModalAddSurgeries({ open, setOpen, changeData }) { + const contentItem = { + type: "", + year: "", + hospital: "", + }; -function ModalAddSurgeries({ open, setOpen }) { const handleOpen = () => setOpen(true); const handleClose = () => setOpen(false); + const [newItem, setNewItem] = useState(contentItem); + const handleAddData = () => { + changeData("add", "surgeries", null, newItem); + setNewItem(contentItem); + handleClose(); + }; return ( <> @@ -24,16 +38,19 @@ function ModalAddSurgeries({ open, setOpen }) { >
-

اضافه کردن جراحی

+

+ اضافه کردن جراحی +

- {/* */} +