table styling update

This commit is contained in:
headpatsyou 2026-01-08 12:41:38 +00:00
parent d0edb00cc7
commit 205f1bfdcd

View file

@ -3,6 +3,34 @@ import React, { useEffect, useMemo, useState } from "react";
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() {
const [meets, setMeets] = useState<{ id: string; name: string }[]>([]);
const [selectedMeet, setSelectedMeet] = useState<string>("");
@ -35,7 +63,7 @@ export function ResultsTable() {
}, [rows, query]);
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]
.map((n) => ({ key: `${prefix}${n}Kg`, label: `${labelPrefix} ${n}` }))
.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["Division"]}</td>
<td className="border p-2">{r["BodyweightKg"]}</td>
<td className="border p-2">{r[squatCol]}</td>
<td className="border p-2">{r[benchCol]}</td>
<td className="border p-2">{r[deadliftCol]}</td>
<td className="border p-2">{r["TotalKg"]}</td>
<td className="border p-2">{r["GLPoints"]}</td>
<ResultCell value={r[squatCol]} />
<ResultCell value={r[benchCol]} />
<ResultCell value={r[deadliftCol]} />
<ResultCell value={r["TotalKg"]} />
<ResultCell value={r["GLPoints"]} />
</tr>
))}
</tbody>