import 'package:flutter/material.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_reset_model.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_bloc.dart';
import 'package:syncrow_web/pages/device_managment/main_door_sensor/bloc/main_door_sensor_event.dart';
import 'package:syncrow_web/pages/device_managment/shared/batch_control/factory_reset.dart';

class MainDoorSensorBatchView extends StatelessWidget {
  const MainDoorSensorBatchView({super.key, required this.devicesIds});

  final List<String> devicesIds;

  @override
  Widget build(BuildContext context) {
    return BlocProvider(
      create: (context) => MainDoorSensorBloc(),
      child: Builder(
        builder: (innerContext) {
          return Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              SizedBox(
                width: 170,
                height: 140,
                child: FactoryResetWidget(
                  callFactoryReset: () {
                    BlocProvider.of<MainDoorSensorBloc>(innerContext).add(
                      MainDoorSensorFactoryReset(
                        deviceId: devicesIds.first,
                        factoryReset: FactoryResetModel(devicesUuid: devicesIds),
                      ),
                    );
                  },
                ),
              ),
            ],
          );
        },
      ),
    );
  }
}
