From edd1f9d297299787a65271a5cb9c7d1d30e4ea11 Mon Sep 17 00:00:00 2001 From: Lea Date: Fri, 11 Aug 2023 20:19:53 +0200 Subject: [PATCH] feat: render notes as markdown --- components/cards/SafetyNotesCard.tsx | 94 ++-- package.json | 3 + pnpm-lock.yaml | 754 ++++++++++++++++++++++++--- tailwind.config.js | 2 +- 4 files changed, 741 insertions(+), 112 deletions(-) diff --git a/components/cards/SafetyNotesCard.tsx b/components/cards/SafetyNotesCard.tsx index 93f842f..0417e5d 100644 --- a/components/cards/SafetyNotesCard.tsx +++ b/components/cards/SafetyNotesCard.tsx @@ -8,6 +8,9 @@ import { Card, CardContent, CardDescription, CardFooter, CardHeader, CardTitle } import { useSession } from "next-auth/react"; import dayjs from "dayjs"; import relativeTime from "dayjs/plugin/relativeTime"; +import ReactMarkdown from 'react-markdown'; +import remarkGfm from 'remark-gfm'; + dayjs.extend(relativeTime); export default function SafetyNotesCard({ objectId, type, title }: { @@ -20,6 +23,7 @@ export default function SafetyNotesCard({ objectId, type, title }: { const [value, setValue] = useState(null); const [ready, setReady] = useState(false); const [error, setError] = useState(null); + const [editing, setEditing] = useState(false); useEffect(() => { fetchSafetyNote(objectId, type) @@ -39,41 +43,63 @@ export default function SafetyNotesCard({ objectId, type, title }: { {title ?? type.charAt(0).toUpperCase() + type.slice(1) + " notes"} -