"use client"; import React from "react"; import { useState, useRef } from "react"; import styles from "../../../../styles/modules/AdminArticlesCreate.module.scss"; import { PostArticle } from "../../../../types/postData"; import Markdown from "../../../Markdown"; import { Category } from "@prisma/client"; import "../../../../styles/inputs.scss"; import Select, { GroupBase, OptionsOrGroups } from "react-select"; import { apiUrl } from "../../../global"; import urlJoin from "url-join"; export default function AdminArticlesCreate() { const [formData, setFormData] = useState(null); const [markdown, setMarkdown] = useState(""); const [selectedCategory, setSelectedCategory] = useState(); const titleRef = useRef(null); const markdownTextAreaRef = useRef(null); const selectCategoriesOptions: any = [ { value: "chocolate", label: "Chocolate" }, { value: "strawberry", label: "Strawberry" }, { value: "vanilla", label: "Vanilla" }, ]; function handleFormChange() { setMarkdown(markdownTextAreaRef.current.value); setFormData({ name: titleRef.current.value.replaceAll(" ", "%20"), title: titleRef.current.value, introduction: "test intro", markdown: markdown, categoryId: 2, }); } async function postData() { console.log(formData); await fetch("/api/articles/create", { method: "POST", headers: { Accept: "application/json", "Content-Type": "application/json", }, body: JSON.stringify(formData), }); } return (

Create a new article

contenttable
); }