Skip to content

Commit

Permalink
vinvoor: add check in status to navbar
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Nov 19, 2024
1 parent 5a795ef commit ed2226f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions vinvoor/src/leaderboard/LeaderboardTableBody.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { Theme } from "@mui/material/styles";
import type { TableHeadCell } from "../types/general";
import type { LeaderboardItem } from "../types/leaderboard";
import {
Chip,
Icon,
TableBody,
TableCell,
Expand Down Expand Up @@ -81,12 +82,21 @@ function getPosition(position: number) {
}
}

function getScanned(scanned: boolean) {
if (scanned)
return <Chip label="Checked In" variant="outlined" color="success" />;

return <></>;
}

function getCell(row: LeaderboardItem, headCell: TableHeadCell<LeaderboardItem>) {
switch (headCell.id) {
case "positionChange":
return getPositionChange(row[headCell.id]);
case "position":
return getPosition(row[headCell.id]);
case "scanned":
return getScanned(row[headCell.id]);
default:
return (
<Typography
Expand All @@ -105,8 +115,7 @@ export function LeaderboardTableBody() {
const theme = useTheme();
const { data: user } = useUser();

if (!rows)
return null; // Can never happen
console.log(rows);

return (
<TableBody>
Expand Down
13 changes: 11 additions & 2 deletions vinvoor/src/types/leaderboard.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export interface LeaderboardItemJSON {
name: string;
total_days: number;
position_change: number;
checked_in: boolean;
}

// Internal
Expand All @@ -18,6 +19,7 @@ export interface LeaderboardItem {
name: string;
totalDays: number;
positionChange: number;
checkedIn: boolean;
}

// Converters
Expand All @@ -27,6 +29,7 @@ export function convertLeaderboardItemJSON(leaderboardItems: LeaderboardItemJSON
...leaderboardItem,
totalDays: leaderboardItem.total_days,
positionChange: leaderboardItem.position_change,
checkedIn: leaderboardItem.checked_in,
}));
}

Expand All @@ -52,9 +55,15 @@ export const leaderboardHeadCells: readonly TableHeadCell<LeaderboardItem>[] = [
padding: "normal",
},
{
id: "totalDays",
label: "Total Days",
id: "checkedIn",
label: "Checked In",
align: "right",
padding: "normal",
},
{
id: "totalDays",
label: "Total Days",
align: "left",
padding: "checkbox",
},
];

0 comments on commit ed2226f

Please sign in to comment.