design and handle modal add, edit and delete in all tabs dashboard & change list & update data profile_other

This commit is contained in:
Ehsan
2025-05-30 02:22:10 +03:30
parent e12e6c171c
commit 0969eca274
28 changed files with 1108 additions and 337 deletions
@@ -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 (
<div>
<Head text="لیست بستگان">
<ModalAddRelatives open={open} setOpen={setOpen} />
<ModalAddRelatives
open={open}
setOpen={setOpen}
changeData={changeData}
/>
</Head>
<CustomTable
zeroRadius={true}
tableHead={tableHead}
centerTable={centerTable}
>
{data.relatives.map((row, idx) => (
<TableRow
key={idx}
className="!border-0 !border-b !border-[#DBDBDB] dark:!border-transparent"
>
<TableCell
className="!pr-[18px] dark:!border-transparent !text-[#616161] dark:!text-[#A1A1A1] !text-[16px] !font-medium !text-nowrap"
align="center"
>
<TextLoading width={15} height={18} loading={false}>
{idx + 1}
</TextLoading>
</TableCell>
<TableCell className="!pr-[18px] dark:!border-transparent !text-[#616161] dark:!text-[#A1A1A1] !text-[16px] !font-medium !text-nowrap">
<TextLoading width={15} height={18} loading={false}>
{row.name}
</TextLoading>
</TableCell>
<TableCell className="!pr-[18px] dark:!border-transparent !text-[#616161] dark:!text-[#A1A1A1] !text-[16px] !font-medium !text-nowrap">
<TextLoading width={15} height={18} loading={false}>
{row.relation}
</TextLoading>
</TableCell>
<TableCell className="!pr-[18px] dark:!border-transparent !text-[#616161] dark:!text-[#A1A1A1] !text-[16px] !font-medium !text-nowrap">
<TextLoading width={15} height={18} loading={false}>
{`${row.contact.phone?.replace("+", "")}+`}
</TextLoading>
</TableCell>
<TableCell className="!pr-[18px] dark:!border-transparent !text-[#616161] dark:!text-[#A1A1A1] !text-[16px] !font-medium !text-nowrap">
{row.contact.address}
</TableCell>
<TableCell
className="!pr-[18px] dark:!border-transparent !text-[#616161] dark:!text-[#A1A1A1] !text-[16px] !font-medium !text-nowrap"
align="right"
>
<div className="flex items-center justify-center gap-[4px]">
<Button className="!min-w-fit !p-1" variant="text">
<TrashB />
</Button>
<Button className="!min-w-fit !p-1" variant="text">
<EditB />
</Button>
</div>
</TableCell>
</TableRow>
))}
</CustomTable>
{data.medications.length ? (
<CustomTable
zeroRadius={true}
tableHead={tableHead}
centerTable={centerTable}
>
{data.relatives.map((row, idx) => (
<ItemRelatives
key={idx}
row={row}
idx={idx}
changeData={changeData}
/>
))}
</CustomTable>
) : (
<p className="text-center py-10 text-gray-500">
هیچ داروی مصرفی وجود ندارد!
</p>
)}
</div>
);
}