Enhance Customer model to include role attribute and update related components
- Added a new `role` attribute to the `Customer` model in `customer.dart` and updated the corresponding generated files. - Modified the `AuthViewModel` to set the user role based on the logged-in user's role. - Updated UI components in `TenderDetailActions` and `DesktopTendersPage` to conditionally render elements based on the user's role. - Refactored tests to validate the new role attribute in the `Customer` model.
This commit is contained in:
@@ -2,6 +2,7 @@ import 'package:flutter/material.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:tm_app/core/theme/colors.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/view_models/auth_view_model.dart';
|
||||
import 'package:tm_app/view_models/tender_detail_view_model.dart';
|
||||
import 'package:tm_app/views/detail/widgets/meeting_time_bottom_sheet.dart';
|
||||
import 'package:tm_app/views/detail/widgets/meeting_time_dialog.dart';
|
||||
@@ -34,8 +35,9 @@ class TenderDetailActions extends StatefulWidget {
|
||||
class _TenderDetailActionsState extends State<TenderDetailActions> {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userRole = context.read<AuthViewModel>().userRole;
|
||||
return widget.isScreenBig
|
||||
? _webActions()
|
||||
? _webActions(userRole!)
|
||||
: Column(
|
||||
children: [
|
||||
Consumer<TenderDetailViewModel>(
|
||||
@@ -141,7 +143,7 @@ class _TenderDetailActionsState extends State<TenderDetailActions> {
|
||||
);
|
||||
}
|
||||
|
||||
Row _webActions() {
|
||||
Row _webActions(Role userRole) {
|
||||
return Row(
|
||||
children: [
|
||||
const Spacer(),
|
||||
@@ -207,8 +209,13 @@ class _TenderDetailActionsState extends State<TenderDetailActions> {
|
||||
if (value ==
|
||||
TenderSubmissionMode.selfApply.value) {
|
||||
if (context.mounted) {
|
||||
const FinalCompletionOfDocumentsRouteData()
|
||||
.push(context);
|
||||
if (userRole == Role.analyst) {
|
||||
const FinalCompletionOfDocumentsRouteData()
|
||||
.push(context);
|
||||
} else {
|
||||
const CompletionOfDocumentsRouteData()
|
||||
.push(context);
|
||||
}
|
||||
}
|
||||
} else if (value ==
|
||||
TenderSubmissionMode.partnership.value) {
|
||||
|
||||
@@ -52,6 +52,7 @@ class _PageSelectionDialogState extends State<PageSelectionDialog> {
|
||||
final pageNumber = index + 1;
|
||||
|
||||
return ListTile(
|
||||
contentPadding: EdgeInsets.zero,
|
||||
leading: Radio<int>(
|
||||
value: pageNumber,
|
||||
groupValue: selectedPage,
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:go_router/go_router.dart';
|
||||
import 'package:tm_app/core/utils/size_config.dart';
|
||||
import 'package:tm_app/views/shared/base_button.dart';
|
||||
|
||||
import '../../core/constants/common_strings.dart';
|
||||
import '../../core/constants/tender_submision_mode.dart';
|
||||
@@ -91,18 +90,35 @@ class _SelectSubmissionDialogState extends State<SelectSubmissionDialog> {
|
||||
// ),
|
||||
// ),
|
||||
// ),
|
||||
BaseButton(
|
||||
isEnabled: true,
|
||||
onPressed: () {
|
||||
InkWell(
|
||||
highlightColor: Colors.transparent,
|
||||
splashColor: Colors.transparent,
|
||||
onTap: () {
|
||||
context.pop();
|
||||
},
|
||||
width: 150,
|
||||
height: 56.0,
|
||||
text: CommonStrings.cancel,
|
||||
backgroundColor: Colors.transparent,
|
||||
textColor: AppColors.errorColor,
|
||||
borderColor: AppColors.errorColor,
|
||||
child: Container(
|
||||
width: 150,
|
||||
height: 56.0,
|
||||
decoration: BoxDecoration(
|
||||
color: Colors.transparent,
|
||||
borderRadius: BorderRadius.circular(100),
|
||||
border: Border.all(
|
||||
color: AppColors.errorColor,
|
||||
width: 2.0,
|
||||
),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: Text(
|
||||
CommonStrings.cancel,
|
||||
style: TextStyle(
|
||||
fontSize: 14.0.sp(),
|
||||
fontWeight: FontWeight.w500,
|
||||
color: AppColors.errorColor,
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
|
||||
SizedBox(width: 10.0.w()),
|
||||
|
||||
InkWell(
|
||||
|
||||
@@ -17,6 +17,7 @@ import 'package:tm_app/views/tenders/widgets/tenders_sort_dialog.dart';
|
||||
|
||||
import '../../../core/constants/common_strings.dart';
|
||||
import '../../../core/utils/app_toast.dart';
|
||||
import '../../../view_models/auth_view_model.dart';
|
||||
|
||||
class DesktopTendersPage extends StatefulWidget {
|
||||
const DesktopTendersPage({super.key});
|
||||
@@ -49,6 +50,7 @@ class _DesktopTendersPageState extends State<DesktopTendersPage> {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
final userRole = context.read<AuthViewModel>().userRole;
|
||||
return Scaffold(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
body: SafeArea(
|
||||
@@ -56,8 +58,8 @@ class _DesktopTendersPageState extends State<DesktopTendersPage> {
|
||||
children: [
|
||||
const DesktopNavigationWidget(currentIndex: 1),
|
||||
SizedBox(height: 48.0.h()),
|
||||
const _SearchBox(),
|
||||
const _ActionButtons(),
|
||||
if (userRole == Role.analyst) const _SearchBox(),
|
||||
if (userRole == Role.analyst) const _ActionButtons(),
|
||||
Expanded(
|
||||
child: Consumer<TendersViewModel>(
|
||||
builder: (context, vm, child) {
|
||||
|
||||
@@ -13,6 +13,7 @@ import 'package:tm_app/views/your_tenders/widgets/liked_disliked_tenders_list.da
|
||||
import 'package:tm_app/views/your_tenders/widgets/tenders_submitted.dart';
|
||||
|
||||
import '../../shared/desktop_navigation_widget.dart';
|
||||
import '../../shared/page_selection_dialog.dart';
|
||||
|
||||
class YourTendersDesktopPage extends StatefulWidget {
|
||||
const YourTendersDesktopPage({super.key});
|
||||
@@ -149,28 +150,37 @@ class _YourTendersDesktopPageState extends State<YourTendersDesktopPage>
|
||||
SizedBox(width: 10.0.w()),
|
||||
InkWell(
|
||||
onTap: () async {
|
||||
// final selectedPage = await showDialog<int>(
|
||||
// context: context,
|
||||
// builder: (context) {
|
||||
// return AlertDialog(
|
||||
// backgroundColor: AppColors.backgroundColor,
|
||||
// title: const Text(YourTendersStrings.selectPage),
|
||||
// content: SizedBox(
|
||||
// width: 200.0.w(),
|
||||
// height: 300.0.h(),
|
||||
// child: ListView.builder(
|
||||
// itemCount: viewModel.totalPages,
|
||||
// itemBuilder: (context, index) {
|
||||
// final pageNumber = index + 1;
|
||||
// return ListTile(
|
||||
// title: Text('${YourTendersStrings.page} $pageNumber'),
|
||||
// onTap: () => Navigator.pop(context, pageNumber),
|
||||
// );
|
||||
// },
|
||||
// ),
|
||||
// ),
|
||||
// );
|
||||
// },
|
||||
// );
|
||||
|
||||
final selectedPage = await showDialog<int>(
|
||||
context: context,
|
||||
builder: (context) {
|
||||
return AlertDialog(
|
||||
backgroundColor: AppColors.backgroundColor,
|
||||
title: const Text(YourTendersStrings.selectPage),
|
||||
content: SizedBox(
|
||||
width: 200.0.w(),
|
||||
height: 300.0.h(),
|
||||
child: ListView.builder(
|
||||
itemCount: viewModel.totalPages,
|
||||
itemBuilder: (context, index) {
|
||||
final pageNumber = index + 1;
|
||||
return ListTile(
|
||||
title: Text('${YourTendersStrings.page} $pageNumber'),
|
||||
onTap: () => Navigator.pop(context, pageNumber),
|
||||
);
|
||||
},
|
||||
),
|
||||
builder:
|
||||
(context) => PageSelectionDialog(
|
||||
totalPages: viewModel.totalPages,
|
||||
currentPage: viewModel.currentPage,
|
||||
),
|
||||
);
|
||||
},
|
||||
);
|
||||
|
||||
if (selectedPage != null) {
|
||||
|
||||
Reference in New Issue
Block a user