forked from eatvio/eatvio_app
feat(video_calls): video calls tokens registration fix
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import 'dart:developer';
|
||||
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:eatvio_app/core/firebase_api.dart';
|
||||
import 'package:eatvio_app/core/token_storage.dart';
|
||||
import 'package:eatvio_app/core/utils/date_time_utils.dart';
|
||||
import 'package:eatvio_app/core/utils/validation_utils.dart';
|
||||
@@ -13,7 +14,11 @@ import 'package:gpassword/gpassword.dart';
|
||||
|
||||
class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||
final RegistrationRepositoryV2 registrationRepository;
|
||||
RegistrationCubitV2({required this.registrationRepository}) : super(const RegistrationStateV2());
|
||||
final FirebaseApi firebaseApi;
|
||||
RegistrationCubitV2({
|
||||
required this.registrationRepository,
|
||||
required this.firebaseApi,
|
||||
}) : super(const RegistrationStateV2());
|
||||
|
||||
void setFirstName(String firstName) {
|
||||
emit(state.copyWith(firstName: firstName));
|
||||
@@ -194,9 +199,12 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||
bool didApiComplainOnValidation = false;
|
||||
String errorMessage = '';
|
||||
try {
|
||||
final token = await registrationRepository.register(registrationModel: registrationModel);
|
||||
final token = await registrationRepository.register(
|
||||
registrationModel: registrationModel,
|
||||
);
|
||||
if (token != null) {
|
||||
TokenStorage.saveTokenInStorage(token);
|
||||
await TokenStorage.saveTokenInStorage(token);
|
||||
await firebaseApi.registerPushToken();
|
||||
emit(state.copyWith(registrationError: null));
|
||||
return (true, false);
|
||||
}
|
||||
@@ -214,11 +222,21 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||
for (var error in emailErrors) {
|
||||
allErrors.add(error.toString());
|
||||
if (error.toString() == 'Некорректный формат email') {
|
||||
emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Некорректный формат email'));
|
||||
emit(
|
||||
state.copyWith(
|
||||
isEmailValid: false,
|
||||
emailDisplayError: 'Некорректный формат email',
|
||||
),
|
||||
);
|
||||
didApiComplainOnValidation = true;
|
||||
}
|
||||
if (error.toString() == 'Такой Эл. почта уже существует.') {
|
||||
emit(state.copyWith(isEmailValid: false, emailDisplayError: 'Такая Эл. почта уже существует.'));
|
||||
emit(
|
||||
state.copyWith(
|
||||
isEmailValid: false,
|
||||
emailDisplayError: 'Такая Эл. почта уже существует.',
|
||||
),
|
||||
);
|
||||
didApiComplainOnValidation = true;
|
||||
}
|
||||
}
|
||||
@@ -227,7 +245,12 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||
for (var error in phoneErrors) {
|
||||
allErrors.add(error.toString());
|
||||
if (error.toString() == 'Такой phone уже существует.') {
|
||||
emit(state.copyWith(isPhoneValid: false, phoneDisplayError: 'Такой номер телефона уже существует.'));
|
||||
emit(
|
||||
state.copyWith(
|
||||
isPhoneValid: false,
|
||||
phoneDisplayError: 'Такой номер телефона уже существует.',
|
||||
),
|
||||
);
|
||||
didApiComplainOnValidation = true;
|
||||
}
|
||||
}
|
||||
@@ -236,7 +259,12 @@ class RegistrationCubitV2 extends Cubit<RegistrationStateV2> {
|
||||
for (var error in dateOfBirth) {
|
||||
allErrors.add(error.toString());
|
||||
if (error.toString() == 'Некорректный формат даты рождения') {
|
||||
emit(state.copyWith(isBirthdayValid: false, dateOfBirthDisplayError: 'Некорректный формат даты рождения'));
|
||||
emit(
|
||||
state.copyWith(
|
||||
isBirthdayValid: false,
|
||||
dateOfBirthDisplayError: 'Некорректный формат даты рождения',
|
||||
),
|
||||
);
|
||||
didApiComplainOnValidation = true;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user