mirror of
https://github.com/gethomepage/homepage.git
synced 2025-12-07 01:26:01 -08:00
* Feature: Added agenda view for calendar, calendar improvements * Fix duplicate event keys * Additional hover on title, not date * Show date once in list * Rename monthly view for consistency * Remove unneeded key props * CSS cleanup, dont slice title to arbitrary 42 chars which can break column layouts * Simplify agenda components * Fix show date once in list --------- Co-authored-by: shamoon <4887959+shamoon@users.noreply.github.com>
41 lines
1.2 KiB
JavaScript
41 lines
1.2 KiB
JavaScript
import { DateTime } from "luxon";
|
|
import { useContext, useEffect } from "react";
|
|
|
|
import useWidgetAPI from "../../../utils/proxy/use-widget-api";
|
|
import { EventContext } from "../../../utils/contexts/calendar";
|
|
import Error from "../../../components/services/widget/error";
|
|
|
|
export default function Integration({ config, params }) {
|
|
const { setEvents } = useContext(EventContext);
|
|
const { data: lidarrData, error: lidarrError } = useWidgetAPI(config, "calendar", {
|
|
...params,
|
|
includeArtist: "false",
|
|
...(config?.params ?? {}),
|
|
});
|
|
|
|
useEffect(() => {
|
|
if (!lidarrData || lidarrError) {
|
|
return;
|
|
}
|
|
|
|
const eventsToAdd = {};
|
|
|
|
lidarrData?.forEach((event) => {
|
|
const title = `${event.artist.artistName} - ${event.title}`;
|
|
|
|
eventsToAdd[title] = {
|
|
title,
|
|
date: DateTime.fromISO(event.releaseDate),
|
|
color: config?.color ?? "green",
|
|
isCompleted: event.grabbed,
|
|
additional: "",
|
|
};
|
|
});
|
|
|
|
setEvents((prevEvents) => ({ ...prevEvents, ...eventsToAdd }));
|
|
}, [lidarrData, lidarrError, config, setEvents]);
|
|
|
|
const error = lidarrError ?? lidarrData?.error;
|
|
return error && <Error error={{ message: `${config.type}: ${error.message ?? error}` }} />;
|
|
}
|