import React from 'react'
import { GridFooterCellDefault } from '../components/'
import { useColumnHeader } from '../hooks/'

type GridFooterCellDefaultRendererProps = {
    columnId: string
    label: string | number
}

const GridFooterCellDefaultRendererImpl = ({
    columnId,
    label,
}: GridFooterCellDefaultRendererProps) => {
    const { column } = useColumnHeader(columnId)

    if (!column) {
        return <></>
    }

    return (
        <GridFooterCellDefault
            columnId={columnId}
            align={column.header?.align}
            label={label}
        />
    )
}

export const GridFooterCellDefaultRenderer = React.memo(
    GridFooterCellDefaultRendererImpl
) as typeof GridFooterCellDefaultRendererImpl
