Skip to content

The open alternative to Salesforce, designed for AI.

797 B
Raw Blame
import { type CHART_CONFIGURATION_SETTING_IDS } from '@/side-panel/pages/page-layout/types/ChartConfigurationSettingIds';
import { getConfigKeyFromSettingId } from '@/side-panel/pages/page-layout/utils/getConfigKeyFromSettingId';
import { useUpdateCurrentWidgetConfig } from './useUpdateCurrentWidgetConfig';

export const useUpdateChartSettingInput = (pageLayoutId: string) => {
  const { updateCurrentWidgetConfig } =
    useUpdateCurrentWidgetConfig(pageLayoutId);

  const updateChartSettingInput = (
    settingId: CHART_CONFIGURATION_SETTING_IDS,
    value: number | null,
  ) => {
    const configKey = getConfigKeyFromSettingId(settingId);

    updateCurrentWidgetConfig({
      configToUpdate: {
        [configKey]: value,
      },
    });
  };

  return { updateChartSettingInput };
};