handle change data and update data in dashboard page for all tabs

This commit is contained in:
Ehsan
2025-06-11 16:52:01 +03:30
parent 72ed07071c
commit bf64271d14
26 changed files with 235 additions and 118 deletions
@@ -57,7 +57,7 @@ function DateBirthday({ data, changeData }) {
<DatePicker
locale="fa"
onChange={(e) => {
changeData(convertToJalali(e._d), "value", "date_of_birth");
changeData(convertToJalali(e._d), "value", "birthday");
handleClose();
}}
/>
@@ -11,8 +11,11 @@ import {
import AutoSelector from "@/app/component/element/AutoSelector";
function Form({ data, userInfo, insurance, changeData, prevData }) {
const findVal = (list, name) =>
data && list && list.length && list.find((g) => g.id === data[name]);
const findVal = (list, name, arr) =>
data &&
list &&
list.length &&
list.find((g) => g.id === (arr ? data[name][0] : data[name]));
return (
<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) => {
changeData([Number(val.id)], "value", name);
}}
value={findVal(insurance, "basic_insurance")}
value={findVal(insurance, "basic_insurance", true)?.name}
label="نوع بیمه"
name="basic_insurance"
list={insurance}
@@ -33,7 +33,7 @@ function Information({ user, data, setData, userInfo, dataUser }) {
setLoading(true);
request[dataUser ? "patchUserProfile" : "postUserProfile"](
data,
Cookies.get("uuid")
dataUser ? dataUser.uuid : Cookies.get("uuid")
)
.then((res) => {
setLoading(false);