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

type BoardArticleListTableRowProps = {
    item: BoardArticleListItem
    index: number
    searchParams: SearchParams
    totalItems: number
    currentPage: number
    totalPages: number
}

export const BoardArticleListTableRow = ({
                                             item,
                                             index,
                                             searchParams,
                                             totalItems,
                                             currentPage,
                                             totalPages,
                                         }: BoardArticleListTableRowProps) => {

    const rowNumber = searchParams.searchSortOrd === 'DESC'
        ? totalItems - (currentPage - 1) * totalPages - index
        : (currentPage - 1) * totalPages + (index + 1)
    return (
        <tr>
            <td></td>
            <td>{rowNumber}</td>
            <td>{item.nttSj}</td>
            <td>{item.atchFileId}</td>
            <td>{item.secretAt}</td>
            <td>{item.frstRegisterNm}</td>
            <td>{item.frstRegisterPnttm}</td>
            <td>{item.inqireCo}</td>
        </tr>
    )
}