Aidra Driver 1.3.5+68
Aidra Driver - Your path to green energy
Loading...
Searching...
No Matches
collections_information_bloc.dart
Go to the documentation of this file.
1import 'package:aidra_drive/features/collections/domain/usecases/send_collection_confirmation_usecase.dart';
2import 'package:equatable/equatable.dart';
3import 'package:flutter_bloc/flutter_bloc.dart';
4
5import '../../../../../core/common/use_case/use_case.dart';
6import '../../../../../core/error/failures.dart';
7import '../../../../../core/services/service_locator.dart';
8import '../../../domain/entities/res/res_collection_confirmation_entity.dart';
9import '../../../domain/entities/res/res_collection_contact_entity.dart';
10import '../../../domain/entities/res/res_collection_information_entity.dart';
11import '../../../domain/entities/res/res_collection_rating_reason_entity.dart';
12import '../../../domain/entities/res/res_partner_payment_entity.dart';
13import '../../../domain/usecases/get_collection_contact_list_usecase.dart';
14import '../../../domain/usecases/get_collection_rating_reasons_usecase.dart';
15import '../../../domain/usecases/get_partner_payment_methods_list_usecase.dart';
16import '../../../domain/usecases/send_collection_information_usecase.dart';
17import '../../../domain/usecases/send_collection_payment_usecase.dart';
18import '../../../domain/usecases/send_collection_rating_usecase.dart';
19
20part 'collections_information_event.dart';
21part 'collections_information_state.dart';
22
23class CollectionsInformationBloc extends Bloc<CollectionsInformationEvent, CollectionsInformationState> {
24
30 final GetCollectionRatingReasonsUseCase getLowRatingResonsListUseCase = sl<GetCollectionRatingReasonsUseCase>();
32
33 CollectionsInformationBloc() : super(CollectionsInformationInitial()) {
34 on<SendCollectionInformationEvent>(_onLoadCollectionsInformation);
35 on<SendCollectionConfirmationEvent>(_onLoadCollectionsConfirmation);
36 on<SendCollectionPaymentEvent>(_onLoadCollectionsPayment);
37 on<SendCollectionRatingEvent>(_onSendCollectionRating);
38 on<GetCollectionContactListEvent>(_onLoadCollectionContactList);
39 on<GetLowRatingResonsListEvent>(_onLoadLowRatingResonsList);
40 on<GetCollectionPaymentModeListEvent>(_onLoadCollectionPaymentModeList);
41 }
42
45 Emitter<CollectionsInformationState> emit,
46 ) async {
47 emit(CollectionsInformationLoading());
48
49 final result = await sendCollectionInformationUseCase(
51 id: event.id,
52 collectionRequest: event.collectionRequest,
53 volumeDeclared: event.volumeDeclared,
54 volumeCollected: event.volumeCollected,
55 recoveredDrum: event.recoveredDrum,
56 depositedDrum: event.depositedDrum,
57 userId: event.userId,
58 note: event.note ?? '',
59 reference: event.reference,
60 address: event.address,
61 restaurant: event.restaurant,
62 restaurantId: event.restaurantId,
63 ),
64 );
65
66 result.fold(
67 (failure) => emit(CollectionsInformationError(failure: failure)),
69 );
70 }
71
73 SendCollectionConfirmationEvent event,
74 Emitter<CollectionsInformationState> emit,
75 ) async {
76 emit(CollectionConfirmationLoading());
77
78 final result = await sendCollectionConfirmationUseCase(
80 id: event.id,
81 invoiceDateDue: event.invoiceDateDue,
82 userId: event.userId,
83 voucherImage: event.voucherImage,
84 containerImage: event.containerImage,
85 address: event.address,
86 reference: event.reference,
87 restaurant: event.restaurant,
88 restaurantId: event.restaurantId,
89 volumeCollected: event.volumeCollected,
90 volumeDeclared: event.volumeDeclared,
91 ),
92 );
93
94 result.fold(
95 (failure) => emit(CollectionConfirmationError(failure: failure)),
97 );
98 }
99
102 Emitter<CollectionsInformationState> emit,
103 ) async {
104 emit(CollectionPaymentLoading());
105
106 final result = await sendCollectionPaymentUseCase(
108 collectionId: event.id,
109 invoiceDateDue: event.invoiceDateDue,
110 userId: event.userId,
111 signatureImage: event.signatureImage,
112 paymentModeId: event.paymentModeId,
113 contactId: event.contactId,
114 ),
115 );
116
117 result.fold(
118 (failure) => emit(CollectionPaymentError(failure: failure)),
120 );
121 }
122
124 GetCollectionContactListEvent event,
125 Emitter<CollectionsInformationState> emit,
126 ) async {
127 emit((CollectionContactListLoading()));
128
129 final result = await getCollectionContactListUseCase(
131 restaurantId: event.restaurentId,
132 ),
133 );
134
135 result.fold(
138 );
139 }
140
142 GetLowRatingResonsListEvent event,
143 Emitter<CollectionsInformationState> emit,
144 ) async {
145 emit((CollectionLowRatingReasonsLoading()));
146
147 final result = await getLowRatingResonsListUseCase(NoParams());
148
149 result.fold(
150 (failure) => emit(CollectionLowRatingReasonsError(failure: failure)),
152 );
153 }
154
157 Emitter<CollectionsInformationState> emit,
158 ) async {
159 emit((CollectionPaymentModeListLoading()));
160
161 final result = await getPartnerPaymentMethodsListUsecase(
163 restaurantId: event.restaurentId,
164 ),
165 );
166
167 result.fold(
168 (failure) => emit(CollectionPaymentModeListError(failure: failure)),
170 );
171 }
172
174 SendCollectionRatingEvent event,
175 Emitter<CollectionsInformationState> emit,
176 ) async {
177 emit(CollectionRatingLoading());
178
179 final result = await sendCollectionRatingUsecase(
181 id: event.id,
182 rate: event.rate,
183 reasonId: event.reasonId ?? '',
184 note: event.note ?? '',
185 ),
186 );
187
188 result.fold(
189 (failure) => emit(CollectionRatingError(failure: failure)),
190 (success) => emit(CollectionRatingSuccess(isDone: success)),
191 );
192 }
193}
sealed class AuthenticationState extends Equatable failure
sealed class CheckInOutEvent extends Equatable userId
Future< void > _onLoadCollectionPaymentModeList(GetCollectionPaymentModeListEvent event, Emitter< CollectionsInformationState > emit,) async
Future< void > _onLoadCollectionContactList(GetCollectionContactListEvent event, Emitter< CollectionsInformationState > emit,) async
Future< void > _onLoadCollectionsConfirmation(SendCollectionConfirmationEvent event, Emitter< CollectionsInformationState > emit,) async
Future< void > _onLoadLowRatingResonsList(GetLowRatingResonsListEvent event, Emitter< CollectionsInformationState > emit,) async
Future< void > _onLoadCollectionsPayment(SendCollectionPaymentEvent event, Emitter< CollectionsInformationState > emit,) async
Future< void > _onLoadCollectionsInformation(SendCollectionInformationEvent event, Emitter< CollectionsInformationState > emit,) async
Future< void > _onSendCollectionRating(SendCollectionRatingEvent event, Emitter< CollectionsInformationState > emit,) async
class UpdateCollectionStatusEvent extends CollectionsEvent collectionId
final String volumeDeclared
const SendCollectionPaymentEvent({ required this.id, required this.invoiceDateDue, required this.userId, required this.signatureImage, required this.paymentModeId, required this.contactId, })
final String note
final String invoiceDateDue
const GetCollectionPaymentModeListEvent({ required this.restaurentId, })
final String collectionRequest
final int restaurantId
const SendCollectionInformationEvent({ required this.id, required this.collectionRequest, required this.volumeDeclared, required this.volumeCollected, required this.recoveredDrum, required this.depositedDrum, required this.userId, required this.reference, required this.address, required this.restaurant, required this.restaurantId, this.note, })
final String recoveredDrum
final String volumeCollected
final String restaurant
final String signatureImage
final String depositedDrum
const CollectionLowRatingReasonsLoaded({required this.reasons})
const CollectionContactListError({required this.failure})
const CollectionConfirmationLoaded({required this.confirmation})
class CollectionLowRatingReasonsError extends CollectionsInformationState paymentModes
const CollectionPaymentModeListLoaded({required this.paymentModes})
const CollectionPaymentLoaded({required this.isDone})
const CollectionsInformationLoaded({required this.confirmation})
const CollectionRatingSuccess({required this.isDone})
class CollectionConfirmationError extends CollectionsInformationState isDone
const CollectionContactListLoaded({required this.contacts})
class CollectionPaymentError extends CollectionsInformationState contacts
class CollectionStatusUpdateError extends CollectionsState reasons
final String address
GetCollectionContactListUseCase({required this.repository})
GetPartnerPaymentMethodsListUsecase({required this.repository})
SendCollectionConfirmationUsecase({required this.repository})
SendCollectionInformationUsecase({required this.repository})
SendCollectionPaymentUsecase({required this.repository})
SendCollectionRatingUsecase({required this.repository})
final sl