feat(InfoByOrder): added user info to InfoByOrderScreen author card

This commit is contained in:
misha
2025-10-29 04:38:04 +03:00
parent 06cafb4257
commit 563d84ca12
10 changed files with 108 additions and 107 deletions

View File

@@ -1,12 +1,13 @@
import 'dart:developer';
import 'package:eatvio_app/features/chat/repositories/chat_repository.dart';
import 'package:eatvio_app/features/order_info/cubit/order_info_state.dart';
import 'package:eatvio_app/features/profile/repositories/profile_repository.dart';
import 'package:flutter_bloc/flutter_bloc.dart';
class OrderInfoCubit extends Cubit<OrderInfoState> {
OrderInfoCubit({required this.chatRepository}) : super(OrderInfoState());
OrderInfoCubit({required this.chatRepository, required this.profileRepository}) : super(OrderInfoState());
final ChatRepository chatRepository;
final ProfileRepository profileRepository;
Future<String?> getPaymentLink() async {
try {
@@ -20,10 +21,14 @@ class OrderInfoCubit extends Cubit<OrderInfoState> {
}
}
Future<void> getChosenPlan(int id) async {
Future<void> getChosenPlan({required int id, String? customerSlug}) async {
try {
emit(state.copyWith(isLoading: true));
final chosenPlan = await chatRepository.getChosenPlan(id: id);
if (customerSlug != null) {
final profile = await profileRepository.getProfileBySlug(customerSlug);
emit(state.copyWith(customerProfile: profile));
}
emit(state.copyWith(isLoading: false, chosenPlan: chosenPlan));
} catch (e) {
log(e.toString());

View File

@@ -1,4 +1,5 @@
import 'package:eatvio_app/features/plans/models/chosen_plan_model.dart';
import 'package:eatvio_app/features/profile/models/profile_model.dart';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'order_info_state.freezed.dart';
@@ -9,6 +10,7 @@ abstract class OrderInfoState with _$OrderInfoState {
factory OrderInfoState({
@Default(true) bool isLoading,
@Default(null) ChosenPlanModel? chosenPlan,
@Default(null) ProfileModel? customerProfile,
}) = _OrderInfoState;
}