Fix build errors: localization syntax, key paths, and ViewOrderCard widget
This commit is contained in:
@@ -238,7 +238,7 @@ class AuthRepositoryImpl
|
||||
final QueryResult<dc.GetUserByIdData, dc.GetUserByIdVariables> response =
|
||||
await executeProtected(() => _dataConnect.getUserById(id: firebaseUserId).execute());
|
||||
final dc.GetUserByIdUser? user = response.data.user;
|
||||
return user != null && user.userRole == 'BUSINESS';
|
||||
return user != null && (user.userRole == 'BUSINESS' || user.userRole == 'BOTH');
|
||||
}
|
||||
|
||||
/// Creates Business and User entities in PostgreSQL for a Firebase user.
|
||||
@@ -261,18 +261,28 @@ class AuthRepositoryImpl
|
||||
final dc.CreateBusinessBusinessInsert businessData = createBusinessResponse.data.business_insert;
|
||||
onBusinessCreated(businessData.id);
|
||||
|
||||
// Create User entity in PostgreSQL
|
||||
// Check if User entity already exists in PostgreSQL
|
||||
final QueryResult<dc.GetUserByIdData, dc.GetUserByIdVariables> userResult =
|
||||
await executeProtected(() => _dataConnect.getUserById(id: firebaseUser.uid).execute());
|
||||
final dc.GetUserByIdUser? existingUser = userResult.data.user;
|
||||
|
||||
final OperationResult<dc.CreateUserData, dc.CreateUserVariables> createUserResponse =
|
||||
await executeProtected(() => _dataConnect.createUser(
|
||||
id: firebaseUser.uid,
|
||||
role: dc.UserBaseRole.USER,
|
||||
)
|
||||
.email(email)
|
||||
.userRole('BUSINESS')
|
||||
.execute());
|
||||
|
||||
final dc.CreateUserUserInsert newUserData = createUserResponse.data.user_insert;
|
||||
if (existingUser != null) {
|
||||
// User exists (likely in another app like STAFF). Update role to BOTH.
|
||||
await executeProtected(() => _dataConnect.updateUser(
|
||||
id: firebaseUser.uid,
|
||||
)
|
||||
.userRole('BOTH')
|
||||
.execute());
|
||||
} else {
|
||||
// Create new User entity in PostgreSQL
|
||||
await executeProtected(() => _dataConnect.createUser(
|
||||
id: firebaseUser.uid,
|
||||
role: dc.UserBaseRole.USER,
|
||||
)
|
||||
.email(email)
|
||||
.userRole('BUSINESS')
|
||||
.execute());
|
||||
}
|
||||
|
||||
return _getUserProfile(
|
||||
firebaseUserId: firebaseUser.uid,
|
||||
@@ -331,11 +341,11 @@ class AuthRepositoryImpl
|
||||
technicalMessage: 'Firebase UID $firebaseUserId not found in users table',
|
||||
);
|
||||
}
|
||||
if (requireBusinessRole && user.userRole != 'BUSINESS') {
|
||||
if (requireBusinessRole && user.userRole != 'BUSINESS' && user.userRole != 'BOTH') {
|
||||
await _firebaseAuth.signOut();
|
||||
dc.ClientSessionStore.instance.clear();
|
||||
throw UnauthorizedAppException(
|
||||
technicalMessage: 'User role is ${user.userRole}, expected BUSINESS',
|
||||
technicalMessage: 'User role is ${user.userRole}, expected BUSINESS or BOTH',
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,94 +27,108 @@ class ClientGetStartedPage extends StatelessWidget {
|
||||
),
|
||||
|
||||
SafeArea(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(height: UiConstants.space10),
|
||||
// Logo
|
||||
Center(
|
||||
child: Image.asset(
|
||||
UiImageAssets.logoBlue,
|
||||
height: 40,
|
||||
fit: BoxFit.contain,
|
||||
child: LayoutBuilder(
|
||||
builder: (BuildContext context, BoxConstraints constraints) {
|
||||
return SingleChildScrollView(
|
||||
child: ConstrainedBox(
|
||||
constraints: BoxConstraints(
|
||||
minHeight: constraints.maxHeight,
|
||||
),
|
||||
child: IntrinsicHeight(
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
const SizedBox(height: UiConstants.space10),
|
||||
// Logo
|
||||
Center(
|
||||
child: Image.asset(
|
||||
UiImageAssets.logoBlue,
|
||||
height: 40,
|
||||
fit: BoxFit.contain,
|
||||
),
|
||||
),
|
||||
|
||||
const Spacer(),
|
||||
|
||||
// Content Cards Area (Keeping prototype layout)
|
||||
Container(
|
||||
height: 300,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space6,
|
||||
),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
// Representative cards from prototype
|
||||
Positioned(
|
||||
top: 20,
|
||||
left: 0,
|
||||
right: 20,
|
||||
child: _ShiftOrderCard(),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
right: 0,
|
||||
left: 40,
|
||||
child: _WorkerProfileCard(),
|
||||
),
|
||||
Positioned(
|
||||
top: 60,
|
||||
right: 10,
|
||||
child: _CalendarCard(),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Spacer(),
|
||||
|
||||
// Bottom Content
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space6,
|
||||
vertical: UiConstants.space10,
|
||||
),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
t.client_authentication.get_started_page.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.displayM,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space3),
|
||||
Text(
|
||||
t.client_authentication.get_started_page
|
||||
.subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body2r.textSecondary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space8),
|
||||
|
||||
// Sign In Button
|
||||
UiButton.primary(
|
||||
text: t.client_authentication.get_started_page
|
||||
.sign_in_button,
|
||||
onPressed: () => Modular.to.toClientSignIn(),
|
||||
fullWidth: true,
|
||||
),
|
||||
|
||||
const SizedBox(height: UiConstants.space3),
|
||||
|
||||
// Create Account Button
|
||||
UiButton.secondary(
|
||||
text: t.client_authentication.get_started_page
|
||||
.create_account_button,
|
||||
onPressed: () => Modular.to.toClientSignUp(),
|
||||
fullWidth: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
const Spacer(),
|
||||
|
||||
// Content Cards Area (Keeping prototype layout)
|
||||
Container(
|
||||
height: 300,
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space6,
|
||||
),
|
||||
child: Stack(
|
||||
children: <Widget>[
|
||||
// Representative cards from prototype
|
||||
Positioned(
|
||||
top: 20,
|
||||
left: 0,
|
||||
right: 20,
|
||||
child: _ShiftOrderCard(),
|
||||
),
|
||||
Positioned(
|
||||
bottom: 40,
|
||||
right: 0,
|
||||
left: 40,
|
||||
child: _WorkerProfileCard(),
|
||||
),
|
||||
Positioned(top: 60, right: 10, child: _CalendarCard()),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
||||
const Spacer(),
|
||||
|
||||
// Bottom Content
|
||||
Padding(
|
||||
padding: const EdgeInsets.symmetric(
|
||||
horizontal: UiConstants.space6,
|
||||
vertical: UiConstants.space10,
|
||||
),
|
||||
child: Column(
|
||||
children: <Widget>[
|
||||
Text(
|
||||
t.client_authentication.get_started_page.title,
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.displayM,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space3),
|
||||
Text(
|
||||
t.client_authentication.get_started_page.subtitle,
|
||||
textAlign: TextAlign.center,
|
||||
style: UiTypography.body2r.textSecondary,
|
||||
),
|
||||
const SizedBox(height: UiConstants.space8),
|
||||
|
||||
// Sign In Button
|
||||
UiButton.primary(
|
||||
text: t
|
||||
.client_authentication
|
||||
.get_started_page
|
||||
.sign_in_button,
|
||||
onPressed: () => Modular.to.toClientSignIn(),
|
||||
fullWidth: true,
|
||||
),
|
||||
|
||||
const SizedBox(height: UiConstants.space3),
|
||||
|
||||
// Create Account Button
|
||||
UiButton.secondary(
|
||||
text: t
|
||||
.client_authentication
|
||||
.get_started_page
|
||||
.create_account_button,
|
||||
onPressed: () => Modular.to.toClientSignUp(),
|
||||
fullWidth: true,
|
||||
),
|
||||
],
|
||||
),
|
||||
),
|
||||
],
|
||||
);
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
Reference in New Issue
Block a user