start
This commit is contained in:
27
src/components/shared/toast.js
Normal file
27
src/components/shared/toast.js
Normal file
@@ -0,0 +1,27 @@
|
||||
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;
|
||||
Reference in New Issue
Block a user