import { HAService } from "haService"; import { HAEntitiesState } from "haService/HAEntities"; import { LangStore } from "lang"; import { FC } from "react"; import { AutomationAction } from "types/automations/actions"; import { AutomationCondition } from "types/automations/conditions"; import { cleanUpUndefined } from "utils/helpers"; export type OptionManager = { defaultState(): T; isReady(s: T): boolean; } & ( | { renderOptionList( s: T, set: (s: T) => void, entities: HAEntitiesState ): JSX.Element; } | { Component: FC<{ state: T; setState: (s: T) => void; ha: HAService; createMode: boolean; langStore: LangStore; }>; } ); export const updateConditionData = (setState: (s: T) => void) => (state: T, data: Partial) => setState( cleanUpUndefined({ ...state, ...data, }) ); export const updateActionData = (state: T, setState: (s: T) => void) => (data: Partial) => setState( cleanUpUndefined({ ...state, ...data, }) );