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 (
); } export default Information;