post.tsx 746 Bytes
Newer Older
1
import React, { MouseEventHandler } from "react";
Lee Soobeom's avatar
Lee Soobeom committed
2
import { Link } from "react-router-dom";
3
import { PostType } from "../types";
Lee Soobeom's avatar
Lee Soobeom committed
4
import { IntoPost } from "./intopost";
5

Lee Soobeom's avatar
Lee Soobeom committed
6
export type Props = {
7
8
9
  post: PostType;
  handleClick: MouseEventHandler;
};
Lee Soobeom's avatar
Lee Soobeom committed
10

11
12
13
14
export default function Post({ handleClick, post }: Props) {
  return (
    <div className="flex flex-row h-16 divide-x-2 border-2 border-solid">
      <div className="basis-full">
Lee Soobeom's avatar
Lee Soobeom committed
15
16
        <button id={post._id} onClick={handleClick}>
          <Link to={`/post/${post._id}`} state={post}>
Lee Soobeom's avatar
Lee Soobeom committed
17
            {post.title}
Lee Soobeom's avatar
Lee Soobeom committed
18
19
          </Link>
        </button>
20
      </div>
Lee Soobeom's avatar
Lee Soobeom committed
21
      <div className="basis-3/12">{post.date.slice(0, 10)}</div>
22
23
24
25
      <div className="basis-2/12">{post.counts}</div>
    </div>
  );
}