-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
116 additions
and
17 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { useEffect, useState } from 'react'; | ||
import { useParams } from 'react-router-dom'; | ||
import { Box, Typography } from "@mui/material"; | ||
import { searchMemoById } from "../services/searchMemo"; | ||
import { useRecoilValue } from 'recoil'; | ||
import { userAtom } from '../states/userAtom'; | ||
import { Memo } from "../services/memoType"; | ||
import DOMPurify from 'dompurify'; | ||
import 'react-quill/dist/quill.snow.css'; | ||
import './check.css'; | ||
|
||
export function ViewMemo(): JSX.Element { | ||
const { id } = useParams(); | ||
const loginUser = useRecoilValue(userAtom); | ||
const [memo, setMemo] = useState<Memo | null>(null); | ||
const safeContent = memo ? DOMPurify.sanitize(memo.content) : ""; | ||
|
||
useEffect(() => { | ||
const fetchMemo = async () => { | ||
if (id && loginUser.userId) { | ||
try { | ||
const fetchedMemo = await searchMemoById(id, loginUser); | ||
if (fetchedMemo) { | ||
setMemo(fetchedMemo); | ||
} else { | ||
setMemo(null); | ||
} | ||
} catch (error) { | ||
console.error("Error fetching memo:", error); | ||
setMemo(null); | ||
} | ||
} | ||
}; | ||
|
||
fetchMemo(); | ||
}, [id, loginUser]); | ||
|
||
if (!memo) { | ||
return <Typography>Loading...</Typography>; | ||
} | ||
|
||
return ( | ||
<Box sx={{ padding: "20px" }}> | ||
<Typography variant="h2">{memo.title}</Typography> | ||
<Box sx={{ marginTop: "20px" }}> | ||
<div dangerouslySetInnerHTML={{ __html: safeContent }} /> | ||
{/* タグや作成日時など、他の情報もここに表示できるよ */} | ||
</Box> | ||
</Box> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
ul[data-checked="true"] li::before { | ||
content: '✔'; /* チェックマーク */ | ||
color: green; /* 色を緑に */ | ||
margin-right: 0.5em; /* 右にマージンを設定 */ | ||
} | ||
|
||
ul[data-checked="false"] li::before { | ||
content: '✘'; /* バツマーク */ | ||
color: red; /* 色を赤に */ | ||
margin-right: 0.5em; /* 右にマージンを設定 */ | ||
} | ||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters