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 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); const handleDeleteClick = async (event: MouseEvent) => { try { if (confirm("삭제하시겠습니까?") == true) { const postId = event.currentTarget.id; const res = await postApi.deletePost(postId); navigate("/board", { replace: true }); console.log("delete post", res); } else { return false; } } catch (error) { console.log("에러발생"); catchErrors(error, setError); } }; return (
{post.title}
작성자: {post.user.slice(0, 8)}
작성일 : {post.date.slice(0, 10)}
{post.city}
{post.theme}
조회수 : {post.counts}
{post.file?.map((file, i) => ( ))}
{post.text}
); }