import React, { useState, useEffect } from "react"; import { Table, Button, Space } from "antd"; import { Link, useHistory } from "react-router-dom"; import { UserAddOutlined } from "@ant-design/icons"; import ClientService from "../service/ClientService"; export default function ClientsPage() { const history = useHistory(); const [clients, setClients] = useState([]); const [selectedClients, setSelectedClients] = useState([]); const [actionsVisible, setActionsVisible] = useState(false); useEffect(() => { ClientService.getClients().then(setClients); }, []); const onSelectChange = (selectedRowKeys) => { setSelectedClients(selectedRowKeys); if (selectedRowKeys.length >= 1) { setActionsVisible(true); } else { setActionsVisible(false); } }; const columns = [ { title: "Name", dataIndex: "id", render: (id) => ( { /* TODO: is there a simpler way? */ clients.filter((c) => c.id == id)[0].name } ), }, ]; return (
{ return { ...client, key: client.id }; })} /> ); }