import { Fragment } from 'inferno';
import { useBackend } from '../backend';
import { toFixed } from 'common/math';
import { RADIO_CHANNELS } from '../constants';
import { Button, LabeledList, NumberInput, NoticeBox, Section, Input } from '../components';
export const TeleInteract = props => {
const { act, data } = useBackend(props);
const {
notice = "",
multitool = false,
multitool_buf = null,
machine = null,
links = [],
freq_listening = [],
} = data;
const {
power = false,
id = "NULL",
network,
prefab = false,
hidden = false,
isrelay = false,
isbus = false,
} = machine;
return (
{!!notice && (
{notice}
)}
{power ? (
act('machine', {
'id': value,
})} />
act('machine', {
'network': value,
})} />
{prefab ? 'TRUE' : 'FALSE'}
{isrelay ? (
) : (
''
)}
{isbus ? (
) : (
''
)}
{hidden ? (
{'ACTIVE'}
) : (
''
)}
{multitool ? (
) : (
act('multitool', {
'Add': true,
})}
/>
)}>
{multitool_buf ? (
`${multitool_buf.name} (${multitool_buf.id})`
) : (
''
)}
) : (
''
)}
) : (
''
)}
{power ? (
{links.map(entity => {
return (
act('unlink', {
'value': entity.ref,
})}
/>
)}>
{`${entity.name} (${entity.id})`}
);
})}
act('freq', {
'add': true,
})}
/>
{(freq_listening && freq_listening.length) ? (
freq_listening.map(thing => {
const valid = RADIO_CHANNELS
.find(channel => channel.freq === thing);
return (
{`${thing} (${valid.name})`}
) : (
thing
)}
onClick={() => act('freq', {
'remove': thing,
})}
/>
);
})
) : (
''
)}
) : (
''
)}
);
};