From ed2226faadbfa4c154a97543e7e39303efbe34bd Mon Sep 17 00:00:00 2001 From: Topvennie Date: Sun, 20 Oct 2024 15:44:01 +0200 Subject: [PATCH 1/3] 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", + }, ]; From ec3e234dbec526bda61eac8e98dfc5488dd764d0 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Sun, 20 Oct 2024 15:47:50 +0200 Subject: [PATCH 2/3] vinvoor: small refactor --- vinvoor/src/leaderboard/LeaderboardTableBody.tsx | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/vinvoor/src/leaderboard/LeaderboardTableBody.tsx b/vinvoor/src/leaderboard/LeaderboardTableBody.tsx index 065aea4..997817c 100644 --- a/vinvoor/src/leaderboard/LeaderboardTableBody.tsx +++ b/vinvoor/src/leaderboard/LeaderboardTableBody.tsx @@ -82,8 +82,13 @@ function getPosition(position: number) { } } +<<<<<<< HEAD function getScanned(scanned: boolean) { if (scanned) +======= +const getScanned = (checkedIn: boolean) => { + if (checkedIn) +>>>>>>> 6b63abc (vinvoor: small refactor) return ; return <>; @@ -95,7 +100,7 @@ function getCell(row: LeaderboardItem, headCell: TableHeadCell) return getPositionChange(row[headCell.id]); case "position": return getPosition(row[headCell.id]); - case "scanned": + case "checkedIn": return getScanned(row[headCell.id]); default: return ( From 6d352b8dc580293aca18475d0a7e0d0e2b00a546 Mon Sep 17 00:00:00 2001 From: Topvennie Date: Tue, 19 Nov 2024 15:37:53 +0100 Subject: [PATCH 3/3] vinvoor: leaderboard --- vinvoor/src/leaderboard/LeaderboardTableBody.tsx | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/vinvoor/src/leaderboard/LeaderboardTableBody.tsx b/vinvoor/src/leaderboard/LeaderboardTableBody.tsx index 997817c..e471ef0 100644 --- a/vinvoor/src/leaderboard/LeaderboardTableBody.tsx +++ b/vinvoor/src/leaderboard/LeaderboardTableBody.tsx @@ -82,16 +82,9 @@ function getPosition(position: number) { } } -<<<<<<< HEAD -function getScanned(scanned: boolean) { - if (scanned) -======= -const getScanned = (checkedIn: boolean) => { +function getScanned(checkedIn: boolean) { if (checkedIn) ->>>>>>> 6b63abc (vinvoor: small refactor) return ; - - return <>; } function getCell(row: LeaderboardItem, headCell: TableHeadCell) { @@ -120,7 +113,8 @@ export function LeaderboardTableBody() { const theme = useTheme(); const { data: user } = useUser(); - console.log(rows); + if (!rows) + return; return (