import { type Theme } from '@mui/material/styles';

import { type EnpsChartDataItem } from './types';

export const generateNullAnnotations = (
  data: EnpsChartDataItem[],
  theme: Theme,
  message: string,
) => {
  return data.reduce(
    (acc, item, index) => {
      if (item.value === null) {
        acc[`null-label-${index}`] = {
          type: 'label',
          xValue: index,
          yValue: 0,
          backgroundColor: theme.palette.new.background.elements.grey,
          borderColor: theme.palette.new.border.neutral.default,
          borderWidth: 1,
          borderRadius: 4,
          content: [message],
          color: theme.palette.new.text.neutral.default,
          font: { size: 12 },
          padding: 8,
        };
      }
      return acc;
    },
    {} as Record<string, any>,
  );
};
