Highlight seasonal Community Center priorities

This commit is contained in:
Codex 2026-10-05 19:10:19 +01:00
parent 8d5a94d7fa
commit d2c7f004ea
8 changed files with 199 additions and 16 deletions

41
static/availability.js Normal file
View file

@ -0,0 +1,41 @@
(function exposeAvailability(root, factory) {
const api = factory();
if (typeof module === "object" && module.exports) module.exports = api;
if (root) root.ValleyAvailability = api;
})(typeof window === "undefined" ? globalThis : window, () => {
const weatherFor = entry => {
if (!String(entry.id || "").startsWith("fish-")) return null;
const detail = String(entry.meta || "").toLowerCase();
if (detail.includes("rain")) return "Rain";
if (detail.includes("sunny")) return "Sun";
return null;
};
const classify = (entry, { checked, chooseGroupComplete, season }) => {
const seasons = Array.isArray(entry.seasons) ? entry.seasons : [];
const seasonal = seasons.length > 0;
const inSeason = seasons.includes(season);
const availableNow = !seasonal || inSeason;
const needed = !checked && !chooseGroupComplete;
return {
checked,
needed,
seasonal,
inSeason,
availableNow,
seasonExclusive: needed && inSeason && seasons.length === 1,
weather: weatherFor(entry),
seasons
};
};
const matchesFilter = (status, filter) => {
if (filter === "open") return status.needed;
if (filter === "now") return status.needed && status.availableNow;
if (filter === "exclusive") return status.seasonExclusive;
if (filter === "weather") return status.needed && status.availableNow && Boolean(status.weather);
return true;
};
return { classify, matchesFilter, weatherFor };
});