diff --git a/frontend/app/recipes/[id]/edit/page.tsx b/frontend/app/recipes/[id]/edit/page.tsx index beb4e693..6f44d615 100644 --- a/frontend/app/recipes/[id]/edit/page.tsx +++ b/frontend/app/recipes/[id]/edit/page.tsx @@ -6,6 +6,40 @@ import { fetchJson } from '../../../../lib/api'; import { parseErrorResponse } from '../../../../lib/error-handler'; import type { Product, Recipe } from '../../../../features/inventory/types'; +const MARKDOWN_HELP = ` +**Fetstil:** **text** eller __text__ +*Kursiv:* *text* eller _text_ +• Punktlista: - punkt eller * punkt +# Rubrik 1 +## Rubrik 2 +### Rubrik 3 +`; + +function SimpleMarkdownPreview({ text }: { text: string }) { + const lines = text.split('\n'); + + return ( +
+ {lines.map((line, i) => { + // Enkel bearbetning + if (line.startsWith('# ')) { + return

{line.slice(2)}

; + } + if (line.startsWith('## ')) { + return

{line.slice(3)}

; + } + if (line.startsWith('- ') || line.startsWith('* ')) { + return
• {line.slice(2)}
; + } + if (line.trim() === '') { + return
; + } + return
{line}
; + })} +
+ ); +} + export default function EditRecipePage() { const router = useRouter(); const params = useParams(); @@ -22,6 +56,7 @@ export default function EditRecipePage() { const [isSaving, setIsSaving] = useState(false); const [isDeleting, setIsDeleting] = useState(false); const [error, setError] = useState(null); + const [showPreview, setShowPreview] = useState(false); useEffect(() => { const loadData = async () => { @@ -137,121 +172,289 @@ export default function EditRecipePage() { if (isLoading) { return ( -
+

Laddar recept...

); } return ( -
-

Redigera recept

+
+

Redigera recept

- {error &&

{error}

} + {error &&

{error}

} -
-
-