import 'package:concierge/domain/models/delivery_location.dart';
import 'package:concierge/presentation/app/cart_cubit.dart';
import 'package:concierge/presentation/base/base_cubit.dart';
import 'package:concierge/presentation/screens/provide_location/bloc/provide_location_state.dart';
class ProvideLocationCubit extends BaseCubit<ProvideLocationState> {
final CartCubit _cartCubit;
ProvideLocationCubit(this._cartCubit) : super(const ProvideLocationState()) {
init();
}
Future<void> init() async {
safeEmit(
state.copyWith(
deliveryLocationCode: _cartCubit.state.deliveryLocationCode,
deliveryLocation: _cartCubit.state.deliveryLocation,
),
);
}
void updateLocation(DeliveryLocation deliveryLocation) {
safeEmit(state.copyWith(deliveryLocation: deliveryLocation));
}
void updateLocationCode(String code) {
safeEmit(state.copyWith(deliveryLocationCode: code));
}
void onConfirmClicked() {
_cartCubit.updateLocationCode(state.deliveryLocationCode);
_cartCubit.updateLocation(state.deliveryLocation);
}
}