diff --git a/lib/provider/markleave_provider.dart b/lib/provider/markleave_provider.dart index 0622af7..f84d704 100644 --- a/lib/provider/markleave_provider.dart +++ b/lib/provider/markleave_provider.dart @@ -64,7 +64,7 @@ class MarkLeaveProvider extends ChangeNotifier{ "date": date, "time": time, "reason": reason, - "leaveType":leaveType, + "leaveType":'$leaveType Leave', }); setLoading(false); if (response.statusCode == 200) { diff --git a/lib/provider/select_task_provider.dart b/lib/provider/select_task_provider.dart index e4f80db..26a6320 100644 --- a/lib/provider/select_task_provider.dart +++ b/lib/provider/select_task_provider.dart @@ -12,7 +12,7 @@ class SelectTaskProvider extends ChangeNotifier { } final _apiClient = ApiClient(); - List tasksList=[]; + List tasksList = []; bool _isLoading = false; @@ -30,7 +30,10 @@ class SelectTaskProvider extends ChangeNotifier { setLoading(false); if (response.statusCode == 200) { final data = SelectTaskKycResponse.fromJson(response.data); - tasksList = data.tasks ?? []; + tasksList = data!.tasks! + .where( + (element) => element.taskStatus!.toLowerCase() != "completed") + .toList(); notifyListeners(); } } catch (e) { diff --git a/lib/screens/add_sales_product_screen.dart b/lib/screens/add_sales_product_screen.dart index 8d980ac..d69cf45 100644 --- a/lib/screens/add_sales_product_screen.dart +++ b/lib/screens/add_sales_product_screen.dart @@ -15,12 +15,13 @@ class AddSalesProductScreen extends StatefulWidget { final String pdRdId; final String? inventoryId; - const AddSalesProductScreen( - {super.key, - required this.distributorType, - required this.tradeName, - required this.pdRdId, - this.inventoryId}); + const AddSalesProductScreen({ + super.key, + required this.distributorType, + required this.tradeName, + required this.pdRdId, + this.inventoryId, + }); @override State createState() => _AddSalesProductScreenState(); @@ -34,250 +35,240 @@ class _AddSalesProductScreenState extends State { @override void initState() { + super.initState(); salesTaskProvider = Provider.of(context, listen: false); - WidgetsBinding.instance.addPostFrameCallback((timeStamp) { + dateController.text = DateFormat('dd/MM/yyyy').format(DateTime.now()); + WidgetsBinding.instance.addPostFrameCallback((_) { salesTaskProvider.getTask(); }); - super.initState(); } @override void dispose() { + searchController.dispose(); + dateController.dispose(); if (mounted) { salesTaskProvider.resetProducts(); } super.dispose(); } - datePicker() async { - final DateTime? picked = await showDatePicker( - context: context, - initialDate: DateTime.now(), - firstDate: DateTime(2000), - lastDate: DateTime(2101), - ); - if (picked != null) { - setState( - () => dateController.text = DateFormat('dd/MM/yyyy').format(picked)); - } - } - @override Widget build(BuildContext context) { return PopScope( canPop: true, child: CommonBackground( - child: Scaffold( - backgroundColor: Colors.transparent, - appBar: CommonAppBar( - actions: [ - IconButton( - onPressed: () => Navigator.pop(context), - icon: Image.asset('assets/Back_attendance.png'), - padding: const EdgeInsets.only(right: 20)) - ], - title: Text('${widget.distributorType}\n${widget.tradeName}', - textAlign: TextAlign.center, - style: const TextStyle( - fontSize: 20, - color: Colors.black, - fontWeight: FontWeight.w400, - fontFamily: 'Anek')), - backgroundColor: Colors.transparent, - elevation: 0), - drawer: const CommonDrawer(), - bottomNavigationBar: Consumer( - builder: (context, value, child) => Column( - mainAxisSize: MainAxisSize.min, - children: [ - Align( - alignment: value.tasksList.isEmpty - ? Alignment.center - : Alignment.bottomCenter, - child: Padding( - padding: const EdgeInsets.all(16.0), - child: Column( - mainAxisSize: MainAxisSize.min, - children: [ - FloatingActionButton.extended( - onPressed: () { - showModalBottomSheet( - isScrollControlled: true, - constraints: BoxConstraints( - maxHeight: MediaQuery.of(context) - .size - .height * - 0.9), - context: context, - builder: (BuildContext context) { - return Consumer( - builder: - (context, value, child) => - StatefulBuilder(builder: - (context, - setState) { - return Column( - children: [ - Padding( - padding: - const EdgeInsets - .all( - 18.0), - child: TextField( - controller: searchController, - decoration: const InputDecoration(labelText: 'Search by name or SKU', border: OutlineInputBorder(), prefixIcon: Icon(Icons.search)), - onChanged: (val) { - value.filterProducts( - val); - setState( - () {}); - })), - Expanded( - child: ListView - .builder( - itemCount: searchController.text.isEmpty - ? value.tasksList.length - : value.searchList.length, - itemBuilder: (context, index) { - bool isAlreadySelected = value.selectedProducts.any((selectedProduct) => selectedProduct.SKU == value.tasksList[index].SKU); - final data = searchController.text.isEmpty ? value.tasksList[index] : value.searchList[index]; - return Card( - child: ListTile( - title: Text(data.ProductName ?? '', style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black)), - subtitle: Text(data.SKU ?? '', style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black)), - onTap: isAlreadySelected - ? null - : () { - setState(() => value.selectedProducts.add(data)); - Navigator.pop(context); - })); - })) - ]); - })); - }, - ).whenComplete(() => setState(() {})); - }, - backgroundColor: Colors.white, - icon: const Icon(Icons.add, - color: Colors.black), - label: const Text('Add Products', - style: - TextStyle(color: Colors.black))), - if (value.selectedProducts.isNotEmpty) ...[ - const SizedBox(height: 16.0), - Consumer( - builder: (context, value, child) => - CommonElevatedButton( - borderRadius: 30, - width: double.infinity, - height: kToolbarHeight - 10, - text: 'SUBMIT', - backgroundColor: - const Color(0xff004791), - onPressed: () { - if (formKey.currentState! - .validate()) { - if (value.selectedProducts - .isNotEmpty && - value.selectedProducts.every((product) => - product.SKU! - .isNotEmpty && - product.ProductName! - .isNotEmpty && - product.SalesAmount != - null && - product.QuantitySold != - null)) { - value.submitProducts( - distributorType: widget - .distributorType, - pdRdId: widget.pdRdId, - inventoryId: - widget.inventoryId, - date: dateController - .text - .trim(), - tradeName: - widget.tradeName); - } else { - ScaffoldMessenger.of( - context) - .showSnackBar( - const SnackBar( - content: Text( - 'Please fill out all product details, including sale and inventory.')), - ); - } - } - })) - ] - ]))), - ], - ), + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: CommonAppBar( + actions: [ + IconButton( + onPressed: () => Navigator.pop(context), + icon: Image.asset('assets/Back_attendance.png'), + padding: const EdgeInsets.only(right: 20), + ) + ], + title: Text( + '${widget.distributorType}\n${widget.tradeName}', + textAlign: TextAlign.center, + style: const TextStyle( + fontSize: 20, + color: Colors.black, + fontWeight: FontWeight.w400, + fontFamily: 'Anek', ), - body: - Consumer(builder: (context, value, child) { - return Stack(children: [ - Column(children: [ - GestureDetector( - onTap: () => datePicker(), - child: AbsorbPointer( - child: Padding( - padding: const EdgeInsets.all(8.0), - child: Form( - key: formKey, - child: TextFormField( - controller: dateController, - validator: (value) { - if (value!.isEmpty) { - return 'Please select a date'; - } - return null; - }, - decoration: const InputDecoration( - labelText: 'Date', - fillColor: Colors.white, - filled: true, - border: InputBorder.none, - suffixIcon: Icon(Icons.calendar_today), - ), - ), + ), + backgroundColor: Colors.transparent, + elevation: 0, + ), + drawer: const CommonDrawer(), + bottomNavigationBar: Consumer( + builder: (context, value, child) => Column( + mainAxisSize: MainAxisSize.min, + children: [ + Align( + alignment: value.tasksList.isEmpty + ? Alignment.center + : Alignment.bottomCenter, + child: Padding( + padding: const EdgeInsets.all(16.0), + child: Column( + mainAxisSize: MainAxisSize.min, + children: [ + FloatingActionButton.extended( + onPressed: () => _showProductSelectionBottomSheet(context), + backgroundColor: Colors.white, + icon: const Icon(Icons.add, color: Colors.black), + label: const Text('Add Products', style: TextStyle(color: Colors.black)), + ), + if (value.selectedProducts.isNotEmpty) ...[ + const SizedBox(height: 16.0), + CommonElevatedButton( + borderRadius: 30, + width: double.infinity, + height: kToolbarHeight - 10, + text: 'SUBMIT', + backgroundColor: const Color(0xff004791), + onPressed: () => _submitProducts(value), + ), + ], + ], + ), + ), + ), + ], + ), + ), + body: Consumer( + builder: (context, value, child) { + return Stack( + children: [ + Column( + children: [ + Padding( + padding: const EdgeInsets.all(8.0), + child: TextFormField( + controller: dateController, + readOnly: true, + decoration: const InputDecoration( + labelText: 'Date', + fillColor: Colors.white, + filled: true, + border: InputBorder.none, + suffixIcon: Icon(Icons.calendar_today), ), ), ), - ), - if (value.selectedProducts.isNotEmpty) - Expanded( + if (value.selectedProducts.isNotEmpty) + Expanded( child: ListView.builder( - itemCount: value.selectedProducts.length, - itemBuilder: (context, index) { - return ProductBlock( - onUpdate: (updatedProduct) { - setState(() { - value.selectedProducts[index] = - updatedProduct; - }); - }, - onRemove: () { - setState(() { - value.selectedProducts.removeAt(index); - }); - }, - product: value.selectedProducts[index]); - })) - ]), - (value.isLoading) - ? Container( - color: Colors.black12, - child: - const Center(child: CircularProgressIndicator())) - : const SizedBox() - ]); - }))), + itemCount: value.selectedProducts.length, + itemBuilder: (context, index) { + return ProductBlock( + onUpdate: (updatedProduct) { + setState(() { + value.selectedProducts[index] = updatedProduct; + }); + }, + onRemove: () { + setState(() { + value.selectedProducts.removeAt(index); + }); + }, + product: value.selectedProducts[index], + ); + }, + ), + ), + ], + ), + if (value.isLoading) + Container( + color: Colors.black12, + child: const Center(child: CircularProgressIndicator()), + ), + ], + ); + }, + ), + ), + ), ); } + + void _showProductSelectionBottomSheet(BuildContext context) { + showModalBottomSheet( + isScrollControlled: true, + context: context, + builder: (BuildContext context) { + return Consumer( + builder: (context, value, child) => StatefulBuilder( + builder: (context, setState) { + return Column( + children: [ + Padding( + padding: const EdgeInsets.all(18.0), + child: TextField( + controller: searchController, + decoration: const InputDecoration( + labelText: 'Search by name or SKU', + border: OutlineInputBorder(), + prefixIcon: Icon(Icons.search), + ), + onChanged: (val) { + value.filterProducts(val); + setState(() {}); + }, + ), + ), + Expanded( + child: ListView.builder( + itemCount: searchController.text.isEmpty + ? value.tasksList.length + : value.searchList.length, + itemBuilder: (context, index) { + final data = searchController.text.isEmpty + ? value.tasksList[index] + : value.searchList[index]; + bool isAlreadySelected = value.selectedProducts + .any((selectedProduct) => selectedProduct.SKU == data.SKU); + return Card( + child: ListTile( + title: Text( + data.ProductName ?? '', + style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black), + ), + subtitle: Text( + data.SKU ?? '', + style: TextStyle(color: isAlreadySelected ? Colors.grey : Colors.black), + ), + onTap: isAlreadySelected + ? null + : () { + setState(() => value.selectedProducts.add(data)); + Navigator.pop(context); + }, + ), + ); + }, + ), + ), + ], + ); + }, + ), + ); + }, + ).whenComplete(() => setState(() {})); + } + + void _submitProducts(AddSalesProvider value) { + if (formKey.currentState!.validate()) { + if (value.selectedProducts.isNotEmpty && + value.selectedProducts.every((product) => + product.SKU!.isNotEmpty && + product.ProductName!.isNotEmpty && + product.SalesAmount != null && + product.QuantitySold != null)) { + value.submitProducts( + distributorType: widget.distributorType, + pdRdId: widget.pdRdId, + inventoryId: widget.inventoryId, + date: dateController.text.trim(), + tradeName: widget.tradeName, + ); + } else { + ScaffoldMessenger.of(context).showSnackBar( + const SnackBar( + content: Text('Please fill out all product details, including sale and inventory.'), + ), + ); + } + } + } } +// The ProductBlock class remains unchanged class ProductBlock extends StatefulWidget { final SalesProduct product; final ValueChanged onUpdate; @@ -304,9 +295,8 @@ class _ProductBlockState extends State { void initState() { super.initState(); saleAmountController.text = (widget.product.SalesAmount ?? '').toString(); - commentController.text = (widget.product.comments?? '').toString(); - quantitySoldController.text = - (widget.product.QuantitySold ?? '').toString(); + commentController.text = (widget.product.comments ?? '').toString(); + quantitySoldController.text = (widget.product.QuantitySold ?? '').toString(); } void validateInput() { @@ -326,7 +316,7 @@ class _ProductBlockState extends State { if (quantitySoldError == null && salesAmountError == null) { int quantitySold = int.parse(quantitySoldController.text); int salesAmount = int.parse(saleAmountController.text); - String comments =commentController.text; + String comments = commentController.text; widget.onUpdate(SalesProduct( SKU: widget.product.SKU, @@ -344,80 +334,86 @@ class _ProductBlockState extends State { @override Widget build(BuildContext context) { return Card( - color: Colors.white, - margin: const EdgeInsets.all(8), - child: Stack(children: [ + color: Colors.white, + margin: const EdgeInsets.all(8), + child: Stack( + children: [ Padding( padding: const EdgeInsets.all(16), - child: - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - Text('Product: ${widget.product.ProductName}', - style: const TextStyle(fontSize: 16)), - Text('SKU: ${widget.product.SKU}', - style: const TextStyle(fontSize: 15)), - const SizedBox(height: 8), - Column(crossAxisAlignment: CrossAxisAlignment.start, children: [ - TextField( - controller: saleAmountController, - onTapOutside: (event) => FocusScope.of(context).unfocus(), - inputFormatters: [FilteringTextInputFormatter.digitsOnly], - decoration: InputDecoration( + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + Text('Product: ${widget.product.ProductName}', + style: const TextStyle(fontSize: 16)), + Text('SKU: ${widget.product.SKU}', + style: const TextStyle(fontSize: 15)), + const SizedBox(height: 8), + Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + TextField( + controller: saleAmountController, + onTapOutside: (event) => FocusScope.of(context).unfocus(), + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + decoration: InputDecoration( labelText: 'Sales amount', errorText: saleAmountController.text.isEmpty ? 'Sales amount cannot be empty.' - : null), - keyboardType: TextInputType.number, - enabled: true, - onChanged: (_) => validateInput()), - TextField( - controller: quantitySoldController, - onTapOutside: (event) => FocusScope.of(context).unfocus(), - inputFormatters: [FilteringTextInputFormatter.digitsOnly], - decoration: InputDecoration( + : null, + ), + keyboardType: TextInputType.number, + enabled: true, + onChanged: (_) => validateInput(), + ), + TextField( + controller: quantitySoldController, + onTapOutside: (event) => FocusScope.of(context).unfocus(), + inputFormatters: [FilteringTextInputFormatter.digitsOnly], + decoration: InputDecoration( labelText: 'Quantity sold', errorText: quantitySoldController.text.isEmpty ? 'Quantity sold cannot be empty.' - : null), - keyboardType: TextInputType.number, - enabled: true, - onChanged: (_) => validateInput()), - TextField( - controller: commentController, - onTapOutside: (event) => FocusScope.of(context).unfocus(), - decoration: const InputDecoration( - labelText: 'Comments',), - enabled: true, - onChanged: (_) => validateInput()) - ]), - ]), + : null, + ), + keyboardType: TextInputType.number, + enabled: true, + onChanged: (_) => validateInput(), + ), + TextField( + controller: commentController, + onTapOutside: (event) => FocusScope.of(context).unfocus(), + decoration: const InputDecoration( + labelText: 'Comments', + ), + enabled: true, + onChanged: (_) => validateInput(), + ), + ], + ), + ], + ), ), Positioned( - top: 0, - right: 0, - child: IconButton( - icon: const Icon( - Icons.delete_outlined, - color: Colors.red, - ), - onPressed: widget.onRemove)), - ])); + top: 0, + right: 0, + child: IconButton( + icon: const Icon( + Icons.delete_outlined, + color: Colors.red, + ), + onPressed: widget.onRemove, + ), + ), + ], + ), + ); } -} -class ProductModel { - final String sku; - final String productName; - final int? sale; - final int? inventory; - final String? comments; - final String? date; - - ProductModel({ - required this.sku, - required this.productName, - this.sale, - this.inventory, - this.comments, - this.date, - }); -} + @override + void dispose() { + saleAmountController.dispose(); + quantitySoldController.dispose(); + commentController.dispose(); + super.dispose(); + } +} \ No newline at end of file diff --git a/lib/screens/on_leave_screen.dart b/lib/screens/on_leave_screen.dart index 1bf7850..57bff94 100644 --- a/lib/screens/on_leave_screen.dart +++ b/lib/screens/on_leave_screen.dart @@ -1,4 +1,3 @@ -import 'package:cheminova/provider/markleave_provider.dart'; import 'package:cheminova/screens/Attendance_success.dart'; import 'package:cheminova/widgets/common_drawer.dart'; import 'package:flutter/material.dart'; @@ -7,6 +6,7 @@ import 'package:geocoding/geocoding.dart'; import 'package:geolocator/geolocator.dart'; import 'package:intl/intl.dart'; import 'package:provider/provider.dart'; +import '../provider/markleave_provider.dart'; import '../widgets/common_app_bar.dart'; import '../widgets/common_elevated_button.dart'; import '../widgets/common_text_form_field.dart'; @@ -22,10 +22,10 @@ class _OnLeaveScreenState extends State { late MarkLeaveProvider _markLeaveProvider; final dateController = TextEditingController( - text: DateFormat('dd/MM/yyyy').format(DateTime.now())); + text: DateFormat('yyyy/MM/dd').format(DateTime.now())); final timeController = - TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); + TextEditingController(text: DateFormat('hh:mm a').format(DateTime.now())); final locationController = TextEditingController(); final notesController = TextEditingController(); @@ -43,7 +43,8 @@ class _OnLeaveScreenState extends State { return GestureDetector( onTap: () => onLeaveTypeSelected(leaveType), - child: Container(margin: const EdgeInsets.only(bottom: 10), + child: Container( + margin: const EdgeInsets.only(bottom: 10), width: 120, padding: const EdgeInsets.symmetric(vertical: 5.0), decoration: BoxDecoration( @@ -62,6 +63,7 @@ class _OnLeaveScreenState extends State { ), ); } + @override void initState() { super.initState(); @@ -92,8 +94,8 @@ class _OnLeaveScreenState extends State { debugPrint('position--- $position'); List placeMarks = - await placemarkFromCoordinates(position.latitude, position.longitude) - .timeout(const Duration(seconds: 10)); + await placemarkFromCoordinates(position.latitude, position.longitude) + .timeout(const Duration(seconds: 10)); debugPrint('place mark--- $placeMarks'); Placemark place = placeMarks[0]; @@ -105,129 +107,139 @@ class _OnLeaveScreenState extends State { @override Widget build(BuildContext context) { return ChangeNotifierProvider( - create: (_) => _markLeaveProvider, - builder: (context, child) => - CommonBackground( - child: Scaffold(backgroundColor: Colors.transparent, - appBar: CommonAppBar( - actions: [ - IconButton( - onPressed: () - { - Navigator.pop(context); - }, - icon: Image.asset('assets/Back_attendance.png'), padding: const EdgeInsets.only(right: 20), - ), - ], - title: const Text('On Leave', - style: TextStyle( - fontSize: 28, - color: Colors.black, - fontWeight: FontWeight.w400, - fontFamily: 'Anek')), backgroundColor: Colors.transparent, elevation: 0, - ), - drawer: const CommonDrawer(), - body: Padding( - padding: const EdgeInsets.all(16.0), - child: SingleChildScrollView( - physics: const BouncingScrollPhysics(), - child: Column( - mainAxisAlignment: MainAxisAlignment.center, - crossAxisAlignment: CrossAxisAlignment.center, - children: [ - const SizedBox(height: 16), - Container( - padding: - const EdgeInsets.all(20.0).copyWith(top: 30, bottom: 30), - margin: const EdgeInsets.symmetric(horizontal: 30.0), - decoration: BoxDecoration( - border: Border.all(color: Colors.white), - color: const Color(0xffB4D1E5).withOpacity(0.9), - borderRadius: BorderRadius.circular(26.0)), - child: Column( - crossAxisAlignment: CrossAxisAlignment.start, - children: [ - CommonTextFormField( - title: 'Date', - readOnly: true, - fillColor: Colors.white, - controller: dateController), - const SizedBox(height: 15), - CommonTextFormField( - title: 'Time', - readOnly: true, - fillColor: Colors.white, - controller: timeController), - const SizedBox(height: 15), - const Text('Leave type', - style: TextStyle( - fontSize: 15, - color: Colors.black, - fontWeight: FontWeight.w400, - fontFamily: 'Anek')), - const SizedBox(height:3 ), - Wrap(direction: Axis.horizontal, - children: [ - buildLeaveTypeOption('Sick'), - const SizedBox(width: 10), - buildLeaveTypeOption('Personal'), - const SizedBox(width: 10), - buildLeaveTypeOption('Privilege '), - ], - ), - const SizedBox(height: 15), - CommonTextFormField( - height: 100, - title: 'Reason', - fillColor: Colors.white, - maxLines: 4, - controller: notesController), - const SizedBox(height: 16), - Align( - alignment: Alignment.center, - child: Consumer( - builder: (context, value, child) =>CommonElevatedButton( - borderRadius: 30, - width: double.infinity, - height: kToolbarHeight - 10, - text: 'ON LEAVE', - backgroundColor: const Color(0xff00784C), - onPressed: () { - value - .markLeave( - dateController.text.trim(), - timeController.text.trim(), - locationController.text.trim(), - notesController.text.trim(), selectedLeaveType) - .then( - (result) { - var (status, message) = result; - ScaffoldMessenger.of(context) - .showSnackBar(SnackBar( - content: Text(message))); - if (status) { - Navigator.pushReplacement( - context, - MaterialPageRoute( - builder: (context) => - const AttendanceSuccess())); - } - }, - ); - - // Navigator.push(context, MaterialPageRoute(builder:(context) => const AttendanceSuccess(),)); - }), - ) - - ), - ], - ), + create: (_) => _markLeaveProvider, + builder: (context, child) => CommonBackground( + child: Scaffold( + backgroundColor: Colors.transparent, + appBar: CommonAppBar( + actions: [ + IconButton( + onPressed: () { + Navigator.pop(context); + }, + icon: Image.asset('assets/Back_attendance.png'), + padding: const EdgeInsets.only(right: 20), ), ], + title: const Text('On Leave', + style: TextStyle( + fontSize: 28, + color: Colors.black, + fontWeight: FontWeight.w400, + fontFamily: 'Anek')), + backgroundColor: Colors.transparent, + elevation: 0, + ), + drawer: const CommonDrawer(), + body: Padding( + padding: const EdgeInsets.all(16.0), + child: SingleChildScrollView( + physics: const BouncingScrollPhysics(), + child: Column( + mainAxisAlignment: MainAxisAlignment.center, + crossAxisAlignment: CrossAxisAlignment.center, + children: [ + const SizedBox(height: 16), + Container( + padding: const EdgeInsets.all(20.0) + .copyWith(top: 30, bottom: 30), + margin: const EdgeInsets.symmetric(horizontal: 30.0), + decoration: BoxDecoration( + border: Border.all(color: Colors.white), + color: const Color(0xffB4D1E5).withOpacity(0.9), + borderRadius: BorderRadius.circular(26.0)), + child: Column( + crossAxisAlignment: CrossAxisAlignment.start, + children: [ + CommonTextFormField( + title: 'Date', + readOnly: true, + fillColor: Colors.white, + controller: dateController), + const SizedBox(height: 15), + CommonTextFormField( + title: 'Time', + readOnly: true, + fillColor: Colors.white, + controller: timeController), + const SizedBox(height: 15), + const Text('Leave type', + style: TextStyle( + fontSize: 15, + color: Colors.black, + fontWeight: FontWeight.w400, + fontFamily: 'Anek')), + const SizedBox(height: 3), + Wrap( + direction: Axis.horizontal, + children: [ + buildLeaveTypeOption('Sick'), + const SizedBox(width: 10), + buildLeaveTypeOption('Personal'), + const SizedBox(width: 10), + buildLeaveTypeOption('Privilege '), + ], + ), + const SizedBox(height: 15), + CommonTextFormField( + height: 100, + title: 'Reason', + fillColor: Colors.white, + maxLines: 4, + controller: notesController), + const SizedBox(height: 16), + Align( + alignment: Alignment.center, + child: Consumer( + builder: (context, value, child) => + CommonElevatedButton( + borderRadius: 30, + width: double.infinity, + height: kToolbarHeight - 10, + text: 'ON LEAVE', + backgroundColor: + const Color(0xff00784C), + onPressed: () { + value + .markLeave( + dateController.text + .trim(), + timeController.text + .trim(), + locationController.text + .trim(), + notesController.text + .trim(), + selectedLeaveType) + .then( + (result) { + var (status, message) = + result; + ScaffoldMessenger.of(context) + .showSnackBar(SnackBar( + content: + Text(message))); + if (status) { + Navigator.pushReplacement( + context, + MaterialPageRoute( + builder: (context) => + const AttendanceSuccess())); + } + }, + ); + + // Navigator.push(context, MaterialPageRoute(builder:(context) => const AttendanceSuccess(),)); + }), + )), + ], + ), + ), + ], + ), + ), ), ), - ),), - ) - ); + )); } -} \ No newline at end of file +} diff --git a/lib/screens/visit_rd_pd_screen.dart b/lib/screens/visit_rd_pd_screen.dart index b3d0c35..26f4ce8 100644 --- a/lib/screens/visit_rd_pd_screen.dart +++ b/lib/screens/visit_rd_pd_screen.dart @@ -146,13 +146,13 @@ class VisitDealersScreenState extends State { CommonTextFormField( title: 'Meeting Summary:', fillColor: Colors.white, - maxLines: 4, + maxLines: 3, controller: meetingSummaryController), const SizedBox(height: 15), CommonTextFormField( title: 'Follow-up Actions:', fillColor: Colors.white, - maxLines: 4, + maxLines: 3, controller: followUpActionsController), const SizedBox(height: 15), CommonTextFormField( diff --git a/lib/services/api_urls.dart b/lib/services/api_urls.dart index 2005caa..97cc692 100644 --- a/lib/services/api_urls.dart +++ b/lib/services/api_urls.dart @@ -21,6 +21,6 @@ class ApiUrls { static const String kycSelectTaskUrl = '${baseUrl}task/task/type/Collect KYC'; static const String updateTaskInventoryUrl = '${baseUrl}task/update-task-status/'; static const String getProductsManual = '${baseUrl}productmanual/getall'; - static const String salesTaskUrl = '${baseUrl}product/getAll/user/?category=Bottle'; + static const String salesTaskUrl = '${baseUrl}product/getAll/user/'; static const String postSalesTaskUrl = '${baseUrl}sales/add-SC'; }