create subspace

This commit is contained in:
hannathkadher
2024-10-31 11:30:35 +04:00
parent 36e5df38ee
commit dcccc4db3a
8 changed files with 123 additions and 74 deletions

View File

@ -14,14 +14,14 @@ PODS:
- Firebase/Database (10.25.0): - Firebase/Database (10.25.0):
- Firebase/CoreOnly - Firebase/CoreOnly
- FirebaseDatabase (~> 10.25.0) - FirebaseDatabase (~> 10.25.0)
- firebase_analytics (10.8.7): - firebase_analytics (10.10.7):
- Firebase/Analytics (= 10.25.0) - Firebase/Analytics (= 10.25.0)
- firebase_core - firebase_core
- Flutter - Flutter
- firebase_core (2.32.0): - firebase_core (2.32.0):
- Firebase/CoreOnly (= 10.25.0) - Firebase/CoreOnly (= 10.25.0)
- Flutter - Flutter
- firebase_crashlytics (3.4.16): - firebase_crashlytics (3.5.7):
- Firebase/Crashlytics (= 10.25.0) - Firebase/Crashlytics (= 10.25.0)
- firebase_core - firebase_core
- Flutter - Flutter
@ -150,12 +150,12 @@ PODS:
- nanopb/encode (= 2.30910.0) - nanopb/encode (= 2.30910.0)
- nanopb/decode (2.30910.0) - nanopb/decode (2.30910.0)
- nanopb/encode (2.30910.0) - nanopb/encode (2.30910.0)
- onesignal_flutter (5.2.0): - onesignal_flutter (5.2.6):
- Flutter - Flutter
- OneSignalXCFramework (= 5.2.0) - OneSignalXCFramework (= 5.2.5)
- OneSignalXCFramework (5.2.0): - OneSignalXCFramework (5.2.5):
- OneSignalXCFramework/OneSignalComplete (= 5.2.0) - OneSignalXCFramework/OneSignalComplete (= 5.2.5)
- OneSignalXCFramework/OneSignal (5.2.0): - OneSignalXCFramework/OneSignal (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalExtension - OneSignalXCFramework/OneSignalExtension
- OneSignalXCFramework/OneSignalLiveActivities - OneSignalXCFramework/OneSignalLiveActivities
@ -163,38 +163,38 @@ PODS:
- OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOSCore
- OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalOutcomes
- OneSignalXCFramework/OneSignalUser - OneSignalXCFramework/OneSignalUser
- OneSignalXCFramework/OneSignalComplete (5.2.0): - OneSignalXCFramework/OneSignalComplete (5.2.5):
- OneSignalXCFramework/OneSignal - OneSignalXCFramework/OneSignal
- OneSignalXCFramework/OneSignalInAppMessages - OneSignalXCFramework/OneSignalInAppMessages
- OneSignalXCFramework/OneSignalLocation - OneSignalXCFramework/OneSignalLocation
- OneSignalXCFramework/OneSignalCore (5.2.0) - OneSignalXCFramework/OneSignalCore (5.2.5)
- OneSignalXCFramework/OneSignalExtension (5.2.0): - OneSignalXCFramework/OneSignalExtension (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalOutcomes
- OneSignalXCFramework/OneSignalInAppMessages (5.2.0): - OneSignalXCFramework/OneSignalInAppMessages (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalNotifications
- OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOSCore
- OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalOutcomes
- OneSignalXCFramework/OneSignalUser - OneSignalXCFramework/OneSignalUser
- OneSignalXCFramework/OneSignalLiveActivities (5.2.0): - OneSignalXCFramework/OneSignalLiveActivities (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOSCore
- OneSignalXCFramework/OneSignalUser - OneSignalXCFramework/OneSignalUser
- OneSignalXCFramework/OneSignalLocation (5.2.0): - OneSignalXCFramework/OneSignalLocation (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalNotifications
- OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOSCore
- OneSignalXCFramework/OneSignalUser - OneSignalXCFramework/OneSignalUser
- OneSignalXCFramework/OneSignalNotifications (5.2.0): - OneSignalXCFramework/OneSignalNotifications (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalExtension - OneSignalXCFramework/OneSignalExtension
- OneSignalXCFramework/OneSignalOutcomes - OneSignalXCFramework/OneSignalOutcomes
- OneSignalXCFramework/OneSignalOSCore (5.2.0): - OneSignalXCFramework/OneSignalOSCore (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalOutcomes (5.2.0): - OneSignalXCFramework/OneSignalOutcomes (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalUser (5.2.0): - OneSignalXCFramework/OneSignalUser (5.2.5):
- OneSignalXCFramework/OneSignalCore - OneSignalXCFramework/OneSignalCore
- OneSignalXCFramework/OneSignalNotifications - OneSignalXCFramework/OneSignalNotifications
- OneSignalXCFramework/OneSignalOSCore - OneSignalXCFramework/OneSignalOSCore
@ -212,7 +212,7 @@ PODS:
- shared_preferences_foundation (0.0.1): - shared_preferences_foundation (0.0.1):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- sqflite (0.0.3): - sqflite_darwin (0.0.4):
- Flutter - Flutter
- FlutterMacOS - FlutterMacOS
- url_launcher_ios (0.0.1): - url_launcher_ios (0.0.1):
@ -232,7 +232,7 @@ DEPENDENCIES:
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`) - permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
- share_plus (from `.symlinks/plugins/share_plus/ios`) - share_plus (from `.symlinks/plugins/share_plus/ios`)
- shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`) - shared_preferences_foundation (from `.symlinks/plugins/shared_preferences_foundation/darwin`)
- sqflite (from `.symlinks/plugins/sqflite/darwin`) - sqflite_darwin (from `.symlinks/plugins/sqflite_darwin/darwin`)
- url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`) - url_launcher_ios (from `.symlinks/plugins/url_launcher_ios/ios`)
SPEC REPOS: SPEC REPOS:
@ -285,17 +285,17 @@ EXTERNAL SOURCES:
:path: ".symlinks/plugins/share_plus/ios" :path: ".symlinks/plugins/share_plus/ios"
shared_preferences_foundation: shared_preferences_foundation:
:path: ".symlinks/plugins/shared_preferences_foundation/darwin" :path: ".symlinks/plugins/shared_preferences_foundation/darwin"
sqflite: sqflite_darwin:
:path: ".symlinks/plugins/sqflite/darwin" :path: ".symlinks/plugins/sqflite_darwin/darwin"
url_launcher_ios: url_launcher_ios:
:path: ".symlinks/plugins/url_launcher_ios/ios" :path: ".symlinks/plugins/url_launcher_ios/ios"
SPEC CHECKSUMS: SPEC CHECKSUMS:
device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d device_info_plus: 97af1d7e84681a90d0693e63169a5d50e0839a0d
Firebase: 0312a2352584f782ea56f66d91606891d4607f06 Firebase: 0312a2352584f782ea56f66d91606891d4607f06
firebase_analytics: 3a9263fedec72970e6bd30a7132bbdd386de2c14 firebase_analytics: cc06e24d6a2343c44f845b3112143db72d10ef78
firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197 firebase_core: a626d00494efa398e7c54f25f1454a64c8abf197
firebase_crashlytics: 0b7cb41f5fb3b6889d0fb408cfce3cc7a4247061 firebase_crashlytics: 17e856fabec68d993662abaf2f6fe2413f0abece
firebase_database: 2713033e426b176d4fe5e7195f3d19aa1b549a91 firebase_database: 2713033e426b176d4fe5e7195f3d19aa1b549a91
FirebaseAnalytics: ec00fe8b93b41dc6fe4a28784b8e51da0647a248 FirebaseAnalytics: ec00fe8b93b41dc6fe4a28784b8e51da0647a248
FirebaseAppCheckInterop: 6a1757cfd4067d8e00fccd14fcc1b8fd78cfac07 FirebaseAppCheckInterop: 6a1757cfd4067d8e00fccd14fcc1b8fd78cfac07
@ -309,23 +309,23 @@ SPEC CHECKSUMS:
FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc FirebaseSessions: dbd14adac65ce996228652c1fc3a3f576bdf3ecc
FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e FirebaseSharedSwift: 20530f495084b8d840f78a100d8c5ee613375f6e
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7 Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_secure_storage: 23fc622d89d073675f2eaa109381aefbcf5a49be flutter_secure_storage: d33dac7ae2ea08509be337e775f6b59f1ff45f12
GoogleAppMeasurement: 9abf64b682732fed36da827aa2a68f0221fd2356 GoogleAppMeasurement: 9abf64b682732fed36da827aa2a68f0221fd2356
GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a GoogleDataTransport: 6c09b596d841063d76d4288cc2d2f42cc36e1e2a
GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15 GoogleUtilities: ea963c370a38a8069cc5f7ba4ca849a60b6d7d15
image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1 image_picker_ios: c560581cceedb403a6ff17f2f816d7fea1421fc1
leveldb-library: e8eadf9008a61f9e1dde3978c086d2b6d9b9dc28 leveldb-library: e8eadf9008a61f9e1dde3978c086d2b6d9b9dc28
nanopb: 438bc412db1928dac798aa6fd75726007be04262 nanopb: 438bc412db1928dac798aa6fd75726007be04262
onesignal_flutter: 5ce68a29861960168e81101cb1bd685d264361de onesignal_flutter: f441aaefa112988a1e786c695a30695ad0291763
OneSignalXCFramework: bdf74fdc06888f9466dc21e826fe1549ed143095 OneSignalXCFramework: 76ca508fc2b941317729d13fdec96817f8ef5b3b
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c path_provider_foundation: 2b6b4c569c0fb62ec74538f866245ac84301af46
permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2 permission_handler_apple: 9878588469a2b0d0fc1e048d9f43605f92e6cec2
PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47 PromisesObjC: f5707f49cb48b9636751c5b2e7d227e43fba9f47
PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851 PromisesSwift: 9d77319bbe72ebf6d872900551f7eeba9bce2851
share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad share_plus: 8875f4f2500512ea181eef553c3e27dba5135aad
shared_preferences_foundation: b4c3b4cddf1c21f02770737f147a3f5da9d39695 shared_preferences_foundation: fcdcbc04712aee1108ac7fda236f363274528f78
sqflite: 673a0e54cc04b7d6dba8d24fb8095b31c3a99eec sqflite_darwin: a553b1fd6fe66f53bbb0fe5b4f5bab93f08d7a13
url_launcher_ios: bbd758c6e7f9fd7b5b1d4cde34d2b95fcce5e812 url_launcher_ios: 5334b05cef931de560670eeae103fd3e431ac3fe
PODFILE CHECKSUM: 4243bd7f9184f79552dd731a7c9d5cad03bd2706 PODFILE CHECKSUM: 4243bd7f9184f79552dd731a7c9d5cad03bd2706

View File

@ -61,7 +61,9 @@ class CreateUnitBloc extends Bloc<CreateUnitEvent, CreateUnitState> {
var storage = const FlutterSecureStorage(); var storage = const FlutterSecureStorage();
var userId = await storage.read(key: UserModel.userUuidKey) ?? ''; var userId = await storage.read(key: UserModel.userUuidKey) ?? '';
Map<String, String> communityBody = {'communityName': event.communityName}; Map<String, String> communityBody = {
'communityName': event.communityName
};
final response = await HomeCreation.createCommunity(communityBody); final response = await HomeCreation.createCommunity(communityBody);
if (response['data']['uuid'] != '') { if (response['data']['uuid'] != '') {
// final result = // final result =
@ -75,15 +77,22 @@ class CreateUnitBloc extends Bloc<CreateUnitEvent, CreateUnitState> {
if (buildingId.isNotEmpty) { if (buildingId.isNotEmpty) {
final floorId = await _createFloor( final floorId = await _createFloor(
floorName: event.floorName, buildingId: buildingId, userId: userId); floorName: event.floorName,
buildingId: buildingId,
userId: userId);
if (floorId.isNotEmpty) { if (floorId.isNotEmpty) {
final unitId = final unitId = await _createUnit(
await _createUnit(unitName: event.unitName, floorId: floorId, userId: userId); unitName: event.unitName, floorId: floorId, userId: userId);
if (unitId.isNotEmpty && rooms.isNotEmpty) { if (unitId.isNotEmpty && rooms.isNotEmpty) {
rooms.forEach((room) async { rooms.forEach((room) async {
await _createNewRoom(roomName: room, unitId: unitId, userId: userId); await _createNewRoom(
roomName: room,
unitId: unitId,
userId: userId,
communityId: response['data']['uuid'],
);
}); });
} }
} }
@ -99,7 +108,8 @@ class CreateUnitBloc extends Bloc<CreateUnitEvent, CreateUnitState> {
} }
} }
Future<bool> _assignToCommunity({required String communityId, required String userId}) async { Future<bool> _assignToCommunity(
{required String communityId, required String userId}) async {
try { try {
Map<String, String> body = { Map<String, String> body = {
'communityUuid': communityId, 'communityUuid': communityId,
@ -114,9 +124,14 @@ Future<bool> _assignToCommunity({required String communityId, required String us
} }
Future<String> _createBuilding( Future<String> _createBuilding(
{required String buildingName, required String communityId, required String userId}) async { {required String buildingName,
required String communityId,
required String userId}) async {
try { try {
Map<String, String> body = {'buildingName': buildingName, 'communityUuid': communityId}; Map<String, String> body = {
'buildingName': buildingName,
'communityUuid': communityId
};
final response = await HomeCreation.createBuilding(body); final response = await HomeCreation.createBuilding(body);
// if (response['data']['uuid'] != '') { // if (response['data']['uuid'] != '') {
// final result = await _assignToBuilding(buildingId: response['data']['uuid'], userId: userId); // final result = await _assignToBuilding(buildingId: response['data']['uuid'], userId: userId);
@ -130,7 +145,8 @@ Future<String> _createBuilding(
} }
} }
Future<bool> _assignToBuilding({required String buildingId, required String userId}) async { Future<bool> _assignToBuilding(
{required String buildingId, required String userId}) async {
try { try {
Map<String, String> body = { Map<String, String> body = {
'buildingUuid': buildingId, 'buildingUuid': buildingId,
@ -145,9 +161,14 @@ Future<bool> _assignToBuilding({required String buildingId, required String user
} }
Future<String> _createFloor( Future<String> _createFloor(
{required String floorName, required String buildingId, required String userId}) async { {required String floorName,
required String buildingId,
required String userId}) async {
try { try {
Map<String, String> body = {'floorName': floorName, 'buildingUuid': buildingId}; Map<String, String> body = {
'floorName': floorName,
'buildingUuid': buildingId
};
final response = await HomeCreation.createFloor(body); final response = await HomeCreation.createFloor(body);
// if (response['data']['uuid'] != '') { // if (response['data']['uuid'] != '') {
// final result = await _assignToFloor(buildingId: response['data']['uuid'], userId: userId); // final result = await _assignToFloor(buildingId: response['data']['uuid'], userId: userId);
@ -161,7 +182,8 @@ Future<String> _createFloor(
} }
} }
Future<bool> _assignToFloor({required String buildingId, required String userId}) async { Future<bool> _assignToFloor(
{required String buildingId, required String userId}) async {
try { try {
Map<String, String> body = { Map<String, String> body = {
'floorUuid': buildingId, 'floorUuid': buildingId,
@ -176,12 +198,15 @@ Future<bool> _assignToFloor({required String buildingId, required String userId}
} }
Future<String> _createUnit( Future<String> _createUnit(
{required String unitName, required String floorId, required String userId}) async { {required String unitName,
required String floorId,
required String userId}) async {
try { try {
Map<String, String> body = {'unitName': unitName, 'floorUuid': floorId}; Map<String, String> body = {'unitName': unitName, 'floorUuid': floorId};
final response = await HomeCreation.createUnit(body); final response = await HomeCreation.createUnit(body);
if (response['data']['uuid'] != '') { if (response['data']['uuid'] != '') {
final result = await _assignToUnit(unitId: response['data']['uuid'], userId: userId); final result =
await _assignToUnit(unitId: response['data']['uuid'], userId: userId);
return result ? response['data']['uuid'] : ''; return result ? response['data']['uuid'] : '';
} else { } else {
@ -192,7 +217,8 @@ Future<String> _createUnit(
} }
} }
Future<bool> _assignToUnit({required String unitId, required String userId}) async { Future<bool> _assignToUnit(
{required String unitId, required String userId}) async {
try { try {
Map<String, String> body = { Map<String, String> body = {
'unitUuid': unitId, 'unitUuid': unitId,
@ -207,10 +233,14 @@ Future<bool> _assignToUnit({required String unitId, required String userId}) asy
} }
Future<String> _createNewRoom( Future<String> _createNewRoom(
{required String roomName, required String unitId, required String userId}) async { {required String roomName,
required String unitId,
required String userId,
required String communityId}) async {
try { try {
Map<String, String> body = {'roomName': roomName, 'unitUuid': unitId}; Map<String, String> body = {'subspaceName': roomName};
final response = await HomeCreation.createRoom(body); final response = await HomeCreation.createRoom(
communityId: communityId, spaceId: unitId, body: body);
// if (response['data']['uuid'] != '') { // if (response['data']['uuid'] != '') {
// final result = await _assignToRoom(roomId: response['data']['uuid'], userId: userId); // final result = await _assignToRoom(roomId: response['data']['uuid'], userId: userId);
@ -223,7 +253,8 @@ Future<String> _createNewRoom(
} }
} }
Future<bool> _assignToRoom({required String roomId, required String userId}) async { Future<bool> _assignToRoom(
{required String roomId, required String userId}) async {
try { try {
Map<String, String> body = { Map<String, String> body = {
'roomUuid': roomId, 'roomUuid': roomId,

View File

@ -107,10 +107,13 @@ class ManageUnitBloc extends Bloc<ManageUnitEvent, ManageUnitState> {
} }
_addNewRoom(AddNewRoom event, Emitter<ManageUnitState> emit) async { _addNewRoom(AddNewRoom event, Emitter<ManageUnitState> emit) async {
Map<String, String> body = {'roomName': event.roomName}; Map<String, String> body = {'subspaceName': event.roomName};
try { try {
emit(LoadingState()); emit(LoadingState());
final response = await HomeCreation.createRoom(body); final response = await HomeCreation.createRoom(
communityId: event.unit.community.uuid,
spaceId: event.unit.id,
body: body);
if (response['data']['uuid'] != '') { if (response['data']['uuid'] != '') {
final roomsList = await SpacesAPI.getSubSpaceBySpaceId( final roomsList = await SpacesAPI.getSubSpaceBySpaceId(
event.unit.community.uuid, event.unit.id); event.unit.community.uuid, event.unit.id);

View File

@ -109,7 +109,7 @@ class RoomsView extends StatelessWidget {
mainAxisAlignment: MainAxisAlignment.start, mainAxisAlignment: MainAxisAlignment.start,
children: [ children: [
BodyMedium( BodyMedium(
text: 'Add Space', text: 'Add Room',
fontColor: ColorsManager.primaryColor, fontColor: ColorsManager.primaryColor,
), ),
], ],

View File

@ -65,6 +65,11 @@ abstract class ApiEndpoints {
//PUT //PUT
static const String renameUnit = '/unit/{unitUuid}'; static const String renameUnit = '/unit/{unitUuid}';
//Subspace Module
//POST
static const String addSubSpace =
'/communities/{communityUuid}/spaces/{spaceUuid}/subspaces';
///Room Module ///Room Module
//POST //POST
static const String addRoom = '/room'; static const String addRoom = '/room';
@ -113,8 +118,10 @@ abstract class ApiEndpoints {
static const String deviceByUuid = '/device/{deviceUuid}'; static const String deviceByUuid = '/device/{deviceUuid}';
static const String deviceFunctions = '/device/{deviceUuid}/functions'; static const String deviceFunctions = '/device/{deviceUuid}/functions';
static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices'; static const String gatewayApi = '/device/gateway/{gatewayUuid}/devices';
static const String deviceFunctionsStatus = '/device/{deviceUuid}/functions/status'; static const String deviceFunctionsStatus =
static const String powerClamp = '/device/{powerClampUuid}/power-clamp/status'; '/device/{deviceUuid}/functions/status';
static const String powerClamp =
'/device/{powerClampUuid}/power-clamp/status';
///Device Permission Module ///Device Permission Module
//POST //POST

View File

@ -1,5 +1,6 @@
import 'dart:async'; import 'dart:async';
import 'dart:convert'; import 'dart:convert';
import 'dart:developer';
import 'package:syncrow_app/features/devices/model/device_category_model.dart'; import 'package:syncrow_app/features/devices/model/device_category_model.dart';
import 'package:syncrow_app/features/devices/model/device_control_model.dart'; import 'package:syncrow_app/features/devices/model/device_control_model.dart';
import 'package:syncrow_app/features/devices/model/device_model.dart'; import 'package:syncrow_app/features/devices/model/device_model.dart';
@ -174,8 +175,6 @@ class DevicesAPI {
return response; return response;
} catch (e) { } catch (e) {
// Log the error if needed // Log the error if needed
print("Error fetching devices for room: $e");
// Return an empty list in case of error // Return an empty list in case of error
return <DeviceModel>[]; return <DeviceModel>[];
} }

View File

@ -4,7 +4,8 @@ import 'package:syncrow_app/services/api/http_service.dart';
class HomeCreation { class HomeCreation {
static final HTTPService _httpService = HTTPService(); static final HTTPService _httpService = HTTPService();
static Future<Map<String, dynamic>> createCommunity(Map<String, String> body) async { static Future<Map<String, dynamic>> createCommunity(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addCommunity, path: ApiEndpoints.addCommunity,
@ -20,7 +21,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> assignUserToCommunity(Map<String, String> body) async { static Future<Map<String, dynamic>> assignUserToCommunity(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addCommunityToUser, path: ApiEndpoints.addCommunityToUser,
@ -36,7 +38,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> createBuilding(Map<String, String> body) async { static Future<Map<String, dynamic>> createBuilding(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addBuilding, path: ApiEndpoints.addBuilding,
@ -52,7 +55,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> assignUserToBuilding(Map<String, String> body) async { static Future<Map<String, dynamic>> assignUserToBuilding(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addBuildingToUser, path: ApiEndpoints.addBuildingToUser,
@ -68,7 +72,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> createFloor(Map<String, String> body) async { static Future<Map<String, dynamic>> createFloor(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addFloor, path: ApiEndpoints.addFloor,
@ -84,7 +89,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> assignUserToFloor(Map<String, String> body) async { static Future<Map<String, dynamic>> assignUserToFloor(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addBuildingToUser, path: ApiEndpoints.addBuildingToUser,
@ -100,7 +106,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> createUnit(Map<String, String> body) async { static Future<Map<String, dynamic>> createUnit(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addUnit, path: ApiEndpoints.addUnit,
@ -116,7 +123,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> assignUserToUnit(Map<String, String> body) async { static Future<Map<String, dynamic>> assignUserToUnit(
Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addUnitToUser, path: ApiEndpoints.addUnitToUser,
@ -132,10 +140,17 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> createRoom(Map<String, String> body) async { static Future<Map<String, dynamic>> createRoom({
required String communityId,
required String spaceId,
required Map<String, String> body,
}) async {
try { try {
final fullPath = ApiEndpoints.addSubSpace
.replaceAll('{communityUuid}', communityId)
.replaceAll('{spaceUuid}', spaceId);
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addRoom, path: fullPath,
body: body, body: body,
showServerMessage: false, showServerMessage: false,
expectedResponseModel: (json) { expectedResponseModel: (json) {
@ -148,8 +163,8 @@ class HomeCreation {
} }
} }
static Future<Map<String, dynamic>> assignUserToRoom(
static Future<Map<String, dynamic>> assignUserToRoom(Map<String, String> body) async { Map<String, String> body) async {
try { try {
final response = await _httpService.post( final response = await _httpService.post(
path: ApiEndpoints.addRoomToUser, path: ApiEndpoints.addRoomToUser,

View File

@ -39,10 +39,6 @@ class HomeManagementAPI {
final path = ApiEndpoints.spaceDevices final path = ApiEndpoints.spaceDevices
.replaceAll("{communityUuid}", communityUuid) .replaceAll("{communityUuid}", communityUuid)
.replaceAll("{spaceUuid}", spaceUuid); .replaceAll("{spaceUuid}", spaceUuid);
// Debugging: Log the path
print("Fetching devices with path: $path");
await _httpService.get( await _httpService.get(
path: path, path: path,
showServerMessage: false, showServerMessage: false,
@ -54,10 +50,8 @@ class HomeManagementAPI {
); );
// Debugging: Log successful fetch // Debugging: Log successful fetch
print("Successfully fetched ${list.length} devices.");
} catch (e) { } catch (e) {
// Log the error for debugging // Log the error for debugging
print("Error fetching devices for the unit: $e");
} }
return list; return list;