Circumference edit success

This commit is contained in:
2024-01-23 15:32:21 +03:00
parent ce345be4a4
commit fcc2b2084a
3 changed files with 12 additions and 5 deletions

View File

@@ -55,6 +55,7 @@ class MyProfileBloc extends Bloc<MyProfileEvent, MyProfileState> {
emit(state.copyWith(
user: data['user'],
userDetails: data['userDetails'],
token: token,
chartPoints: data['chartPoints'],
plans: data['plans'],
chestCircumferenceController: TextEditingController(),

View File

@@ -13,6 +13,7 @@ class MyProfileState extends Equatable {
this.userDetails,
this.chartPoints,
this.plans,
this.token,
this.circumferences});
MyProfileModel? myProfileModelObj;
@@ -24,6 +25,7 @@ class MyProfileState extends Equatable {
TextEditingController? chestCircumferenceController;
TextEditingController? waistCircumferenceController;
TextEditingController? hipCircumferenceController;
String? token;
@override
List<Object?> get props => [
@@ -34,7 +36,8 @@ class MyProfileState extends Equatable {
plans,
chestCircumferenceController,
waistCircumferenceController,
hipCircumferenceController
hipCircumferenceController,
token
];
MyProfileState copyWith({
MyProfileModel? myProfileModelObj,
@@ -46,6 +49,7 @@ class MyProfileState extends Equatable {
TextEditingController? chestCircumferenceController,
TextEditingController? waistCircumferenceController,
TextEditingController? hipCircumferenceController,
String? token,
}) {
return MyProfileState(
myProfileModelObj: myProfileModelObj ?? this.myProfileModelObj,
@@ -60,6 +64,7 @@ class MyProfileState extends Equatable {
waistCircumferenceController ?? this.waistCircumferenceController,
hipCircumferenceController:
hipCircumferenceController ?? this.hipCircumferenceController,
token: token ?? this.token,
);
}
}

View File

@@ -190,7 +190,9 @@ class MyProfileScreen extends StatelessWidget {
// Отправка HTTP-запроса
print(jsonData);
print(state.token);
try {
final token = state.token;
final response =
await http.post(
Uri.parse(dotenv.env[
@@ -199,15 +201,15 @@ class MyProfileScreen extends StatelessWidget {
headers: {
'Content-Type':
'application/json',
'Authorization':
'Bearer $token',
},
body: jsonData,
);
if (response.statusCode ==
200) {
// Успешный ответ от сервера
print(
"Данные успешно отправлены");
Navigator.pop(context);
} else {
// Ошибка от сервера
print(
@@ -218,7 +220,6 @@ class MyProfileScreen extends StatelessWidget {
print(
"Ошибка при отправке запроса: $e");
}
//Navigator.pop(context);
},
child: Text("Изменить",
style: CustomTextStyles