mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-16 01:56:24 +00:00
Refactor RemoteDeleteSpaceService to use a private HTTPService instance and update URL construction with ApiEndpoints for improved maintainability. Update DeleteSpaceDialog to reflect changes in service initialization.
This commit is contained in:
@ -4,18 +4,17 @@ import 'package:syncrow_web/pages/space_management_v2/modules/delete_space/domai
|
||||
import 'package:syncrow_web/pages/space_management_v2/modules/delete_space/domain/services/delete_space_service.dart';
|
||||
import 'package:syncrow_web/services/api/api_exception.dart';
|
||||
import 'package:syncrow_web/services/api/http_service.dart';
|
||||
import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
|
||||
final class RemoteDeleteSpaceService implements DeleteSpaceService {
|
||||
RemoteDeleteSpaceService({
|
||||
required this.httpService,
|
||||
});
|
||||
const RemoteDeleteSpaceService(this._httpService);
|
||||
|
||||
final HTTPService httpService;
|
||||
final HTTPService _httpService;
|
||||
|
||||
@override
|
||||
Future<void> delete(DeleteSpaceParam param) async {
|
||||
try {
|
||||
await httpService.delete(
|
||||
await _httpService.delete(
|
||||
path: await _makeUrl(param),
|
||||
expectedResponseModel: (json) {
|
||||
final response = json as Map<String, dynamic>;
|
||||
@ -56,6 +55,10 @@ final class RemoteDeleteSpaceService implements DeleteSpaceService {
|
||||
if (param.spaceUuid.isEmpty) {
|
||||
throw APIException('Space UUID is not set');
|
||||
}
|
||||
return '/projects/$projectUuid/communities/${param.communityUuid}/spaces/${param.spaceUuid}';
|
||||
|
||||
return ApiEndpoints.deleteSpace
|
||||
.replaceAll('{projectId}', projectUuid)
|
||||
.replaceAll('{communityId}', param.communityUuid)
|
||||
.replaceAll('{spaceId}', param.spaceUuid);
|
||||
}
|
||||
}
|
||||
|
@ -27,7 +27,7 @@ class DeleteSpaceDialog extends StatelessWidget {
|
||||
Widget build(BuildContext context) {
|
||||
return BlocProvider(
|
||||
create: (context) => DeleteSpaceBloc(
|
||||
RemoteDeleteSpaceService(httpService: HTTPService()),
|
||||
RemoteDeleteSpaceService(HTTPService()),
|
||||
),
|
||||
child: Builder(
|
||||
builder: (context) => Dialog(
|
||||
|
Reference in New Issue
Block a user