design and handle modal add, edit and delete in all tabs dashboard & change list & update data profile_other
This commit is contained in:
@@ -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 (
|
||||
<div className="mt-[32px] md:mt-[36px] lg:mt-[40px] flex flex-col gap-[24px] md:gap-[28px] lg:gap-[32px] px-0 sm:px-[52px]">
|
||||
<FieldLabel title="ماده آلرژیزا">
|
||||
<Field isPlaceHolder={true} title="" type="text" />
|
||||
<Field
|
||||
title=""
|
||||
type="text"
|
||||
name="substance"
|
||||
isPlaceHolder={true}
|
||||
value={data?.substance}
|
||||
handleChange={handleChange}
|
||||
/>
|
||||
</FieldLabel>
|
||||
<FieldLabel title="واکنش">
|
||||
<Field isPlaceHolder={true} title="" type="text" />
|
||||
<Field
|
||||
title=""
|
||||
type="text"
|
||||
name="reaction"
|
||||
isPlaceHolder={true}
|
||||
value={data?.reaction}
|
||||
handleChange={handleChange}
|
||||
/>
|
||||
</FieldLabel>
|
||||
<FieldLabel title="ماده آلرژیزا">
|
||||
<AutoCompleteSelect list={listIntensity} label="شدت" />
|
||||
<AutoSelector
|
||||
label="شدت"
|
||||
name="severity"
|
||||
list={listIntensity}
|
||||
value={data?.severity}
|
||||
updateData={handleChange}
|
||||
/>
|
||||
</FieldLabel>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -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 }) {
|
||||
>
|
||||
<div>
|
||||
<div className="flex justify-between w-full">
|
||||
<p className="text-[#3B3B3B] text-[20px] font-bold">اضافه کردن آلرژی</p>
|
||||
<p className="text-[#3B3B3B] text-[20px] font-bold">
|
||||
اضافه کردن آلرژی
|
||||
</p>
|
||||
</div>
|
||||
<Content />
|
||||
<Content setData={setNewItem} />
|
||||
</div>
|
||||
<Button
|
||||
className="!mt-[32px] md:!mt-[36px] lg:!mt-[40px] !px-3 !py-2 !text-[16px] !font-medium !w-fit !mr-auto"
|
||||
onClick={handleClose}
|
||||
onClick={handleAddData}
|
||||
disabled={!newItem.reaction || !newItem.severity || !newItem.substance}
|
||||
variant="contained"
|
||||
>
|
||||
اعمال تغییرات
|
||||
اضافه کردن
|
||||
</Button>
|
||||
</div>
|
||||
</Modal>
|
||||
|
||||
Reference in New Issue
Block a user