import React, { useEffect, useReducer, useRef, useState } from 'react'; import { useDispatch, useSelector } from 'react-redux' import { MdDone, MdClose } from 'react-icons/md' import { GiVerticalFlip } from 'react-icons/gi' import * as Icon from "./icons"; export const Dialog = ({ dialog, setDialog }) => { if (!dialog) return null const dispatch = useDispatch() const treeEntriesById = useSelector(state => state.treeEntries.byId) const activeSketchId = useSelector(state => state.treeEntries.activeSketchId) const ref = useRef() useEffect(() => { ref.current.focus() }, []) const extrude = () => { let sketch if (sc.activeSketch) { sketch = sc.activeSketch } else if (sc.selected.length === 1 && sc.selected[0].userData.type == 'sketch') { sketch = treeEntriesById[sc.selected[0].name] } else { console.log('invalid selection') return } setDialog(null) sc.extrude(sketch, ref.current.value) sc.render() forceUpdate() } const [_, forceUpdate] = useReducer(x => x + 1, 0); return