I'm currently working on a web app that uses Tables to display data, within this table I have a column named actions that has buttons responsible for viewing details of the associated table item, deleting the table item as well as updating the table item. This has been implemented with the use of Modals instead of opening an entirely new page. The issue I'm currently facing is that the modal seems to only capture the last table Item instead of the corresponding table item with which they share the same row.
{
title: 'Actions',
key: 'actions',
render: (_, elm) => (
<div className="text-right d-flex justify-content-end">
<Tooltip title="View">
<Button type="primary" className="mr-2" icon={<EyeOutlined />} onClick={() => {console.log(elm.id)}} size="small"/>
</Tooltip>
<Tooltip title='Edit'>
<Button type="default" className='mr-2' icon={<EditOutlined />} onClick={ () => {console.log(elm.name)} } size="small" />
</Tooltip>
<Tooltip title="Delete">
<Button danger icon={<DeleteOutlined />} onClick={this.showModal} size="small" />
<Modal
title="Title"
visible={visible}
onOk={() => this.deletePlanType(elm.id)}
confirmLoading = {confirmLoading}
onCancel={this.handleCancel}
okText="Delete"
>
<p> Are you sure you would like to delete Plan type <span className='text-
primary'>{elm.name}</span>?</p>
</Modal>
</Tooltip>
</div>
)
}
How can I get the Modal when opened to have the data of its respective table Item?