update dashboard data and design and change req from ssr to csr & change design and data doctor and clinic item

This commit is contained in:
Ehsan
2025-06-17 00:26:16 +03:30
parent 528006e7ff
commit debd6b0eb5
13 changed files with 306 additions and 116 deletions
@@ -10,13 +10,17 @@ function Information({
data,
setData,
userInfo,
prevInfo,
dataUser,
initialData,
information,
setInformation,
updateDataUser,
}) {
const [disable, setDisable] = useState(true);
const [loading, setLoading] = useState(false);
const [insurance, setInsurance] = useState();
const [loading, setLoading] = useState(false);
const [errors, setErrors] = useState();
useEffect(() => {
request.getInsuranceType().then((res) => {
@@ -28,43 +32,54 @@ function Information({
}, []);
const changeData = (value, type, name) => {
disable && setDisable(false);
setData({
...data,
setInformation({
...information,
[name]: value,
});
};
const validationInfo = () => {};
const sendReq = () => {
setLoading(true);
console.log(data);
console.log(prevInfo);
console.log(prevInfo ? true : false);
if (!validationInfo())
request[prevInfo ? "patchUserProfile" : "postUserProfile"](
data,
prevInfo ? prevInfo.uuid : Cookies.get("uuid")
)
.then((res) => {
console.log(res);
request[dataUser ? "patchUserProfile" : "postUserProfile"](
data,
dataUser ? dataUser.uuid : Cookies.get("uuid")
)
.then(() => {
if (!dataUser) {
updateDataUser();
}
setLoading(false);
})
.catch(() => {
setLoading(false);
});
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
disabled={disable}
variant="contained"
onClick={sendReq}
loading={loading}