datos para el servicio
This commit is contained in:
@@ -12,12 +12,8 @@ class ProfessionalBloc extends Bloc<ProfessionalEvent, ProfessionalState> {
|
||||
final FirebaseProfessionalRepository _professionalRepository;
|
||||
final UserRepository _userRepository;
|
||||
|
||||
ProfessionalBloc(
|
||||
{required FirebaseProfessionalRepository professionalRepository,
|
||||
required UserRepository userRepository})
|
||||
: _professionalRepository = professionalRepository,
|
||||
_userRepository = userRepository,
|
||||
super(ProfessionalInitial()) {
|
||||
ProfessionalBloc({required FirebaseProfessionalRepository professionalRepository, required UserRepository userRepository})
|
||||
: _professionalRepository = professionalRepository, _userRepository = userRepository, super(ProfessionalInitial()) {
|
||||
bool isProModeActive = _professionalRepository.isProModeActive;
|
||||
final proInfo = _professionalRepository.lastProInfo();
|
||||
emit(LoadedModeProState(isProModeActive, proInfo));
|
||||
|
||||
@@ -44,7 +44,6 @@ class ProfessionalProfileBloc
|
||||
event.longitude,
|
||||
event.schedules,
|
||||
event.paymentMethods,
|
||||
|
||||
);
|
||||
|
||||
emit(const UpdateProfessionalInfoSuccess());
|
||||
|
||||
@@ -1,3 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:cloud_firestore/cloud_firestore.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter_bloc/flutter_bloc.dart';
|
||||
import 'package:equatable/equatable.dart';
|
||||
|
||||
@@ -11,7 +15,38 @@ class ServiceBloc extends Bloc<ServiceEvent, ServiceState> {
|
||||
|
||||
ServiceBloc({required FirebaseServiceRepository serviceRepository})
|
||||
: _serviceRepository = serviceRepository,
|
||||
super(ServiceInitial()) {
|
||||
|
||||
}
|
||||
super(CreateServiceInitial()) {
|
||||
on<CreateService>(_onCreateService);
|
||||
}
|
||||
|
||||
void _onCreateService(CreateService event, Emitter<ServiceState> emit) async {
|
||||
try {
|
||||
ServiceEntity service = ServiceEntity(
|
||||
professionalId: event.professionalId,
|
||||
professionalScored: false,
|
||||
userId: event.userId,
|
||||
userScored: false,
|
||||
address: event.address,
|
||||
aditionalAddress: event.aditionalAddress,
|
||||
latitude: event.latitude,
|
||||
longitude: event.longitude,
|
||||
day: event.day,
|
||||
createdAt: event.createdAt,
|
||||
description: event.description,
|
||||
range1Hour1: event.range1Hour1,
|
||||
range1Hour2: event.range1Hour2,
|
||||
rate: event.rate,
|
||||
status: ServiceStatus.pending,
|
||||
location: event.location,
|
||||
);
|
||||
|
||||
log('xd -- $service');
|
||||
|
||||
await _serviceRepository.createService(service);
|
||||
|
||||
emit(const CreateServiceSuccess());
|
||||
} catch (e) {
|
||||
emit(CreateServiceFailure());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,5 +4,63 @@ abstract class ServiceEvent extends Equatable {
|
||||
const ServiceEvent();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
List<Object?> get props => [];
|
||||
}
|
||||
|
||||
class CreateService extends ServiceEvent {
|
||||
final String professionalId;
|
||||
final bool? professionalScored;
|
||||
final String userId;
|
||||
final bool? userScored;
|
||||
final String address;
|
||||
final String aditionalAddress;
|
||||
final double latitude;
|
||||
final double longitude;
|
||||
final String day;
|
||||
final Timestamp createdAt;
|
||||
final String description;
|
||||
final TimeOfDay range1Hour1;
|
||||
final TimeOfDay range1Hour2;
|
||||
final String rate;
|
||||
final ServiceStatus? status;
|
||||
final ServiceLocationPreferences location;
|
||||
|
||||
const CreateService({
|
||||
required this.professionalId,
|
||||
this.professionalScored,
|
||||
required this.userId,
|
||||
this.userScored,
|
||||
required this.address,
|
||||
required this.aditionalAddress,
|
||||
required this.latitude,
|
||||
required this.longitude,
|
||||
required this.day,
|
||||
required this.createdAt,
|
||||
required this.description,
|
||||
required this.range1Hour1,
|
||||
required this.range1Hour2,
|
||||
required this.rate,
|
||||
this.status,
|
||||
required this.location,
|
||||
});
|
||||
|
||||
@override
|
||||
List<Object?> get props => [
|
||||
professionalId,
|
||||
professionalScored,
|
||||
userId,
|
||||
userScored,
|
||||
address,
|
||||
aditionalAddress,
|
||||
latitude,
|
||||
longitude,
|
||||
day,
|
||||
createdAt,
|
||||
description,
|
||||
range1Hour1,
|
||||
range1Hour2,
|
||||
rate,
|
||||
status,
|
||||
location,
|
||||
];
|
||||
}
|
||||
|
||||
@@ -7,4 +7,15 @@ abstract class ServiceState extends Equatable {
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
class ServiceInitial extends ServiceState {}
|
||||
class CreateServiceInitial extends ServiceState {}
|
||||
|
||||
class CreateServiceFailure extends ServiceState {}
|
||||
|
||||
class CreateServiceLoading extends ServiceState {}
|
||||
|
||||
class CreateServiceSuccess extends ServiceState {
|
||||
const CreateServiceSuccess();
|
||||
|
||||
@override
|
||||
List<Object> get props => [];
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user