profile page with HomeCubit

This commit is contained in:
mohammad
2024-07-24 16:03:22 +03:00
parent 1044775066
commit 69b901afed
10 changed files with 153 additions and 159 deletions

View File

@ -1,5 +1,5 @@
import 'dart:async';
import 'package:syncrow_app/features/auth/bloc/auth_cubit.dart';
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/bloc/profile_bloc/region_model.dart';
import 'package:syncrow_app/features/menu/bloc/profile_bloc/time_zone_model.dart';
@ -12,7 +12,7 @@ class ProfileApi {
static Future<Map<String, dynamic>> saveName({String? firstName, String? lastName,}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveName.replaceAll('{userUuid}', AuthCubit.user!.uuid!),
path: ApiEndpoints.saveName.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"firstName": firstName,
"lastName": lastName
@ -30,7 +30,7 @@ class ProfileApi {
static Future saveRegion({String? regionUuid,}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveRegion.replaceAll('{userUuid}', AuthCubit.user!.uuid!),
path: ApiEndpoints.saveRegion.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"regionUuid": regionUuid,
},
@ -46,7 +46,7 @@ class ProfileApi {
static Future saveTimeZone({String? regionUuid,}) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.saveTimeZone.replaceAll('{userUuid}', AuthCubit.user!.uuid!),
path: ApiEndpoints.saveTimeZone.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"timezoneUuid": regionUuid,
},
@ -63,7 +63,7 @@ class ProfileApi {
static Future<Map<String, dynamic>> saveImage(String image) async {
try {
final response = await _httpService.put(
path: ApiEndpoints.sendPicture.replaceAll('{userUuid}', AuthCubit.user!.uuid!),
path: ApiEndpoints.sendPicture.replaceAll('{userUuid}', HomeCubit.user!.uuid!),
body: {
"profilePicture": 'data:image/png;base64,$image'
},
@ -77,11 +77,13 @@ class ProfileApi {
}
}
static Future fetchUserInfo(userId) async {
Future fetchUserInfo(userId) async {
final response = await _httpService.get(
path: ApiEndpoints.getUser.replaceAll('{userUuid}', userId!),
showServerMessage: true,
expectedResponseModel: (json) =>UserModel.fromJson(json)
expectedResponseModel: (json) {
return UserModel.fromJson(json);
}
);
return response;
}