import type {BoardArticleListItem} from "../type/boardArticle.types.ts";
import type {SearchParams} from "../../../../../type/searchParams.ts";
import {CheckBox} from "../../../../component/checkbox/CheckBox.tsx";
import {getTableRowNumber} from "../../../../component/table/getTableRowNumber.ts";

type BoardArticleListTableRowProps = {
    item: BoardArticleListItem
    index: number
    searchParams: SearchParams
    totalItems: number
    currentPage: number
    checked: boolean
    onCheck: (id: string, checked: boolean) => void
}

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

    const rowNumber = getTableRowNumber({
        searchParams,
        totalItems,
        currentPage,
        index,
    });

    return (
        <tr>
            <td>
                <CheckBox
                    id={`checkList_${item.nttId}`}
                    name="checkList"
                    value={item.nttId}
                    checked={checked}
                    onChange={(nextChecked) => onCheck(item.nttId, nextChecked)}
                />
            </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>
    )
}
