input area

This commit is contained in:
ari committed 2022-06-16 17:24:31 -04:00
1 parent 0fc3ea6146
commit 15c97b81b4
16 files changed
+699 -416

No files matched your search

+5 -25
View File
@@ -1,41 +1,21 @@
import { BaseOption } from "haService";
import { FieldData, TargetData, TypedHassService } from "haService/fieldTypes";
import { BaseOption } from "components/Inputs/InputAutoComplete";
import { FieldData, TypedHassService } from "haService/fieldTypes";
import { prettyName } from "utils/formatting";
export type ServiceEditorData = {
field: Record<string, any>;
target: Record<string, any>;
};
export type ServiceEditorOption = BaseOption<
| {
type: "field";
data: {
description: string;
} & FieldData;
}
| {
type: "target";
data: {
description: string;
} & TargetData;
}
>;
export type ServiceEditorOption = BaseOption<{
data: FieldData
}>;
export const convertFieldToOption = (id: string, data: FieldData): ServiceEditorOption => ({
id,
label: data.name ?? prettyName(id),
type: "field",
data,
})
export const convertTargetToOption = (id: string, data: TargetData): ServiceEditorOption => ({
id,
type: "target",
label: ((data ?? {}) as any).name ?? prettyName(id),
data: (data as any) ?? {
description: "",
},
})
export const splitUpOptions = (service: TypedHassService, data: ServiceEditorData) => {
const required: ServiceEditorOption[] = [];