Filter
This commit is contained in:
parent
647f5ff05d
commit
6c1fdb1c10
File diff suppressed because one or more lines are too long
@ -764,9 +764,15 @@ class ApiService {
|
||||
// '${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}',
|
||||
// );
|
||||
|
||||
url = Uri.parse(
|
||||
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus&staff_id=$selectedStaffId',
|
||||
);
|
||||
if (role == 'staff') {
|
||||
url = Uri.parse(
|
||||
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus',
|
||||
);
|
||||
} else {
|
||||
url = Uri.parse(
|
||||
'${Env.apiUrl}enquiry/enquiryList?$query&from_date=${fromDate ?? ''}&to_date=${toDate ?? ''}&status=$selectedStatus&staff_id=$selectedStaffId',
|
||||
);
|
||||
}
|
||||
|
||||
// if (role == 'manager') {
|
||||
// url = Uri.parse('${Env.apiUrl}enquiry/enquiryList?manager_id=$id');
|
||||
|
||||
@ -111,18 +111,25 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
getStaffList(userId, roleId);
|
||||
}
|
||||
|
||||
void refrshfilterDateRange() {
|
||||
setState(() {
|
||||
SelectedStatus = '';
|
||||
SelectedStaffId = null;
|
||||
controllers['startDate']!.clear();
|
||||
controllers['endDate']!.clear();
|
||||
Future<void> refrshfilterDateRange() async {
|
||||
// setState(() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
controllers['startDate']?.text = '';
|
||||
controllers['endDate']?.text = '';
|
||||
// Reset the FormField validation
|
||||
_formKey.currentState?.reset();
|
||||
});
|
||||
// ✅ Clear any old data
|
||||
await prefs.remove('dashboardKeyProvider');
|
||||
await prefs.remove('dashboardStatusProvider');
|
||||
await prefs.remove('dashboardStaffIdProvider');
|
||||
SelectedStatus = '';
|
||||
SelectedStaffId = null;
|
||||
|
||||
controllers['startDate']!.clear();
|
||||
controllers['endDate']!.clear();
|
||||
|
||||
controllers['startDate']?.text = '';
|
||||
controllers['endDate']?.text = '';
|
||||
// Reset the FormField validation
|
||||
_formKey.currentState?.reset();
|
||||
// });
|
||||
getStaffList(userId, roleId);
|
||||
}
|
||||
|
||||
@ -184,12 +191,32 @@ class EnquiryListState extends ConsumerState<EnquiryList> {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
dynamic fromDt;
|
||||
dynamic toDt;
|
||||
|
||||
final fromDateVal = controllers['startDate']?.text ?? '';
|
||||
final toDateVal = controllers['endDate']?.text ?? '';
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
|
||||
if (fromDateVal == '' && toDateVal == '') {
|
||||
print("ENQ LIST PAGE");
|
||||
|
||||
final today = DateTime.now();
|
||||
fromDt = dateFormat.format(today.subtract(Duration(days: 15)));
|
||||
toDt = dateFormat.format(today);
|
||||
|
||||
print('Enq FROM TO - $fromDt - $toDt');
|
||||
} else {
|
||||
fromDt = fromDateVal;
|
||||
toDt = toDateVal;
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await apiService.fetchEnquiryList(
|
||||
managerId,
|
||||
role,
|
||||
fromDate: controllers['startDate']?.text ?? '',
|
||||
toDate: controllers['endDate']?.text ?? '',
|
||||
fromDate: fromDt,
|
||||
toDate: toDt,
|
||||
selectedStatus: SelectedStatus != null ? SelectedStatus : '',
|
||||
selectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
|
||||
@ -548,6 +548,9 @@ class StaffState extends ConsumerState<Staff> {
|
||||
} else {
|
||||
showHandler = false;
|
||||
}
|
||||
|
||||
final isReadOnly = widget.id != null;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
children: [
|
||||
@ -562,81 +565,88 @@ class StaffState extends ConsumerState<Staff> {
|
||||
? null
|
||||
: MediaQuery.of(context).size.width * 0.26,
|
||||
// height: 40,
|
||||
child: DropdownSearch<Map<String, dynamic>>(
|
||||
key: dropDownKey,
|
||||
selectedItem: selectedroleVal.isNotEmpty ? selectedroleVal : null,
|
||||
items: (filter, infiniteScrollProps) {
|
||||
return filteredRolesData;
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
absorbing: isReadOnly,
|
||||
child: DropdownSearch<Map<String, dynamic>>(
|
||||
key: dropDownKey,
|
||||
selectedItem: selectedroleVal.isNotEmpty ? selectedroleVal : null,
|
||||
items: (filter, infiniteScrollProps) {
|
||||
return filteredRolesData;
|
||||
},
|
||||
|
||||
itemAsString: (val) => val['role'].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 Role",
|
||||
).copyWith(
|
||||
filled: true,
|
||||
fillColor:
|
||||
Colors.white, // 👈 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
|
||||
itemAsString: (val) => val['role'].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 Role",
|
||||
).copyWith(
|
||||
filled: true,
|
||||
fillColor:
|
||||
Colors.white, // 👈 makes the dropdown input white
|
||||
),
|
||||
),
|
||||
showSearchBox: true,
|
||||
searchFieldProps: TextFieldProps(
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
hintText: "Search Role...",
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
), // 👈 Normal border
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
width: 1.5,
|
||||
), // 👈 Focused border
|
||||
|
||||
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 Role...",
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
), // 👈 Normal border
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
width: 1.5,
|
||||
), // 👈 Focused border
|
||||
),
|
||||
enabled: widget.id == null,
|
||||
),
|
||||
),
|
||||
// constraints: BoxConstraints(),
|
||||
),
|
||||
// constraints: BoxConstraints(),
|
||||
|
||||
onChanged: widget.id != null
|
||||
? null
|
||||
: (val) {
|
||||
if (val != null) {
|
||||
print("Selected Role : ${val['role']}");
|
||||
print("Id: ${val['id']}");
|
||||
selectedRole = val['id'];
|
||||
if (val['role'] == 'Staff') {
|
||||
setState(() {
|
||||
showHandler = true;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
showHandler = false;
|
||||
});
|
||||
}
|
||||
|
||||
// controllers['agentId']?.text = val['agent_code'];
|
||||
// agentId = agent['id'];
|
||||
}
|
||||
},
|
||||
),
|
||||
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
print("Selected Role : ${val['role']}");
|
||||
print("Id: ${val['id']}");
|
||||
selectedRole = val['id'];
|
||||
if (val['role'] == 'Staff') {
|
||||
setState(() {
|
||||
showHandler = true;
|
||||
});
|
||||
} else {
|
||||
setState(() {
|
||||
showHandler = false;
|
||||
});
|
||||
}
|
||||
|
||||
// controllers['agentId']?.text = val['agent_code'];
|
||||
// agentId = agent['id'];
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
],
|
||||
@ -648,6 +658,7 @@ class StaffState extends ConsumerState<Staff> {
|
||||
(item) => item['id'].toString() == selectedHandler,
|
||||
orElse: () => {},
|
||||
);
|
||||
final isReadOnly = widget.id != null;
|
||||
|
||||
return Row(
|
||||
mainAxisAlignment: MainAxisAlignment.spaceBetween,
|
||||
@ -663,73 +674,76 @@ class StaffState extends ConsumerState<Staff> {
|
||||
? null
|
||||
: MediaQuery.of(context).size.width * 0.26,
|
||||
// height: 40,
|
||||
child: DropdownSearch<Map<String, dynamic>>(
|
||||
key: dropDownKeyHandler,
|
||||
selectedItem: selectedHandlered.isNotEmpty
|
||||
? selectedHandlered
|
||||
: null,
|
||||
items: (filter, infiniteScrollProps) {
|
||||
return filteredHandlersData;
|
||||
},
|
||||
child: AbsorbPointer(
|
||||
absorbing: isReadOnly,
|
||||
child: DropdownSearch<Map<String, dynamic>>(
|
||||
key: dropDownKeyHandler,
|
||||
selectedItem: selectedHandlered.isNotEmpty
|
||||
? selectedHandlered
|
||||
: null,
|
||||
items: (filter, infiniteScrollProps) {
|
||||
return filteredHandlersData;
|
||||
},
|
||||
|
||||
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 Handler",
|
||||
).copyWith(
|
||||
filled: true,
|
||||
fillColor:
|
||||
Colors.white, // 👈 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
|
||||
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 Handler",
|
||||
).copyWith(
|
||||
filled: true,
|
||||
fillColor:
|
||||
Colors.white, // 👈 makes the dropdown input white
|
||||
),
|
||||
),
|
||||
showSearchBox: true,
|
||||
searchFieldProps: TextFieldProps(
|
||||
decoration: InputDecoration(
|
||||
filled: true,
|
||||
fillColor: Colors.white,
|
||||
hintText: "Search Handler...",
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
), // 👈 Normal border
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
width: 1.5,
|
||||
), // 👈 Focused border
|
||||
|
||||
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 Handler...",
|
||||
enabledBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
), // 👈 Normal border
|
||||
),
|
||||
focusedBorder: OutlineInputBorder(
|
||||
borderSide: BorderSide(
|
||||
color: Colors.white,
|
||||
width: 1.5,
|
||||
), // 👈 Focused border
|
||||
),
|
||||
),
|
||||
),
|
||||
// constraints: BoxConstraints(),
|
||||
),
|
||||
// constraints: BoxConstraints(),
|
||||
),
|
||||
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
print("Selected Handler : ${val['name']}");
|
||||
print("Id: ${val['id']}");
|
||||
selectedHandler = val['id'];
|
||||
// controllers['agentId']?.text = val['agent_code'];
|
||||
// agentId = agent['id'];
|
||||
}
|
||||
},
|
||||
onChanged: (val) {
|
||||
if (val != null) {
|
||||
print("Selected Handler : ${val['name']}");
|
||||
print("Id: ${val['id']}");
|
||||
selectedHandler = val['id'];
|
||||
// controllers['agentId']?.text = val['agent_code'];
|
||||
// agentId = agent['id'];
|
||||
}
|
||||
},
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
|
||||
@ -1353,7 +1353,7 @@ class othersPendings extends StatelessWidget {
|
||||
handleDashboardNavigation(
|
||||
context,
|
||||
status: "Awaiting Proposal",
|
||||
staffId: row['staff_id'],
|
||||
staffId: row['staff_id'] ?? '',
|
||||
role: role,
|
||||
);
|
||||
},
|
||||
@ -1375,7 +1375,7 @@ class othersPendings extends StatelessWidget {
|
||||
handleDashboardNavigation(
|
||||
context,
|
||||
status: "Proposal Created",
|
||||
staffId: row['staff_id'],
|
||||
staffId: row['staff_id'] ?? '',
|
||||
role: role,
|
||||
);
|
||||
},
|
||||
@ -1398,7 +1398,7 @@ class othersPendings extends StatelessWidget {
|
||||
handleDashboardNavigation(
|
||||
context,
|
||||
status: "Proposal Accepted",
|
||||
staffId: row['staff_id'],
|
||||
staffId: row['staff_id'] ?? '',
|
||||
role: role,
|
||||
);
|
||||
},
|
||||
@ -1928,7 +1928,7 @@ class UnassignedEnq extends StatelessWidget {
|
||||
Future<void> handleDashboardNavigation(
|
||||
BuildContext context, {
|
||||
required String status,
|
||||
required String staffId,
|
||||
String? staffId,
|
||||
required String role,
|
||||
}) async {
|
||||
print('Dashboard Tap => Status: $status | Staff: $staffId');
|
||||
@ -1943,7 +1943,7 @@ Future<void> handleDashboardNavigation(
|
||||
// ✅ Save new values
|
||||
await prefs.setString('dashboardKeyProvider', 'fromDashboard');
|
||||
await prefs.setString('dashboardStatusProvider', status);
|
||||
await prefs.setString('dashboardStaffIdProvider', staffId);
|
||||
await prefs.setString('dashboardStaffIdProvider', staffId!);
|
||||
|
||||
// ✅ Navigate
|
||||
if (role == 'manager') {
|
||||
|
||||
@ -89,7 +89,6 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
|
||||
|
||||
if (managerId != null &&
|
||||
dashboardKey != null &&
|
||||
dashboardKey == 'fromDashboard' &&
|
||||
dashboardStatus != null &&
|
||||
dashboardStaffId != null) {
|
||||
print("DASHBOARD STATus-$dashboardStatus -- $dashboardStaffId -");
|
||||
@ -143,11 +142,22 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
|
||||
// }
|
||||
|
||||
// ✅ Call your API
|
||||
getStaffList(managerId, roleId);
|
||||
getStaffList(
|
||||
managerId,
|
||||
roleId,
|
||||
SelectedStatus: SelectedStatus ?? '',
|
||||
SelectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
void refrshfilterDateRange() {
|
||||
setState(() {
|
||||
setState(() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
// ✅ Clear any old data
|
||||
await prefs.remove('dashboardKeyProvider');
|
||||
await prefs.remove('dashboardStatusProvider');
|
||||
await prefs.remove('dashboardStaffIdProvider');
|
||||
SelectedStatus = '';
|
||||
SelectedStaffId = null;
|
||||
controllers['startDate']!.clear();
|
||||
@ -174,12 +184,34 @@ class EnquiryHandlerState extends ConsumerState<EnquiryHandler> {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
dynamic fromDt;
|
||||
dynamic toDt;
|
||||
|
||||
final fromDateVal = controllers['startDate']?.text ?? '';
|
||||
final toDateVal = controllers['endDate']?.text ?? '';
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
|
||||
if (dashboardKey != 'fromDashboard' &&
|
||||
fromDateVal == '' &&
|
||||
toDateVal == '') {
|
||||
print("ENQ LIST PAGE");
|
||||
|
||||
final today = DateTime.now();
|
||||
fromDt = dateFormat.format(today.subtract(Duration(days: 15)));
|
||||
toDt = dateFormat.format(today);
|
||||
|
||||
print('Enq FROM TO - $fromDt - $toDt');
|
||||
} else {
|
||||
fromDt = fromDateVal;
|
||||
toDt = toDateVal;
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await apiService.fetchEnquiryList(
|
||||
managerId,
|
||||
role,
|
||||
fromDate: controllers['startDate']?.text ?? '',
|
||||
toDate: controllers['endDate']?.text ?? '',
|
||||
fromDate: fromDt,
|
||||
toDate: toDt,
|
||||
selectedStatus: SelectedStatus != null ? SelectedStatus : '',
|
||||
selectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
|
||||
@ -63,6 +63,7 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
List<Map<String, dynamic>> filteredData = [];
|
||||
bool isLoading = false;
|
||||
dynamic roleId;
|
||||
dynamic dashboardKey;
|
||||
|
||||
Map<String, TextEditingController> controllers = {};
|
||||
List<String> tabHeader = ['startDate', 'endDate'];
|
||||
@ -77,15 +78,49 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
controllers[field] = TextEditingController();
|
||||
}
|
||||
|
||||
Future.microtask(() {
|
||||
Future.microtask(() async {
|
||||
final id = ref.read(managerIdProvider);
|
||||
roleId = ref.read(userRoleProvider);
|
||||
userId = ref.read(userIdProvider);
|
||||
|
||||
print("C72 => r : $roleId | mId: $id | uId: $userId ");
|
||||
if (userId != null) {
|
||||
getStaffList(userId, roleId);
|
||||
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
dashboardKey = prefs.getString('dashboardKeyProvider');
|
||||
final dashboardStatus = prefs.getString('dashboardStatusProvider');
|
||||
final dashboardStaffId = prefs.getString('dashboardStaffIdProvider');
|
||||
// handlerId = ref.read(handlerIdProvider);
|
||||
|
||||
print('dashboardKey - $dashboardKey');
|
||||
print('dashboardStatus - $dashboardStatus');
|
||||
print('dashboardStaffId - $dashboardStaffId');
|
||||
|
||||
if (userId != null &&
|
||||
dashboardKey != null &&
|
||||
dashboardKey == 'fromDashboard' &&
|
||||
dashboardStatus != null &&
|
||||
dashboardStaffId != null) {
|
||||
print("DASHBOARD STATus-$dashboardStatus -- $dashboardStaffId -");
|
||||
SelectedStatus = dashboardStatus;
|
||||
SelectedStaffId = dashboardStaffId;
|
||||
getStaffList(
|
||||
userId,
|
||||
roleId,
|
||||
SelectedStatus: dashboardStatus,
|
||||
SelectedStaffId: dashboardStaffId,
|
||||
);
|
||||
} else {
|
||||
print('ELSE');
|
||||
getStaffList(
|
||||
userId,
|
||||
roleId,
|
||||
SelectedStatus: SelectedStatus ?? '',
|
||||
SelectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
}
|
||||
// if (userId != null) {
|
||||
// getStaffList(userId, roleId);
|
||||
// }
|
||||
});
|
||||
}
|
||||
|
||||
@ -96,7 +131,12 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
|
||||
print("C82 => r : $roleId | mId: $id | uId: $userId ");
|
||||
if (userId != null) {
|
||||
getStaffList(userId, roleId);
|
||||
getStaffList(
|
||||
userId,
|
||||
roleId,
|
||||
SelectedStatus: SelectedStatus ?? '',
|
||||
SelectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,26 +188,47 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
// return;
|
||||
// }
|
||||
// ✅ Call your API
|
||||
getStaffList(userId, roleId);
|
||||
getStaffList(
|
||||
userId,
|
||||
roleId,
|
||||
SelectedStatus: SelectedStatus ?? '',
|
||||
SelectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
void refrshfilterDateRange() {
|
||||
Future<void> refrshfilterDateRange() async {
|
||||
print('refrshfilterDateRange--1');
|
||||
setState(() {
|
||||
SelectedStatus = '';
|
||||
SelectedStaffId = null;
|
||||
// setState(() async {
|
||||
final prefs = await SharedPreferences.getInstance();
|
||||
|
||||
print('refrshselectedStaff - $SelectedStaffId');
|
||||
print('refrshfilterDateRange--1 - $SelectedStatus');
|
||||
controllers['startDate']!.clear();
|
||||
controllers['endDate']!.clear();
|
||||
// ✅ Clear any old data
|
||||
await prefs.remove('dashboardKeyProvider');
|
||||
await prefs.remove('dashboardStatusProvider');
|
||||
await prefs.remove('dashboardStaffIdProvider');
|
||||
SelectedStatus = '';
|
||||
SelectedStaffId = null;
|
||||
|
||||
controllers['startDate']?.text = '';
|
||||
controllers['endDate']?.text = '';
|
||||
// Reset the FormField validation
|
||||
_formKey.currentState?.reset();
|
||||
});
|
||||
getStaffList(userId, roleId);
|
||||
print('refrshselectedStaff - $SelectedStaffId');
|
||||
print('refrshfilterDateRange--1 - $SelectedStatus');
|
||||
controllers['startDate']!.clear();
|
||||
print('1');
|
||||
controllers['endDate']!.clear();
|
||||
print('2');
|
||||
controllers['startDate']?.text = '';
|
||||
print('3');
|
||||
controllers['endDate']?.text = '';
|
||||
print('4');
|
||||
// Reset the FormField validation
|
||||
_formKey.currentState?.reset();
|
||||
print('5');
|
||||
// });
|
||||
print('6');
|
||||
getStaffList(
|
||||
userId,
|
||||
roleId,
|
||||
SelectedStatus: SelectedStatus ?? '',
|
||||
SelectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
}
|
||||
|
||||
Future<void> getStaffList(
|
||||
@ -175,18 +236,44 @@ class EnquiryStaffState extends ConsumerState<EnquiryStaff> {
|
||||
role, {
|
||||
String fromDate = '',
|
||||
String toDate = '',
|
||||
String SelectedStatus = '',
|
||||
String SelectedStaffId = '',
|
||||
}) async {
|
||||
print('C89 => Fns called => $managerId | $role');
|
||||
setState(() {
|
||||
isLoading = true;
|
||||
});
|
||||
|
||||
dynamic fromDt;
|
||||
dynamic toDt;
|
||||
|
||||
final fromDateVal = controllers['startDate']?.text ?? '';
|
||||
final toDateVal = controllers['endDate']?.text ?? '';
|
||||
final dateFormat = DateFormat('dd-MM-yyyy');
|
||||
|
||||
if (dashboardKey != 'fromDashboard' &&
|
||||
fromDateVal == '' &&
|
||||
toDateVal == '') {
|
||||
print("ENQ LIST PAGE");
|
||||
|
||||
final today = DateTime.now();
|
||||
fromDt = dateFormat.format(today.subtract(Duration(days: 15)));
|
||||
toDt = dateFormat.format(today);
|
||||
|
||||
print('Enq FROM TO - $fromDt - $toDt');
|
||||
} else {
|
||||
fromDt = fromDateVal;
|
||||
toDt = toDateVal;
|
||||
}
|
||||
|
||||
try {
|
||||
final response = await apiService.fetchPolicyList(
|
||||
managerId,
|
||||
role,
|
||||
fromDate: controllers['startDate']?.text ?? '',
|
||||
toDate: controllers['endDate']?.text ?? '',
|
||||
fromDate: fromDt,
|
||||
toDate: toDt,
|
||||
// fromDate: controllers['startDate']?.text ?? '',
|
||||
// toDate: controllers['endDate']?.text ?? '',
|
||||
selectedStatus: SelectedStatus ?? '',
|
||||
selectedStaffId: SelectedStaffId ?? '',
|
||||
);
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
// import 'dart:io' as html;
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/services.dart';
|
||||
import 'package:http/http.dart' as http;
|
||||
import 'package:dropdown_search/dropdown_search.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@ -8,6 +9,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/providers/userRoleProvider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import 'package:toastification/toastification.dart';
|
||||
@ -94,6 +96,8 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
|
||||
dynamic acceptedQuotationId;
|
||||
dynamic choosedPolcyId;
|
||||
|
||||
dynamic roleId;
|
||||
|
||||
List<Map<String, dynamic>> getVehicleTypeData = [];
|
||||
List<Map<String, dynamic>> filteredVechicleData = [];
|
||||
|
||||
@ -152,6 +156,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
|
||||
Future.microtask(() {
|
||||
managerId = ref.read(managerIdProvider); // ✅ use read
|
||||
userId = ref.read(userIdProvider); // ✅ use read
|
||||
roleId = ref.read(userRoleProvider); // ✅ use read
|
||||
print('QmanagerId - $managerId');
|
||||
print('QuserId - $userId');
|
||||
enqQuotation = ref.read(quotationStaffIdProvider); // ✅ use read
|
||||
@ -541,7 +546,7 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
|
||||
// const SizedBox(height: 20),
|
||||
|
||||
//confirm button
|
||||
if (!hasPolicyData) ...[
|
||||
if (!hasPolicyData && roleId != 'manager') ...[
|
||||
Row(
|
||||
mainAxisAlignment: MainAxisAlignment.end,
|
||||
children: [
|
||||
@ -1010,6 +1015,9 @@ class PolicyStaffTabState extends ConsumerState<PolicyStaffTab> {
|
||||
ThemedFormField(
|
||||
controller: controllers['policyNumber']!,
|
||||
validator: (value) => Validators.requiredField(value, "policyNumber"),
|
||||
inputFormatters: [
|
||||
FilteringTextInputFormatter.allow(RegExp(r'[a-zA-Z 0-9]')),
|
||||
],
|
||||
txtwidth: ResponsiveLayout.isMobile(context)
|
||||
? null
|
||||
: MediaQuery.of(context).size.width * 0.26,
|
||||
|
||||
@ -8,6 +8,7 @@ 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:nhance_partner/presentation/providers/userRoleProvider.dart';
|
||||
import 'package:shared_preferences/shared_preferences.dart';
|
||||
|
||||
import '../../../../../core/routing/routes.dart';
|
||||
@ -69,6 +70,7 @@ class QuotationStaffTabState extends ConsumerState<QuotationStaffTab> {
|
||||
Map<String, TextEditingController> controllers = {};
|
||||
String? _token;
|
||||
dynamic userId;
|
||||
dynamic roleId;
|
||||
dynamic selectedEnquiryId;
|
||||
dynamic managerId;
|
||||
dynamic enqQuotation;
|
||||
@ -134,9 +136,11 @@ class QuotationStaffTabState extends ConsumerState<QuotationStaffTab> {
|
||||
Future.microtask(() {
|
||||
managerId = ref.read(managerIdProvider); // ✅ use read
|
||||
userId = ref.read(userIdProvider); // ✅ use read
|
||||
roleId = ref.read(userRoleProvider); // ✅ use read
|
||||
|
||||
print('QmanagerId - $managerId');
|
||||
print('QuserId - $userId');
|
||||
print('QroleId - $roleId');
|
||||
enqQuotation = ref.read(quotationStaffIdProvider); // ✅ use read
|
||||
print('QenqQuotation - $enqQuotation');
|
||||
if (enqQuotation != null) {
|
||||
@ -262,7 +266,7 @@ class QuotationStaffTabState extends ConsumerState<QuotationStaffTab> {
|
||||
// scrollDirection: Axis.vertical,
|
||||
child: Column(
|
||||
children: [
|
||||
if (!blockKey) ...[
|
||||
if (!blockKey && roleId != 'manager') ...[
|
||||
CreateQuotationForm(
|
||||
key: ValueKey(selectedQuotationFrmListId ?? "new"),
|
||||
userId: userId,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user