diff --git a/src/app/snippets/new/page.tsx b/src/app/snippets/new/page.tsx index 0595ad0..1341035 100644 --- a/src/app/snippets/new/page.tsx +++ b/src/app/snippets/new/page.tsx @@ -1,18 +1,23 @@ "use client"; +import { useState } from "react"; import * as actions from "@/actions"; +import SnippetEditor from "@/components/snippet-create-form"; import { useActionState } from "react"; export default function SnippetCreatePage() { const [formState, action] = useActionState(actions.createSnippet, { message: "", }); - + const [code, setCode] = useState(""); + const handleCodeChange = (newCode: string = "") => { + setCode(newCode); + }; return (

Create a Snippet

-
+
@@ -22,11 +27,12 @@ export default function SnippetCreatePage() { id="title" />
-
+
- + +
{formState.message ? ( diff --git a/src/components/snippet-create-form.tsx b/src/components/snippet-create-form.tsx new file mode 100644 index 0000000..ebe6a05 --- /dev/null +++ b/src/components/snippet-create-form.tsx @@ -0,0 +1,30 @@ +"use client"; + +import { Editor } from "@monaco-editor/react"; + +interface SnippetEditorProps { + code: string; + onCodeChange: (value: string) => void; +} + +export default function SnippetEditor({ + code, + onCodeChange, +}: SnippetEditorProps) { + const handleEditorChange = (value: string = "") => { + onCodeChange(value); + }; + + return ( +
+ +
+ ); +}