Skip to content
Snippets Groups Projects
Commit 47d6a173 authored by Niklas Schrötler's avatar Niklas Schrötler
Browse files

everywhere: Improved code style

parent 6e765ddf
No related branches found
No related tags found
No related merge requests found
...@@ -42,7 +42,8 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => { ...@@ -42,7 +42,8 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => {
// Determine stop data from the departures // Determine stop data from the departures
for(let departure of departures) { for(let departure of departures) {
// First throw away all data that belongs to a filtered category // First throw away all data that belongs to a filtered category
if((props.definition.filter.types ?? []).includes(departure.type)) { const filterTypes = props.definition.filter.types ?? [];
if(filterTypes.includes(departure.type)) {
continue; continue;
} }
...@@ -83,7 +84,8 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => { ...@@ -83,7 +84,8 @@ const FahrplanPanel = (props: {definition: FahrplanPanelDefinition}) => {
countdown: parseInt(departure.countdown) countdown: parseInt(departure.countdown)
}) })
newRoutes[existing_ind].stops = newRoutes[existing_ind].stops.sort((a, b) => a.countdown - b.countdown) newRoutes[existing_ind].stops = newRoutes[existing_ind].stops
.sort((a, b) => a.countdown - b.countdown)
} }
} }
......
...@@ -81,6 +81,7 @@ const PlanElement = (props: { ...@@ -81,6 +81,7 @@ const PlanElement = (props: {
{ {
props.stops.map((stop, index) => ( props.stops.map((stop, index) => (
<ProgressIndicator <ProgressIndicator
key={stop.name}
first={index === 0} first={index === 0}
id={stop.name} id={stop.name}
name={deDortmund(stop.name)} name={deDortmund(stop.name)}
......
// import TimeAgo from 'javascript-time-ago'
// import de from 'javascript-time-ago/locale/de'
// import {useEffect, useState} from "react";
import classNames from "../../../util/classNames"; import classNames from "../../../util/classNames";
export default function ProgressIndicator(props: {first?: boolean, id: string, name: string, arrival: Date, delay?: number}) { type ProgressIndicatorProps = {
// const [timeUntil, setTimeUntil] = useState<string>(""); first?: boolean,
// id: string,
// useEffect(() => { name: string,
// // Setup TimeAgo arrival: Date,
// TimeAgo.addDefaultLocale(de); delay?: number
// const timeAgo = new TimeAgo('de-DE') }
//
// const update = () => {
// setTimeUntil(timeAgo.format(new Date(), {future: true}));
// }
//
// setInterval(update, 1000);
// update();
// }, []);
export default function ProgressIndicator(props: Readonly<ProgressIndicatorProps>) {
return ( return (
<li className={`relative ${!(props.first ?? false) ? "-mt-3.5" : "-mt-2"} text-sm text-zinc-300`} key={props.id}> <li className={`relative ${!(props.first ?? false) ? "-mt-3.5" : "-mt-2"} text-sm text-zinc-300`} key={props.id}>
<div className={"flex flex-row gap-4"}> <div className={"flex flex-row gap-4"}>
......
...@@ -53,7 +53,7 @@ const MensaplanPanel = (props: {definition: MensaPanelDefinition}) => { ...@@ -53,7 +53,7 @@ const MensaplanPanel = (props: {definition: MensaPanelDefinition}) => {
// Request the API // Request the API
const request = await fetch(`/canteen-menu/v3/canteens/${props.definition.canteenId}/${fetchFor}`); const request = await fetch(`/canteen-menu/v3/canteens/${props.definition.canteenId}/${fetchFor}`);
if (!(request.status === 200)) { if (request.status !== 200) {
menus.current = []; menus.current = [];
specials.current = []; specials.current = [];
return; return;
...@@ -157,11 +157,11 @@ const MensaplanPanel = (props: {definition: MensaPanelDefinition}) => { ...@@ -157,11 +157,11 @@ const MensaplanPanel = (props: {definition: MensaPanelDefinition}) => {
<PanelContent> <PanelContent>
<div className={"flex flex-col gap-4"}> <div className={"flex flex-col gap-4"}>
{dishes.map(dish => ( {dishes.map(dish => (
<div className={"flex flex-row items-center gap-4"}> <div key={dish.name} className={"flex flex-row items-center gap-4"}>
{/* Fixme: This shifts the name out of line if there is more than one */} {/* Fixme: This shifts the name out of line if there is more than one */}
<div className={"flex flex-row gap-2 mr-2"}> <div className={"flex flex-row gap-2 mr-2"}>
{dish.typeIcons.map(Icon => ( {dish.typeIcons.map((Icon, index) => (
<Icon size={32} className={"text-zinc-400"}/> <Icon key={Icon.name + index} size={32} className={"text-zinc-400"}/>
))} ))}
</div> </div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment