fixed space creation api

This commit is contained in:
hannathkadher
2025-01-12 11:37:10 +04:00
parent 1be52adcc8
commit a588351482
10 changed files with 123 additions and 45 deletions

View File

@ -1,7 +1,10 @@
import 'package:flutter/material.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/community_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/create_subspace_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_model.dart';
import 'package:syncrow_web/pages/spaces_management/all_spaces/model/space_response_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/create_space_template_body_model.dart';
import 'package:syncrow_web/pages/spaces_management/space_model/models/tag_body_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';
@ -161,15 +164,17 @@ class CommunitySpaceManagementApi {
}
}
Future<SpaceModel?> createSpace({
required String communityId,
required String name,
String? parentId,
String? direction,
bool isPrivate = false,
required Offset position,
String? icon,
}) async {
Future<SpaceModel?> createSpace(
{required String communityId,
required String name,
String? parentId,
String? direction,
bool isPrivate = false,
required Offset position,
String? spaceModelUuid,
String? icon,
List<CreateTagBodyModel>? tags,
List<CreateSubspaceModel>? subspaces}) async {
try {
final body = {
'spaceName': name,
@ -182,6 +187,13 @@ class CommunitySpaceManagementApi {
if (parentId != null) {
body['parentUuid'] = parentId;
}
if (tags != null) {
body['tags'] = tags;
}
if (spaceModelUuid != null) body['spaceModelUuid'] = spaceModelUuid;
if (subspaces != null) body['subspaces'] = subspaces;
final response = await HTTPService().post(
path: ApiEndpoints.createSpace
.replaceAll('{communityId}', communityId)
@ -263,7 +275,6 @@ class CommunitySpaceManagementApi {
.replaceAll('{communityId}', communityId)
.replaceAll('{projectId}', TempConst.projectId),
expectedResponseModel: (json) {
print(json);
final spaceModels = (json['data'] as List)
.map((spaceJson) => SpaceModel.fromJson(spaceJson))
.toList();