Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

zess: navbar checked in #100

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion 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,19 @@ function getPosition(position: number) {
}
}

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

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 "checkedIn":
return getScanned(row[headCell.id]);
default:
return (
<Typography
Expand All @@ -106,7 +114,7 @@ export function LeaderboardTableBody() {
const { data: user } = useUser();

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

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",
},
];
Loading