* fix(deps): update dependency typescript-eslint to v8 * fix: lint issues * fix: more lint issues --------- Co-authored-by: homarr-renovate[bot] <158783068+homarr-renovate[bot]@users.noreply.github.com> Co-authored-by: Meier Lukas <meierschlumpf@gmail.com>
36 lines
787 B
TypeScript
36 lines
787 B
TypeScript
"use server";
|
|
|
|
import type { RouterOutputs } from "@homarr/api";
|
|
import { api } from "@homarr/api/server";
|
|
|
|
import type { WidgetProps } from "../definition";
|
|
|
|
export default async function getServerDataAsync({ integrationIds, itemId }: WidgetProps<"calendar">) {
|
|
if (!itemId) {
|
|
return {
|
|
initialData: [],
|
|
};
|
|
}
|
|
try {
|
|
const data = await api.widget.calendar.findAllEvents({
|
|
integrationIds,
|
|
itemId,
|
|
});
|
|
|
|
return {
|
|
initialData: data
|
|
.filter(
|
|
(
|
|
item,
|
|
): item is Exclude<Exclude<RouterOutputs["widget"]["calendar"]["findAllEvents"][number], null>, undefined> =>
|
|
item !== null,
|
|
)
|
|
.flatMap((item) => item.data),
|
|
};
|
|
} catch {
|
|
return {
|
|
initialData: [],
|
|
};
|
|
}
|
|
}
|