OSD-Frontend/src/Core.js

34 lines
721 B
JavaScript
Raw Normal View History

2020-12-20 20:19:50 +01:00
import React from "react";
import { useSelector, useDispatch } from "react-redux";
import { setPlugin, selectCore } from "./coreSlice";
import * as plugins from "./plugins";
function Core() {
const coreState = useSelector(selectCore);
const dispatch = useDispatch();
const plugin = plugins.default[coreState.plugin];
const props = {
data: coreState.data,
close: () => dispatch(setPlugin(false))
};
return <>
{plugin ? null :
<>
<p>Welcome to Honda!</p>
{Object.keys(plugins.default).map(
i => <p
onClick={() => dispatch(setPlugin(i))}
key={i}
>
{plugins.default[i].pluginName}
</p>)
}
</>
}
{plugin ? plugin(props) :null}
2020-12-20 20:19:50 +01:00
</>;
}
export default Core;