Broker Include

This commit is contained in:
venbaittech 2025-12-05 12:04:11 +05:30
parent 6d7e6f24b9
commit 0b0a30f9d6
20 changed files with 3931 additions and 534 deletions

File diff suppressed because one or more lines are too long

View File

@ -5,7 +5,7 @@ import 'package:nhance_partner/core/routing/routes.dart';
import 'package:nhance_partner/presentation/screens/Enquiry/enquiryList.dart';
import 'package:nhance_partner/presentation/screens/Masters/PaymentMode/paymentList.dart';
import 'package:nhance_partner/presentation/screens/UserManagement/Profile/profile_web.dart';
import 'package:nhance_partner/presentation/screens/dashboard/dashboard.dart';
import 'package:nhance_partner/presentation/screens/dashboard/dashboard_nw.dart';
import 'package:nhance_partner/presentation/screens/payout/invoice_list.dart';
import '../../data/services/auth_service.dart';
@ -21,6 +21,7 @@ import '../../presentation/screens/UserManagement/Agent/agentList.dart';
import '../../presentation/screens/UserManagement/Profile/profile_mobile.dart';
import '../../presentation/screens/UserManagement/Staff/staff.dart';
import '../../presentation/screens/UserManagement/Staff/staffList.dart';
import '../../presentation/screens/dashboard/dashboard.dart';
import '../../presentation/screens/handler/enquiryList.dart';
import '../../presentation/screens/handler/enquiryListOld.dart';
import '../../presentation/screens/home/home_screen.dart';
@ -53,7 +54,8 @@ final GoRouter appRouter = GoRouter(
// ),
GoRoute(
path: AppRoutes.dashboard,
builder: (context, state) => const DashboardScreen(),
// builder: (context, state) => const DashboardScreen(),
builder: (context, state) => const Dashboard(),
),
GoRoute(

View File

@ -820,6 +820,28 @@ class ApiService {
return response;
}
Future<Map<String, dynamic>> deleteEnquiy(id, val) async {
final url = Uri.parse(
'${Env.apiUrl}/enquiry/updateEnquiryStatus?enquiry_id=$id&is_active=$val',
);
// final token = await getToken(); // Fetch token
if (_token == null) {
throw Exception('Token not found. Please log in.');
}
final headers = {
'Authorization': 'Bearer $_token',
'Content-Type': 'application/json',
'app-signature': Env.App_Signature,
// 'app-signature': 'nhance-partner-2025-signature-35468846JRhH551HK',
};
// final response = await _makePostRequestJson(url, data, headers);
final response = await _makeGetRequest(url, headers);
return response;
}
//------------------------------------ Quotation ------------------------------------------------
Future<Map<String, dynamic>> fetchQuickQuotationList(int managerId) async {

View File

@ -1,4 +1,4 @@
import 'package:firebase_app_check/firebase_app_check.dart';
// import 'package:firebase_app_check/firebase_app_check.dart';
import 'package:firebase_core/firebase_core.dart';
import 'package:firebase_messaging/firebase_messaging.dart';
import 'package:flutter/foundation.dart';
@ -62,12 +62,12 @@ Future<void> main() async {
),
);
} else {
await Firebase.initializeApp();
await FirebaseAppCheck.instance.activate(
// webProvider: ReCaptchaV3Provider('recaptcha-v3-site-key'),
androidProvider: AndroidProvider.playIntegrity,
appleProvider: AppleProvider.appAttest,
);
// await Firebase.initializeApp();
// await FirebaseAppCheck.instance.activate(
// // webProvider: ReCaptchaV3Provider('recaptcha-v3-site-key'),
// androidProvider: AndroidProvider.playIntegrity,
// appleProvider: AppleProvider.appAttest,
// );
// FirebaseMessaging.onBackgroundMessage(_firebaseMessagingBackgroundHandler);
// FirebaseMessaging messaging = FirebaseMessaging.instance;

View File

@ -600,19 +600,20 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
data: staffQuotationsPendingList,
stringFlag: "Proposal",
role: role!,
onRefresh: refresh,
),
),
if (role == 'handler') ...[
// if (role == 'handler') ...[
Expanded(
child: UnassignedEnq(
key: UniqueKey(),
title: "Unassigned Enquiries",
role: role,
role: role!,
data: unAssignedEnqList,
onRefresh: refresh,
),
),
],
// ],
],
)
: Row(
@ -737,50 +738,40 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
],
),
),
const SizedBox(height: 5),
// Container(
// child: DynamicHorizontalBarChart(
// data: [
// {"label": "Jan", "value": 30},
// {"label": "Feb", "value": 45},
// {"label": "Mar", "value": 20},
// const SizedBox(height: 5),
// if (role == 'manager')
// SizedBox(
// // replace Expanded
// height: 350, // adjust height as needed
// child: Row(
// children: [
// Expanded(
// child: UnassignedEnq(
// key: UniqueKey(),
// title: "Unassigned Enquiries",
// role: role!,
// data: unAssignedEnqList,
// onRefresh: refresh,
// ),
// ),
// SizedBox(width: 16),
// Expanded(
// child: Performance(
// title: "Performing Partner",
// data: agentsPerformanceList,
// ),
// ),
// SizedBox(width: 16),
// Expanded(
// child: Performance(
// title: "Non-Performing Partner",
// data: nonAgentsPerformanceList,
// ),
// ),
// ],
// ),
// ),
const SizedBox(height: 5),
if (role == 'manager')
SizedBox(
// replace Expanded
height: 350, // adjust height as needed
child: Row(
children: [
Expanded(
child: UnassignedEnq(
key: UniqueKey(),
title: "Unassigned Enquiries",
role: role!,
data: unAssignedEnqList,
onRefresh: refresh,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Performing Partner",
data: agentsPerformanceList,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Non-Performing Partner",
data: nonAgentsPerformanceList,
),
),
],
),
),
],
),
),
@ -1210,6 +1201,7 @@ class othersPendings extends StatelessWidget {
final String stringFlag;
String role;
final List<Map<String, dynamic>> data;
final VoidCallback? onRefresh;
othersPendings({
Key? key,
@ -1217,6 +1209,7 @@ class othersPendings extends StatelessWidget {
required this.role,
required this.data,
required this.stringFlag,
required this.onRefresh,
}) : super(key: key);
@override
@ -1228,12 +1221,33 @@ class othersPendings extends StatelessWidget {
int totalPending = 0;
int totalInProgress = 0;
int totalCompleted = 0;
int totalPrevPending = 0;
int totalPendingAll = 0;
for (var row in data) {
totalTodayAssigned += int.tryParse(row['today_assigned'] ?? '0') ?? 0;
totalPending += int.tryParse(row['pending_assigned'] ?? '0') ?? 0;
totalInProgress += int.tryParse(row['total_in_progress'] ?? '0') ?? 0;
totalCompleted += int.tryParse(row['total_completed'] ?? '0') ?? 0;
totalPending += int.tryParse(row['today_pending'] ?? '0') ?? 0;
totalInProgress += int.tryParse(row['today_in_progress'] ?? '0') ?? 0;
totalCompleted += int.tryParse(row['today_completed'] ?? '0') ?? 0;
totalPrevPending += int.tryParse(row['total_completed'] ?? '0') ?? 0;
int totalPendingdata =
int.tryParse(row['total_pending']?.toString() ?? '0') ?? 0;
int todayAssigned =
int.tryParse(row['today_assigned']?.toString() ?? '0') ?? 0;
// totalTodayAssigned += todayAssigned;
totalPendingAll += totalPendingdata;
int staffPending = totalPendingdata - todayAssigned;
// totalPrevPending += staffPending;
final rowPrevPending =
(int.tryParse(row['total_pending'] ?? '0') ?? 0) -
(int.tryParse(row['today_assigned'] ?? '0') ?? 0);
totalPrevPending += rowPrevPending < 0 ? 0 : rowPrevPending;
}
return Card(
@ -1247,7 +1261,19 @@ class othersPendings extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(title, style: _title),
InkWell(
onTap: () {
onRefresh!();
},
child: Icon(Icons.refresh, size: 18),
),
],
),
const SizedBox(height: 10),
// Header row
@ -1345,6 +1371,14 @@ class othersPendings extends StatelessWidget {
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
'Prev Pending',
textAlign: TextAlign.center,
style: _headerStyle,
),
),
// Expanded(
// flex: 2,
// child: Text(
@ -1366,6 +1400,18 @@ class othersPendings extends StatelessWidget {
itemBuilder: (context, index) {
final row = data[index];
final totalPending =
int.tryParse(row['total_pending']?.toString() ?? '0') ??
0;
final todayAssigned =
int.tryParse(row['today_assigned']?.toString() ?? '0') ??
0;
final staffPending = (totalPending - todayAssigned);
final safePending = staffPending < 0 ? 0 : staffPending;
// final staffPending = totalPending - todayAssigned;
final issuedCount = stringFlag == "Policies"
? (row['total_policis_pending'] ?? 0).toString()
: (row['total_quotation_pending'] ?? 0).toString();
@ -1396,8 +1442,8 @@ class othersPendings extends StatelessWidget {
flex: 2,
child: Text(
row['staff_name'] ?? "",
textAlign: TextAlign.center,
textAlign: TextAlign.left,
// textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
@ -1416,7 +1462,8 @@ class othersPendings extends StatelessWidget {
handleDashboardNavigation(
context,
status: "Assigned",
status: '',
// status: "Assigned",
staffId: row['staff_id'] ?? '',
role: role,
);
@ -1451,7 +1498,7 @@ class othersPendings extends StatelessWidget {
);
},
child: Text(
row['pending_assigned'] ?? "",
row['today_pending'] ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
@ -1481,7 +1528,7 @@ class othersPendings extends StatelessWidget {
},
child: Text(
row['total_in_progress'] ?? "",
row['today_in_progress'] ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
@ -1509,7 +1556,35 @@ class othersPendings extends StatelessWidget {
);
},
child: Text(
row['total_completed'] ?? "",
row['today_completed'] ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
),
),
),
Expanded(
flex: 2,
child: Material(
color: Colors.white,
child: Center(
child: InkWell(
hoverColor: Color(0xFFEAF6F4),
onTap: () async {
print(
'Awaiting Approval : ${row['total_completed']} - ${row['staff_id']}',
);
handleDashboardNavigation(
context,
status: 'PrevPending',
staffId: row['staff_id'] ?? '',
role: role,
);
},
child: Text(
safePending.toString() ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
@ -1585,6 +1660,14 @@ class othersPendings extends StatelessWidget {
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
totalPrevPending.toString(),
textAlign: TextAlign.center,
style: _headerStyle,
),
),
],
),
),

View File

@ -0,0 +1,146 @@
import 'package:flutter/material.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:nhance_partner/presentation/screens/dashboard/tabs/bussiness.dart';
import 'package:nhance_partner/presentation/screens/dashboard/tabs/chart.dart';
import 'package:nhance_partner/presentation/screens/dashboard/tabs/live.dart';
import 'package:shared_preferences/shared_preferences.dart';
import '../../../core/responsive/responsive_builder.dart';
import '../../../core/routing/routes.dart';
import '../../../core/services/api_service.dart';
import '../../layouts/main_layout.dart';
import '../../providers/manager_provider.dart';
import '../../providers/quotation_staff_proivder.dart';
import '../../providers/userRoleProvider.dart';
import '../../themes/charts/barChart.dart';
import '../staff/Enquiry/tabs/tab.dart';
import '../staff/assignStaff.dart';
final enquiriesProvider = Provider<List<Map<String, String>>>((ref) {
return List.generate(5, (i) {
return {
"reg": "rrTN64V4387",
"Insurer": "rrNew India",
"date": "rr09/09/2025",
"time": "rr11:30 AM",
};
});
});
class Dashboard extends ConsumerStatefulWidget {
const Dashboard({super.key});
@override
ConsumerState<Dashboard> createState() => _DashboardState();
}
class _DashboardState extends ConsumerState<Dashboard>
with SingleTickerProviderStateMixin {
late TabController _tabController;
// Dynamic items (4 values)
final List<String> tabs = ["Live", "Business", "Partner", "Productivity"];
@override
void initState() {
super.initState();
_tabController = TabController(length: tabs.length, vsync: this);
}
@override
void dispose() {
_tabController.dispose();
super.dispose();
}
final List<Color> tabColors = [
Colors.amber.shade100, // Live
// Color(0XFFF1556C), // Business
// Color(0XFF02A8B5), // Business
Colors.blue.shade100, // Business
Colors.orange.shade100, // Partner
Colors.green.shade100, // Productivity
];
@override
Widget build(BuildContext context) {
return MainLayout(
title: "Dashboard",
body: SafeArea(
child: Container(
// color: Colors.amber.shade100,
child: Column(
children: [
// TabBar(
// padding: EdgeInsets.zero,
// controller: _tabController,
// isScrollable: false,
// indicatorColor: Colors.teal,
// labelColor: Colors.teal,
// unselectedLabelColor: Colors.grey,
// tabs: tabs.map((e) => Tab(text: e)).toList(),
// ),
Row(
// mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: List.generate(tabs.length, (index) {
final isSelected = _tabController.index == index;
return GestureDetector(
onTap: () {
_tabController.animateTo(index);
setState(() {});
},
child: Container(
padding: const EdgeInsets.symmetric(
vertical: 2,
horizontal: 10,
),
margin: EdgeInsets.only(left: 10),
decoration: BoxDecoration(
// color: isSelected ? Colors.teal : tabColors[index],
color: tabColors[index],
borderRadius: BorderRadius.circular(5),
border: Border.all(
color: isSelected ? Colors.teal : tabColors[index],
width: 1,
),
),
child: Text(
tabs[index],
style: TextStyle(
// color: isSelected ? Colors.white : Colors.black87,
color: Colors.black87,
fontSize: 11,
fontWeight: FontWeight.w500,
),
),
),
);
}),
),
Expanded(
child: TabBarView(
controller: _tabController,
children: [
// Text('A'),
LiveDashboard(),
BussinessDashboard(),
// BarChartSample7(),
// ReportsPage(),
// UsersPage(),
// SettingsPage(),
],
),
),
],
),
),
),
);
}
}

View File

@ -11,6 +11,7 @@ import '../../layouts/main_layout.dart';
import '../../providers/manager_provider.dart';
import '../../providers/quotation_staff_proivder.dart';
import '../../providers/userRoleProvider.dart';
import '../../themes/charts/barChart.dart';
import '../staff/Enquiry/tabs/tab.dart';
import '../staff/assignStaff.dart';
@ -584,7 +585,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
? MediaQuery.of(context).size.height *
0.69 //400
: (role == 'manager')
? MediaQuery.of(context).size.height * 0.5
? MediaQuery.of(context).size.height * 0.85
: (role == 'staff' || role == 'handler')
? MediaQuery.of(context).size.height * 0.85
: MediaQuery.of(context).size.height *
@ -599,19 +600,20 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
data: staffQuotationsPendingList,
stringFlag: "Proposal",
role: role!,
onRefresh: refresh,
),
),
if (role == 'handler') ...[
// if (role == 'handler') ...[
Expanded(
child: UnassignedEnq(
key: UniqueKey(),
title: "Unassigned Enquiries",
role: role,
role: role!,
data: unAssignedEnqList,
onRefresh: refresh,
),
),
],
// ],
],
)
: Row(
@ -736,39 +738,40 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
],
),
),
const SizedBox(height: 5),
if (role == 'manager')
SizedBox(
// replace Expanded
height: 350, // adjust height as needed
child: Row(
children: [
Expanded(
child: UnassignedEnq(
key: UniqueKey(),
title: "Unassigned Enquiries",
role: role!,
data: unAssignedEnqList,
onRefresh: refresh,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Performing Partner",
data: agentsPerformanceList,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Non-Performing Partner",
data: nonAgentsPerformanceList,
),
),
],
),
),
// const SizedBox(height: 5),
// if (role == 'manager')
// SizedBox(
// // replace Expanded
// height: 350, // adjust height as needed
// child: Row(
// children: [
// Expanded(
// child: UnassignedEnq(
// key: UniqueKey(),
// title: "Unassigned Enquiries",
// role: role!,
// data: unAssignedEnqList,
// onRefresh: refresh,
// ),
// ),
// SizedBox(width: 16),
// Expanded(
// child: Performance(
// title: "Performing Partner",
// data: agentsPerformanceList,
// ),
// ),
// SizedBox(width: 16),
// Expanded(
// child: Performance(
// title: "Non-Performing Partner",
// data: nonAgentsPerformanceList,
// ),
// ),
// ],
// ),
// ),
],
),
),
@ -1198,6 +1201,7 @@ class othersPendings extends StatelessWidget {
final String stringFlag;
String role;
final List<Map<String, dynamic>> data;
final VoidCallback? onRefresh;
othersPendings({
Key? key,
@ -1205,12 +1209,47 @@ class othersPendings extends StatelessWidget {
required this.role,
required this.data,
required this.stringFlag,
required this.onRefresh,
}) : super(key: key);
@override
Widget build(BuildContext context) {
print(' Data: $data');
// Compute totals
int totalTodayAssigned = 0;
int totalPending = 0;
int totalInProgress = 0;
int totalCompleted = 0;
int totalPrevPending = 0;
int totalPendingAll = 0;
for (var row in data) {
totalTodayAssigned += int.tryParse(row['today_assigned'] ?? '0') ?? 0;
totalPending += int.tryParse(row['today_pending'] ?? '0') ?? 0;
totalInProgress += int.tryParse(row['today_in_progress'] ?? '0') ?? 0;
totalCompleted += int.tryParse(row['today_completed'] ?? '0') ?? 0;
totalPrevPending += int.tryParse(row['total_completed'] ?? '0') ?? 0;
int totalPendingdata =
int.tryParse(row['total_pending']?.toString() ?? '0') ?? 0;
int todayAssigned =
int.tryParse(row['today_assigned']?.toString() ?? '0') ?? 0;
totalTodayAssigned += todayAssigned;
totalPendingAll += totalPendingdata;
int staffPending = totalPendingdata - todayAssigned;
// totalPrevPending += staffPending;
final rowPrevPending =
(int.tryParse(row['total_pending'] ?? '0') ?? 0) -
(int.tryParse(row['today_assigned'] ?? '0') ?? 0);
totalPrevPending += rowPrevPending < 0 ? 0 : rowPrevPending;
}
return Card(
color: Colors.white,
// color: const Color(0xFFEAF6F4),
@ -1222,7 +1261,19 @@ class othersPendings extends StatelessWidget {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(title, style: _title),
InkWell(
onTap: () {
onRefresh!();
},
child: Icon(Icons.refresh, size: 18),
),
],
),
const SizedBox(height: 10),
// Header row
@ -1320,6 +1371,14 @@ class othersPendings extends StatelessWidget {
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
'Prev Pending',
textAlign: TextAlign.center,
style: _headerStyle,
),
),
// Expanded(
// flex: 2,
// child: Text(
@ -1341,6 +1400,18 @@ class othersPendings extends StatelessWidget {
itemBuilder: (context, index) {
final row = data[index];
final totalPending =
int.tryParse(row['total_pending']?.toString() ?? '0') ??
0;
final todayAssigned =
int.tryParse(row['today_assigned']?.toString() ?? '0') ??
0;
final staffPending = (totalPending - todayAssigned);
final safePending = staffPending < 0 ? 0 : staffPending;
// final staffPending = totalPending - todayAssigned;
final issuedCount = stringFlag == "Policies"
? (row['total_policis_pending'] ?? 0).toString()
: (row['total_quotation_pending'] ?? 0).toString();
@ -1350,9 +1421,9 @@ class othersPendings extends StatelessWidget {
: row['total_premium_value'];
return Container(
margin: const EdgeInsets.symmetric(vertical: 5),
margin: const EdgeInsets.symmetric(vertical: 3),
padding: const EdgeInsets.symmetric(
vertical: 5,
vertical: 4,
horizontal: 12,
),
decoration: BoxDecoration(
@ -1367,25 +1438,6 @@ class othersPendings extends StatelessWidget {
),
child: Row(
children: [
// Expanded(
// flex: 1,
// child: Text(
// (index + 1).toString(),
// textAlign: TextAlign.center,
// style: _tableDataStyle,
// ),
// ),
// if (role == 'manager') ...[
// Expanded(
// flex: 2,
// child: Text(
// row['handler_name'] ?? "",
//
// textAlign: TextAlign.center,
// style: _tableDataStyle,
// ),
// ),
// ],
Expanded(
flex: 2,
child: Text(
@ -1396,44 +1448,6 @@ class othersPendings extends StatelessWidget {
),
),
// Expanded(
// flex: 2,
// child: Text(
// row['total_assigned'] ?? "",
// // row['total_approval_pending'] ?? "",
// textAlign: TextAlign.center,
// style: _tableDataStyle,
// ),
// ),
// Expanded(
// flex: 2,
// child: Material(
// color: Colors.white,
// child: Center(
// child: InkWell(
// hoverColor: Color(0xFFEAF6F4),
// onTap: () {
// print(
// 'total_assigned : ${row['total_assigned']}',
// );
//
// handleDashboardNavigation(
// context,
// status: "Assigned",
// staffId: row['staff_id'] ?? '',
// role: role,
// );
// },
// child: Text(
// row['total_assigned'] ?? "",
// // row['total_approval_pending'] ?? "",
// textAlign: TextAlign.center,
// style: _tableDataStyle,
// ),
// ),
// ),
// ),
// ),
Expanded(
flex: 2,
child: Material(
@ -1483,7 +1497,7 @@ class othersPendings extends StatelessWidget {
);
},
child: Text(
row['pending_assigned'] ?? "",
row['today_pending'] ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
@ -1513,7 +1527,7 @@ class othersPendings extends StatelessWidget {
},
child: Text(
row['total_in_progress'] ?? "",
row['today_in_progress'] ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
@ -1541,7 +1555,35 @@ class othersPendings extends StatelessWidget {
);
},
child: Text(
row['total_completed'] ?? "",
row['today_completed'] ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
),
),
),
Expanded(
flex: 2,
child: Material(
color: Colors.white,
child: Center(
child: InkWell(
hoverColor: Color(0xFFEAF6F4),
onTap: () async {
print(
'Awaiting Approval : ${row['total_completed']} - ${row['staff_id']}',
);
handleDashboardNavigation(
context,
status: 'PrevPending',
staffId: row['staff_id'] ?? '',
role: role,
);
},
child: Text(
safePending.toString() ?? "",
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
@ -1566,6 +1608,60 @@ class othersPendings extends StatelessWidget {
},
),
),
const SizedBox(height: 8),
// Header row
Container(
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 12),
decoration: BoxDecoration(
color: Color(0xFFF1F5F9),
// color: Color(0xFFE3F9F8),
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Expanded(
flex: 2,
child: Text(
"Total",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
totalTodayAssigned.toString(),
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
totalPending.toString(),
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
totalInProgress.toString(),
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
totalPrevPending.toString(),
textAlign: TextAlign.center,
style: _headerStyle,
),
),
],
),
),
],
),
),

View File

@ -0,0 +1,48 @@
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/src/widgets/framework.dart';
import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:google_fonts/google_fonts.dart';
import '../../../themes/charts/barChart.dart';
class BussinessDashboard extends ConsumerStatefulWidget {
const BussinessDashboard({super.key});
@override
ConsumerState<BussinessDashboard> createState() => _BussinessDashboardState();
}
class _BussinessDashboardState extends ConsumerState<BussinessDashboard> {
@override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(10),
// color: Colors.white,
// color: Colors.amber.shade100,
child: Column(
children: [
Row(
children: [
Text('Product Wise', style: _headerStyle2),
// BarChart(
// dataList: [
// _BarData(Colors.blue, 10, 8),
// _BarData(Colors.orange, 12, 10),
// _BarData(Colors.green, 8, 5),
// ],
// labels: ["A", "B", "C"],
// ),
],
),
],
),
);
}
}
final _headerStyle2 = GoogleFonts.poppins(
fontSize: 12,
color: Colors.black,
fontWeight: FontWeight.w500,
);

View File

@ -0,0 +1,242 @@
import 'dart:math' as math;
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/material.dart';
import '../../../themes/charts/appChartColors.dart';
class BarChartSample7 extends StatefulWidget {
BarChartSample7({super.key});
final shadowColor = const Color(0xFFCCCCCC);
final dataList = [
_BarData(AppColors.contentColorYellow, 18, 18),
_BarData(AppColors.contentColorGreen, 17, 8),
_BarData(AppColors.contentColorOrange, 10, 15),
_BarData(AppColors.contentColorPink, 2.5, 5),
_BarData(AppColors.contentColorBlue, 2, 2.5),
_BarData(AppColors.contentColorRed, 2, 2),
];
@override
State<BarChartSample7> createState() => _BarChartSample7State();
}
class _BarChartSample7State extends State<BarChartSample7> {
BarChartGroupData generateBarGroup(
int x,
Color color,
double value,
double shadowValue,
) {
return BarChartGroupData(
x: x,
barRods: [
BarChartRodData(toY: value, color: color, width: 6),
BarChartRodData(toY: shadowValue, color: widget.shadowColor, width: 6),
],
showingTooltipIndicators: touchedGroupIndex == x ? [0] : [],
);
}
int touchedGroupIndex = -1;
int rotationTurns = 1;
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [
Row(
children: [
Expanded(child: Container()),
const Text(
'Horizontal Bar Chart',
style: TextStyle(color: AppColors.mainTextColor1, fontSize: 20),
),
Expanded(
child: Align(
alignment: Alignment.centerRight,
child: Tooltip(
message: 'Rotate the chart 90 degrees (cw)',
child: IconButton(
onPressed: () {
setState(() {
rotationTurns += 1;
});
},
icon: RotatedBox(
quarterTurns: rotationTurns - 1,
child: const Icon(Icons.rotate_90_degrees_cw),
),
),
),
),
),
],
),
const SizedBox(height: 18),
AspectRatio(
aspectRatio: 1.4,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceBetween,
rotationQuarterTurns: rotationTurns,
borderData: FlBorderData(
show: true,
border: Border.symmetric(
horizontal: BorderSide(
color: AppColors.borderColor.withValues(alpha: 0.2),
),
),
),
titlesData: FlTitlesData(
show: true,
leftTitles: const AxisTitles(
drawBelowEverything: true,
sideTitles: SideTitles(showTitles: true, reservedSize: 30),
),
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
reservedSize: 50,
getTitlesWidget: (value, meta) {
final index = value.toInt();
return SideTitleWidget(
meta: meta,
child: Text('data'),
// child: _IconWidget(
// color: widget.dataList[index].color,
// isSelected: touchedGroupIndex == index,
// ),
);
},
),
),
// rightTitles: const AxisTitles(),
// topTitles: const AxisTitles(),
),
gridData: FlGridData(
show: true,
drawVerticalLine: false,
getDrawingHorizontalLine: (value) => FlLine(
color: AppColors.borderColor.withValues(alpha: 0.2),
strokeWidth: 1,
),
),
barGroups: widget.dataList.asMap().entries.map((e) {
final index = e.key;
final data = e.value;
return generateBarGroup(
index,
data.color,
data.value,
data.shadowValue,
);
}).toList(),
maxY: 20,
barTouchData: BarTouchData(
enabled: true,
handleBuiltInTouches: false,
touchTooltipData: BarTouchTooltipData(
getTooltipColor: (group) => Colors.transparent,
tooltipMargin: 0,
getTooltipItem:
(
BarChartGroupData group,
int groupIndex,
BarChartRodData rod,
int rodIndex,
) {
return BarTooltipItem(
rod.toY.toString(),
TextStyle(
fontWeight: FontWeight.bold,
color: rod.color,
fontSize: 18,
shadows: const [
Shadow(color: Colors.black26, blurRadius: 12),
],
),
);
},
),
touchCallback: (event, response) {
if (event.isInterestedForInteractions &&
response != null &&
response.spot != null) {
setState(() {
touchedGroupIndex = response.spot!.touchedBarGroupIndex;
});
} else {
setState(() {
touchedGroupIndex = -1;
});
}
},
),
),
),
),
],
),
);
}
}
class _BarData {
const _BarData(this.color, this.value, this.shadowValue);
final Color color;
final double value;
final double shadowValue;
}
class _IconWidget extends ImplicitlyAnimatedWidget {
const _IconWidget({required this.color, required this.isSelected})
: super(duration: const Duration(milliseconds: 300));
final Color color;
final bool isSelected;
@override
ImplicitlyAnimatedWidgetState<ImplicitlyAnimatedWidget> createState() =>
_IconWidgetState();
}
class _IconWidgetState extends AnimatedWidgetBaseState<_IconWidget> {
Tween<double>? _rotationTween;
@override
Widget build(BuildContext context) {
final rotation = math.pi * 4 * _rotationTween!.evaluate(animation);
final scale = 1 + _rotationTween!.evaluate(animation) * 0.5;
return Transform(
transform: Matrix4.identity()..scale(0.8),
// transform: Matrix4.rotationZ(rotation)..scaled(scale, scale, scale),
// transform: Matrix4.rotationZ(rotation)..scale(scale, scale, scale),
origin: const Offset(14, 14),
child: Icon(
widget.isSelected ? Icons.face_retouching_natural : Icons.face,
color: widget.color,
size: 28,
),
);
}
@override
void forEachTween(TweenVisitor<dynamic> visitor) {
_rotationTween =
visitor(
_rotationTween,
widget.isSelected ? 1.0 : 0.0,
(dynamic value) => Tween<double>(
begin: value as double,
end: widget.isSelected ? 1.0 : 0.0,
),
)
as Tween<double>?;
}
}

