import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/bloc/communities_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/communities/presentation/communities_tree_selection_bloc/communities_tree_selection_bloc.dart';
import 'package:syncrow_web/pages/space_management_v2/modules/create_community/presentation/create_community_dialog.dart';

abstract final class SpaceManagementCommunityDialogHelper {
  static void showCreateDialog(BuildContext context) {
    showDialog<void>(
      context: context,
      builder: (_) => CreateCommunityDialog(
        title: const SelectableText('Community Name'),
        onCreateCommunity: (community) {
          context.read<CommunitiesBloc>().add(
                InsertCommunity(community),
              );
          context.read<CommunitiesTreeSelectionBloc>().add(
                SelectCommunityEvent(community: community),
              );
        },
      ),
    );
  }
}
