import React from 'react'; import './App.scss'; import Sidebar from './Components/Sidebar/Sidebar'; import { IAvailableContainerModel } from './Interfaces/IAvailableContainerModel'; import { IConfigurationResponseModel } from './Interfaces/IConfigurationResponseModel'; interface IAppProps { } interface IAppState { componentOptions: IAvailableContainerModel[] isSidebarOpen: boolean } class App extends React.Component { public state: IAppState; constructor(props: IAppProps) { super(props); this.state = { isSidebarOpen: true, componentOptions: [] }; } componentDidMount() { fetchConfiguration().then((configuration: IConfigurationResponseModel) => { this.setState({ isSidebarOpen: this.state.isSidebarOpen, componentOptions: configuration.AvailableContainers }); }); } public ToggleMenu() { this.setState({ isSidebarOpen: !this.state.isSidebarOpen, componentOptions: this.state.componentOptions }); } render() { return (
this.ToggleMenu()} />
); } } async function fetchConfiguration(): Promise { const url = `${import.meta.env.VITE_API_URL}`; const myHeaders = new Headers({ 'Content-Type': 'application/json' }); const myInit = { method: 'POST', headers: myHeaders }; return await fetch(url, myInit) .then((response) => response.json() ) as IConfigurationResponseModel; } export default App;