UI_DASHBOARD_Insurer

This commit is contained in:
venbaittech 2025-10-09 17:23:52 +05:30
parent 88e65c0923
commit dc87e4b818
8 changed files with 932 additions and 235 deletions

File diff suppressed because one or more lines are too long

View File

@ -555,7 +555,7 @@ class ApiService {
}
Future<Map<String, dynamic>> findEnqQuotePolicyView(id) async {
// print(_token);
print('findEnqQuotePolicyView - $id');
if (_token == null) {
await _initializeToken();
}

View File

@ -99,7 +99,7 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
"email": controllers["email"]?.text,
"reg_no": controllers["regNo"]?.text,
"vehicle_type_id": selectedVehicleType,
"insurer_id": selectedInsurer,
// "insurer_id": selectedInsurer,
// "rc_file_name": "rc_doc.pdf",
// "id_proof_file_name": "id_proof.pdf",
// "previous_policy_file_name": "previous_policy.pdf",
@ -596,21 +596,24 @@ class EnquiryTabState extends ConsumerState<EnquiryTab> {
_buildResponsiveRow(
context,
buildVehicleType(context),
buildInsurer(context),
),
isMobile ? SizedBox(height: 5) : SizedBox(height: 20),
_buildResponsiveRow(
context,
// buildInsurer(context),
buildUploadRCDocument(context),
),
isMobile ? SizedBox(height: 5) : SizedBox(height: 20),
_buildResponsiveRow(
context,
// buildUploadRCDocument(context),
buildUploadIDDocument(context),
buildUploadPolicyDocument(context),
),
isMobile ? SizedBox(height: 5) : SizedBox(height: 20),
_buildResponsiveRow(
context,
buildUploadPolicyDocument(context),
// buildUploadPolicyDocument(context),
buildRemarks(context),
SizedBox.shrink(),
),
],
),

View File

