Created
May 22, 2021 04:51
-
-
Save brlafreniere/6fbcee97703a9cf7ad8acebdca4b4299 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, {useState, useEffect, useContext} from "react" | |
import {Link} from "react-router-dom" | |
import axios from "axios" | |
import AppContext from "../../contexts/AppContext" | |
import Card from "../Card" | |
import EmployeeType from "../../types/EmployeeType" | |
import CrudIndex from "../CrudIndex" | |
const EmployeesCrudIndex = (props: any) => { | |
return ( | |
<CrudIndex> | |
<table className="table table-bordered" style={{tableLayout: 'fixed'}}> | |
<thead className="thead-light"> | |
<tr className="bg-light text-center"> | |
<th>Name</th> | |
<th>Actions</th> | |
</tr> | |
</thead> | |
<tbody> | |
{records && employees.map((employee: EmployeeType) => ( | |
<tr key={employee.id}> | |
<td> | |
<Link to={`/employees/${employee.id}`}> | |
{employee.firstName} {employee.lastName} | |
</Link> | |
</td> | |
<td> | |
<button className="btn btn-danger btn-sm" onClick={() => deleteEmployee(employee.id)}> | |
Delete | |
</button> | |
</td> | |
</tr> | |
))} | |
</tbody> | |
</table> | |
</Card> | |
) | |
} | |
export default EmployeesIndex |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment