2021-04-28 07:41:20 -04:00
|
|
|
import PropTypes from 'prop-types'
|
2021-05-21 07:32:51 -04:00
|
|
|
import { useEditorContext } from '../../../shared/context/editor-context'
|
2021-04-28 07:41:20 -04:00
|
|
|
|
2021-06-10 07:26:04 -04:00
|
|
|
export default function FileViewImage({ fileName, fileId, onLoad, onError }) {
|
2021-05-21 07:32:51 -04:00
|
|
|
const { projectId } = useEditorContext({
|
|
|
|
projectId: PropTypes.string.isRequired,
|
|
|
|
})
|
|
|
|
|
2021-04-28 07:41:20 -04:00
|
|
|
return (
|
|
|
|
<img
|
2021-05-21 07:32:51 -04:00
|
|
|
src={`/project/${projectId}/file/${fileId}`}
|
2021-04-28 07:41:20 -04:00
|
|
|
onLoad={onLoad}
|
|
|
|
onError={onError}
|
|
|
|
onAbort={onError}
|
|
|
|
alt={fileName}
|
|
|
|
/>
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
2021-06-10 07:26:04 -04:00
|
|
|
FileViewImage.propTypes = {
|
2021-04-28 07:41:20 -04:00
|
|
|
fileName: PropTypes.string.isRequired,
|
|
|
|
fileId: PropTypes.string.isRequired,
|
|
|
|
onLoad: PropTypes.func.isRequired,
|
|
|
|
onError: PropTypes.func.isRequired,
|
|
|
|
}
|