import { useMutation, useLazyQuery } from '@apollo/react-hooks' import { makeStyles } from '@material-ui/core/styles' import gql from 'graphql-tag' // import moment from 'moment' import React, { memo, useState } from 'react' import { ConfirmDialog } from 'src/components/ConfirmDialog' import ActionButton from 'src/components/buttons/ActionButton' // // import { Status } from 'src/components/Status' import { ReactComponent as EditReversedIcon } from 'src/styling/icons/button/edit/white.svg' import { ReactComponent as EditIcon } from 'src/styling/icons/button/edit/zodiac.svg' import { ReactComponent as RebootReversedIcon } from 'src/styling/icons/button/reboot/white.svg' import { ReactComponent as RebootIcon } from 'src/styling/icons/button/reboot/zodiac.svg' import { ReactComponent as ShutdownReversedIcon } from 'src/styling/icons/button/shut down/white.svg' import { ReactComponent as ShutdownIcon } from 'src/styling/icons/button/shut down/zodiac.svg' import { ReactComponent as UnpairReversedIcon } from 'src/styling/icons/button/unpair/white.svg' import { ReactComponent as UnpairIcon } from 'src/styling/icons/button/unpair/zodiac.svg' import { machineActionsStyles } from './MachineActions.styles' const useStyles = makeStyles(machineActionsStyles) const MACHINE_ACTION = gql` mutation MachineAction( $deviceId: ID! $action: MachineAction! $newName: String ) { machineAction(deviceId: $deviceId, action: $action, newName: $newName) { deviceId } } ` const MACHINE = gql` query getMachine($deviceId: ID!) { machine(deviceId: $deviceId) { latestEvent { note } } } ` const isStaticState = machineState => { if (!machineState) { return true } const staticStates = [ 'chooseCoin', 'idle', 'pendingIdle', 'dualIdle', 'networkDown', 'unpaired', 'maintenance', 'virgin', 'wifiList' ] return staticStates.includes(machineState) } const getState = machineEventsLazy => JSON.parse(machineEventsLazy.machine.latestEvent?.note ?? '{"state": null}') .state const Label = ({ children }) => { const classes = useStyles() return