import { useParams, Link, useNavigate } from 'react-router-dom'; import { useState } from 'react'; import { WidePageLayout } from '../components/WidePageLayout'; import RichTextEditor from '../components/RichTextEditor'; import useWikis from '../hooks/useWikis'; import CheckSquareIcon from '../components/icons/CheckSquareIcon'; import type { CreateWikiRequest } from '../types/epic'; export function CreateWiki() { const { id: boardId } = useParams<{ id: string }>(); const navigate = useNavigate(); const { createWiki } = useWikis(boardId || '0'); const [name, setName] = useState(''); const [slug, setSlug] = useState(''); const [summary, setSummary] = useState(''); const [category, setCategory] = useState(''); const [tags, setTags] = useState(''); const [content, setContent] = useState([{ children: [{ text: '' }] }]); const handleSubmit = async (e: React.FormEvent) => { e.preventDefault(); if (!name.trim()) { return; } const wikiData: CreateWikiRequest = { name: name.trim(), slug: slug.trim() || undefined, summary: summary.trim() || undefined, content: content.length > 1 || (content[0] as any).children[0].text !== '' ? (content as unknown as Record) : { children: [{ text: '' }] }, category: category.trim() || undefined, tags: tags.trim() ? tags.split(',').map((t) => t.trim()) : undefined, }; try { const newWiki = await createWiki(wikiData); navigate(`/boards/${boardId}/wikis/${newWiki.id}`); } catch { // Error is handled by hook } }; return (
← Back to Wikis

Create Wiki

Create a new wiki for this board

{/* Name */}
setName(e.target.value)} className="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-blue-500" placeholder="Enter wiki name..." required />
{/* Slug */}
setSlug(e.target.value)} className="w-full bg-gray-700 border border-gray-600 rounded-lg px-4 py-2 text-white focus:outline-none focus:border-blue-500" placeholder="url-friendly-slug" />

Leave empty to auto-generate from name. Used in URLs.

{/* Summary */}