Profile UI & Product manual api integrate
This commit is contained in:
parent
91912fcc95
commit
b4bf13214a
@ -36,8 +36,6 @@ class ProductProvider extends ChangeNotifier {
|
||||
}
|
||||
|
||||
Future<void> getProducts() async {
|
||||
// setLoading(true);
|
||||
// try {
|
||||
Response response = await _apiClient.get(ApiUrls.getProducts);
|
||||
debugPrint('Response: $response');
|
||||
setLoading(false);
|
||||
@ -49,10 +47,6 @@ class ProductProvider extends ChangeNotifier {
|
||||
.toList();
|
||||
notifyListeners();
|
||||
}
|
||||
// } catch (e) {
|
||||
// setLoading(false);
|
||||
// debugPrint("Error: $e");
|
||||
// }
|
||||
}
|
||||
|
||||
Future<void> submitProducts(
|
||||
|
45
lib/provider/userprofile_provider.dart
Normal file
45
lib/provider/userprofile_provider.dart
Normal file
@ -0,0 +1,45 @@
|
||||
import 'package:cheminova/models/profile_response.dart';
|
||||
import 'package:cheminova/services/api_client.dart';
|
||||
import 'package:cheminova/services/api_urls.dart';
|
||||
import 'package:cheminova/services/secure__storage_service.dart';
|
||||
import 'package:dio/dio.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import '../screens/login_screen.dart';
|
||||
|
||||
class UserprofileProvider extends ChangeNotifier {
|
||||
final _apiClient = ApiClient();
|
||||
ProfileResponse? profileResponse;
|
||||
bool _isLoading = false;
|
||||
|
||||
bool get isLoading => _isLoading;
|
||||
|
||||
void setLoading(bool loading) {
|
||||
_isLoading = loading;
|
||||
notifyListeners();
|
||||
}
|
||||
|
||||
Future<void> getProfile() async {
|
||||
setLoading(true);
|
||||
try {
|
||||
Response response = await _apiClient.get(ApiUrls.profileUrl);
|
||||
setLoading(false);
|
||||
if (response.statusCode == 200) {
|
||||
profileResponse = ProfileResponse.fromJson(response.data);
|
||||
} else {}
|
||||
} catch (e) {
|
||||
setLoading(false);
|
||||
}
|
||||
}
|
||||
|
||||
Future<void> logOut(BuildContext context) async {
|
||||
Response response = await _apiClient.get(ApiUrls.logOutUrl);
|
||||
if (response.statusCode == 200) {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
SnackBar(content: Text(response.data['message'].toString())));
|
||||
SecureStorageService().clear();
|
||||
Navigator.pushReplacement(
|
||||
context, MaterialPageRoute(builder: (context) => const LoginPage()));
|
||||
}
|
||||
}
|
||||
}
|
@ -178,7 +178,7 @@ class _AddProductsScreenState extends State<AddProductsScreen> {
|
||||
product.inventory != null)) {
|
||||
value.submitProducts(
|
||||
distributorType: widget.distributorType,
|
||||
pdRdId: widget.pdRdId, inventoryId: widget.inventoryId!
|
||||
pdRdId: widget.pdRdId, inventoryId: widget.inventoryId
|
||||
);
|
||||
} else {
|
||||
ScaffoldMessenger.of(context).showSnackBar(
|
||||
|
@ -63,22 +63,35 @@ class _UpdateInventoryTaskScreenState extends State<UpdateInventoryTaskScreen> {
|
||||
|
||||
Widget _buildTaskList() {
|
||||
return Consumer<DailyTaskProvider>(
|
||||
builder: (context, value, child) =>
|
||||
value.isLoading
|
||||
? const Center(child: CircularProgressIndicator())
|
||||
: ListView.separated(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: value.newTasksList.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
||||
itemBuilder: (context, index) {
|
||||
final task = value.newTasksList[index];
|
||||
if (task.task?.toLowerCase() == 'update inventory data') {
|
||||
return _buildTaskCard(task);
|
||||
} else {
|
||||
return const SizedBox.shrink();
|
||||
builder: (context, value, child) {
|
||||
if (value.isLoading) {
|
||||
return const Center(child: CircularProgressIndicator());
|
||||
}
|
||||
},
|
||||
|
||||
final inventoryTasks = value.newTasksList
|
||||
.where((task) => task.task?.toLowerCase() == 'update inventory data')
|
||||
.toList();
|
||||
|
||||
if (inventoryTasks.isEmpty) {
|
||||
return const Center(
|
||||
child: Text(
|
||||
'NO TASK',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
return ListView.separated(
|
||||
padding: const EdgeInsets.all(16),
|
||||
itemCount: inventoryTasks.length,
|
||||
separatorBuilder: (context, index) => const SizedBox(height: 8),
|
||||
itemBuilder: (context, index) => _buildTaskCard(inventoryTasks[index]),
|
||||
);
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
@ -119,7 +132,6 @@ class _UpdateInventoryTaskScreenState extends State<UpdateInventoryTaskScreen> {
|
||||
],
|
||||
),
|
||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
||||
|
||||
),
|
||||
),
|
||||
);
|
||||
|
@ -203,8 +203,8 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
||||
MaterialPageRoute(
|
||||
builder: (context) => AddProductsScreen(
|
||||
distributorType: tasksList.addedFor!,
|
||||
tradeName: tasksList.tradeName ?? '',
|
||||
pdRdId: tasksList.sId!, inventoryId:tasksList.sId!)));
|
||||
tradeName: tasksList.tradeName?? '',
|
||||
pdRdId: tasksList.addedForId!, inventoryId:tasksList.sId)));
|
||||
} else if (tasksList.task == 'Update Sales Data') {
|
||||
Navigator.push(
|
||||
context,
|
||||
@ -215,7 +215,7 @@ class _DailyTasksScreenState extends State<DailyTasksScreen> {
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) => VisitDealersScreen(
|
||||
tradeName: tasksList.tradeName??'',id: tasksList.sId!,
|
||||
tradeName: tasksList.tradeName??'',
|
||||
)));
|
||||
}
|
||||
},
|
||||
|
@ -46,17 +46,6 @@ class RetailerDetailsScreenState extends State<RetailerDetailsScreen> {
|
||||
Column(
|
||||
children: [
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Trade Name',
|
||||
fillColor: Colors.white,
|
||||
validator: (String? value) {
|
||||
if (value!.isEmpty) {
|
||||
return 'Trade Name cannot be empty';
|
||||
}
|
||||
return null;
|
||||
},
|
||||
controller: value.tradeNameController),
|
||||
const SizedBox(height: 15),
|
||||
CommonTextFormField(
|
||||
title: 'Name',
|
||||
fillColor: Colors.white,
|
||||
|
@ -41,7 +41,8 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
||||
icon: Image.asset('assets/Back_attendance.png'),
|
||||
padding: const EdgeInsets.only(right: 20),
|
||||
),
|
||||
]),
|
||||
],
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Consumer<SelectTaskProvider>(
|
||||
builder: (context, value, child) =>
|
||||
@ -50,19 +51,31 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
||||
: _buildTaskList(),
|
||||
),
|
||||
),
|
||||
));
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTaskList() {
|
||||
return Consumer<SelectTaskProvider>(builder: (context, value, child) {
|
||||
return Consumer<SelectTaskProvider>(
|
||||
builder: (context, value, child) {
|
||||
if (value.tasksList.isEmpty) {
|
||||
return const Center(child: Text('No tasks available'));
|
||||
return const Center(
|
||||
child: Text(
|
||||
'NO TASK',
|
||||
style: TextStyle(
|
||||
fontSize: 18,
|
||||
fontWeight: FontWeight.bold,
|
||||
color: Colors.black87,
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
return ListView.builder(
|
||||
itemCount: value.tasksList.length,
|
||||
itemBuilder: (context, index) => _buildTaskCard(value.tasksList[index]),
|
||||
);
|
||||
});
|
||||
},
|
||||
);
|
||||
}
|
||||
|
||||
Widget _buildTaskCard(Tasks task) {
|
||||
@ -70,8 +83,9 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
||||
onTap: () => Navigator.push(
|
||||
context,
|
||||
MaterialPageRoute(
|
||||
builder: (context) =>
|
||||
CollectKycScreen(id: task.taskId ?? ''))),
|
||||
builder: (context) => CollectKycScreen(id: task.taskId ?? ''),
|
||||
),
|
||||
),
|
||||
child: Card(
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16, vertical: 8),
|
||||
color: Colors.white,
|
||||
@ -90,10 +104,7 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
||||
fontFamily: 'Anek',
|
||||
),
|
||||
),
|
||||
trailing:
|
||||
const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
||||
|
||||
|
||||
trailing: const Icon(Icons.arrow_forward_ios, color: Colors.black87),
|
||||
),
|
||||
Padding(
|
||||
padding: const EdgeInsets.all(8.0),
|
||||
@ -103,10 +114,9 @@ class SelectTaskkycScreenState extends State<SelectTaskkycScreen> {
|
||||
Text('Note: ${task.note}'),
|
||||
if (task.taskDueDate != null)
|
||||
Text(
|
||||
'Date: ${task.taskDueDate == null ? '' : DateFormat(
|
||||
'dd/MM/yyyy').format(
|
||||
DateTime.parse(task.taskDueDate ?? ''))}'),
|
||||
Text('Priority: ${task.taskPriority}')
|
||||
'Date: ${task.taskDueDate == null ? '' : DateFormat('dd/MM/yyyy').format(DateTime.parse(task.taskDueDate ?? ''))}',
|
||||
),
|
||||
Text('Priority: ${task.taskPriority}'),
|
||||
],
|
||||
),
|
||||
),
|
||||
|
@ -87,9 +87,7 @@ class VisitDealersScreenState extends State<VisitDealersScreen> {
|
||||
elevation: 0,
|
||||
),
|
||||
drawer: const CommonDrawer(),
|
||||
body: Padding(
|
||||
padding: const EdgeInsets.all(16.0),
|
||||
child: SingleChildScrollView(
|
||||
body: SingleChildScrollView(
|
||||
physics: const BouncingScrollPhysics(),
|
||||
child: Column(
|
||||
mainAxisAlignment: MainAxisAlignment.center,
|
||||
@ -99,7 +97,7 @@ class VisitDealersScreenState extends State<VisitDealersScreen> {
|
||||
Container(
|
||||
padding:
|
||||
const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30),
|
||||
// margin: const EdgeInsets.symmetric(horizontal: 30.0),
|
||||
margin: const EdgeInsets.symmetric(horizontal: 16.0),
|
||||
decoration: BoxDecoration(
|
||||
border: Border.all(color: Colors.white),
|
||||
color: const Color(0xffB4D1E5).withOpacity(0.9),
|
||||
@ -200,7 +198,6 @@ class VisitDealersScreenState extends State<VisitDealersScreen> {
|
||||
),
|
||||
),
|
||||
),
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user