import Constants from 'expo-constants';
import { MessageType, showMessage } from 'react-native-flash-message';

import { UNAUTHORIZED_ERROR } from '../../constants/custom';

export const showFeedback = ({
  title,
  description,
  type,
  err = '',
}: {
  title: string;
  description?: string;
  type: MessageType;
  err?: unknown;
}) => {
  const msg = err === UNAUTHORIZED_ERROR ? `${UNAUTHORIZED_ERROR}.` : title;
  showMessage({
    message: msg,
    description,
    type,
    icon: 'auto',
    statusBarHeight: Constants.statusBarHeight,
  });
};
