Skip to content

Commit 86cda8f

Browse files
Add displaydist icon and initial states
1 parent 8e9e03a commit 86cda8f

File tree

2 files changed

+32
-4
lines changed

2 files changed

+32
-4
lines changed

src/components/Barchart.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { BarChart, Bar, XAxis, YAxis, Tooltip } from "recharts";
44
export default class Barchart extends Component {
55
render() {
66
const { data, isLoading, dataKey, stroke } = this.props;
7-
// const updatedData = data.slice(25, -1);
87
const result = data.map((dataItem) => {
98
return {
109
date: dataItem.day.slice(5),
@@ -27,7 +26,6 @@ export default class Barchart extends Component {
2726
<XAxis dataKey="date" />
2827
<YAxis />
2928
<Tooltip />
30-
{/* <Legend /> */}
3129
<Bar dataKey={dataKey} fill={stroke} />
3230
</BarChart>
3331
)}

src/components/DisplayTable.js

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1-
import React from "react";
1+
import React, { useState, useEffect } from "react";
2+
import { FontAwesomeIcon } from "@fortawesome/react-fontawesome";
3+
import {
4+
faArrowCircleRight,
5+
faArrowCircleDown,
6+
} from "@fortawesome/free-solid-svg-icons";
27
import "../styles/DisplayTable.css";
38

49
const useSortableData = (items, config = null) => {
@@ -37,15 +42,29 @@ const useSortableData = (items, config = null) => {
3742

3843
const DisplayTable = ({ tableData, isDarkMode }) => {
3944
const { items, requestSort, sortConfig } = useSortableData(tableData);
45+
const [displayDist, setDisplayDist] = useState(false);
46+
const [distId, setDistId] = useState("");
47+
4048
const lightText = {
4149
color: isDarkMode && "rgba(255,255,255,.75)",
4250
};
51+
4352
const getClassNamesFor = (name) => {
4453
if (!sortConfig) {
4554
return;
4655
}
4756
return sortConfig.key === name ? sortConfig.direction : undefined;
4857
};
58+
59+
const toggleDistView = (id) => {
60+
setDistId(id);
61+
setDisplayDist(!displayDist);
62+
};
63+
64+
useEffect(() => {
65+
console.log(distId, displayDist);
66+
}, [distId, displayDist]);
67+
4968
return (
5069
<table>
5170
{/* <caption>Products</caption> */}
@@ -101,7 +120,18 @@ const DisplayTable = ({ tableData, isDarkMode }) => {
101120
<tbody>
102121
{items.map((item) => (
103122
<tr key={item.id}>
104-
<td style={lightText}>{item.name}</td>
123+
<td style={lightText}>
124+
<FontAwesomeIcon
125+
icon={
126+
distId === item.id && displayDist
127+
? faArrowCircleDown
128+
: faArrowCircleRight
129+
}
130+
className="but"
131+
onClick={() => toggleDistView(item.id)}
132+
/>{" "}
133+
{item.name}
134+
</td>
105135
<td style={lightText}>{item.confirmed}</td>
106136
<td style={lightText}>{item.active}</td>
107137
<td style={lightText}>{item.discharged}</td>

0 commit comments

Comments
 (0)