feat(api): update DeviceLocation model and clean up AuthRepositoryImpl and BillingPageSkeleton

This commit is contained in:
Achintha Isuru
2026-03-18 10:00:27 -04:00
parent f218be44e2
commit 0b5254311d
5 changed files with 25 additions and 408 deletions

View File

@@ -10,7 +10,6 @@ import 'package:krow_domain/krow_domain.dart'
AppException,
BaseApiService,
ClientSession,
InvalidCredentialsException,
NetworkException,
PasswordMismatchException,
SignInFailedException,
@@ -28,7 +27,7 @@ import 'package:krow_domain/krow_domain.dart'
class AuthRepositoryImpl implements AuthRepositoryInterface {
/// Creates an [AuthRepositoryImpl] with the given [BaseApiService].
AuthRepositoryImpl({required BaseApiService apiService})
: _apiService = apiService;
: _apiService = apiService;
/// The V2 API service for backend calls.
final BaseApiService _apiService;
@@ -46,23 +45,16 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
// via Identity Toolkit and returns a full auth envelope.
final ApiResponse response = await _apiService.post(
AuthEndpoints.clientSignIn,
data: <String, dynamic>{
'email': email,
'password': password,
},
data: <String, dynamic>{'email': email, 'password': password},
);
final Map<String, dynamic> body =
response.data as Map<String, dynamic>;
final Map<String, dynamic> body = response.data as Map<String, dynamic>;
// Step 2: Sign in locally so AuthInterceptor can attach Bearer tokens
// to subsequent requests. The V2 API already validated credentials, so
// email/password sign-in establishes the local Firebase Auth state.
final firebase.UserCredential credential =
await _auth.signInWithEmailAndPassword(
email: email,
password: password,
);
final firebase.UserCredential credential = await _auth
.signInWithEmailAndPassword(email: email, password: password);
final firebase.User? firebaseUser = credential.user;
if (firebaseUser == null) {
@@ -106,11 +98,8 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
// Step 2: Sign in locally to Firebase Auth so AuthInterceptor works
// for subsequent requests. The V2 API already created the Firebase
// account, so this should succeed.
final firebase.UserCredential credential =
await _auth.signInWithEmailAndPassword(
email: email,
password: password,
);
final firebase.UserCredential credential = await _auth
.signInWithEmailAndPassword(email: email, password: password);
final firebase.User? firebaseUser = credential.user;
if (firebaseUser == null) {
@@ -155,10 +144,7 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
// Step 1: Call V2 sign-out endpoint for server-side token revocation.
await _apiService.post(AuthEndpoints.clientSignOut);
} catch (e) {
developer.log(
'V2 sign-out request failed: $e',
name: 'AuthRepository',
);
developer.log('V2 sign-out request failed: $e', name: 'AuthRepository');
// Continue with local sign-out even if server-side fails.
}
@@ -202,14 +188,14 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
'userId': userJson['id'] ?? userJson['userId'],
},
};
final ClientSession clientSession =
ClientSession.fromJson(normalisedEnvelope);
final ClientSession clientSession = ClientSession.fromJson(
normalisedEnvelope,
);
ClientSessionStore.instance.setSession(clientSession);
}
final String userId =
userJson?['id'] as String? ?? firebaseUser.uid;
final String? email = userJson?['email'] as String? ?? fallbackEmail;
final String userId = userJson?['id'] as String? ?? firebaseUser.uid;
final String email = userJson?['email'] as String? ?? fallbackEmail;
return User(
id: userId,

View File

@@ -19,7 +19,7 @@ class BillingPageSkeleton extends StatelessWidget {
padding: const EdgeInsets.all(UiConstants.space5),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
// Pending invoices section header
const UiShimmerSectionHeader(),
const SizedBox(height: UiConstants.space3),
@@ -39,7 +39,7 @@ class BillingPageSkeleton extends StatelessWidget {
),
child: const Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
children: <Widget>[
UiShimmerLine(width: 160, height: 16),
SizedBox(height: UiConstants.space4),
// Breakdown rows

View File

@@ -10,7 +10,7 @@ class BreakdownRowSkeleton extends StatelessWidget {
Widget build(BuildContext context) {
return const Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
children: <Widget>[
UiShimmerLine(width: 100, height: 14),
UiShimmerLine(width: 60, height: 14),
],