mirror of
https://github.com/tomru/advcal.git
synced 2026-03-03 14:37:19 +01:00
43 lines
1.0 KiB
JavaScript
43 lines
1.0 KiB
JavaScript
import { useContext } from "react";
|
|
|
|
import AppContext from "../context/app";
|
|
|
|
const Calendar = () => {
|
|
const { loading, songs, openDoor } = useContext(AppContext);
|
|
|
|
if (loading || !songs) {
|
|
return null;
|
|
}
|
|
|
|
return (
|
|
<div>
|
|
<ul className="cal">
|
|
{songs.map((song, index) => {
|
|
const classes = ["calcard", song.locked && "calcard__locked"]
|
|
.filter(Boolean)
|
|
.join(" ");
|
|
|
|
return (
|
|
<li
|
|
className={classes}
|
|
data-id={index}
|
|
key={song.id}
|
|
onClick={() => !song.locked && openDoor(index)}
|
|
title={
|
|
song.locked &&
|
|
`Es ist noch nicht der ${new Date(
|
|
song.lockedUntil
|
|
).toLocaleDateString()}! Geduld, nur Geduld!` || index + 1
|
|
}
|
|
>
|
|
<span className="cardnumber">{index + 1}</span>
|
|
</li>
|
|
);
|
|
})}
|
|
</ul>
|
|
</div >
|
|
);
|
|
};
|
|
|
|
export default Calendar;
|