import { useEffect } from "react"; import { toast } from "react-hot-toast"; import { useTranslate } from "@/utils/i18n"; import { Link, useLocation, useParams } from "react-router-dom"; import { useGlobalStore, useMemoStore } from "@/store/module"; import useLoading from "@/hooks/useLoading"; import Icon from "@/components/Icon"; import Memo from "@/components/Memo"; const MemoDetail = () => { const t = useTranslate(); const params = useParams(); const location = useLocation(); const globalStore = useGlobalStore(); const memoStore = useMemoStore(); const loadingState = useLoading(); const customizedProfile = globalStore.state.systemStatus.customizedProfile; const memoId = Number(params.memoId); const memo = memoStore.state.memos.find((memo) => memo.id === memoId); useEffect(() => { if (memoId && !isNaN(memoId)) { memoStore .fetchMemoById(memoId) .then(() => { loadingState.setFinish(); }) .catch((error) => { console.error(error); toast.error(error.response.data.message); }); } }, [location]); return (

{customizedProfile.name}

{!loadingState.isLoading && (memo ? ( <>
{t("router.back-to-home")}
) : ( <>

Not found

))}
); }; export default MemoDetail;