File diff suppressed because it is too large Load Diff

View File

@ -2413,6 +2413,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInlineTST> {
print("Enquiry saved successfully");
// RESET FORM
raiseEnqKey.currentState?.resetFormFields();
getStaffDetailsForEnquiryAssignment(userId);
} catch (e) {
showDialog(
context: context,

View File

@ -10,7 +10,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:nhance_partner/presentation/screens/dashboard/dashboard.dart';
import 'package:nhance_partner/presentation/screens/dashboard/dashboard_nw.dart';
import 'package:nhance_partner/presentation/screens/staff/Enquiry/quotationPopUpAccptReject.dart';
import 'package:nhance_partner/presentation/screens/staff/Enquiry/raise_enq_form.dart';
import 'package:nhance_partner/presentation/screens/staff/Enquiry/staff_policy.dart';

View File

@ -10,7 +10,7 @@ import 'package:flutter_riverpod/flutter_riverpod.dart';
import 'package:go_router/go_router.dart';
import 'package:google_fonts/google_fonts.dart';
import 'package:intl/intl.dart';
import 'package:nhance_partner/presentation/screens/dashboard/dashboard.dart';
import 'package:nhance_partner/presentation/screens/dashboard/dashboard_nw.dart';
import 'package:nhance_partner/presentation/screens/staff/Enquiry/quotationPopUpAccptReject.dart';
import 'package:nhance_partner/presentation/screens/staff/Enquiry/raise_enq_form.dart';
import 'package:nhance_partner/presentation/screens/staff/Enquiry/staff_policy.dart';
@ -96,6 +96,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
'remarks',
];
String formRebuildKey = UniqueKey().toString();
Map<int, bool> isEditingRow = {};
Map<int, Map<String, TextEditingController>> rowControllers = {};
@ -206,8 +208,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
String? selectedBroker;
final ScrollController _horizontalScrollController = ScrollController();
late Timer timer;
// late Timer timer;
Timer? timer;
int selectedSeconds = 30;
bool isActionable = false;
//---------------------- Assign Staff Ends -------------------------------- //
@ -218,12 +221,14 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
super.initState();
apiService = ApiService();
timer = Timer.periodic(Duration(seconds: 10), (Timer t) => callRefresh());
// timer = Timer.periodic(Duration(seconds: 10), (Timer t) => callRefresh()); //static
startTimer();
for (String field in tabHeader) {
controllers[field] = TextEditingController();
}
_initializeToken();
loadPreferences();
Future.microtask(() async {
// final id = ref.read(managerIdProvider);
roleId = ref.read(userRoleProvider);
@ -280,16 +285,53 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
getPaymentMode();
}
Future<void> loadPreferences() async {
final prefs = await SharedPreferences.getInstance();
setState(() {
isActionable = prefs.getBool('isActionable') ?? false;
selectedSeconds = prefs.getInt('selectedSeconds') ?? 30;
_showFilterRow = true;
});
startTimer(); // restart timer using stored value
}
Future<void> resetPreferences() async {
final prefs = await SharedPreferences.getInstance();
await prefs.remove('isActionable');
await prefs.remove('selectedSeconds');
setState(() {
// isActionable = false; // default
selectedSeconds = 30; // default
});
startTimer(); // restart timer with default value
print("Storage cleared & reset completed");
}
Future<void> _initializeToken() async {
_token = await AuthService.getToken();
print("APISERTOKEN - $_token");
}
void startTimer() {
timer?.cancel(); // stop existing timer
timer = Timer.periodic(Duration(seconds: selectedSeconds), (Timer t) {
callRefresh();
});
}
void callRefresh() {
print('Call Refresh');
if (!isActionable) {
print('Call Refresh isActionable');
refrshfilterDateRange();
autoRefrshfilterDateRange();
}
}
@ -321,6 +363,26 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
super.dispose();
}
Future<void> autoRefrshfilterDateRange() async {
print('autorefrshfilterDateRange');
// setState(() async {
final prefs = await SharedPreferences.getInstance();
// _formKey.currentState?.reset();
final int parsedManagerId = int.tryParse(managerId.toString()) ?? 0;
print('autorefrshfilterDateRange 1');
getStaffList(
// managerId,
parsedManagerId,
roleId,
SelectedStatus: SelectedStatus ?? '',
SelectedStaffId: SelectedStaffId ?? '',
);
_searchStaffController.clear();
print('refrshfilterDateRange 2');
}
Future<void> refrshfilterDateRange() async {
print('refrshfilterDateRange');
// setState(() async {
@ -526,7 +588,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
String SelectedStatus = '',
String SelectedStaffId = '',
}) async {
print('A72 => Fns called => $managerId | $role');
print('DAJJshA72 => Fns called => $managerId | $role');
setState(() {
isLoading = true;
});
@ -538,13 +600,40 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
final toDateVal = controllers['endDate']?.text ?? '';
final dateFormat = DateFormat('dd-MM-yyyy');
if (dashboardKey != 'fromDashboard' &&
if (dashboardKey == 'fromDashboard' && SelectedStatus == "PrevPending") {
// For PREV PENDING set date range until yesterday
final today = DateTime.now();
// Change to dd-MM-yyyy
final dateFormat = DateFormat('dd-MM-yyyy');
final yesterday = today.subtract(Duration(days: 1));
fromDt = dateFormat.format(yesterday.subtract(Duration(days: 15)));
toDt = dateFormat.format(yesterday);
print('PrevPending FROM TO - $fromDt - $toDt');
} else if (dashboardKey == 'fromDashboard' &&
SelectedStatus != "PrevPending" &&
SelectedStatus != '') {
// For PREV PENDING set date range until yesterday
final today = DateTime.now();
// Change to dd-MM-yyyy
final dateFormat = DateFormat('dd-MM-yyyy');
fromDt = dateFormat.format(today);
toDt = dateFormat.format(today);
print('PrevPending FROM TO - $fromDt - $toDt');
} else if (dashboardKey != 'fromDashboard' &&
fromDateVal == '' &&
toDateVal == '') {
print("ENQ LIST PAGE");
final today = DateTime.now();
fromDt = dateFormat.format(today.subtract(Duration(days: 15)));
// fromDt = dateFormat.format(today);
toDt = dateFormat.format(today);
print('Enq FROM TO - $fromDt - $toDt');
@ -560,7 +649,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
role,
fromDate: fromDt,
toDate: toDt,
selectedStatus: SelectedStatus != null ? SelectedStatus : '',
selectedStatus:
(SelectedStatus != '' && SelectedStatus != 'PrevPending')
? SelectedStatus
: '',
selectedStaffId: SelectedStaffId ?? '',
);
@ -627,18 +719,27 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
return (item['agent_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['agent_code'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['reg_no'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['insurer_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['enquiry_status'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['assigned_to_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['insured_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['insurer_short_name'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
(item['premium_amount'] ?? '-').toLowerCase().contains(
query.toLowerCase(),
) ||
@ -716,6 +817,18 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
();
}
Future<void> handleDeleteEnq(Map<String, dynamic> item) async {
final id = int.tryParse(item['id'].toString()) ?? 0;
idPrimary = item['id'];
print("handleDeleteEnq - $idPrimary");
final res = await apiService.deleteEnquiy(id, 0);
if (res['status'] == 'success') {
autoRefrshfilterDateRange();
}
}
void handleEdit(Map<String, dynamic> item) {
print("handleEdit");
@ -745,6 +858,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
selectedInsurer = item['insurer_id'];
selectedStaff = item['assigned_to'];
selectedBroker = item['broker_id'];
setState(() {});
}
@ -983,9 +1097,24 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
horizontal: 8,
vertical: 3,
),
child: Text(
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
item['name'].toString(),
style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
style: GoogleFonts.inter(
fontSize: 12,
color: Colors.black,
),
),
Text(
"(${item['today_assigned']} / ${item['total_pending']})",
style: GoogleFonts.poppins(
fontSize: 10,
color: Colors.blueGrey.shade200,
),
),
],
),
);
},
@ -1177,7 +1306,12 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
(item) => item['id'].toString() == selectedBroker,
orElse: () => {},
);
return SizedBox(
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Broker', style: _subLabelTimeStyle),
SizedBox(height: 5),
SizedBox(
height: 30,
width: MediaQuery.of(context).size.width * 0.07,
child: DropdownSearch<Map<String, dynamic>>(
@ -1214,7 +1348,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
alignment: Alignment.centerLeft,
child: Text(
selectedItem != null ? selectedItem['name'].toString() : "",
style: GoogleFonts.poppins(fontSize: 11, color: Colors.black),
style: GoogleFonts.poppins(
fontSize: 11,
color: Color(0XFF6366F1),
),
overflow: TextOverflow.ellipsis,
maxLines: 1,
softWrap: false,
@ -1226,15 +1363,22 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
label: "Select Broker",
).copyWith(
filled: true,
fillColor: Colors.white, // 👈 makes the dropdown input white
fillColor:
Colors.white, // 👈 makes the dropdown input white
isDense: true,
border: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: const BorderSide(color: Colors.black, width: 0.1),
borderSide: const BorderSide(
color: Color(0XFF6366F1),
width: 0.1,
),
),
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.circular(5),
borderSide: const BorderSide(color: Colors.black, width: 0.1),
borderSide: const BorderSide(
color: Color(0XFF6366F1),
width: 0.5,
),
),
contentPadding: EdgeInsets.symmetric(
horizontal: 8,
@ -1252,15 +1396,21 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
),
showSearchBox: true,
searchFieldProps: TextFieldProps(
autofocus: true,
style: GoogleFonts.inter(fontSize: 11, color: Colors.black),
decoration: InputDecoration(
contentPadding: EdgeInsets.all(1),
filled: true,
fillColor: Colors.white,
hintText: "Search Broker...",
hintStyle: GoogleFonts.inter(fontSize: 12, color: Colors.black),
hintStyle: GoogleFonts.inter(
fontSize: 12,
color: Colors.black,
),
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white), // 👈 Normal border
borderSide: BorderSide(
color: Colors.white,
), // 👈 Normal border
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
@ -1274,7 +1424,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
itemBuilder: (context, item, isDisabled, isSelected) {
return Container(
// color: isSelected ? Colors.blue.withOpacity(0.1) : null,
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 3),
padding: const EdgeInsets.symmetric(
horizontal: 8,
vertical: 3,
),
child: Text(
item['name'].toString(),
style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
@ -1294,6 +1447,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
}
},
),
),
],
);
}
@ -1582,7 +1737,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
SizedBox(height: 5),
SizedBox(
width: MediaQuery.of(context).size.width * 0.08,
child: ThemedFormInlineField(
child: ThemedFormField(
controller: controllers['regNo']!,
hintText: 'Vehicle Number',
borderColor: Color(0XFF6366F1),
@ -1593,7 +1748,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
FilteringTextInputFormatter.allow(RegExp(r'[A-Za-z0-9- ]')),
],
validator: (value) => Validators.requiredVechileNum(value, "regNo"),
widthNone: true,
// widthNone: true,
),
),
],
@ -2425,6 +2580,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
buildSelectStaffMem(context),
buildAgentName(context, fromHeader: false),
buildInsurer(context),
buildBroker(context),
buildInsuredName(context),
buildVehicleNumber(context),
@ -2537,7 +2693,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
splashRadius: 14, // ripple radius
onPressed: () {
setState(() {
isActionable = false;
// isActionable = false;
bool isOpen = rowExpanded[id] ?? false;
rowExpanded.clear(); // close all
@ -2866,6 +3022,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
docUploadedFile = null;
});
refrshfilterDateRange();
setState(() {});
return;
}
@ -2911,7 +3068,8 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
Container(
// height: MediaQuery.of(context).size.height*0.
child: RaiseEnqForm(
key: raiseEnqKey,
// key: raiseEnqKey,
key: ValueKey(formRebuildKey),
onSubmit: (dataSet) async {
print('Check checking dataSet $dataSet');
try {
@ -2919,6 +3077,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
print("Enquiry saved successfully");
// RESET FORM
raiseEnqKey.currentState?.resetFormFields();
// REBUILD THE ENTIRE FORM
setState(() {
formRebuildKey = UniqueKey().toString();
});
} catch (e) {
showDialog(
context: context,
@ -3038,9 +3200,9 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
print("Dialog closed");
print("Dialog result: $result");
if (result) {
setState(() {
isActionable = false;
});
// setState(() {
// isActionable = false;
// });
refrshfilterDateRange();
}
}
@ -3101,17 +3263,119 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
});
},
),
SizedBox(width: 10),
Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(10),
border: Border.all(color: Color(0xFFE2E8F0), width: 1),
),
child: Row(
children: [
Container(
// color: Colors.yellow.shade50,
child: Row(
mainAxisSize: MainAxisSize.min,
children: [
Text(
isActionable ? "OFF" : "ON",
style: GoogleFonts.poppins(
fontSize: 10,
color: !isActionable ? Colors.green : Colors.grey,
),
),
SizedBox(
height: 10,
width: 30,
child: Padding(
padding: EdgeInsets.zero,
child: Transform.scale(
scale: 0.4,
child: Switch(
value: !isActionable,
onChanged: (v) async {
bool newValue = !v;
setState(() => isActionable = newValue);
final prefs =
await SharedPreferences.getInstance();
await prefs.setBool(
'isActionable',
newValue,
);
},
),
),
),
),
],
),
),
Tooltip(
message: 'Set AutoRefresh Timer',
child: Container(
padding: EdgeInsets.symmetric(horizontal: 5),
decoration: BoxDecoration(
// color: Colors.white,
// borderRadius: BorderRadius.circular(30),
border: Border(
left: BorderSide(
color: Color(0xFFE2E8F0),
width: 2,
),
// right: BorderSide(
// color: Color(0xFFE2E8F0),
// width: 2,
// ),
),
),
height: 30,
child: DropdownButton<int>(
value: selectedSeconds,
underline: SizedBox(),
items: [30, 45, 60].map((e) {
return DropdownMenuItem(
value: e,
child: Text(
"$e sec",
style: GoogleFonts.poppins(fontSize: 11),
),
);
}).toList(),
onChanged: (value) async {
setState(() {
selectedSeconds = value!;
startTimer(); // restart timer with new value
});
final prefs = await SharedPreferences.getInstance();
await prefs.setInt('selectedSeconds', value!);
},
),
),
),
//
// InkWell(
// onTap: () {
// resetPreferences();
// },
// child: Icon(Icons.refresh, size: 18),
// ),
],
),
),
SizedBox(width: 10),
MouseRegion(
onEnter: (_) {
setState(() {
isActionable = true;
});
// setState(() {
// isActionable = true;
// });
},
onExit: (_) {
setState(() {
// isActionable = false;
isActionable = _searchStaffController.text.isNotEmpty;
});
// setState(() {
// // isActionable = false;
// isActionable = _searchStaffController.text.isNotEmpty;
// });
},
child: ThemedSearchField(
hintText: 'Search',
@ -3725,6 +3989,10 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
// Insurer Name
DataCell(
Column(
crossAxisAlignment: CrossAxisAlignment.start,
mainAxisAlignment: MainAxisAlignment.center,
children: [
SizedBox(
width: 60,
child: Text(
@ -3732,6 +4000,17 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
style: _dataBoldthm2,
),
),
Tooltip(
message: 'Broker : ${item['broker_name']}',
child: Text(
item['broker_name'] != null
? _truncateText(item['broker_name'], 8)
: '-',
style: _dataBoldthm4,
),
),
],
),
),
DataCell(
@ -3820,7 +4099,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
DataCell(
SizedBox(
width: 70.0,
width: 80.0,
child: Row(
children: [
Tooltip(
@ -3874,13 +4153,13 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
tooltip: "Edit",
onPressed: () {
setState(() {
isActionable = false;
// isActionable = false;
bool isOpen = rowExpanded[id] ?? false;
rowExpanded.clear(); // close all
if (!isOpen) {
isActionable = true;
// isActionable = true;
rowExpanded[id] =
true; // open only if previously closed
}
@ -3943,6 +4222,28 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
),
),
),
if (item['enquiry_status'] != 'Completed') ...[
IconButton(
padding: EdgeInsets.zero, // remove outer padding
constraints: BoxConstraints(
// reduce clickable area
minWidth: 24,
minHeight: 24,
),
icon: Icon(
Icons.delete,
color: Colors.red.shade400,
size: 15,
),
tooltip: "Delete Enquiry",
onPressed: () {
setState(() {});
handleDeleteEnq(item);
},
),
],
],
),
),
@ -4556,7 +4857,73 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
((item['enquiry_status'] == 'Assigned') &&
(item['quotation_id'] == null)))
? Text('-')
: ThemedUploadField(
: Row(
children: [
if ((((item['enquiry_status'] == 'Completed') &&
(item['quotation_id'] != null)))) ...[
// Text(item['policy_pdf_file_name']),
Tooltip(
message: 'Download Policy File',
child: InkWell(
onTap: () => apiService.downloadFile(
apiUrl:
'api/policy/downloadPolicyFile?policy_id=${item["policy_id"]}&file_type=policy_pdf',
apiId: item["policy_id"],
localFile: null,
fileName: item['policy_pdf_file_name'],
),
child: Icon(
Icons.file_download,
size: 14,
color: Colors.blueAccent,
),
),
),
],
Builder(
builder: (buttonContext) => Material(
color: Colors.white,
child: InkWell(
// hoverColor: Color(0xFFEAF6F4),
onTap: () async {
// Get overlay and button position RELATIVE to InkWell
final RenderBox button =
buttonContext.findRenderObject() as RenderBox;
final RenderBox overlay =
Overlay.of(
buttonContext,
).context.findRenderObject()
as RenderBox;
final Offset position = button.localToGlobal(
Offset.zero,
ancestor: overlay,
);
await showMenu(
context: buttonContext,
position: RelativeRect.fromLTRB(
position.dx,
position.dy + button.size.height,
overlay.size.width,
// overlay.size.width - position.dx,
0,
),
items: [
PopupMenuItem(
child: Column(
crossAxisAlignment:
CrossAxisAlignment.start,
mainAxisSize: MainAxisSize.min,
children: [
Text(
'Upload Policy PDF',
style: _dataBold,
),
SizedBox(height: 10),
ThemedUploadField(
// key: ValueKey(selectedFileNames),
// hintText: item['policy_pdf_file_name'] ?? "Upload Document",
hintText:
@ -4569,24 +4936,34 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
padVertical: 5,
fontSZ: 11,
borderCirculr: 5,
txtwidth: ResponsiveLayout.isMobile(context)
txtwidth:
ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.18,
: MediaQuery.of(
context,
).size.width *
0.18,
borderColor: Color(0xFFE2E8F0),
// highlightColor: Color(0xFF50A398),
// backgroundColor: Color(0xFFEDF6F5),
onFileSelected: (fileName, file) async {
print("Picked file: $fileName (${file.size} bytes)");
print(
"Picked file: $fileName (${file.size} bytes)",
);
if (lastPickedFile == fileName) {
print("❌ Cancel clicked. Ignoring old file.");
print(
"❌ Cancel clicked. Ignoring old file.",
);
setState(() {
print('Clear Fields');
selectedFileNames = null; // clears the field
selectedFileNames =
null; // clears the field
docUploadedFile = null;
print('Clear Fields - 1');
});
// Navigator.of(context).pop();
// refrshfilterDateRange();
return;
}
@ -4603,45 +4980,87 @@ class EnquiryStaffState extends ConsumerState<EnquiryListStaffInline> {
fileName == null ||
fileName.isEmpty ||
file.size == 0) {
print("❌ File selection canceled. No upload.");
print(
"❌ File selection canceled. No upload.",
);
return;
}
print("Picked file: $fileName (${file.size} bytes)");
print(
"Picked file: $fileName (${file.size} bytes)",
);
if (!fileName.toLowerCase().endsWith('.pdf')) {
if (!fileName
.toLowerCase()
.endsWith('.pdf')) {
ToastHelper.showErrorToast(
context,
'Only PDF files are allowed.',
);
ScaffoldMessenger.of(context).showSnackBar(
ScaffoldMessenger.of(
context,
).showSnackBar(
const SnackBar(
content: Text('Only PDF files are allowed.'),
content: Text(
'Only PDF files are allowed.',
),
backgroundColor: Colors.red,
),
);
return; // Stop here
}
print("Picked file: $fileName (${file.size} bytes)");
print(
"Picked file: $fileName (${file.size} bytes)",
);
setState(() {
docUploadedFile = file;
});
await uploadPolicyPDF(
file: docUploadedFile,
data: {
"quotation_id": item["quotation_id"],
"quotation_id":
item["quotation_id"],
"manager_id": managerId,
"created_by": userId,
"updated_by": userId,
"id": item["policy_id"], // ONLY while updating
"id":
item["policy_id"], // ONLY while updating
},
);
Navigator.of(context).pop();
// if (selectedBrokerName == 'Nhance') {
// handleUploadPolicy();
// }
},
),
],
),
),
],
color: Colors.white,
);
},
child: Tooltip(
message:
'Click and Upload Policy PDF', // what appears on hover/long press
waitDuration: const Duration(
milliseconds: 500,
), // optional
showDuration: const Duration(
seconds: 2,
), // optional
child: Icon(
Icons.file_upload_outlined,
size: 15,
color: Colors.green,
),
),
),
),
),
],
),
),
),

View File

@ -192,6 +192,8 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
// 3. Reset form validation
_formKey.currentState?.reset();
setState(() {});
}
Future<void> getVehicleType() async {
@ -365,6 +367,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
// color: Color(0xFFFCFCFC),
// margin: const EdgeInsets.symmetric(vertical: 8),
padding: const EdgeInsets.symmetric(vertical: 8, horizontal: 25),
height: MediaQuery.of(context).size.height * 0.16,
decoration: BoxDecoration(
color: Colors.white,
// color: Colors.amber,
@ -387,7 +390,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
key: _formKey,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
crossAxisAlignment: CrossAxisAlignment.end,
crossAxisAlignment: CrossAxisAlignment.center,
children: [
buildAgentName(context, fromHeader: true),
if (roleId != 'staff') ...[buildSelectStaffMem(context)],
@ -398,6 +401,7 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
// buildInsuredName(context, fromHeader: true),
buildVehicleNumber(context),
Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
buildRefresh(context),
SizedBox(width: 5),
@ -952,9 +956,25 @@ class RaiseEnqFormState extends ConsumerState<RaiseEnqForm> {
horizontal: 8,
vertical: 3,
),
child: Text(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
Text(
item['name'].toString(),
style: GoogleFonts.inter(fontSize: 12, color: Colors.black),
style: GoogleFonts.inter(
fontSize: 12,
color: Colors.black,
),
),
Text(
"(${item['today_assigned']} / ${item['total_pending']})",
style: GoogleFonts.poppins(
fontSize: 10,
color: Colors.blueGrey.shade200,
),
),
],
),
);
},

View File

@ -0,0 +1,25 @@
import 'package:flutter/material.dart';
class AppColors {
static const Color primary = contentColorCyan;
static const Color menuBackground = Color(0xFF090912);
static const Color itemsBackground = Color(0xFF1B2339);
static const Color pageBackground = Color(0xFF282E45);
static const Color mainTextColor1 = Colors.white;
static const Color mainTextColor2 = Colors.white70;
static const Color mainTextColor3 = Colors.white38;
static const Color mainGridLineColor = Colors.white10;
static const Color borderColor = Colors.white54;
static const Color gridLinesColor = Color(0x11FFFFFF);
static const Color contentColorBlack = Colors.black;
static const Color contentColorWhite = Colors.white;
static const Color contentColorBlue = Color(0xFF2196F3);
static const Color contentColorYellow = Color(0xFFFFC300);
static const Color contentColorOrange = Color(0xFFFF683B);
static const Color contentColorGreen = Color(0xFF3BFF49);
static const Color contentColorPurple = Color(0xFF6E1BFF);
static const Color contentColorPink = Color(0xFFFF3AF2);
static const Color contentColorRed = Color(0xFFE80054);
static const Color contentColorCyan = Color(0xFF50E4FF);
}

View File

@ -1,87 +1,136 @@
// import 'package:fl_chart/fl_chart.dart';
// import 'package:flutter/material.dart';
//
// class DynamicHorizontalBarChart extends StatelessWidget {
// final List<Map<String, dynamic>> data;
// // Example:
// // [
// // {"label": "Apple", "value": 35},
// // {"label": "Banana", "value": 20},
// // {"label": "Orange", "value": 15},
// // ]
//
// const DynamicHorizontalBarChart({super.key, required this.data});
//
// @override
// Widget build(BuildContext context) {
// double maxValue = data
// .map((e) => e["value"] as double)
// .reduce((a, b) => a > b ? a : b);
//
// return SizedBox(
// height: data.length * 50,
// child: BarChart(
// BarChartData(
// maxY: maxValue + 10,
// barTouchData: BarTouchData(enabled: false),
//
// titlesData: FlTitlesData(
// leftTitles: AxisTitles(
// sideTitles: SideTitles(
// showTitles: true,
// reservedSize: 100,
// getTitlesWidget: (value, meta) {
// int index = value.toInt();
// if (index < data.length) {
// return Text(
// data[index]["label"],
// style: const TextStyle(fontSize: 12),
// );
// }
// return Container();
// },
// ),
// ),
// rightTitles: AxisTitles(),
// topTitles: AxisTitles(),
// bottomTitles: AxisTitles(),
// ),
//
// gridData: FlGridData(show: false),
// borderData: FlBorderData(show: false),
//
// barGroups: List.generate(data.length, (index) {
// final item = data[index];
// final double value = item["value"] * 1.0;
//
// return BarChartGroupData(
// x: index,
// barRods: [
// BarChartRodData(
// toY: value,
// width: 25,
// color: Colors.teal,
// borderRadius: BorderRadius.circular(5),
//
// // 🟩 LABEL INSIDE THE BAR
// rodStackItems: [
// BarChartRodStackItem(
// 0,
// value,
// Colors.transparent,
// // BorderSide(),
// // StackItemLabel(
// // label: "${value.toInt()}",
// // labelStyle: const TextStyle(color: Colors.white),
// // ),
// ),
// ],
// ),
// ],
// );
// }),
// ),
// ),
// );
// }
// }
import 'package:fl_chart/fl_chart.dart';
import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'appChartColors.dart';
class BarChart extends StatefulWidget {
final List<_BarData>? dataList;
final List<String>? labels;
final String title;
final double maxY;
final int initialRotation;
const BarChart(
BarChartData barChartData, {
super.key,
this.dataList,
this.labels,
this.title = "Horizontal Bar Chart",
this.maxY = 20,
this.initialRotation = 1,
});
final shadowColor = const Color(0xFFCCCCCC);
@override
State<BarChart> createState() => _BarChartState();
}
class _BarChartState extends State<BarChart> {
int touchedGroupIndex = -1;
late int rotationTurns;
@override
void initState() {
super.initState();
rotationTurns = widget.initialRotation;
}
BarChartGroupData generateBarGroup(
int x,
Color color,
double value,
double shadowValue,
) {
return BarChartGroupData(
x: x,
barRods: [
BarChartRodData(toY: value, color: color, width: 6),
BarChartRodData(toY: shadowValue, color: widget.shadowColor, width: 6),
],
showingTooltipIndicators: touchedGroupIndex == x ? [0] : [],
);
}
@override
Widget build(BuildContext context) {
return Padding(
padding: const EdgeInsets.all(24),
child: Column(
children: [
Row(
children: [
const Spacer(),
Text(
widget.title,
style: const TextStyle(
color: AppColors.mainTextColor1,
fontSize: 20,
),
),
Spacer(),
IconButton(
onPressed: () {
setState(() => rotationTurns += 1);
},
icon: RotatedBox(
quarterTurns: rotationTurns - 1,
child: const Icon(Icons.rotate_90_degrees_cw),
),
),
],
),
const SizedBox(height: 18),
AspectRatio(
aspectRatio: 1.4,
child: BarChart(
BarChartData(
alignment: BarChartAlignment.spaceBetween,
rotationQuarterTurns: rotationTurns,
borderData: FlBorderData(show: false),
titlesData: FlTitlesData(
bottomTitles: AxisTitles(
sideTitles: SideTitles(
showTitles: true,
getTitlesWidget: (value, meta) {
final i = value.toInt();
if (i >= widget.labels!.length) return const SizedBox();
return SideTitleWidget(
meta: meta,
child: Text(widget.labels![i]),
);
},
),
),
leftTitles: const AxisTitles(),
),
gridData: const FlGridData(show: false),
barGroups: widget.dataList?.asMap().entries.map((e) {
final index = e.key;
final data = e.value;
return generateBarGroup(
index,
data.color,
data.value,
data.shadowValue,
);
}).toList(),
maxY: widget.maxY,
),
// dataList: [],
// labels: [],
),
),
],
),
);
}
}
class _BarData {
final Color color;
final double value;
final double shadowValue;
const _BarData(this.color, this.value, this.shadowValue);
}

View File

@ -200,7 +200,7 @@ class _DateFilterRowState extends ConsumerState<DateFilterRow> {
message: 'Filter',
child: IconButton(
icon: const Icon(
Icons.filter_alt_outlined,
Icons.search_rounded,
size: 18,
color: const Color(0xFF94A3B8),
),

View File

@ -7,7 +7,6 @@ import Foundation
import connectivity_plus
import file_picker
import firebase_app_check
import firebase_auth
import firebase_core
import firebase_messaging
@ -23,7 +22,6 @@ import url_launcher_macos
func RegisterGeneratedPlugins(registry: FlutterPluginRegistry) {
ConnectivityPlusPlugin.register(with: registry.registrar(forPlugin: "ConnectivityPlusPlugin"))
FilePickerPlugin.register(with: registry.registrar(forPlugin: "FilePickerPlugin"))
FLTFirebaseAppCheckPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAppCheckPlugin"))
FLTFirebaseAuthPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseAuthPlugin"))
FLTFirebaseCorePlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseCorePlugin"))
FLTFirebaseMessagingPlugin.register(with: registry.registrar(forPlugin: "FLTFirebaseMessagingPlugin"))

View File

@ -13,10 +13,10 @@ packages:
dependency: transitive
description:
name: _flutterfire_internals
sha256: "948f7d74f41dd6f2d563ea9f4c21d7ea764f8e047d2b24138974c19c24d37eb6"
sha256: "8a1f5f3020ef2a74fb93f7ab3ef127a8feea33a7a2276279113660784ee7516a"
url: "https://pub.dev"
source: hosted
version: "1.3.61"
version: "1.3.64"
analyzer:
dependency: transitive
description:
@ -297,30 +297,6 @@ packages:
url: "https://pub.dev"
source: hosted
version: "10.3.3"
firebase_app_check:
dependency: "direct main"
description:
name: firebase_app_check
sha256: "3bf5d9c9043723ae12c09b2a012ca5f32653a1bc30a0a9818983766ea06d72a8"
url: "https://pub.dev"
source: hosted
version: "0.4.0+1"
firebase_app_check_platform_interface:
dependency: transitive
description:
name: firebase_app_check_platform_interface
sha256: bdda519aa487be605a53093ececa564d48afadd1a1d018520ce45d00415ac03d
url: "https://pub.dev"
source: hosted
version: "0.2.0+1"
firebase_app_check_web:
dependency: transitive
description:
name: firebase_app_check_web
sha256: ab7b57c95faf266e2d5cd9fc57cda54d1fdfbc2c429c09b095830d4186f25920
url: "https://pub.dev"
source: hosted
version: "0.2.0+16"
firebase_auth:
dependency: "direct main"
description:
@ -349,26 +325,26 @@ packages:
dependency: "direct main"
description:
name: firebase_core
sha256: "967dae9a65f69377beb9f4ab292ea63ce5befa1ce24682cab1b69ca4b7a46927"
sha256: "1f2dfd9f535d81f8b06d7a50ecda6eac1e6922191ed42e09ca2c84bd2288927c"
url: "https://pub.dev"
source: hosted
version: "4.1.0"
version: "4.2.1"
firebase_core_platform_interface:
dependency: transitive
description:
name: firebase_core_platform_interface
sha256: "5dbc900677dcbe5873d22ad7fbd64b047750124f1f9b7ebe2a33b9ddccc838eb"
sha256: cccb4f572325dc14904c02fcc7db6323ad62ba02536833dddb5c02cac7341c64
url: "https://pub.dev"
source: hosted
version: "6.0.0"
version: "6.0.2"
firebase_core_web:
dependency: transitive
description:
name: firebase_core_web
sha256: f7ee08febc1c4451588ce58ffcf28edaee857e9a196fee88b85deb889990094a
sha256: ff18fabb0ad0ed3595d2f2c85007ecc794aadecdff5b3bb1460b7ee47cded398
url: "https://pub.dev"
source: hosted
version: "3.1.0"
version: "3.3.0"
firebase_messaging:
dependency: "direct main"
description:
@ -401,6 +377,14 @@ packages:
url: "https://pub.dev"
source: hosted
version: "1.1.1"
fl_chart:
dependency: "direct main"
description:
name: fl_chart
sha256: "5276944c6ffc975ae796569a826c38a62d2abcf264e26b88fa6f482e107f4237"
url: "https://pub.dev"
source: hosted
version: "0.70.2"
flutter:
dependency: "direct main"
description: flutter

View File

@ -58,7 +58,6 @@ dependencies:
google_sign_in: ^7.1.1
firebase_core: ^4.1.0
firebase_auth: ^6.0.2
firebase_app_check: ^0.4.0+1
package_info_plus: ^8.3.1
flutter_lints: ^6.0.0
easy_loading_button: ^0.4.0
@ -69,6 +68,8 @@ dependencies:
dropdown_search: ^6.0.2
file_picker: ^10.3.3
fluttertoast: ^9.0.0
fl_chart: ^0.70.0
# fl_chart: ^1.1.0