feat: Add widget integration option (#14)

* wip: add widget integrations

* feat: Add integration option to widgets

* feat: Add translation for widget integration select

* fix: formatting issue

* chore: address pull request feedback
This commit is contained in:
Meier Lukas
2024-02-03 10:24:39 +01:00
committed by GitHub
parent 3a0f280984
commit 1740450648
22 changed files with 378 additions and 55 deletions

View File

@@ -1,3 +1,4 @@
import { objectEntries } from "@homarr/common";
import type { z } from "@homarr/validation";
interface CommonInput<TType> {
@@ -140,3 +141,15 @@ const createOptions = <TOptions extends WidgetOptionsRecord>(
export const opt = {
from: createOptions,
};
export const reduceWidgetOptionsWithDefaultValues = (
optionsDefinition: Record<string, WidgetOptionDefinition>,
currentValue: Record<string, unknown> = {},
) =>
objectEntries(optionsDefinition).reduce(
(prev, [key, value]) => ({
...prev,
[key]: currentValue[key] ?? value.defaultValue,
}),
{} as Record<string, unknown>,
);