import React, { MouseEvent, useEffect, useState } from "react"; import { useLocation, useNavigate, Link, Outlet } from "react-router-dom"; import { catchErrors } from "../helpers"; import { postApi } from "../apis"; import { PostType } from "../types"; export interface PostState { state: PostType; } export function IntoPost() { const [posts, setPosts] = useState(); const location = useLocation() as PostState; const post = location.state; const navigate = useNavigate(); const [loading, setLoading] = useState(false); const [error, setError] = useState(""); const [addSuccess, setAddSuccess] = useState(false); const [delSuccess, setDelSuccess] = useState(false); // console.log("post.file", post.file); useEffect(() => { setPosts(post); }, []); const handleDeleteClick = async (event: MouseEvent) => { try { if (confirm("삭제하시겠습니까?") == true) { const postId = event.currentTarget.id; const res = await postApi.deletePost(postId); navigate("/board"); console.log("delete post", res); } else { return false; } } catch (error) { console.log("에러발생"); catchErrors(error, setError); } }; return (
[{post.city}] / [{post.theme}] Travel Report
{posts?.title}
작성자: {posts?.user.name}
작성일 : {posts?.date.slice(0, 10)}
{" "} {posts?.city}
{" "} {posts?.theme}
조회수 : {posts?.counts}
{posts?.file?.map((file, i) => ( ))}
{posts?.text}
); }