import {useTheme} from '@shared/theme';

interface Params {
  isSuccess?: boolean;
  isError?: boolean;
  disabled?: boolean;
  focused?: boolean;
}

export const useInputColors = ({
  disabled,
  focused,
  isError,
  isSuccess,
}: Params) => {
  const {theme} = useTheme();

  const defaultColors = {
    labelColor: theme.text.neutral.default,
    helperColor: theme.text.neutral.lighter,
    inputBorder: theme.border.neutral.default,
    inputBackground: theme.background.layout.tertiary,
  };

  return focused
    ? {...defaultColors, inputBorder: theme.border.neutral.brand}
    : disabled
    ? {
        ...defaultColors,
        labelColor: theme.text.neutral.disabled,
        inputBackground: theme.action.background.brand.disabled,
      }
    : isSuccess
    ? {
        ...defaultColors,
        labelColor: theme.text.feedback.success,
        helperColor: theme.text.feedback.success,
        inputBorder: theme.graphics.success[500],
      }
    : isError
    ? {
        ...defaultColors,
        labelColor: theme.text.feedback.error,
        helperColor: theme.text.feedback.error,
        inputBorder: theme.graphics.error[500],
      }
    : defaultColors;
};
