import { Link, Modal, useModal } from "@geist-ui/core"; import { Post } from "@lib/types"; import Cookies from "js-cookie"; import useSWR from "swr"; import { adminFetcher } from "."; import styles from './admin.module.css' const PostModal = ({ id }: { id: string, }) => { const { visible, setVisible, bindings } = useModal() const { data: post, error } = useSWR(`/server-api/admin/post/${id}`, adminFetcher) if (error) return failed to load if (!post) return loading... const deletePost = async () => { await fetch(`/server-api/admin/post/${id}`, { method: "DELETE", headers: { "Content-Type": "application/json", "Authorization": `Bearer ${Cookies.get("drift-token")}`, } }) setVisible(false) } return ( <> setVisible(true)}>{post.title} {post.title} Click an item to expand {post.files?.map((file) => (
{file.title}
) )} Delete setVisible(false)}>Close
) } export default PostModal