Skip to content

Commit

Permalink
vinvoor: add a new zess logo
Browse files Browse the repository at this point in the history
  • Loading branch information
Topvennie committed Jul 18, 2024
1 parent db96f94 commit 656a329
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 27 deletions.
2 changes: 1 addition & 1 deletion vinvoor/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<html lang="en">
<head>
<meta charset="UTF-8" />
<link rel="icon" type="image/svg+xml" href="/zeus.svg" />
<link rel="icon" type="image/svg+xml" href="/logo.svg" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>ZeSS</title>
</head>
Expand Down
1 change: 1 addition & 0 deletions vinvoor/public/logo.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 4 additions & 0 deletions vinvoor/src/main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ const router = createBrowserRouter([
path: "leaderboard",
element: <Leaderboard />,
},
{
path: "settings",

}
],
},
]);
Expand Down
2 changes: 1 addition & 1 deletion vinvoor/src/navbar/NavBarUserMenu.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const NavBarUserMenu: FC<NavBarUserMenuProps> = ({ pageIcons }) => {
</UnstyledLink>
))}
<MenuItem>
<Logout>
<Logout sx={{ color: "inherit" }}>
<ExitRun sx={{ mr: ".3rem" }} />
<Typography>Logout</Typography>
</Logout>
Expand Down
2 changes: 1 addition & 1 deletion vinvoor/src/overview/Overview.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ export const Overview = () => {
setScans,
convertScanJSON
);
const [checked, setChecked] = useState<boolean>(true);
const [checked, setChecked] = useState<boolean>(false);
const daysRef = useRef<HTMLDivElement>(null);
const heatmapSwitchRef = useRef<HTMLDivElement>(null);
const [heatmapSwitchHeight, setHeatmapSwitchHeight] = useState<number>(0);
Expand Down
32 changes: 23 additions & 9 deletions vinvoor/src/overview/streak/Streak.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,24 +28,38 @@ const isStreakDay = (date1: Date, date2: Date) => {
};

const getStreak = (scans: readonly Scan[]): [boolean, number] => {
const dates = scans
.map((scan) => {
scan.scanTime.setHours(0, 0, 0, 0);
return scan.scanTime;
})
.filter((value, index, array) => {
return (
array.findIndex(
(date) => date.getTime() === value.getTime()
) === index
);
});
dates.sort((a, b) => a.getTime() - b.getTime());

let streak = 0;

const isOnStreak =
scans.length > 0 &&
(isTheSameDay(scans[scans.length - 1].scanTime, new Date()) ||
isWeekendBetween(scans[scans.length - 1].scanTime, new Date()));
dates.length > 0 &&
(isTheSameDay(dates[dates.length - 1], new Date()) ||
isWeekendBetween(dates[dates.length - 1], new Date()));

if (isOnStreak) {
let i = scans.length;
let i = dates.length;
streak++;

while (i-- > 1 && isStreakDay(scans[i].scanTime, scans[i - 1].scanTime))
streak++;
while (i-- > 1 && isStreakDay(dates[i], dates[i - 1])) streak++;
} else {
streak =
scans.length > 0
dates.length > 0
? Math.floor(
(new Date().getTime() -
scans[scans.length - 1].scanTime.getTime()) /
dates[dates.length - 1].getTime()) /
MILLISECONDS_IN_ONE_DAY -
1
)
Expand All @@ -57,7 +71,7 @@ const getStreak = (scans: readonly Scan[]): [boolean, number] => {

export const Streak = () => {
const { scans } = useContext(ScanContext);
const [isOnStreak, streak] = getStreak(scans);
let [isOnStreak, streak] = getStreak(scans);

const color = isOnStreak ? "primary" : "error";
const textEnd = isOnStreak ? "streak" : "absent";
Expand Down
7 changes: 3 additions & 4 deletions vinvoor/src/scans/ScansBody.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { TableBody, TableCell, Typography } from "@mui/material";
import { TableRow } from "mdi-material-ui";
import { TableBody, TableCell, TableRow, Typography } from "@mui/material";
import { FC, useEffect, useState } from "react";
import { Card } from "../types/cards";
import {
Expand All @@ -23,8 +22,8 @@ export const ScansTableBody: FC<ScansTableBodyProps> = ({ scans, cards }) => {

return (
<TableBody>
{scanCards.map((scanCard) => (
<TableRow key={scanCard.scanTime.toString()}>
{scanCards.map((scanCard, index) => (
<TableRow key={index}>
{scanCardHeadCells.map((headCell) => (
<TableCell
key={headCell.id}
Expand Down
Empty file.
22 changes: 11 additions & 11 deletions vinvoor/src/types/scans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ import { TableHeadCell } from "./general";

interface ScanJSON {
scanTime: string;
card: string;
cardSerial: string;
}

export interface Scan {
scanTime: Date;
card: string;
cardSerial: string;
}

export interface ScanCard {
Expand All @@ -20,7 +20,7 @@ export const convertScanJSON = (scansJSON: ScanJSON[]): Scan[] =>
scansJSON
.map((scanJSON) => ({
scanTime: new Date(scanJSON.scanTime),
card: scanJSON.card,
cardSerial: scanJSON.cardSerial,
}))
.sort((a, b) => a.scanTime.getTime() - b.scanTime.getTime());

Expand All @@ -30,23 +30,23 @@ export const mergeScansCards = (
): readonly ScanCard[] =>
scans.map((scan) => ({
scanTime: scan.scanTime,
card: cards.find((card) => card.serial === scan.card),
card: cards.find((card) => card.serial === scan.cardSerial),
}));

export const scanCardHeadCells: readonly TableHeadCell<ScanCard>[] = [
{
id: "card",
label: "Card",
id: "scanTime",
label: "Scan time",
align: "left",
padding: "normal",
convert: (value: Card | undefined) =>
value?.name ?? value?.serial ?? "Unknown",
convert: (value: Date) => value.toDateString(),
},
{
id: "scanTime",
label: "Scan time",
id: "card",
label: "Card",
align: "right",
padding: "normal",
convert: (value: Date) => value.toDateString(),
convert: (value: Card | undefined) =>
value?.name || (value?.serial ?? "Unknown"),
},
];

0 comments on commit 656a329

Please sign in to comment.