change_password

This commit is contained in:
mohammad
2024-12-30 16:51:35 +03:00
parent 33d2bbc91f
commit 8be05fbd91
16 changed files with 864 additions and 33 deletions

View File

@ -1,4 +1,5 @@
import 'dart:async';
import 'dart:developer';
import 'package:syncrow_app/features/app_layout/bloc/home_cubit.dart';
import 'package:syncrow_app/features/auth/model/user_model.dart';
import 'package:syncrow_app/features/menu/model/region_model.dart';
@ -9,14 +10,15 @@ import 'package:syncrow_app/services/api/http_service.dart';
class ProfileApi {
static final HTTPService _httpService = HTTPService();
static Future<Map<String, dynamic>> saveName({String? firstName, String? lastName,}) async {
static Future<Map<String, dynamic>> saveName({
String? firstName,
String? lastName,
}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveName.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"firstName": firstName,
"lastName": lastName
},
path: ApiEndpoints.saveName
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {"firstName": firstName, "lastName": lastName},
expectedResponseModel: (json) {
return json;
},
@ -27,10 +29,13 @@ class ProfileApi {
}
}
static Future saveRegion({String? regionUuid,}) async {
static Future saveRegion({
String? regionUuid,
}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveRegion.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
path: ApiEndpoints.saveRegion
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"regionUuid": regionUuid,
},
@ -44,10 +49,13 @@ class ProfileApi {
}
}
static Future saveTimeZone({String? regionUuid,}) async {
static Future saveTimeZone({
String? regionUuid,
}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveTimeZone.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
path: ApiEndpoints.saveTimeZone
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"timezoneUuid": regionUuid,
},
@ -64,10 +72,9 @@ class ProfileApi {
static Future<Map<String, dynamic>> saveImage(String image) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.sendPicture.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"profilePicture": 'data:image/png;base64,$image'
},
path: ApiEndpoints.sendPicture
.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {"profilePicture": 'data:image/png;base64,$image'},
expectedResponseModel: (json) {
return json;
},
@ -78,14 +85,14 @@ class ProfileApi {
}
}
Future fetchUserInfo(userId) async {
Future fetchUserInfo(userId) async {
final response = await _httpService.get(
path: ApiEndpoints.getUser.replaceAll('{userUuid}', userId!),
showServerMessage: true,
expectedResponseModel: (json) {
return UserModel.fromJson(json);
}
);
path: ApiEndpoints.getUser.replaceAll('{userUuid}', userId!),
showServerMessage: true,
expectedResponseModel: (json) {
log('user json =$json');
return UserModel.fromJson(json);
});
return response;
}
@ -94,9 +101,10 @@ class ProfileApi {
path: ApiEndpoints.getRegion,
showServerMessage: true,
expectedResponseModel: (json) {
return (json as List).map((zone) => RegionModel.fromJson(zone)).toList();
}
);
return (json as List)
.map((zone) => RegionModel.fromJson(zone))
.toList();
});
return response as List<RegionModel>;
}
@ -106,9 +114,7 @@ class ProfileApi {
showServerMessage: true,
expectedResponseModel: (json) {
return (json as List).map((zone) => TimeZone.fromJson(zone)).toList();
}
);
});
return response as List<TimeZone>;
}
}