// @ts-nocheck -- deprecated component, will be removed in upcoming cleanup
import Chip, { ChipProps } from '@material-hu/mui/Chip';
import * as colors from '@material-hu/mui/colors';
import { type Theme } from '@material-hu/mui/styles';

import { ManagerSurveyStatus, CollaboratorSurveyStatus } from '../types';
import { useLokaliseTranslation } from 'src/utils/i18n';

type Status = CollaboratorSurveyStatus | ManagerSurveyStatus;

const getCustomStyle = (theme: Theme, status: Status) => {
  switch (status) {
    case CollaboratorSurveyStatus.PENDING:
      return {
        backgroundColor: theme.palette.new.graphics.teal[50],
        color: theme.palette.new.graphics.teal[700],
      };
    case CollaboratorSurveyStatus.FINISHED:
      return {
        backgroundColor: colors.deepPurple[50],
        color: colors.deepPurple[500],
      };
    default:
      return {};
  }
};

const getTransKey = (status: Status) => {
  switch (status) {
    case CollaboratorSurveyStatus.UNCOMPLETED:
      return 'finished';
    case CollaboratorSurveyStatus.FINISHED:
      return 'completed';
    case ManagerSurveyStatus.ACTIVE:
      return 'survey.active_one';
    case ManagerSurveyStatus.IMPORTED:
      return 'imported_survey';
    default:
      return status;
  }
};

type StatusChipProps = Omit<ChipProps, 'label'> & {
  status: CollaboratorSurveyStatus | ManagerSurveyStatus;
  label?: string;
};

const StatusChip = ({ status, sx, label, ...props }: StatusChipProps) => {
  const { t } = useLokaliseTranslation('people_experience');

  return (
    <Chip
      {...props}
      sx={theme => ({
        color: theme.palette.new.text.neutral.lighter,
        fontWeight: theme.typography.fontWeightMedium,
        textTransform: 'uppercase',
        ...getCustomStyle(theme, status),
        ...sx,
      })}
      label={label ?? t(getTransKey(status))}
      variant={
        status === CollaboratorSurveyStatus.IN_PROGRESS ? 'outlined' : 'filled'
      }
    />
  );
};

export default StatusChip;
