File tree Expand file tree Collapse file tree
src/components/SearchResult Expand file tree Collapse file tree Original file line number Diff line number Diff line change 77 background-color : rgb (31 , 11 , 31 );
88 color : white ;
99}
10- tbody tr :hover {
11- background-color : skyblue ;
12- }
10+
1311th ,
1412td {
1513 padding : 8px ;
2018th {
2119 font-weight : bold ;
2220}
23- tr :nth-child (even ) {
24- background-color : #f2f2f2 ;
21+ .table-row {
22+ cursor : pointer ;
23+ }
24+ .selected {
25+ background-color : skyblue ;
2526}
Original file line number Diff line number Diff line change 1- // import FakeBookings from "@/data/fakeBookings.json";
2-
1+ import FakeBookings from "@/data/fakeBookings.json" ;
2+ import React from "react" ;
3+ import { useState } from "react" ;
34function TableBody ( props ) {
5+ const [ selectedRow , setSelectedRow ] = useState ( "unselect" ) ;
6+ function handleSelect ( ) {
7+ setSelectedRow ( selectedRow === "unselect" ? "selected" : "unselect" ) ;
8+ }
49 let {
510 id,
611 title,
@@ -15,7 +20,11 @@ function TableBody(props) {
1520 } = props ;
1621 return (
1722 < >
18- < tr key = { id } >
23+ < tr
24+ key = { id }
25+ onClick = { handleSelect }
26+ className = { `table-row ${ selectedRow } ` }
27+ >
1928 < td > { id } </ td >
2029 < td > { title } </ td >
2130 < td > { firstName } </ td >
You can’t perform that action at this time.
0 commit comments