updated delete automation endpoint

This commit is contained in:
hannathkadher
2025-03-14 12:12:15 +04:00
parent 2a065efc0e
commit bc64efa557
3 changed files with 6 additions and 4 deletions

View File

@ -798,6 +798,8 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
FutureOr<void> _deleteScene(DeleteScene event, Emitter<RoutineState> emit) async { FutureOr<void> _deleteScene(DeleteScene event, Emitter<RoutineState> emit) async {
try { try {
final projectId = await ProjectManager.getProjectUUID() ?? '';
emit(state.copyWith(isLoading: true)); emit(state.copyWith(isLoading: true));
BuildContext context = NavigationService.navigatorKey.currentContext!; BuildContext context = NavigationService.navigatorKey.currentContext!;
var spaceBloc = context.read<SpaceTreeBloc>(); var spaceBloc = context.read<SpaceTreeBloc>();
@ -806,7 +808,7 @@ class RoutineBloc extends Bloc<RoutineEvent, RoutineState> {
unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? ''); unitUuid: spaceBloc.state.selectedSpaces[0], sceneId: state.sceneId ?? '');
} else { } else {
await SceneApi.deleteAutomation( await SceneApi.deleteAutomation(
unitUuid: spaceBloc.state.selectedSpaces[0], automationId: state.automationId ?? ''); unitUuid: spaceBloc.state.selectedSpaces[0], automationId: state.automationId ?? '',projectId: projectId);
} }
add(const LoadScenes()); add(const LoadScenes());

View File

@ -213,12 +213,12 @@ class SceneApi {
// delete automation // delete automation
static Future<bool> deleteAutomation( static Future<bool> deleteAutomation(
{required String unitUuid, required String automationId}) async { {required String unitUuid, required String automationId, required String projectId}) async {
try { try {
final response = await _httpService.delete( final response = await _httpService.delete(
path: ApiEndpoints.deleteAutomation path: ApiEndpoints.deleteAutomation
.replaceAll('{automationId}', automationId) .replaceAll('{automationId}', automationId)
.replaceAll('{unitUuid}', unitUuid), .replaceAll('{projectId}', projectId),
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) => json['statusCode'] == 200, expectedResponseModel: (json) => json['statusCode'] == 200,
); );

View File

@ -79,7 +79,7 @@ abstract class ApiEndpoints {
static const String getScene = '/scene/tap-to-run/{sceneId}'; static const String getScene = '/scene/tap-to-run/{sceneId}';
static const String deleteScene = '/scene/tap-to-run/{sceneId}'; static const String deleteScene = '/scene/tap-to-run/{sceneId}';
static const String deleteAutomation = '/automation/{automationId}'; static const String deleteAutomation = '/projects/{projectId}/automations/{automationId}';
static const String updateScene = '/scene/tap-to-run/{sceneId}'; static const String updateScene = '/scene/tap-to-run/{sceneId}';
static const String updateAutomation = '/automation/{automationId}'; static const String updateAutomation = '/automation/{automationId}';