table styling update
This commit is contained in:
parent
d0edb00cc7
commit
205f1bfdcd
1 changed files with 34 additions and 6 deletions
|
|
@ -3,6 +3,34 @@ import React, { useEffect, useMemo, useState } from "react";
|
||||||
|
|
||||||
type Row = Record<string, string>;
|
type Row = Record<string, string>;
|
||||||
|
|
||||||
|
const ResultCell = ({ value }: { value: string | undefined }) => {
|
||||||
|
if (!value) return <td className="border p-2">—</td>;
|
||||||
|
|
||||||
|
const numValue = parseFloat(value);
|
||||||
|
const isNegative = numValue < 0;
|
||||||
|
const isPositive = numValue > 0;
|
||||||
|
|
||||||
|
const displayValue = isNegative ? Math.abs(numValue).toString() : value;
|
||||||
|
|
||||||
|
if (isNegative) {
|
||||||
|
return (
|
||||||
|
<td className="border p-2 bg-red-600 text-white font-semibold">
|
||||||
|
{displayValue}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isPositive) {
|
||||||
|
return (
|
||||||
|
<td className="border p-2 bg-red-600 text-green-400 font-semibold">
|
||||||
|
{displayValue}
|
||||||
|
</td>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return <td className="border p-2">{value}</td>;
|
||||||
|
};
|
||||||
|
|
||||||
export function ResultsTable() {
|
export function ResultsTable() {
|
||||||
const [meets, setMeets] = useState<{ id: string; name: string }[]>([]);
|
const [meets, setMeets] = useState<{ id: string; name: string }[]>([]);
|
||||||
const [selectedMeet, setSelectedMeet] = useState<string>("");
|
const [selectedMeet, setSelectedMeet] = useState<string>("");
|
||||||
|
|
@ -35,7 +63,7 @@ export function ResultsTable() {
|
||||||
}, [rows, query]);
|
}, [rows, query]);
|
||||||
|
|
||||||
const attemptOptions = (prefix: string) => {
|
const attemptOptions = (prefix: string) => {
|
||||||
const labelPrefix = prefix === "Squat" ? "Agachamento" : prefix === "Bench" ? "Supino" : "Levantamento terra";
|
const labelPrefix = prefix === "Squat" ? "Agachamento" : prefix === "Bench" ? "Supino" : "Deadlift";
|
||||||
const opts = [1, 2, 3, 4]
|
const opts = [1, 2, 3, 4]
|
||||||
.map((n) => ({ key: `${prefix}${n}Kg`, label: `${labelPrefix} ${n}` }))
|
.map((n) => ({ key: `${prefix}${n}Kg`, label: `${labelPrefix} ${n}` }))
|
||||||
.filter((o) => rows.some((r) => o.key in r));
|
.filter((o) => rows.some((r) => o.key in r));
|
||||||
|
|
@ -126,11 +154,11 @@ export function ResultsTable() {
|
||||||
<td className="border p-2">{r["Equipment"]}</td>
|
<td className="border p-2">{r["Equipment"]}</td>
|
||||||
<td className="border p-2">{r["Division"]}</td>
|
<td className="border p-2">{r["Division"]}</td>
|
||||||
<td className="border p-2">{r["BodyweightKg"]}</td>
|
<td className="border p-2">{r["BodyweightKg"]}</td>
|
||||||
<td className="border p-2">{r[squatCol]}</td>
|
<ResultCell value={r[squatCol]} />
|
||||||
<td className="border p-2">{r[benchCol]}</td>
|
<ResultCell value={r[benchCol]} />
|
||||||
<td className="border p-2">{r[deadliftCol]}</td>
|
<ResultCell value={r[deadliftCol]} />
|
||||||
<td className="border p-2">{r["TotalKg"]}</td>
|
<ResultCell value={r["TotalKg"]} />
|
||||||
<td className="border p-2">{r["GLPoints"]}</td>
|
<ResultCell value={r["GLPoints"]} />
|
||||||
</tr>
|
</tr>
|
||||||
))}
|
))}
|
||||||
</tbody>
|
</tbody>
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue