feat(dashboard): loading spinner and success toast on profile save

The ثبت اطلاعات button gave no feedback. Show a spinner while saving
(both POST and PATCH) and a 'اطلاعات با موفقیت ثبت شد' toast on success,
for the info tab and the medical-history sub-tabs.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
hamed
2026-06-15 22:21:09 +03:30
co-authored by Claude Opus 4.8
parent caca3fda97
commit e7db7c705b
2 changed files with 14 additions and 3 deletions
@@ -13,6 +13,7 @@ import FamilyHistory from "./familyHistory";
import Relatives from "./relatives"; import Relatives from "./relatives";
import { removeAdditionalKeysDashboard } from "@/helper"; import { removeAdditionalKeysDashboard } from "@/helper";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { toast } from "react-toastify";
import LoadingComponent from "@/app/component/LoadingComponent"; import LoadingComponent from "@/app/component/LoadingComponent";
function DetailUser({ user, isTurnsDetails, setIsTurnsDetails }) { function DetailUser({ user, isTurnsDetails, setIsTurnsDetails }) {
@@ -43,6 +44,7 @@ function DetailUser({ user, isTurnsDetails, setIsTurnsDetails }) {
) )
.then(() => { .then(() => {
setLoading(false); setLoading(false);
toast.success("اطلاعات با موفقیت ثبت شد");
}) })
.catch(() => { .catch(() => {
setLoading(false); setLoading(false);
@@ -5,8 +5,9 @@ import {
removeAdditionalKeysDashboard, removeAdditionalKeysDashboard,
} from "@/helper"; } from "@/helper";
import { request } from "@/services/response"; import { request } from "@/services/response";
import { Button } from "@mui/material"; import { Button, CircularProgress } from "@mui/material";
import Cookies from "js-cookie"; import Cookies from "js-cookie";
import { toast } from "react-toastify";
function ButtonSendData({ function ButtonSendData({
loading, loading,
@@ -51,6 +52,7 @@ function ButtonSendData({
uuid: response.uuid, uuid: response.uuid,
}); });
setLoading(false); setLoading(false);
toast.success("اطلاعات با موفقیت ثبت شد");
}) })
.catch(() => { .catch(() => {
setLoading(false); setLoading(false);
@@ -73,6 +75,7 @@ function ButtonSendData({
) )
.then(() => { .then(() => {
setLoading(false); setLoading(false);
toast.success("اطلاعات با موفقیت ثبت شد");
}) })
.catch((err) => handleErrReq(err)); .catch((err) => handleErrReq(err));
}; };
@@ -96,8 +99,14 @@ function ButtonSendData({
!mt-[32px] sm:!mt-[38px] md:!mt-[43px] lg:!mt-[48px] !px-[16px] sm:!px-[19px] md:!px-[22px] lg:!px-[24px] !mt-[32px] sm:!mt-[38px] md:!mt-[43px] lg:!mt-[48px] !px-[16px] sm:!px-[19px] md:!px-[22px] lg:!px-[24px]
`} `}
> >
ثبت اطلاعات {loading ? (
<ArrowLeftWhiteD /> <CircularProgress size={20} sx={{ color: "#fff" }} />
) : (
<>
ثبت اطلاعات
<ArrowLeftWhiteD />
</>
)}
</Button> </Button>
); );
} }