Compare commits

..

3 Commits

Author SHA1 Message Date
dd5fe10a21 removed print 2024-12-09 10:03:40 +04:00
4055265b0a for create 2024-12-09 10:02:57 +04:00
aff7ceeac4 added condition to check parent name 2024-12-09 10:02:20 +04:00
6 changed files with 34 additions and 54 deletions

View File

@ -309,8 +309,6 @@ class SpaceManagementBloc
await _api.deleteSpace(communityUuid, parent.uuid!);
}
} catch (e) {
print(
'Error deleting space ${parent.name} (UUID: ${parent.uuid}, Community UUID: $communityUuid): $e');
rethrow; // Decide whether to stop execution or continue
}
}
@ -342,7 +340,6 @@ class SpaceManagementBloc
space.uuid = response?.uuid;
}
} catch (e) {
print('Error creating space ${space.name}: $e');
rethrow; // Stop further execution on failure
}
}

View File

@ -133,13 +133,7 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
isNameFieldInvalid = value.isEmpty;
if (!isNameFieldInvalid) {
if ((widget.parentSpace?.children.any(
(child) => child.name == value) ??
false) ||
(widget.parentSpace?.name == value) ||
(widget.editSpace?.children.any(
(child) => child.name == value) ??
false)) {
if (_isNameConflict(value)) {
isNameFieldExist = true;
isOkButtonEnabled = false;
} else {
@ -387,7 +381,14 @@ class CreateSpaceDialogState extends State<CreateSpaceDialog> {
);
}
bool _isNameConflict(String value) {
return (widget.parentSpace?.children.any((child) => child.name == value) ??
false) ||
(widget.parentSpace?.name == value) ||
(widget.editSpace?.parent?.name == value) ||
(widget.editSpace?.children.any((child) => child.name == value) ??
false);
}
String _mapIconToProduct(String uuid, List<ProductModel> products) {
// Find the product with the matching UUID

View File

@ -6,7 +6,6 @@ import 'package:syncrow_web/pages/routiens/models/routine_details_model.dart';
import 'package:syncrow_web/pages/routiens/models/routine_model.dart';
import 'package:syncrow_web/services/api/http_service.dart';
import 'package:syncrow_web/utils/constants/api_const.dart';
import 'package:syncrow_web/utils/constants/temp_const.dart';
class SceneApi {
static final HTTPService _httpService = HTTPService();
@ -77,8 +76,7 @@ class SceneApi {
final response = await _httpService.get(
path: ApiEndpoints.getUnitScenes
.replaceAll('{spaceUuid}', unitId)
.replaceAll('{communityUuid}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{communityUuid}', communityId),
queryParameters: {'showInHomePage': showInDevice},
showServerMessage: false,
expectedResponseModel: (json) {

View File

@ -5,7 +5,6 @@ import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart';
import 'package:syncrow_web/services/api/http_service.dart';
import 'package:syncrow_web/utils/constants/api_const.dart';
import 'package:syncrow_web/utils/constants/temp_const.dart';
class CommunitySpaceManagementApi {
// Community Management APIs
@ -16,8 +15,7 @@ class CommunitySpaceManagementApi {
while (hasNext) {
await HTTPService().get(
path: ApiEndpoints.getCommunityList
.replaceAll('{projectId}', TempConst.projectId),
path: ApiEndpoints.getCommunityList,
queryParameters: {'page': page},
expectedResponseModel: (json) {
List<dynamic> jsonData = json['data'];
@ -61,8 +59,7 @@ class CommunitySpaceManagementApi {
String name, String description) async {
try {
final response = await HTTPService().post(
path: ApiEndpoints.createCommunity
.replaceAll('{projectId}', TempConst.projectId),
path: ApiEndpoints.createCommunity,
body: {
'name': name,
'description': description,
@ -82,8 +79,7 @@ class CommunitySpaceManagementApi {
try {
final response = await HTTPService().put(
path: ApiEndpoints.updateCommunity
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{communityId}', communityId),
body: {
'name': name,
},
@ -102,8 +98,7 @@ class CommunitySpaceManagementApi {
try {
final response = await HTTPService().delete(
path: ApiEndpoints.deleteCommunity
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{communityId}', communityId),
expectedResponseModel: (json) {
return json['success'] ?? false;
},
@ -118,9 +113,7 @@ class CommunitySpaceManagementApi {
Future<SpacesResponse> fetchSpaces(String communityId) async {
try {
final response = await HTTPService().get(
path: ApiEndpoints.listSpaces
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
path: ApiEndpoints.listSpaces.replaceAll('{communityId}', communityId),
expectedResponseModel: (json) {
return SpacesResponse.fromJson(json);
},
@ -146,8 +139,7 @@ class CommunitySpaceManagementApi {
final response = await HTTPService().get(
path: ApiEndpoints.getSpace
.replaceAll('{communityId}', communityId)
.replaceAll('{spaceId}', spaceId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{spaceId}', spaceId),
expectedResponseModel: (json) {
return SpaceModel.fromJson(json);
},
@ -183,9 +175,7 @@ class CommunitySpaceManagementApi {
body['parentUuid'] = parentId;
}
final response = await HTTPService().post(
path: ApiEndpoints.createSpace
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
path: ApiEndpoints.createSpace.replaceAll('{communityId}', communityId),
body: body,
expectedResponseModel: (json) {
return SpaceModel.fromJson(json['data']);
@ -226,8 +216,7 @@ class CommunitySpaceManagementApi {
final response = await HTTPService().put(
path: ApiEndpoints.updateSpace
.replaceAll('{communityId}', communityId)
.replaceAll('{spaceId}', spaceId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{spaceId}', spaceId),
body: body,
expectedResponseModel: (json) {
return SpaceModel.fromJson(json['data']);
@ -245,8 +234,7 @@ class CommunitySpaceManagementApi {
final response = await HTTPService().delete(
path: ApiEndpoints.deleteSpace
.replaceAll('{communityId}', communityId)
.replaceAll('{spaceId}', spaceId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{spaceId}', spaceId),
expectedResponseModel: (json) {
return json['success'] ?? false;
},
@ -262,8 +250,7 @@ class CommunitySpaceManagementApi {
try {
final response = await HTTPService().get(
path: ApiEndpoints.getSpaceHierarchy
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
.replaceAll('{communityId}', communityId),
expectedResponseModel: (json) {
final spaceModels = (json['data'] as List)
.map((spaceJson) => SpaceModel.fromJson(spaceJson))

View File

@ -36,21 +36,21 @@ abstract class ApiEndpoints {
static const String getDeviceLogs = '/device/report-logs/{uuid}?code={code}';
// Space Module
static const String createSpace = '/projects/{projectId}/communities/{communityId}/spaces';
static const String listSpaces = '/projects/{projectId}/communities/{communityId}/spaces';
static const String deleteSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}';
static const String updateSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}';
static const String getSpace = '/projects/{projectId}/communities/{communityId}/spaces/{spaceId}';
static const String getSpaceHierarchy = '/projects/{projectId}/communities/{communityId}/spaces';
static const String createSpace = '/communities/{communityId}/spaces';
static const String listSpaces = '/communities/{communityId}/spaces';
static const String deleteSpace = '/communities/{communityId}/spaces/{spaceId}';
static const String updateSpace = '/communities/{communityId}/spaces/{spaceId}';
static const String getSpace = '/communities/{communityId}/spaces/{spaceId}';
static const String getSpaceHierarchy = '/communities/{communityId}/spaces';
// Community Module
static const String createCommunity = '/projects/{projectId}/communities';
static const String getCommunityList = '/projects/{projectId}/communities';
static const String getCommunityById = '/projects/{projectId}/communities/{communityId}';
static const String updateCommunity = '/projects/{projectId}/communities/{communityId}';
static const String deleteCommunity = '/projects/{projectId}communities/{communityId}';
static const String getUserCommunities = '/projects/{projectId}/communities/user/{userUuid}';
static const String createUserCommunity = '/projects/{projectId}/communities/user';
static const String createCommunity = '/communities';
static const String getCommunityList = '/communities';
static const String getCommunityById = '/communities/{communityId}';
static const String updateCommunity = '/communities/{communityId}';
static const String deleteCommunity = '/communities/{communityId}';
static const String getUserCommunities = '/communities/user/{userUuid}';
static const String createUserCommunity = '/communities/user';
static const String getDeviceLogsByDate =
'/device/report-logs/{uuid}?code={code}&startTime={startTime}&endTime={endTime}';
@ -68,7 +68,7 @@ abstract class ApiEndpoints {
static const String getIconScene = '/scene/icon';
static const String createScene = '/scene/tap-to-run';
static const String createAutomation = '/automation';
static const String getUnitScenes = '/projects/{projectId}/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
static const String getUnitScenes = '/communities/{communityUuid}/spaces/{spaceUuid}/scenes';
static const String getAutomationDetails = '/automation/details/{automationId}';
static const String getScene = '/scene/tap-to-run/{sceneId}';
static const String deleteScene = '/scene/tap-to-run/{sceneId}';

View File

@ -1,3 +0,0 @@
class TempConst {
static const projectId = '0e62577c-06fa-41b9-8a92-99a21fbaf51c';
}