set dockerfile reset dockerfile fix dockerfile fix dockerfile use node 22 fix dockerfile fix dockerfile
109 lines
2.6 KiB
JavaScript
109 lines
2.6 KiB
JavaScript
import { useEffect, useState } from "react";
|
|
import Form from "./Form";
|
|
import { Button } from "@mui/material";
|
|
import ArrowLeftWhiteD from "@/components/icons/ArrowLeftWhiteD";
|
|
import { request } from "@/services/response";
|
|
import Cookies from "js-cookie";
|
|
|
|
function Information({
|
|
user,
|
|
data,
|
|
setData,
|
|
userInfo,
|
|
prevInfo,
|
|
dataUser,
|
|
initialData,
|
|
information,
|
|
setInformation,
|
|
updateDataUser,
|
|
}) {
|
|
const [disable, setDisable] = useState(true);
|
|
const [insurance, setInsurance] = useState();
|
|
const [loading, setLoading] = useState(false);
|
|
const [errors, setErrors] = useState({});
|
|
|
|
useEffect(() => {
|
|
request.getInsuranceType().then((res) => {
|
|
if (res && res.data) {
|
|
setInsurance(res.data);
|
|
}
|
|
});
|
|
// .catch((err) => {});
|
|
}, []);
|
|
|
|
const changeData = (value, name) => {
|
|
setInformation({
|
|
...information,
|
|
[name]: value,
|
|
});
|
|
if (errors && errors[name]) {
|
|
setErrors({
|
|
...errors,
|
|
[name]: false,
|
|
});
|
|
}
|
|
};
|
|
console.log(information);
|
|
|
|
const validationInfo = () => {};
|
|
|
|
const sendReq = () => {
|
|
setLoading(true);
|
|
console.log(prevInfo);
|
|
console.log(prevInfo ? true : false);
|
|
console.log(information);
|
|
|
|
if (!validationInfo())
|
|
request[prevInfo ? "patchUserProfile" : "postUserProfile"](
|
|
information,
|
|
prevInfo ? prevInfo.uuid : Cookies.get("uuid")
|
|
)
|
|
.then((res) => {
|
|
console.log(res);
|
|
|
|
if (!dataUser) {
|
|
updateDataUser();
|
|
}
|
|
setLoading(false);
|
|
})
|
|
.catch((err) => {
|
|
console.log(err);
|
|
console.log(err?.response?.data);
|
|
if (err?.response?.data) {
|
|
setErrors(err.response.data);
|
|
}
|
|
|
|
setLoading(false);
|
|
});
|
|
};
|
|
|
|
return (
|
|
<div className="opacity-page">
|
|
<Form
|
|
data={data}
|
|
errors={errors}
|
|
userInfo={userInfo}
|
|
prevInfo={prevInfo}
|
|
prevData={dataUser}
|
|
insurance={insurance}
|
|
changeData={changeData}
|
|
/>
|
|
<Button
|
|
variant="contained"
|
|
onClick={sendReq}
|
|
loading={loading}
|
|
disabled={Object.values(errors).find((error) => error)}
|
|
className={`!gap-[4px] !mr-auto !text-nowrap !flex !flex-nowrap !py-[8px]
|
|
!rounded-[4px] !text-[14px] md:!text-[16px] !font-medium
|
|
!mt-[32px] sm:!mt-[38px] md:!mt-[43px] lg:!mt-[48px] !px-[16px] sm:!px-[19px] md:!px-[22px] lg:!px-[24px]
|
|
`}
|
|
>
|
|
ثبت اطلاعات
|
|
<ArrowLeftWhiteD />
|
|
</Button>
|
|
</div>
|
|
);
|
|
}
|
|
|
|
export default Information;
|