import React from 'react'
import Path from '../path'
import Point from '../point'
import Snippet from '../snippet'
import { getProps } from '../utils'
import { round } from 'shared/utils'
import { Tr, KeyTd, ValTd, Attributes, pointCoords } from '../path/index'
class ErrorBoundary extends React.Component {
constructor(props) {
super(props);
this.state = { hasError: false };
}
static getDerivedStateFromError(error) {
console.log(error)
return { hasError: true }
}
componentDidCatch(error, errorInfo) {
console.log(error, errorInfo)
}
render() {
if (this.state.hasError) {
console.log('in error boundary', props)
return Something went wrong.
}
return this.props.children
}
}
const partInfo = (props) => {
return (
Part info
Name
{props.partName}
Width
{round(props.part.width,2)}mm
Height
{round(props.part.height,2)}mm
Top Left
{pointCoords(props.part.topLeft)}
Bottom Right
{pointCoords(props.part.bottomRight)}
Attributes
{props.gist?.only && props.gist.only.length > 0
? (
) : (
)}
)
}
const XrayPart = props => {
const { topLeft, bottomRight } = props.part
return (
{ evt.stopPropagation(); props.showInfo(partInfo(props)) }}
/>
)
}
const Part = props => {
const { partName, part, app, gist, updateGist } = props
const grid = gist.paperless ? (
) : null
return (
{grid}
{
props.gist?._state?.xray?.enabled &&
}
{Object.keys(part.paths).map((pathName) => (
))}
{Object.keys(props.part.points).map((pointName) => (
))}
{Object.keys(props.part.snippets).map((snippetName) => (
))}
{focus}
)
}
/*
*/
export default Part