diff --git a/lib/pages/spaces_management/view/spaces_management_page.dart b/lib/pages/spaces_management/view/spaces_management_page.dart index 54027066..0496c179 100644 --- a/lib/pages/spaces_management/view/spaces_management_page.dart +++ b/lib/pages/spaces_management/view/spaces_management_page.dart @@ -36,32 +36,22 @@ class SpaceManagementPageState extends State { @override Widget build(BuildContext context) { return BlocProvider( - create: (context) => - SpaceManagementBloc(_api, _productApi)..add(LoadCommunityAndSpacesEvent()), + create: (context) => SpaceManagementBloc(_api, _productApi) + ..add(LoadCommunityAndSpacesEvent()), child: WebScaffold( - appBarTitle: Text('Space Management', style: Theme.of(context).textTheme.headlineLarge), + appBarTitle: Text('Space Management', + style: Theme.of(context).textTheme.headlineLarge), enableMenuSidebar: false, rightBody: const NavigateHomeGridView(), - scaffoldBody: - BlocBuilder(builder: (context, state) { + scaffoldBody: BlocBuilder( + builder: (context, state) { if (state is SpaceManagementLoading) { return const Center(child: CircularProgressIndicator()); } else if (state is SpaceManagementLoaded) { - int selectedIndex = state.communities.indexWhere( - (community) => community.uuid == selectedCommunity?.uuid, - ); - if (selectedIndex != -1) { - selectedCommunity = state.communities[selectedIndex]; - } else if (state.selectedCommunity != null) { - selectedCommunity = state.selectedCommunity; - } else { - selectedCommunity = null; - selectedSpace = null; - } return LoadedSpaceView( communities: state.communities, - selectedCommunity: selectedCommunity, - selectedSpace: selectedSpace, + selectedCommunity: state.selectedCommunity, + selectedSpace: state.selectedSpace, products: state.products, onCommunitySelected: (community) { setState(() {