import 'package:bloc/bloc.dart';
import 'package:easycook_mobile/repositories/register_repository.dart';
import 'package:flutter/widgets.dart';
import 'package:http/http.dart';
import 'package:meta/meta.dart';
import '../../models/register_form_model.dart';
import 'package:equatable/equatable.dart';
part 'register_state.dart';

class RegisterCubit extends Cubit<RegisterState> {
  RegisterCubit() : super(RegisterInitial());

  final RegisterRepository _register = RegisterRepository();

  Future<void> register(
      {firstName, lastName, username, email, password, phone}) async {
    emit(RegisterLoading());
    try {
      await _register.register(
          firstName, lastName, username, email, password, phone);
      emit(RegisterSuccess());
    } catch (error) {
      emit(RegisterFailure(message: error.toString()));
    }
  }
}
