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 Oct 20, 2024
1 parent 40c17f1 commit f718563
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 2 deletions.
12 changes: 12 additions & 0 deletions vinvoor/src/leaderboard/LeaderboardTableBody.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {
Chip,
Icon,
TableBody,
TableCell,
Expand Down Expand Up @@ -77,6 +78,13 @@ const getPosition = (position: number) => {
}
};

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

return <></>;
};

const getCell = (
row: LeaderboardItem,
headCell: TableHeadCell<LeaderboardItem>,
Expand All @@ -86,6 +94,8 @@ const getCell = (
return getPositionChange(row[headCell.id]);
case "position":
return getPosition(row[headCell.id]);
case "scanned":
return getScanned(row[headCell.id]);
default:
return (
<Typography
Expand All @@ -106,6 +116,8 @@ export const LeaderboardTableBody = () => {
const theme = useTheme();
const { data: user } = useUser();

console.log(rows);

return (
<TableBody>
{rows.map((row, index) => {
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 @@ -29,6 +31,7 @@ export const convertLeaderboardItemJSON = (
...leaderboardItem,
totalDays: leaderboardItem.total_days,
positionChange: leaderboardItem.position_change,
checkedIn: leaderboardItem.checked_in,
}));

// Table
Expand All @@ -53,9 +56,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 f718563

Please sign in to comment.