diff --git a/lib/pages/device_managment/all_devices/models/factory_reset_model.dart b/lib/pages/device_managment/all_devices/models/factory_reset_model.dart index 56c6c90b..1b5685a1 100644 --- a/lib/pages/device_managment/all_devices/models/factory_reset_model.dart +++ b/lib/pages/device_managment/all_devices/models/factory_reset_model.dart @@ -19,6 +19,7 @@ class FactoryResetModel { Map toJson() { return { 'devicesUuid': devicesUuid, + 'operationType': operationType, }; } @@ -33,6 +34,7 @@ class FactoryResetModel { Map toMap() { return { 'devicesUuid': devicesUuid, + 'operationType': operationType, }; } @@ -56,3 +58,4 @@ class FactoryResetModel { @override int get hashCode => devicesUuid.hashCode; } + diff --git a/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart b/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart index 7337c9fd..bbebabaa 100644 --- a/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart +++ b/lib/pages/device_managment/main_door_sensor/view/main_door_sensor_batch_view.dart @@ -4,7 +4,6 @@ import 'package:syncrow_web/pages/device_managment/all_devices/models/factory_re 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'; -// import 'package:syncrow_web/pages/device_managment/shared/batch_control/firmware_update.dart'; class MainDoorSensorBatchView extends StatelessWidget { const MainDoorSensorBatchView({super.key, required this.devicesIds}); @@ -13,35 +12,31 @@ class MainDoorSensorBatchView extends StatelessWidget { @override Widget build(BuildContext context) { - return Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - // SizedBox( - // width: 170, - // height: 140, - // child: FirmwareUpdateWidget( - // deviceId: devicesIds.first, - // version: 12, - // ), - // ), - // const SizedBox( - // width: 12, - // ), - SizedBox( - width: 170, - height: 140, - child: FactoryResetWidget( - callFactoryReset: () { - BlocProvider.of(context).add( - MainDoorSensorFactoryReset( - deviceId: devicesIds.first, - factoryReset: FactoryResetModel(devicesUuid: devicesIds), + 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(innerContext).add( + MainDoorSensorFactoryReset( + deviceId: devicesIds.first, + factoryReset: FactoryResetModel(devicesUuid: devicesIds), + ), + ); + }, ), - ); - }, - ), - ), - ], + ), + ], + ); + }, + ), ); } } diff --git a/lib/services/devices_mang_api.dart b/lib/services/devices_mang_api.dart index 85e91759..b4de6326 100644 --- a/lib/services/devices_mang_api.dart +++ b/lib/services/devices_mang_api.dart @@ -321,13 +321,14 @@ class DevicesManagementApi { Future factoryReset(FactoryResetModel factoryReset, String uuid) async { try { final response = await HTTPService().post( - path: ApiEndpoints.factoryReset.replaceAll('{deviceUuid}', uuid), + path: ApiEndpoints.factoryReset, body: factoryReset.toMap(), showServerMessage: true, expectedResponseModel: (json) { return json['success'] ?? false; }, ); + return response; } catch (e) { debugPrint('Error fetching $e');