import { Fragment } from 'react';
import PropTypes from 'prop-types';

function Toast(props) {
  const { errorCode, errorText, errorData } = props;
  return (
    <Fragment>
      <div>خطا</div>
      <div dir='auto' className='text-start'>
        {errorCode ? `${errorCode}: ${errorText}` : errorText}
      </div>
      {errorData && (
        <div dir='auto' className='text-start'>
          {`error data: ${JSON.stringify(errorData, null, 2)}`}
        </div>
      )}
    </Fragment>
  );
}

Toast.propTypes = {
  errorCode: PropTypes.number.isRequired,
  errorText: PropTypes.string.isRequired,
  errorData: PropTypes.oneOfType([PropTypes.string, PropTypes.object, PropTypes.array]).isRequired
};

export default Toast;
