Fix build errors: localization syntax, key paths, and ViewOrderCard widget

This commit is contained in:
2026-02-14 16:26:10 +05:30
parent 097481d26a
commit 4e1a41ebff
25 changed files with 420 additions and 207 deletions

View File

@@ -156,24 +156,30 @@ class AuthRepositoryImpl
.userRole('STAFF')
.execute());
} else {
if (user.userRole != 'STAFF') {
await firebaseAuth.signOut();
throw const domain.UnauthorizedAppException(
technicalMessage: 'User is not authorized for this app.',
);
}
// User exists in PostgreSQL. Check if they have a STAFF profile.
final QueryResult<GetStaffByUserIdData, GetStaffByUserIdVariables>
staffResponse = await executeProtected(() => dataConnect
.getStaffByUserId(
userId: firebaseUser.uid,
)
.execute());
if (staffResponse.data.staffs.isNotEmpty) {
// If profile exists, they should use Login mode.
await firebaseAuth.signOut();
throw const domain.AccountExistsException(
technicalMessage: 'This user already has a staff profile. Please log in.',
technicalMessage:
'This user already has a staff profile. Please log in.',
);
}
// If they don't have a staff profile but they exist as BUSINESS,
// they are allowed to "Sign Up" for Staff.
// We update their userRole to 'BOTH'.
if (user.userRole == 'BUSINESS') {
await executeProtected(() =>
dataConnect.updateUser(id: firebaseUser.uid).userRole('BOTH').execute());
}
}
} else {
if (user == null) {
@@ -182,7 +188,8 @@ class AuthRepositoryImpl
technicalMessage: 'Authenticated user profile not found in database.',
);
}
if (user.userRole != 'STAFF') {
// Allow STAFF or BOTH roles to log in to the Staff App
if (user.userRole != 'STAFF' && user.userRole != 'BOTH') {
await firebaseAuth.signOut();
throw const domain.UnauthorizedAppException(
technicalMessage: 'User is not authorized for this app.',

View File

@@ -5,7 +5,7 @@ import 'package:staff_authentication/src/domain/ui_entities/auth_mode.dart';
abstract class AuthEvent extends Equatable {
const AuthEvent();
@override
List<Object> get props => <Object>[];
List<Object?> get props => <Object?>[];
}
/// Event for requesting a sign-in with a phone number.
@@ -19,7 +19,7 @@ class AuthSignInRequested extends AuthEvent {
const AuthSignInRequested({this.phoneNumber, required this.mode});
@override
List<Object> get props => <Object>[mode];
List<Object?> get props => <Object?>[phoneNumber, mode];
}
/// Event for submitting an OTP (One-Time Password) for verification.
@@ -43,7 +43,7 @@ class AuthOtpSubmitted extends AuthEvent {
});
@override
List<Object> get props => <Object>[verificationId, smsCode, mode];
List<Object?> get props => <Object?>[verificationId, smsCode, mode];
}
/// Event for clearing any authentication error in the state.
@@ -57,7 +57,7 @@ class AuthResetRequested extends AuthEvent {
const AuthResetRequested({required this.mode});
@override
List<Object> get props => <Object>[mode];
List<Object?> get props => <Object?>[mode];
}
/// Event for ticking down the resend cooldown.
@@ -67,7 +67,7 @@ class AuthCooldownTicked extends AuthEvent {
const AuthCooldownTicked(this.secondsRemaining);
@override
List<Object> get props => <Object>[secondsRemaining];
List<Object?> get props => <Object?>[secondsRemaining];
}
/// Event for updating the current draft OTP in the state.
@@ -78,7 +78,7 @@ class AuthOtpUpdated extends AuthEvent {
const AuthOtpUpdated(this.otp);
@override
List<Object> get props => <Object>[otp];
List<Object?> get props => <Object?>[otp];
}
/// Event for updating the current draft phone number in the state.
@@ -89,5 +89,5 @@ class AuthPhoneUpdated extends AuthEvent {
const AuthPhoneUpdated(this.phoneNumber);
@override
List<Object> get props => <Object>[phoneNumber];
List<Object?> get props => <Object?>[phoneNumber];
}

View File

@@ -50,7 +50,13 @@ class _PhoneVerificationPageState extends State<PhoneVerificationPage> {
required BuildContext context,
required String phoneNumber,
}) {
final String normalized = phoneNumber.replaceAll(RegExp(r'\\D'), '');
String normalized = phoneNumber.replaceAll(RegExp(r'\D'), '');
// Handle US numbers entered with a leading 1
if (normalized.length == 11 && normalized.startsWith('1')) {
normalized = normalized.substring(1);
}
if (normalized.length == 10) {
BlocProvider.of<AuthBloc>(
context,

View File

@@ -88,7 +88,7 @@ class _PhoneInputFormFieldState extends State<PhoneInputFormField> {
keyboardType: TextInputType.phone,
inputFormatters: <TextInputFormatter>[
FilteringTextInputFormatter.digitsOnly,
LengthLimitingTextInputFormatter(10),
LengthLimitingTextInputFormatter(11),
],
decoration: InputDecoration(
hintText: t.staff_authentication.phone_input.hint,