import { useRef, useState, useMemo } from 'react' import { useLocation } from 'react-router-dom' import { Space, Flex, Card, Spin } from 'antd' import { LoadingOutlined } from '@ant-design/icons' import loglevel from 'loglevel' import config from '../../../../config.js' import useCollapseState from '../../hooks/useCollapseState.jsx' import NotesPanel from '../../common/NotesPanel.jsx' import InfoCollapse from '../../common/InfoCollapse.jsx' import ViewButton from '../../common/ViewButton.jsx' import NoteIcon from '../../../Icons/NoteIcon.jsx' import EyeIcon from '../../../Icons/EyeIcon.jsx' import ObjectForm from '../../common/ObjectForm.jsx' import ActivityIndicator from '../../common/ActivityIndicator.jsx' import ObjectActions from '../../common/ObjectActions.jsx' import ObjectTableNavigationButtons from '../../common/ObjectTableNavigationButtons.jsx' import { useDashboardObjectTools } from '../../context/DashboardObjectToolsContext' import ScrollBox from '../../common/ScrollBox.jsx' import FilePreview from '../../common/FilePreview.jsx' import MissingPlaceholder from '../../common/MissingPlaceholder.jsx' import InfoCollapsePlaceholder from '../../common/InfoCollapsePlaceholder.jsx' import DocumentPrintButton from '../../common/DocumentPrintButton.jsx' import UserNotifierToggle from '../../common/UserNotifierToggle.jsx' const log = loglevel.getLogger('GCodeFilePreview') log.setLevel(config.logLevel) const GCodeFilePreview = () => { const location = useLocation() const objectFormRef = useRef(null) const gcodeFileId = new URLSearchParams(location.search).get('gcodeFileId') const [collapseState, updateCollapseState] = useCollapseState( 'GCodeFilePreview', { preview: true, notes: true } ) const [objectFormState, setEditFormState] = useState({ loading: false, objectData: {}, lock: null }) const currentObjectTools = useMemo( () => ( ), [objectFormState.loading, gcodeFileId] ) useDashboardObjectTools(currentObjectTools) return ( { setEditFormState((prev) => ({ ...prev, ...state })) }} > {({ loading, objectData }) => ( } active={collapseState.preview} onToggle={(expanded) => updateCollapseState('preview', expanded) } collapseKey='preview' > {loading ? ( ) : objectData?.file?._id ? ( ) : ( )} )} } active={collapseState.notes} onToggle={(expanded) => updateCollapseState('notes', expanded)} collapseKey='notes' > } > ) } export default GCodeFilePreview