@ -11,10 +11,10 @@ import '../../providers/userRoleProvider.dart';
final enquiriesProvider = Provider<List<Map<String, String>>>((ref) {
return List.generate(5, (i) {
return {
"reg": "TN64V4387",
"company": "New India",
"date": "09/09/2025",
"time": "11:30 AM",
"reg": "rrTN64V4387",
"company": "rrNew India",
"date": "rr09/09/2025",
"time": "rr11:30 AM",
};
});
});
@ -54,14 +54,19 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
String? earningsMonth;
String? earningsYear;
String? quotationsPendingCounts; // cross verify
String? currentKey; // cross verify
// List<Map<String, dynamic>> dataVal = [];
List<Map<String, dynamic>> getStaffData = [];
List<Map<String, dynamic>> originalData = [];
List<Map<String, dynamic>> filteredData = [];
int selectedTabIndex = 0;
List<Map<String, dynamic>> currentList = [];
List<Map<String, dynamic>> quotationsPendingList = []; // cross verify
List<Map<String, dynamic>> policiesPendingList = []; // cross verify
List<Map<String, dynamic>> awaitingApprovalList = []; // cross verify
List<Map<String, dynamic>> unAssignedEnqList = []; // cross verify
List<Map<String, dynamic>> agentsPerformanceList = []; // cross verify
List<Map<String, dynamic>> nonAgentsPerformanceList = []; // cross verify
@ -98,15 +103,53 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
final data = response['data'];
print('B99 => getStaffListData => ${response['data']}');
setState(() {
policiesIssuedToday = data['policies_issued']['today'].toString();
policiesIssuedYear = data['policies_issued']['year'].toString();
policiesIssuedMonth = data['policies_issued']['month'].toString();
premiumValueToday = data['premium_value']['today'].toString();
premiumValueYear = data['premium_value']['year'].toString();
premiumValueMonth = data['premium_value']['month'].toString();
earningsToday = data['earnings']['today'].toString();
earningsYear = data['earnings']['year'].toString();
earningsMonth = data['earnings']['month'].toString();
// policiesIssuedToday = data['policies_issued']['today'].toString();
// policiesIssuedYear = data['policies_issued']['year'].toString();
// policiesIssuedMonth = data['policies_issued']['month'].toString();
// premiumValueToday = data['premium_value']['today'].toString();
// premiumValueYear = data['premium_value']['year'].toString();
// premiumValueMonth = data['premium_value']['month'].toString();
// earningsToday = data['earnings']['today'].toString();
// earningsYear = data['earnings']['year'].toString();
// earningsMonth = data['earnings']['month'].toString();
// Policies Issued
if (data['policies_issued'] != null) {
policiesIssuedToday =
data['policies_issued']['today']?.toString() ?? "0";
policiesIssuedYear =
data['policies_issued']['year']?.toString() ?? "0";
policiesIssuedMonth =
data['policies_issued']['month']?.toString() ?? "0";
} else {
policiesIssuedToday = "0";
policiesIssuedYear = "0";
policiesIssuedMonth = "0";
}
// Premium Value
if (data['premium_value'] != null) {
premiumValueToday =
data['premium_value']['today']?.toString() ?? "0";
premiumValueYear = data['premium_value']['year']?.toString() ?? "0";
premiumValueMonth =
data['premium_value']['month']?.toString() ?? "0";
} else {
premiumValueToday = "0";
premiumValueYear = "0";
premiumValueMonth = "0";
}
// Earnings
if (data['earnings'] != null) {
earningsToday = data['earnings']['today']?.toString() ?? "0";
earningsYear = data['earnings']['year']?.toString() ?? "0";
earningsMonth = data['earnings']['month']?.toString() ?? "0";
} else {
earningsToday = "0";
earningsYear = "0";
earningsMonth = "0";
}
// agents_performance
if (data['agents_performance'] != null) {
@ -115,6 +158,7 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
(item) => Map<String, dynamic>.from(item),
),
);
agentsPerformanceList.sort((a, b) {
int aValue = a['total_policis_pending'] ?? 0;
int bValue = b['total_policis_pending'] ?? 0;
@ -138,6 +182,21 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
});
}
if (data['quotations_pending'] != null) {
quotationsPendingList = List<Map<String, dynamic>>.from(
(data['quotations_pending'] as List).map(
(item) => Map<String, dynamic>.from(item),
),
);
}
if (data['quotations_approval_pending'] != null) {
awaitingApprovalList = List<Map<String, dynamic>>.from(
(data['quotations_approval_pending'] as List).map(
(item) => Map<String, dynamic>.from(item),
),
);
}
if (data['policies_pending'] != null) {
policiesPendingList = List<Map<String, dynamic>>.from(
(data['policies_pending'] as List).map(
@ -146,9 +205,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
);
}
if (data['quotations_pending'] != null) {
quotationsPendingList = List<Map<String, dynamic>>.from(
(data['quotations_pending'] as List).map(
if (data['unassigned_enquiry'] != null) {
unAssignedEnqList = List<Map<String, dynamic>>.from(
(data['unassigned_enquiry'] as List).map(
(item) => Map<String, dynamic>.from(item),
),
);
@ -177,7 +236,9 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
return MainLayout(
title: "Home",
body: ResponsiveBuilder.isMobile(context)
? Expanded(
? Container(
// color: Colors.redAccent,
// height: MediaQuery.of(context).size.height,
// take available space
child: SingleChildScrollView(
scrollDirection: Axis.vertical,
@ -238,29 +299,57 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
borderRadius: BorderRadius.circular(25),
),
padding: const EdgeInsets.all(6),
child: SingleChildScrollView(
scrollDirection: Axis.horizontal,
child: Row(
children: [
Expanded(
child: buildTab("Enquiries Pending", 0),
Padding(
padding: const EdgeInsets.all(8.0),
child: buildTab("Awaiting Quotation", 0),
),
const SizedBox(width: 10),
Expanded(
child: buildTab("Quotation Pending", 1),
Padding(
padding: const EdgeInsets.all(8.0),
child: buildTab("Awaiting Approval", 1),
),
const SizedBox(width: 10),
Padding(
padding: const EdgeInsets.all(8.0),
child: buildTab("Awaiting Policy", 2),
),
],
),
),
),
const SizedBox(height: 20),
// 🔹 Scrollable list
ListView.builder(
itemCount: enquiries.length,
itemCount: currentList.length,
shrinkWrap: true,
physics:
const NeverScrollableScrollPhysics(), // disable inner scroll
physics: const NeverScrollableScrollPhysics(),
itemBuilder: (context, index) {
final item = enquiries[index];
final item = currentList[index];
// Split date & time from created_on
String date = "";
String time = "";
if ((item['created_on'] ?? "").isNotEmpty) {
final parts = item['created_on'].split(' ');
date = parts[0];
if (parts.isNotEmpty) {
DateTime parsedDate = DateTime.parse(
parts[0],
);
date = DateFormat(
'dd/MM/yyyy',
).format(parsedDate); // 19/09/2025
}
time = parts.length > 1 ? parts[1] : "";
}
return Card(
elevation: 2,
margin: const EdgeInsets.symmetric(vertical: 8),
@ -270,30 +359,33 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
color: Colors.white,
child: ListTile(
title: Text(
item["reg"]!,
item["reg_no"] ?? "-", // from API
style: GoogleFonts.inter(
fontWeight: FontWeight.bold,
fontSize: 12,
),
),
subtitle: Text(
item["company"]!,
subtitle: (currentKey == 'policies')
? Text(
item["insurer_name"] ?? "-",
style: GoogleFonts.inter(
fontSize: 12,
fontWeight: FontWeight.bold,
),
),
)
: SizedBox.shrink(),
trailing: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text(
item["date"]!,
style: GoogleFonts.inter(fontSize: 12),
),
Text(
item["time"]!,
'$date ${time}',
style: GoogleFonts.inter(fontSize: 12),
),
// Text(
// (time ?? "").toString().split(" ").last,
// style: GoogleFonts.inter(fontSize: 12),
// ),
],
),
),
@ -348,50 +440,37 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
),
],
),
if (role == 'manager')
SizedBox(
// replace Expanded
height: 350, // adjust height as needed
child: Row(
children: [
Expanded(
child: Performance(
title: "Top Agent Performance",
data: agentsPerformanceList,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Bottom Non-Performing Agents",
data: nonAgentsPerformanceList,
),
),
],
),
),
const SizedBox(height: 10),
SizedBox(
// replace Expanded
height: (role == 'agent')
? MediaQuery.of(context).size.height *
0.69 //400
: (role == 'manager')
? MediaQuery.of(context).size.height * 0.5
: MediaQuery.of(context).size.height *
0.5, // 350 adjust height as needed
0.85, // 350 adjust height as needed
child: Row(
children: [
Expanded(
child: (role == 'agent')
? agentPendings(
title:
"Enquiries Pending (${policiesPendingList.length})",
data: policiesPendingList,
"Awaiting Quotation (${quotationsPendingList.length})",
data: quotationsPendingList,
)
: othersPendings(
: (role == 'manager')
? othersPendings(
title:
"Quotations Pending (${quotationsPendingList.length})",
"Awaiting Quotation (${quotationsPendingList.length})",
data: quotationsPendingList,
stringFlag: "Quotation",
)
: agentPendings(
title:
"Awaiting Quotation (${quotationsPendingList.length})",
data: quotationsPendingList,
),
),
const SizedBox(width: 16),
@ -399,14 +478,73 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
child: (role == 'agent')
? agentPendings(
title:
"Quotations Pending (${quotationsPendingList.length})",
data: quotationsPendingList,
"Awaiting Approval (${awaitingApprovalList.length})",
data: awaitingApprovalList,
)
: othersPendings(
: (role == 'manager')
? awaitingApproval(
title:
"Policies Pending (${policiesPendingList.length})",
"Awaiting Approval (${awaitingApprovalList.length})",
data: awaitingApprovalList,
stringFlag: "Quotation",
)
: agentPendings(
title:
"Awaiting Approval (${awaitingApprovalList.length})",
data: awaitingApprovalList,
),
),
const SizedBox(width: 16),
Expanded(
child: (role == 'agent')
? agentPendings(
title:
"Awaiting Policy (${policiesPendingList.length})",
data: policiesPendingList,
stringFlag: "Policies",
)
: (role == 'manager')
? othersPendings(
title:
"Awaiting Policy (${policiesPendingList.length})",
data: policiesPendingList,
stringFlag: "Policies",
)
: agentPendings(
title:
"Awaiting Policy (${policiesPendingList.length})",
data: policiesPendingList,
stringFlag: "Policies",
),
),
],
),
),
const SizedBox(height: 10),
if (role == 'manager')
SizedBox(
// replace Expanded
height: 350, // adjust height as needed
child: Row(
children: [
Expanded(
child: UnassignedEnq(
title: "Unassigned Enquires",
data: unAssignedEnqList,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Performing Agents",
data: agentsPerformanceList,
),
),
SizedBox(width: 16),
Expanded(
child: Performance(
title: "Non-Performing Agents",
data: nonAgentsPerformanceList,
),
),
],
@ -465,14 +603,14 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
// children: [
// Expanded(
// child: Performance(
// title: "Top Agent Performance",
// title: "Performing Agents",
// data: agentsPerformanceList,
// ),
// ),
// SizedBox(width: 16),
// Expanded(
// child: Performance(
// title: "Bottom Non-Performing Agents",
// title: "Non-Performing Agents",
// data: nonAgentsPerformanceList,
// ),
// ),
@ -528,38 +666,78 @@ class _DashboardScreenState extends ConsumerState<DashboardScreen> {
);
}
// Widget buildTab(String title, int index) {
// final isSelected = selectedIndex == index + 1;
// return GestureDetector(
// onTap: () {
// print('buildTab - $index');
//
// setState(() {
// selectedIndex = index + 1;
// print('buildTab1 - $selectedIndex');
// if (selectedIndex == 2) {
// switcherStatus = 0;
// } else {
// switcherStatus = 1;
// }
// });
// },
// child: SizedBox(
// child: Container(
// padding: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
// decoration: BoxDecoration(
// color: isSelected ? const Color(0xFFFFFFFF) : Colors.transparent,
// borderRadius: BorderRadius.circular(16),
// ),
// child: Center(
// child: Text(
// title,
// style: GoogleFonts.poppins(
// fontSize: 12,
//
// color: isSelected ? Colors.black : Colors.white,
// fontWeight: FontWeight.w500,
// ),
// maxLines: 2,
// softWrap: true,
// ),
// ),
// ),
// ),
// );
// }
Widget buildTab(String title, int index) {
final isSelected = selectedIndex == index + 1;
final isSelected = selectedTabIndex == index;
if (selectedTabIndex == 0) {
currentList = quotationsPendingList;
currentKey = 'pending';
} else if (selectedTabIndex == 1) {
currentList = awaitingApprovalList;
currentKey = 'approval';
} else if (selectedTabIndex == 2) {
currentList = policiesPendingList;
currentKey = 'policies';
}
return GestureDetector(
onTap: () {
setState(() {
selectedIndex = index + 1;
if (selectedIndex == 2) {
switcherStatus = 0;
} else {
switcherStatus = 1;
}
selectedTabIndex = index;
});
},
child: SizedBox(
child: Container(
padding: EdgeInsets.symmetric(vertical: 6, horizontal: 10),
padding: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
decoration: BoxDecoration(
color: isSelected ? const Color(0xFFFFFFFF) : Colors.transparent,
borderRadius: BorderRadius.circular(16),
color: isSelected ? Colors.white : Colors.transparent,
borderRadius: BorderRadius.circular(20),
),
child: Center(
child: Text(
title,
style: GoogleFonts.poppins(
fontSize: 12,
color: isSelected ? Colors.black : Colors.white,
fontWeight: FontWeight.w500,
),
maxLines: 2,
softWrap: true,
),
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.bold,
color: isSelected ? const Color(0xFF425B5B) : Colors.white,
),
),
),
@ -682,9 +860,14 @@ class StatCard extends StatelessWidget {
class agentPendings extends StatelessWidget {
final String title;
final String? stringFlag;
final List<Map<String, dynamic>> data;
const agentPendings({Key? key, required this.title, required this.data})
: super(key: key);
const agentPendings({
Key? key,
required this.title,
required this.data,
this.stringFlag,
}) : super(key: key);
@override
Widget build(BuildContext context) {
@ -865,6 +1048,15 @@ class agentPendings extends StatelessWidget {
child: Row(
children: [
Expanded(
flex: 1,
child: Text(
"S.No",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
flex: 1,
child: Text(
"Date & Time",
textAlign: TextAlign.center,
@ -872,13 +1064,16 @@ class agentPendings extends StatelessWidget {
),
),
Expanded(
flex: 2,
child: Text(
"Registration number",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
if (stringFlag == "Policies") ...[
Expanded(
flex: 2,
child: Text(
"Insurer Company",
textAlign: TextAlign.center,
@ -886,6 +1081,7 @@ class agentPendings extends StatelessWidget {
),
),
],
],
),
),
const SizedBox(height: 8),
@ -924,8 +1120,17 @@ class agentPendings extends StatelessWidget {
),
child: Row(
children: [
Expanded(
flex: 1,
child: Text(
(index + 1).toString(),
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
// Date & Time
Expanded(
flex: 1,
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
@ -937,22 +1142,25 @@ class agentPendings extends StatelessWidget {
// Registration number
Expanded(
flex: 2,
child: Text(
row['reg_no'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
if (stringFlag == "Policies") ...[
// Insurer company
Expanded(
flex: 2,
child: Text(
row['insurer_name'] ?? "",
row['insurer_short_name'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
],
],
),
);
},
@ -1022,21 +1230,22 @@ class othersPendings extends StatelessWidget {
Expanded(
flex: 2,
child: Text(
stringFlag + " Issued",
// stringFlag + " Issued",
'Pending Count',
textAlign: TextAlign.center,
style: _headerStyle,
),
),
(stringFlag == "Policies")
? Expanded(
flex: 2,
child: Text(
"Total Premium Value",
textAlign: TextAlign.center,
style: _headerStyle,
),
)
: const SizedBox.shrink(),
// (stringFlag == "Policies")
// ? Expanded(
// flex: 2,
// child: Text(
// "Total Premium Value",
// textAlign: TextAlign.center,
// style: _headerStyle,
// ),
// )
// : const SizedBox.shrink(),
],
),
),
@ -1081,6 +1290,7 @@ class othersPendings extends StatelessWidget {
flex: 2,
child: Text(
row['staff_name'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
@ -1090,23 +1300,182 @@ class othersPendings extends StatelessWidget {
flex: 2,
child: Text(
issuedCount,
// row['total_approval_pending'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
stringFlag == "Policies"
? Expanded(
// stringFlag == "Policies"
// ? Expanded(
// flex: 2,
// child: Text(
// formatToCroresLakhsAndThousands(permiumValue),
// textAlign: TextAlign.center,
// style: GoogleFonts.inter(
// fontSize: 14,
// fontWeight: FontWeight.w500,
// ),
// ),
// )
// : const SizedBox.shrink(),
],
),
);
},
),
),
],
),
),
);
}
}
class awaitingApproval extends StatelessWidget {
final String title;
final String stringFlag;
final List<Map<String, dynamic>> data;
awaitingApproval({
Key? key,
required this.title,
required this.data,
required this.stringFlag,
}) : super(key: key);
@override
Widget build(BuildContext context) {
print(' Data: $data');
return Card(
color: const Color(0xFFEAF6F4),
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title
Text(title, style: _title),
const SizedBox(height: 10),
// Header row
Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
decoration: BoxDecoration(
color: const Color(0xFF3E5B56),
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Expanded(
flex: 1,
child: Text(
"S.No",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
flex: 2,
child: Text(
formatToCroresLakhsAndThousands(permiumValue),
"Staff Name",
textAlign: TextAlign.center,
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.w500,
style: _headerStyle,
),
),
)
: const SizedBox.shrink(),
Expanded(
flex: 2,
child: Text(
// stringFlag + " Issued",
'Pending Count',
textAlign: TextAlign.center,
style: _headerStyle,
),
),
// (stringFlag == "Policies")
// ? Expanded(
// flex: 2,
// child: Text(
// "Total Premium Value",
// textAlign: TextAlign.center,
// style: _headerStyle,
// ),
// )
// : const SizedBox.shrink(),
],
),
),
const SizedBox(height: 8),
// List of rows
Flexible(
child: ListView.builder(
itemCount: data.length,
itemBuilder: (context, index) {
final row = data[index];
final issuedCount = stringFlag == "Policies"
? (row['total_policis_pending'] ?? 0).toString()
: (row['total_quotation_pending'] ?? 0).toString();
final permiumValue = row['total_premium_value'] == null
? '0'
: row['total_premium_value'];
return Container(
margin: const EdgeInsets.symmetric(vertical: 5),
padding: const EdgeInsets.symmetric(
vertical: 5,
horizontal: 12,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Expanded(
flex: 1,
child: Text(
(index + 1).toString(),
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
Expanded(
flex: 2,
child: Text(
row['staff_name'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
Expanded(
flex: 2,
child: Text(
// issuedCount,
(row['total_approval_pending'] ?? 0).toString(),
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
// stringFlag == "Policies"
// ? Expanded(
// flex: 2,
// child: Text(
// formatToCroresLakhsAndThousands(permiumValue),
// textAlign: TextAlign.center,
// style: GoogleFonts.inter(
// fontSize: 14,
// fontWeight: FontWeight.w500,
// ),
// ),
// )
// : const SizedBox.shrink(),
],
),
);
@ -1174,9 +1543,7 @@ class Performance extends StatelessWidget {
),
Expanded(
child: Text(
title == "Top Agent Performance"
? "Premium Value"
: "Status",
title == "Performing Agents" ? "Premium Value" : "Status",
textAlign: TextAlign.center,
style: _headerStyle,
),
@ -1232,7 +1599,7 @@ class Performance extends StatelessWidget {
Expanded(
child: Text(
title == "Top Agent Performance"
title == "Performing Agents"
? formatToCroresLakhsAndThousands(
row['total_premium_value'] ?? 0,
)
@ -1241,7 +1608,7 @@ class Performance extends StatelessWidget {
style: GoogleFonts.inter(
fontSize: 14,
fontWeight: FontWeight.w500,
color: title == "Top Agent Performance"
color: title == "Performing Agents"
? Colors.black
: (row['status']?.toString().toLowerCase() ==
"active"
@ -1263,6 +1630,119 @@ class Performance extends StatelessWidget {
}
}
class UnassignedEnq extends StatelessWidget {
final String title;
final List<Map<String, dynamic>> data;
UnassignedEnq({Key? key, required this.title, required this.data})
: super(key: key);
@override
Widget build(BuildContext context) {
return Card(
color: const Color(0xFFEAF6F4),
elevation: 0,
shape: RoundedRectangleBorder(borderRadius: BorderRadius.circular(12)),
child: Padding(
padding: const EdgeInsets.all(12.0),
child: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
// Title
Text(title, style: _title),
const SizedBox(height: 10),
// Header row
Container(
padding: const EdgeInsets.symmetric(vertical: 10, horizontal: 12),
decoration: BoxDecoration(
color: const Color(0xFF3E5B56),
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Expanded(
child: Text(
"S.No",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
child: Text(
"Registration number",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
Expanded(
child: Text(
"Date",
textAlign: TextAlign.center,
style: _headerStyle,
),
),
],
),
),
const SizedBox(height: 8),
// List of rows
Flexible(
child: ListView.builder(
itemCount: data.length,
itemBuilder: (context, index) {
final row = data[index];
return Container(
// height: 5200,
margin: const EdgeInsets.symmetric(vertical: 5),
padding: const EdgeInsets.symmetric(
vertical: 5,
horizontal: 12,
),
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.circular(10),
),
child: Row(
children: [
Expanded(
child: Text(
(index + 1).toString(), // convert int to string
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
Expanded(
child: Text(
row['reg_no'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
Expanded(
child: Text(
row['created_on'] ?? "",
textAlign: TextAlign.center,
style: _tableDataStyle,
),
),
],
),
);
},
),
),
],
),
),
);
}
}
final _headerStyle = GoogleFonts.inter(
fontWeight: FontWeight.w600,
fontSize: 14,

View File

@ -287,7 +287,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
regNum,
) {
return [
if (roleId == 'manager' && data['status'] != 'Quotation Created') ...[
if (roleId == 'manager' && data['status'] == 'Awaiting Quotation') ...[
Material(
color: Colors.transparent,
child: InkWell(

View File

@ -250,7 +250,7 @@ class PolicyScreenState extends ConsumerState<PolicyScreen> {
selectedEnquiryId = enquiryData['id'];
print('selectedEnquiryId- $selectedEnquiryId');
controllers["regNum"]?.text = enquiryData['reg_no'];
controllers["insurer"]?.text = enquiryData['insurer_name'];
// controllers["insurer"]?.text = enquiryData['insurer_name'];
});
}
@ -266,6 +266,7 @@ class PolicyScreenState extends ConsumerState<PolicyScreen> {
if (quotationAcceptedData != null) {
if (!mounted) return;
setState(() {
controllers["insurer"]?.text = quotationAcceptedData?['insurer_name'];
acceptedQuotationId = quotationAcceptedData?['id']?.toString() ?? '';
controllers["idv"]?.text =
quotationAcceptedData?['insured_declared_value']?.toString() ??
@ -1200,6 +1201,19 @@ class PolicyScreenState extends ConsumerState<PolicyScreen> {
controllers['startDate']?.text = DateFormat(
'dd-MM-yyyy',
).format(date);
// auto set end date (1 year later - 1 day if needed)
final endDate = DateTime(
date.year + 1,
date.month,
date.day,
).subtract(const Duration(days: 1)); // optional: subtract 1 day
controllers['endDate']?.text = DateFormat(
'dd-MM-yyyy',
).format(endDate);
print("Auto-set End Date: $endDate");
// controllers['date']?.text = date as String;
},
),
@ -1220,13 +1234,75 @@ class PolicyScreenState extends ConsumerState<PolicyScreen> {
: MediaQuery.of(context).size.width * 0.26,
txtheight: 50,
// backgroundColor: const Color(0xFFECECEC),
validator: (value) => Validators.requiredField(value, "date"),
// validator: (value) => Validators.requiredField(value, "date"),
validator: (value) {
if (value == null || value.isEmpty) {
return "Required";
}
final startDateControllerText = controllers['startDate']?.text;
if (startDateControllerText == null ||
startDateControllerText.isEmpty) {
return "Select start date first";
}
final startDate = DateFormat(
'dd-MM-yyyy',
).parse(startDateControllerText);
final endDate = DateFormat('dd-MM-yyyy').parse(value);
if (endDate.isBefore(startDate)) {
return "End date cannot be before start date";
}
// Minimum end date = start date + 1 year - 1 day (or just +1 year)
final minEndDate = DateTime(
startDate.year + 1,
startDate.month,
startDate.day,
);
if (endDate.isBefore(minEndDate)) {
return "End date must be at least 1 year from start date";
}
return null;
// final startDateControllerText = controllers['startDate']?.text;
// if (startDateControllerText == null ||
// startDateControllerText.isEmpty) {
// return "Select start date first";
// }
//
// final startDate = DateFormat(
// 'dd-MM-yyyy',
// ).parse(startDateControllerText);
// final endDate = DateFormat('dd-MM-yyyy').parse(value);
//
// if (endDate.isBefore(startDate)) {
// return "End date cannot be before start date";
// }
//
// final expectedEndDate = DateTime(
// startDate.year + 1,
// startDate.month,
// startDate.day,
// ).subtract(const Duration(days: 1));
//
// if (endDate != expectedEndDate) {
// return "End date must be exactly 1 year from start date";
// }
//
// return null; // valid
},
controller: controllers['endDate']!,
onDateSelected: (date) {
print("Picked Date: $date");
controllers['endDate']?.text = DateFormat(
'dd-MM-yyyy',
).format(date);
_formKey.currentState?.validate();
// controllers['date']?.text = date as String;
},
),

View File

@ -46,6 +46,10 @@ class createQuotatDialogState extends State<createQuotatDialog> {
String? selectedFileNames;
List<Map<String, dynamic>> getInsurersData = [];
List<Map<String, dynamic>> filteredInsurersData = [];
String? selectedInsurer;
bool isLoading = false;
late TextEditingController controller;
Map<String, TextEditingController> controllers = {};
@ -59,6 +63,9 @@ class createQuotatDialogState extends State<createQuotatDialog> {
final GlobalKey<DropdownSearchState<Map<String, dynamic>>> dropDownKey =
GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
final GlobalKey<DropdownSearchState<Map<String, dynamic>>>
dropDownKeyInsurer = GlobalKey<DropdownSearchState<Map<String, dynamic>>>();
List<String> tabHeader = ['idv', 'premium_Amount'];
List<Map<String, dynamic>> getInsuranceTypeData = [];
@ -71,6 +78,7 @@ class createQuotatDialogState extends State<createQuotatDialog> {
final data = {
"enquiry_id": widget.selectedEnquiryId,
"insured_declared_value": controllers["idv"]?.text,
"insurer_id": selectedInsurer,
"premium_amount": controllers["premium_Amount"]?.text,
"insurance_plan_type_id": selectedInsPlanType,
// "additional_uploaded_file_name": "extra_doc.pdf",
@ -91,6 +99,7 @@ class createQuotatDialogState extends State<createQuotatDialog> {
// 🔹 Init logic here (API calls, token fetch, etc.)
_initializeToken();
getInsuranceType();
getInsurers();
updateData();
}
@ -126,6 +135,9 @@ class createQuotatDialogState extends State<createQuotatDialog> {
.selectedQuotationFrmListdata!['insurance_plan_type_id']
?.toString();
selectedInsurer =
widget.selectedQuotationFrmListdata!['insurer_id']?.toString() ?? '';
String? apiDocPath =
widget.selectedQuotationFrmListdata!["additional_uploaded_file_name"];
if (apiDocPath != null && apiDocPath.isNotEmpty) {
@ -143,6 +155,37 @@ class createQuotatDialogState extends State<createQuotatDialog> {
}
}
Future<void> getInsurers() async {
print('Insurers called');
setState(() {
isLoading = true;
});
try {
final response = await apiService.fetchMasterDropDown('Insurers');
if (response['status'] == 200) {
print('getInsurers - ${response['data']}');
setState(() {
getInsurersData = List<Map<String, dynamic>>.from(response['data']);
print('API Data - $getInsurersData');
filteredInsurersData = List.from(getInsurersData);
print('originalData - $filteredInsurersData');
});
} else {
getInsurersData = [];
filteredInsurersData = [];
}
} catch (e) {
print('Exception occurred: $e');
} finally {
setState(() {
isLoading = false;
});
}
}
Future<void> getInsuranceType() async {
print('getClaimList called');
setState(() {
@ -380,6 +423,7 @@ class createQuotatDialogState extends State<createQuotatDialog> {
crossAxisAlignment: CrossAxisAlignment.start,
children: [
buildIdv(context),
buildInsurer(context),
buildInsurancePlanType(context),
buildPremiumAmnt(context),
buildDocuments(context),
@ -417,6 +461,97 @@ class createQuotatDialogState extends State<createQuotatDialog> {
);
}
Widget buildInsurer(BuildContext context) {
Map<String, dynamic>? selectedInsurerd = filteredInsurersData.firstWhere(
(item) => item['id'].toString() == selectedInsurer,
orElse: () => {},
);
return Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text('Insurer *', style: _textStyle),
SizedBox(height: 10),
Container(
decoration: BoxDecoration(
// color: Colors.white,
borderRadius: BorderRadius.circular(10.0),
),
width: ResponsiveLayout.isMobile(context)
? null
: MediaQuery.of(context).size.width * 0.26,
// height: 40,
child: DropdownSearch<Map<String, dynamic>>(
key: dropDownKeyInsurer,
selectedItem: selectedInsurerd.isNotEmpty ? selectedInsurerd : null,
items: (filter, infiniteScrollProps) {
return filteredInsurersData;
},
itemAsString: (val) => val['name'].toString(), // what to show
compareFn: (item, selectedItem) =>
item['id'] == selectedItem['id'], // compare by id
validator: (val) {
if (val == null) {
return "Required"; // error message
}
return null;
},
decoratorProps: DropDownDecoratorProps(
decoration:
AppInputDecorations.dropdownDecoration(
label: "Select Insurer",
).copyWith(
filled: true,
fillColor: Color(
0xFFEDF6F5,
), // 👈 makes the dropdown input white
),
),
popupProps: PopupProps.menu(
fit: FlexFit.loose,
constraints: BoxConstraints(maxHeight: 250),
menuProps: MenuProps(
backgroundColor:
Colors.white, // 👈 sets dropdown background to white
),
showSearchBox: true,
searchFieldProps: TextFieldProps(
decoration: InputDecoration(
filled: true,
fillColor: Colors.white,
hintText: "Search Insurer...",
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
), // 👈 Normal border
),
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(
color: Colors.white,
width: 1.5,
), // 👈 Focused border
),
),
),
// constraints: BoxConstraints(),
),
onChanged: (val) {
if (val != null) {
print("Selected Insurer : ${val['name']}");
print("Id: ${val['id']}");
selectedInsurer = val['id'];
// controllers['agentId']?.text = val['agent_code'];
// agentId = agent['id'];
}
},
),
),
],
);
}
Widget buildPremiumAmnt(BuildContext context) {
return Column(
crossAxisAlignment: CrossAxisAlignment.start,

View File

@ -159,7 +159,7 @@ class QuotationScreenState extends ConsumerState<QuotationScreen> {
selectedEnquiryId = enquiryData['id'];
print('selectedEnquiryId- $selectedEnquiryId');
controllers["regNum"]?.text = enquiryData['reg_no'];
controllers["insurer"]?.text = enquiryData['insurer_name'];
// controllers["insurer"]?.text = enquiryData['insurer_name'];
});
}
@ -194,7 +194,9 @@ class QuotationScreenState extends ConsumerState<QuotationScreen> {
originalData = getQuotationData;
filteredData = List.from(originalData);
blockKey = getQuotationData.any((item) => item['status'] == 'Accepted');
blockKey = getQuotationData.any(
(item) => item['status'] == 'Accepted',
);
print('blockKey- $blockKey');
// print('originalData - $getClaimPolicies');
});
@ -332,8 +334,8 @@ class QuotationScreenState extends ConsumerState<QuotationScreen> {
),
SizedBox(height: 15),
registerNumber(context),
SizedBox(height: 16),
insurer(context),
// SizedBox(height: 16),
// insurer(context),
SizedBox(height: 16),
buildDocRC(context, isMobile),
@ -369,13 +371,13 @@ class QuotationScreenState extends ConsumerState<QuotationScreen> {
crossAxisAlignment: CrossAxisAlignment.end,
children: [
registerNumber(context),
Spacer(),
insurer(context),
Spacer(),
SizedBox(width: 10),
// insurer(context),
// Spacer(),
buildDocRC(context, isMobile),
Spacer(),
SizedBox(width: 10),
buildDocIdProof(context, isMobile),
Spacer(),
SizedBox(width: 10),
buildDocPrevPolicy(context, isMobile),
],
),
@ -450,7 +452,8 @@ class QuotationScreenState extends ConsumerState<QuotationScreen> {
),
),
const SizedBox(height: 20),],
const SizedBox(height: 20),
],
//3RD SECTION (TABLE)
Container(