diff --git a/apps/client/src/common/models/OntimeSettings.ts b/apps/client/src/common/models/OntimeSettings.ts index 26470c7b0..a12319f64 100644 --- a/apps/client/src/common/models/OntimeSettings.ts +++ b/apps/client/src/common/models/OntimeSettings.ts @@ -6,4 +6,5 @@ export const ontimePlaceholderSettings: Settings = { operatorKey: null, timeFormat: '24', language: 'en', + auxTimerNames: ['', '', ''], }; diff --git a/apps/client/src/common/utils/auxTimerUtils.ts b/apps/client/src/common/utils/auxTimerUtils.ts new file mode 100644 index 000000000..2a2485707 --- /dev/null +++ b/apps/client/src/common/utils/auxTimerUtils.ts @@ -0,0 +1,11 @@ +/** + * Resolves the display label for an aux timer. + * Falls back to the provided default when no custom name is set. + * @param names - the auxTimerNames array from settings (indexed 0-based) + * @param index - 1-based aux timer index (1, 2, 3) + * @param fallback - label to use when no custom name is set + */ +export function getAuxTimerLabel(names: string[] | undefined, index: number, fallback: string): string { + const custom = names?.[index - 1]?.trim(); + return custom ? custom : fallback; +} diff --git a/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx b/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx index 11f6413b4..24e982d01 100644 --- a/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx +++ b/apps/client/src/features/app-settings/panel/automations-panel/OntimeActionForm.tsx @@ -4,6 +4,8 @@ import { UseFormRegister, UseFormSetValue, UseFormWatch } from 'react-hook-form' import Input from '../../../../common/components/input/input/Input'; import Select from '../../../../common/components/select/Select'; +import useSettings from '../../../../common/hooks-query/useSettings'; +import { getAuxTimerLabel } from '../../../../common/utils/auxTimerUtils'; import * as Panel from '../../panel-utils/PanelUtils'; import TemplateInput from './template-input/TemplateInput'; @@ -34,12 +36,15 @@ export default function OntimeActionForm({ watch, }: PropsWithChildren) { const [selectedAction, setSelectedAction] = useState(value); + const { data: settings } = useSettings(); const handleSetAction = (value: OntimeActionKey) => { setValue(`outputs.${index}.action`, value, { shouldDirty: true }); setSelectedAction(value); }; + const auxLabel = (auxIndex: number) => getAuxTimerLabel(settings.auxTimerNames, auxIndex, `Aux ${auxIndex}`); + return (