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:
amirrezaghabeli
2025-10-14 09:12:24 +03:30
parent 504fa1e80a
commit 13dbb5fae5
10 changed files with 109 additions and 53 deletions
@@ -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) {