forked from eatvio/eatvio_app
(debug)diary: Some debugging for API
This commit is contained in:
@@ -40,7 +40,7 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
) async {
|
||||
try {
|
||||
final token =
|
||||
"laravel_sanctum_Q22zOtJhQUcJnh0kseZFblFv5XAPaKbG3gTM5hga71ecbb49";
|
||||
"laravel_sanctum_1lPFtd9tpGmHYS243C4K7YF8BrVhxxgXm8cTmjuZda1da694";
|
||||
final response = await http.get(
|
||||
Uri.parse(dotenv.env['SERVER_ROOT']! + '/diary/index'),
|
||||
headers: {
|
||||
@@ -61,7 +61,6 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
);
|
||||
final diary = jsonDecode(response.body)['diary'];
|
||||
if (diary is Map<String, dynamic>) {
|
||||
print(diary['meals'][1].runtimeType);
|
||||
final String diaryDate =
|
||||
diary['date'] ?? DateTime.now().toString();
|
||||
// Продолжайте обработку данных дневника
|
||||
@@ -145,8 +144,6 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
var updatedState =
|
||||
currentState.copyWith(selectedSatiety: event.selectedElement);
|
||||
|
||||
emit(updatedState); // Передаем обновленное состояние в emit
|
||||
|
||||
// Отправляем данные по HTTP маршруту и ждем ответ
|
||||
var response = await sendSatietyData(
|
||||
currentState.token,
|
||||
@@ -155,8 +152,8 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
currentState.diaryId);
|
||||
|
||||
if (response.statusCode == 200) {
|
||||
currentState.selectedSatiety = event.selectedElement;
|
||||
emit(currentState); // Передаем обновленное состояние в emit
|
||||
updatedState.selectedSatiety = event.selectedElement;
|
||||
emit(updatedState); // Передаем обновленное состояние в emit
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -167,21 +164,19 @@ class DiaryEditBloc extends Bloc<DiaryEditEvent, DiaryEditState> {
|
||||
int? mealID,
|
||||
int diaryID,
|
||||
) async {
|
||||
String url =
|
||||
dotenv.env['SERVER_ROOT']! + '$diaryID/meal/$mealID/satiety/fill';
|
||||
String url = dotenv.env['SERVER_ROOT']! +
|
||||
'/diary/$diaryID/meal/$mealID/satiety/fill';
|
||||
final credentials = {
|
||||
'satiety': selectedSatiety,
|
||||
'meal_id': mealID,
|
||||
'diary_id': diaryID,
|
||||
};
|
||||
|
||||
print(json.encode(credentials));
|
||||
var response = await http.post(Uri.parse(url),
|
||||
headers: {
|
||||
'Authorization': 'Bearer $token',
|
||||
},
|
||||
body: json.encode(credentials),
|
||||
encoding: utf8);
|
||||
|
||||
print(response.body);
|
||||
return response;
|
||||
}
|
||||
|
||||
|
||||
@@ -198,7 +198,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
);
|
||||
}
|
||||
|
||||
_buildMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
Padding _buildMeal(BuildContext context, DiaryEditLoadedState state) {
|
||||
final digitsOnly = FilteringTextInputFormatter.digitsOnly;
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
@@ -734,7 +734,7 @@ class DiaryEditScreen extends StatelessWidget {
|
||||
));
|
||||
}
|
||||
|
||||
Widget _buildWakupRetire(BuildContext context, DiaryEditLoadedState state) {
|
||||
Padding _buildWakupRetire(BuildContext context, DiaryEditLoadedState state) {
|
||||
return Padding(
|
||||
padding: EdgeInsets.symmetric(horizontal: 16.h),
|
||||
child: Container(
|
||||
|
||||
Reference in New Issue
Block a user