From ed2226faadbfa4c154a97543e7e39303efbe34bd Mon Sep 17 00:00:00 2001 From: Topvennie Date: Sun, 20 Oct 2024 15:44:01 +0200 Subject: [PATCH] vinvoor: add check in status to navbar --- vinvoor/src/leaderboard/LeaderboardTableBody.tsx | 13 +++++++++++-- vinvoor/src/types/leaderboard.ts | 13 +++++++++++-- 2 files changed, 22 insertions(+), 4 deletions(-) diff --git a/vinvoor/src/leaderboard/LeaderboardTableBody.tsx b/vinvoor/src/leaderboard/LeaderboardTableBody.tsx index eaaa2e7..065aea4 100644 --- a/vinvoor/src/leaderboard/LeaderboardTableBody.tsx +++ b/vinvoor/src/leaderboard/LeaderboardTableBody.tsx @@ -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, @@ -81,12 +82,21 @@ function getPosition(position: number) { } } +function getScanned(scanned: boolean) { + if (scanned) + return ; + + return <>; +} + function getCell(row: LeaderboardItem, headCell: TableHeadCell) { 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 ( diff --git a/vinvoor/src/types/leaderboard.ts b/vinvoor/src/types/leaderboard.ts index ffb6a06..66527d9 100644 --- a/vinvoor/src/types/leaderboard.ts +++ b/vinvoor/src/types/leaderboard.ts @@ -8,6 +8,7 @@ export interface LeaderboardItemJSON { name: string; total_days: number; position_change: number; + checked_in: boolean; } // Internal @@ -18,6 +19,7 @@ export interface LeaderboardItem { name: string; totalDays: number; positionChange: number; + checkedIn: boolean; } // Converters @@ -27,6 +29,7 @@ export function convertLeaderboardItemJSON(leaderboardItems: LeaderboardItemJSON ...leaderboardItem, totalDays: leaderboardItem.total_days, positionChange: leaderboardItem.position_change, + checkedIn: leaderboardItem.checked_in, })); } @@ -52,9 +55,15 @@ export const leaderboardHeadCells: readonly TableHeadCell[] = [ 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", + }, ];