import { Box } from '@mui/material'
import { IServer } from '../interfaces/servers'
import { useServerIps } from '../hooks/swrHooks'
import { GridColDef } from '@mui/x-data-grid'
import { Table } from '@mantine/core'

function ServerData({ id }: IServer) {
    const { serverIps } = useServerIps(id, 0, 10)

    const serverIpsColumns: GridColDef[] = [
        { field: 'id', headerName: 'ID', type: 'number' },
        { field: 'server_id', headerName: 'Server ID', type: 'number' },
        { field: 'name', headerName: 'Название', type: 'string' },
        { field: 'is_actual', headerName: 'Действителен', type: 'boolean' },
        { field: 'ip', headerName: 'IP', type: 'string' },
        { field: 'servername', headerName: 'Название сервера', type: 'string' },
    ]

    return (
        <Box sx={{ display: 'flex', flexDirection: 'column', p: '16px' }}>
            {serverIps &&
                // <FullFeaturedCrudGrid
                //     initialRows={serverIps}
                //     columns={serverIpsColumns}
                //     actions
                //     onRowClick={() => {
                //         //setCurrentServerData(params.row)
                //         //setServerDataOpen(true)
                //     }}
                //     onSave={undefined}
                //     onDelete={undefined}
                //     loading={false}
                // />
                <Table highlightOnHover>
                    <Table.Thead>
                        <Table.Tr>
                            {serverIpsColumns.map(column => (
                                <Table.Th key={column.field}>{column.headerName}</Table.Th>
                            ))}
                        </Table.Tr>
                    </Table.Thead>
                    <Table.Tbody>
                        <Table.Tr>
                            {serverIpsColumns.map(column => (
                                <Table.Td key={column.field}>{serverIps ? serverIps[column.field] : ''}</Table.Td>
                            ))}
                        </Table.Tr>
                    </Table.Tbody>
                </Table>
            }
        </Box>
    )
}

export default ServerData