import { useEffect, useState } from "react"; import Form from "./Form"; import { request } from "@/services/response"; import ButtonSendData from "./ButtonSendData"; import { getParsedUserInfo } from "@/helper"; import { disease } from "../information/disease"; function Information({ information, setInformation }) { const [loading, setLoading] = useState(false); const [insurance, setInsurance] = useState(); const [errors, setErrors] = useState({}); useEffect(() => { const parsedUserInfo = getParsedUserInfo(); request.getInsuranceType().then((res) => { if (res && res.data) { setInsurance(res.data); } }); if (parsedUserInfo) { request .getUserProfile(parsedUserInfo.uuid) .then((res) => { const changedData = res; changedData.basic_insurance = [Number(res?.basic_insurance?.id)]; changedData.prev_data = true; setInformation(changedData); }) .catch((err) => { if (err?.response?.data === "Entity not found") { setInformation({ prev_data: false, other: { disease: disease, allergies: [], medications: [], surgeries: [], family_history: [], relatives: [], }, }); } }); } }, []); const changeData = (value, name) => { setInformation({ ...information, [name]: value, }); if (errors && errors[name]) { setErrors((prevErrors) => ({ ...prevErrors, [name]: false, })); } }; return (