import { Fragment } from 'inferno'; import { useBackend, useSharedState } from '../backend'; import { Button, LabeledList, Section, Tabs, NoticeBox, Table, Input } from '../components'; import { Window } from '../layouts'; export const LawManager = (props, context) => { const { act, data } = useBackend(context); const { isSlaved } = data; return ( {(isSlaved && Law-synced to {isSlaved}) || null} ); }; const LawManagerContent = (props, context) => { const [tabIndex, setTabIndex] = useSharedState(context, 'lawsTabIndex', 0); return ( setTabIndex(0)}> Law Management setTabIndex(1)}> Law Sets {(tabIndex === 0 && ) || null} {(tabIndex === 1 && ) || null} ); }; const LawManagerLaws = (props, context) => { const { act, data } = useBackend(context); const { ion_law_nr, ion_law, zeroth_law, inherent_law, supplied_law, supplied_law_position, zeroth_laws, has_zeroth_laws, ion_laws, has_ion_laws, inherent_laws, has_inherent_laws, supplied_laws, has_supplied_laws, isAI, isMalf, isAdmin, channel, channels, } = data; let allLaws = zeroth_laws .map((law) => { law.zero = true; return law; }) .concat(inherent_laws); return (
{(has_ion_laws && ) || null} {((has_zeroth_laws || has_inherent_laws) && ) || null} {(has_supplied_laws && ) || null}
{channels.map((chan) => ( {(isAI && ( )) || null}
{(isMalf && (
Type Law Index Add {(isAdmin && !has_zeroth_laws && ( Zero act('change_zeroth_law', { val: val })} /> N/A )) || null} Ion act('change_ion_law', { val: val })} /> N/A Inherent act('change_inherent_law', { val: val })} /> N/A Supplied act('change_supplied_law', { val: val })} />
)) || null}
); }; const LawsTable = (props, context) => { const { act, data } = useBackend(context); const { isMalf, isAdmin } = data; const { laws, title, noButtons, ...rest } = props; return (
Index Law {(!noButtons && State) || null} {(isMalf && !noButtons && ( Edit Delete )) || null} {laws.map((law) => ( {law.index}. {law.law} {(!noButtons && ( )) || null} {(isMalf && !noButtons && ( )) || null} ))}
); }; const LawManagerLawSets = (props, context) => { const { act, data } = useBackend(context); const { isMalf, law_sets } = data; return ( Remember: Stating laws other than those currently loaded may be grounds for decommissioning! - NanoTrasen {(law_sets.length && law_sets.map((laws) => (
}> {(laws.laws.has_ion_laws && ( )) || null} {((laws.laws.has_zeroth_laws || laws.laws.has_inherent_laws) && ( )) || null} {(laws.laws.has_supplied_laws && ( )) || null}
))) || null}
); };