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