mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-08-25 22:09:40 +00:00
Integrate ReorderSpaces functionality into CommunityStructureCanvas and enhance RemoteReorderSpacesService with dynamic URL generation. Update ReorderSpacesParam to require parentSpaceUuid and spaces for improved validation and serialization.
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:syncrow_web/pages/common/bloc/project_manager.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/reorder_spaces/domain/params/reorder_spaces_param.dart';
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/reorder_spaces/domain/services/reorder_spaces_service.dart';
|
||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||
@ -14,8 +15,8 @@ final class RemoteReorderSpacesService implements ReorderSpacesService {
|
||||
Future<void> reorderSpaces(ReorderSpacesParam param) async {
|
||||
try {
|
||||
await _httpClient.post(
|
||||
path: ApiEndpoints.reorderSpaces,
|
||||
body: param,
|
||||
path: await _makeUrl(param),
|
||||
body: param.toJson(),
|
||||
expectedResponseModel: (json) => json,
|
||||
);
|
||||
} on DioException catch (e) {
|
||||
@ -32,4 +33,26 @@ final class RemoteReorderSpacesService implements ReorderSpacesService {
|
||||
final errorMessage = error?['message'] as String? ?? '';
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
Future<String> _makeUrl(ReorderSpacesParam param) async {
|
||||
final projectUuid = await ProjectManager.getProjectUUID();
|
||||
final communityUuid = param.communityUuid;
|
||||
|
||||
if (projectUuid == null || projectUuid.isEmpty) {
|
||||
throw APIException('Project UUID is not set');
|
||||
}
|
||||
|
||||
if (communityUuid.isEmpty) {
|
||||
throw APIException('Community UUID is not set');
|
||||
}
|
||||
|
||||
if (param.parentSpaceUuid.isEmpty) {
|
||||
throw APIException('Parent Space UUID is not set');
|
||||
}
|
||||
|
||||
return ApiEndpoints.reorderSpaces
|
||||
.replaceAll('{projectUuid}', projectUuid)
|
||||
.replaceAll('{communityUuid}', communityUuid)
|
||||
.replaceAll('{parentSpaceUuid}', param.parentSpaceUuid);
|
||||
}
|
||||
}
|
||||
|
@ -3,14 +3,14 @@ import 'package:syncrow_web/pages/space_management_v2/modules/communities/domain
|
||||
|
||||
class ReorderSpacesParam extends Equatable {
|
||||
const ReorderSpacesParam({
|
||||
required this.spaces,
|
||||
required this.communityUuid,
|
||||
this.parentSpaceUuid,
|
||||
required this.parentSpaceUuid,
|
||||
required this.spaces,
|
||||
});
|
||||
|
||||
final List<SpaceModel> spaces;
|
||||
final String communityUuid;
|
||||
final String? parentSpaceUuid;
|
||||
final String parentSpaceUuid;
|
||||
final List<SpaceModel> spaces;
|
||||
|
||||
@override
|
||||
List<Object?> get props => [spaces, communityUuid, parentSpaceUuid];
|
||||
|
Reference in New Issue
Block a user