fix bug dashboard bugs & handle request update data in user profile & change design button in home page

This commit is contained in:
Ehsan
2025-06-13 22:12:58 +03:30
parent eea8737778
commit 891b0e8273
9 changed files with 23 additions and 24 deletions
@@ -9,7 +9,7 @@ function ButtonFilter({ selected, setOpen }) {
return ( return (
<div> <div>
<Button <Button
className="!border-none hover:!bg-transparent !py-[11.5px] !min-w-fit !px-[7px] sm:!py-3 sm:!px-[9px] md:!px-[11px] lg:!px-[12px] !rounded-3" className="!border-none hover:!bg-transparent !shadow-none !py-[11.5px] !min-w-fit !px-[7px] sm:!py-3 sm:!px-[9px] md:!px-[11px] lg:!px-[12px] !rounded-3"
onClick={handleOpen} onClick={handleOpen}
variant="contained" variant="contained"
color="secondary" color="secondary"
@@ -5,8 +5,8 @@ import ItemAllergie from "./ItemAllergie";
import ModalAddAlergie from "./modal"; import ModalAddAlergie from "./modal";
function Allergies({ data, changeData, updateData, loading }) { function Allergies({ data, changeData, updateData, loading }) {
const { other } = data; const allergies =
const { allergies } = other && other[0]; data && data.other && data.other[0] && data.other[0].allergies;
const tableHead = ["ردیف", "ماده آلرژی‌زا", "واکنش", "شدت", ""]; const tableHead = ["ردیف", "ماده آلرژی‌زا", "واکنش", "شدت", ""];
const centerTable = [0]; const centerTable = [0];
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -5,8 +5,7 @@ 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, loading }) { function Disease({ data, setData, updateData, loading }) {
const { other } = data; const disease = data && data.other && data.other[0] && data.other[0].disease;
const { disease } = other && other[0];
const tableHead = ["ردیف", "اسم", "وضعیت", ""]; const tableHead = ["ردیف", "اسم", "وضعیت", ""];
const centerTable = [0]; const centerTable = [0];
@@ -5,8 +5,8 @@ import ModalAddHistory from "./modal";
import ItemHistory from "./ItemHistory"; import ItemHistory from "./ItemHistory";
function FamilyHistory({ data, changeData, loading, updateData }) { function FamilyHistory({ data, changeData, loading, updateData }) {
const { other } = data; const family_history =
const { family_history } = other && other[0]; data && data.other && data.other[0] && data.other[0].family_history;
const tableHead = ["ردیف", "بیماری", "نسبت خانوادگی", ""]; const tableHead = ["ردیف", "بیماری", "نسبت خانوادگی", ""];
const centerTable = [0]; const centerTable = [0];
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -19,14 +19,12 @@ function Information({
const [insurance, setInsurance] = useState(); const [insurance, setInsurance] = useState();
useEffect(() => { useEffect(() => {
request request.getInsuranceType().then((res) => {
.getInsuranceType() if (res && res.data) {
.then((res) => { setInsurance(res.data);
if (res && res.data) { }
setInsurance(res.data); });
} // .catch((err) => {});
})
// .catch((err) => {});
}, []); }, []);
const changeData = (value, type, name) => { const changeData = (value, type, name) => {
@@ -39,17 +37,19 @@ function Information({
const sendReq = () => { const sendReq = () => {
setLoading(true); setLoading(true);
console.log(data);
request[dataUser ? "patchUserProfile" : "postUserProfile"]( request[dataUser ? "patchUserProfile" : "postUserProfile"](
data, data,
dataUser ? dataUser.uuid : Cookies.get("uuid") dataUser ? dataUser.uuid : Cookies.get("uuid")
) )
.then((res) => { .then(() => {
if (!dataUser) { if (!dataUser) {
updateDataUser(); updateDataUser();
} }
setLoading(false); setLoading(false);
}) })
.catch((err) => { .catch(() => {
setLoading(false); setLoading(false);
}); });
}; };
@@ -5,8 +5,8 @@ import ItemMedication from "./ItemMedication";
import ModalAddMedications from "./modal"; import ModalAddMedications from "./modal";
function Medications({ data, changeData, updateData, loading }) { function Medications({ data, changeData, updateData, loading }) {
const { other } = data; const medications =
const { medications } = other && other[0]; data && data.other && data.other[0] && data.other[0].medications;
const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""]; const tableHead = ["ردیف", "نام دارو", "دوز مصرفی", "تعداد و زمان مصرف", ""];
const centerTable = [0]; const centerTable = [0];
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -5,8 +5,8 @@ import ModalAddRelatives from "./modal";
import ItemRelatives from "./ItemRelatives"; import ItemRelatives from "./ItemRelatives";
function Relatives({ data, changeData, loading, updateData }) { function Relatives({ data, changeData, loading, updateData }) {
const { other } = data; const relatives =
const { relatives } = other && other[0]; data && data.other && data.other[0] && data.other[0].relatives;
const tableHead = ["ردیف", "نام", "نسبت", "شماره تماس", "آدرس", ""]; const tableHead = ["ردیف", "نام", "نسبت", "شماره تماس", "آدرس", ""];
const centerTable = [0]; const centerTable = [0];
const [open, setOpen] = useState(false); const [open, setOpen] = useState(false);
@@ -5,8 +5,8 @@ import ItemSurgeries from "./ItemSurgeries";
import ModalAddSurgeries from "./modal"; import ModalAddSurgeries from "./modal";
function Surgeries({ data, changeData, loading, updateData }) { function Surgeries({ data, changeData, loading, updateData }) {
const { other } = data; const surgeries =
const { surgeries } = other && other[0]; data && data.other && data.other[0] && data.other[0].surgeries;
const tableHead = [ const tableHead = [
"ردیف", "ردیف",
"نوع جراحی", "نوع جراحی",
+1 -1
View File
@@ -3,7 +3,7 @@ import Image from "next/image";
function Head({ user }) { function Head({ user }) {
const userInfo = Cookies.get("userInfo"); const userInfo = Cookies.get("userInfo");
const parsedInfo = JSON.parse(userInfo); const parsedInfo = userInfo && JSON.parse(userInfo);
return ( return (
<div className="w-full flex flex-row md:flex-col items-center justify-center md:justify-start gap-[12px] md:gap-[4px]"> <div className="w-full flex flex-row md:flex-col items-center justify-center md:justify-start gap-[12px] md:gap-[4px]">