import type { AppState, StateRepository } from '@domain/ports/StateRepository'; export interface UpdateSettingsCommand { type: 'update-settings'; alarmSound?: string; notifsEnabled?: boolean; ntfyTopic?: string; inventaire?: Record; } export function createUpdateSettingsHandler(state: AppState, repo: StateRepository) { return (cmd: UpdateSettingsCommand): void => { if (cmd.alarmSound !== undefined) state.alarmSound = cmd.alarmSound; if (cmd.notifsEnabled !== undefined) state.notifsEnabled = cmd.notifsEnabled; if (cmd.ntfyTopic !== undefined) state.ntfyTopic = cmd.ntfyTopic; if (cmd.inventaire !== undefined) state.inventaire = cmd.inventaire; repo.save(state); }; }