import { type Theme } from '@mui/material/styles';
import { alpha } from '@material-hu/mui/styles';
import { type NewPalette } from '@material-hu/theme/hugo/newTokens';

import { ReviewCycleStatus } from 'src/pages/dashboard/performance/types';

export type StatusColors = { background: string; label: string };

export const getReviewStatusColors = (
  theme: Theme,
  status: ReviewCycleStatus,
): StatusColors => {
  const newPalette = (theme.palette as Theme['palette'] & { new: NewPalette })
    .new;
  const defaultColors: StatusColors = {
    background: alpha(newPalette?.text.neutral.default ?? '#303036', 0.08),
    label: newPalette?.text.neutral.disabled ?? theme.palette.text.secondary,
  };

  if (!newPalette) {
    return defaultColors;
  }

  switch (status) {
    case ReviewCycleStatus.FINISHED:
      return {
        background: newPalette.background.feedback.success,
        label: newPalette.text.feedback.success,
      };
    case ReviewCycleStatus.IN_PROGRESS:
      return {
        background: newPalette.background.feedback.warning,
        label: newPalette.text.feedback.warning,
      };
    case ReviewCycleStatus.PENDING:
      return {
        background: newPalette.background.feedback.error,
        label: newPalette.text.feedback.error,
      };
    case ReviewCycleStatus.SELECTION:
      return {
        background: newPalette.background.feedback.info,
        label: newPalette.text.feedback.info,
      };
    default:
      return defaultColors;
  }
};
