import { type Theme } from '@mui/material';
import { IconMoodEmpty, IconMoodSad, IconMoodSmile } from '@tabler/icons-react';

import { FilterOption } from './types';

export type FilterColors = {
  backgroundColor: string;
  textColor: string;
  icon: React.ReactNode;
};

export const getFilterColors = (
  filter: FilterOption,
  theme: Theme,
): FilterColors | null => {
  if (filter === FilterOption.ALL) {
    return null;
  }

  const colorMap: Record<FilterOption, FilterColors> = {
    [FilterOption.ALL]: {
      backgroundColor: '',
      textColor: '',
      icon: null,
    },
    [FilterOption.PROMOTERS]: {
      backgroundColor: theme.palette.new.background.feedback.success,
      textColor: theme.palette.new.text.feedback.success,
      icon: <IconMoodSmile size={20} />,
    },
    [FilterOption.DETRACTORS]: {
      backgroundColor: theme.palette.new.background.feedback.error,
      textColor: theme.palette.new.text.feedback.error,
      icon: <IconMoodSad size={20} />,
    },
    [FilterOption.NEUTRALS]: {
      backgroundColor: theme.palette.new.background.feedback.warning,
      textColor: theme.palette.new.text.feedback.warning,
      icon: <IconMoodEmpty size={20} />,
    },
  };

  return colorMap[filter];
};
