import { Admin, Resource } from 'react-admin';
import { authProvider } from './auth/authProvider';
import { dataProvider } from './dataProvider';
import { EmbeddedActiveEquipmentPage } from './pages/EmbeddedActiveEquipmentPage';
import { EquipmentCreate } from './resources/equipment/EquipmentCreate';
import { EquipmentEdit } from './resources/equipment/EquipmentEdit';
import { EquipmentList } from './resources/equipment/EquipmentList';
import { EquipmentShow } from './resources/equipment/EquipmentShow';
import { EquipmentStatusChangeCreate } from './resources/equipment-status-change/EquipmentStatusChangeCreate';
import { EquipmentStatusChangeEdit } from './resources/equipment-status-change/EquipmentStatusChangeEdit';
import { EquipmentStatusChangeList } from './resources/equipment-status-change/EquipmentStatusChangeList';
import { EquipmentStatusChangeShow } from './resources/equipment-status-change/EquipmentStatusChangeShow';

function App() {
  if (window.location.pathname === '/embedded/equipment-active') {
    return <EmbeddedActiveEquipmentPage />;
  }

  return (
    <Admin dataProvider={dataProvider} authProvider={authProvider}>
      <Resource
        name="equipment"
        list={EquipmentList}
        create={EquipmentCreate}
        edit={EquipmentEdit}
        show={EquipmentShow}
      />
      <Resource
        name="status-changes"
        list={EquipmentStatusChangeList}
        create={EquipmentStatusChangeCreate}
        edit={EquipmentStatusChangeEdit}
        show={EquipmentStatusChangeShow}
      />
    </Admin>
  );
}

export default App;
