handle change data and update data in dashboard page for all tabs
This commit is contained in:
@@ -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}
|
||||
|
||||
Reference in New Issue
Block a user