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 = () => { if (sc.activeSketch) { sc.extrude(sc.activeSketch, ref.current.value) setDialog(null) } else if (sc.selected.length === 1 && sc.selected[0].userData.type == 'sketch') { sc.extrude(treeEntriesById[sc.selected[0].name], ref.current.value) setDialog(null) } else { console.log('invalid selection') } } const [_, forceUpdate] = useReducer(x => x + 1, 0); return