import type {BoardListItem} from "../type/board.types.ts";
import type {SearchParams} from "../../../../type/searchParams.ts";

interface BoardListTableRowProps {
    item: BoardListItem
    index: number
    searchParams: SearchParams
    totalCount: number
    currentPage: number
    recordPerPage: number
}

export function BoardListTableRow({item, index, searchParams, totalCount, currentPage, recordPerPage}: BoardListTableRowProps) {
    const rowNumber = searchParams.searchSortOrd === 'DESC'
        ? totalCount - (currentPage - 1) * recordPerPage - index
        : (currentPage - 1) * recordPerPage + (index + 1)

    return (
        <tr>
            <td>{rowNumber}</td>
            <td>{item.bbsNm}</td>
            <td>{item.menuNm}</td>
            <td>
                {item.newCnt}/{item.totCnt}
            </td>
            <td>{item.bbsTyCodeNm}</td>
            <td>{item.frstRegisterPnttm}</td>
            <td>
                {item.useAt === 'Y' ? (
                    <span className="status text blue">사용</span>
                ) : (
                    <span className="status text gray">미사용</span>
                )}
            </td>
            <td>
                <div className="btn_wrap center">
                    <button className="btn line primary small">수정</button>
                    <button className="btn line lightgray small">게시판보기</button>
                    <button className="btn line lightgray small">템플릿</button>
                </div>
            </td>
        </tr>
    )
}
