mirror of
https://github.com/SyncrowIOT/web.git
synced 2025-07-10 07:07:19 +00:00
Added ProjectCubit
as a dependency in blocs
for managing project-level state.
This commit is contained in:
@ -11,10 +11,10 @@ import 'package:syncrow_web/utils/constants/api_const.dart';
|
||||
class UserPermissionApi {
|
||||
static final HTTPService _httpService = HTTPService();
|
||||
|
||||
Future<List<RolesUserModel>> fetchUsers() async {
|
||||
Future<List<RolesUserModel>> fetchUsers(String projectId) async {
|
||||
try {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUsers,
|
||||
path: ApiEndpoints.getUsers.replaceAll('{projectUuid}', projectId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
debugPrint('fetchUsers Response: $json');
|
||||
@ -34,8 +34,9 @@ class UserPermissionApi {
|
||||
path: ApiEndpoints.roleTypes,
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
final List<RoleTypeModel> fetchedRoles =
|
||||
(json['data'] as List).map((item) => RoleTypeModel.fromJson(item)).toList();
|
||||
final List<RoleTypeModel> fetchedRoles = (json['data'] as List)
|
||||
.map((item) => RoleTypeModel.fromJson(item))
|
||||
.toList();
|
||||
return fetchedRoles;
|
||||
},
|
||||
);
|
||||
@ -47,7 +48,9 @@ class UserPermissionApi {
|
||||
path: ApiEndpoints.permission.replaceAll("roleUuid", roleUuid),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
return (json as List).map((data) => PermissionOption.fromJson(data)).toList();
|
||||
return (json as List)
|
||||
.map((data) => PermissionOption.fromJson(data))
|
||||
.toList();
|
||||
},
|
||||
);
|
||||
return response ?? [];
|
||||
@ -61,6 +64,7 @@ class UserPermissionApi {
|
||||
String? phoneNumber,
|
||||
String? roleUuid,
|
||||
List<String>? spaceUuids,
|
||||
required String projectUuid,
|
||||
}) async {
|
||||
try {
|
||||
final body = <String, dynamic>{
|
||||
@ -70,7 +74,7 @@ class UserPermissionApi {
|
||||
"jobTitle": jobTitle != '' ? jobTitle : null,
|
||||
"phoneNumber": phoneNumber != '' ? phoneNumber : null,
|
||||
"roleUuid": roleUuid,
|
||||
"projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c",
|
||||
"projectUuid": projectUuid,
|
||||
"spaceUuids": spaceUuids,
|
||||
};
|
||||
final response = await _httpService.post(
|
||||
@ -121,9 +125,11 @@ class UserPermissionApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<EditUserModel?> fetchUserById(userUuid) async {
|
||||
Future<EditUserModel?> fetchUserById(userUuid, String projectId) async {
|
||||
final response = await _httpService.get(
|
||||
path: ApiEndpoints.getUserById.replaceAll("{userUuid}", userUuid),
|
||||
path: ApiEndpoints.getUserById
|
||||
.replaceAll("{userUuid}", userUuid)
|
||||
.replaceAll("{projectId}", projectId),
|
||||
showServerMessage: true,
|
||||
expectedResponseModel: (json) {
|
||||
EditUserModel res = EditUserModel.fromJson(json['data']);
|
||||
@ -141,6 +147,7 @@ class UserPermissionApi {
|
||||
String? phoneNumber,
|
||||
String? roleUuid,
|
||||
List<String>? spaceUuids,
|
||||
required String projectUuid,
|
||||
}) async {
|
||||
try {
|
||||
final body = <String, dynamic>{
|
||||
@ -149,7 +156,7 @@ class UserPermissionApi {
|
||||
"jobTitle": jobTitle != '' ? jobTitle : " ",
|
||||
"phoneNumber": phoneNumber != '' ? phoneNumber : " ",
|
||||
"roleUuid": roleUuid,
|
||||
"projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c",
|
||||
"projectUuid": projectUuid,
|
||||
"spaceUuids": spaceUuids,
|
||||
};
|
||||
final response = await _httpService.put(
|
||||
@ -186,15 +193,16 @@ class UserPermissionApi {
|
||||
}
|
||||
}
|
||||
|
||||
Future<bool> changeUserStatusById(userUuid, status) async {
|
||||
Future<bool> changeUserStatusById(userUuid, status, String projectUuid) async {
|
||||
try {
|
||||
Map<String, dynamic> bodya = {
|
||||
"disable": status,
|
||||
"projectUuid": "0e62577c-06fa-41b9-8a92-99a21fbaf51c"
|
||||
"projectUuid": projectUuid
|
||||
};
|
||||
|
||||
final response = await _httpService.put(
|
||||
path: ApiEndpoints.changeUserStatus.replaceAll("{invitedUserUuid}", userUuid),
|
||||
path: ApiEndpoints.changeUserStatus
|
||||
.replaceAll("{invitedUserUuid}", userUuid),
|
||||
body: bodya,
|
||||
expectedResponseModel: (json) {
|
||||
return json['success'];
|
||||
|
Reference in New Issue
Block a user