cancelled product
This commit is contained in:
@@ -998,7 +998,7 @@
|
|||||||
"languageVersion": "3.4"
|
"languageVersion": "3.4"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"generated": "2025-02-25T13:35:16.100085Z",
|
"generated": "2025-02-27T10:55:41.147060Z",
|
||||||
"generator": "pub",
|
"generator": "pub",
|
||||||
"generatorVersion": "3.4.4",
|
"generatorVersion": "3.4.4",
|
||||||
"flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter",
|
"flutterRoot": "file:///Users/rajeevsingh/Documents/allSoftwares/flutter",
|
||||||
|
|||||||
File diff suppressed because one or more lines are too long
@@ -43,4 +43,10 @@ class APIURL {
|
|||||||
|
|
||||||
static const String deleteProduct = "${BASE_URL}products/";
|
static const String deleteProduct = "${BASE_URL}products/";
|
||||||
static const String updateProduct = "${BASE_URL}products/";
|
static const String updateProduct = "${BASE_URL}products/";
|
||||||
|
|
||||||
|
|
||||||
|
static const String getAssignedOtp =
|
||||||
|
"${BASE_URL}delivery/customer-otp";
|
||||||
|
|
||||||
|
static const String updateStatus = "${BASE_URL}orders/items/";
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -637,6 +637,7 @@ class OrderItem {
|
|||||||
dynamic productImage;
|
dynamic productImage;
|
||||||
dynamic productVariant;
|
dynamic productVariant;
|
||||||
dynamic? quantity;
|
dynamic? quantity;
|
||||||
|
dynamic orderItemStatus;
|
||||||
// dynamic originalProductPrice;
|
// dynamic originalProductPrice;
|
||||||
// dynamic originalProductDiscountPrice;
|
// dynamic originalProductDiscountPrice;
|
||||||
// dynamic discountAmount;
|
// dynamic discountAmount;
|
||||||
@@ -658,6 +659,7 @@ class OrderItem {
|
|||||||
this.productImage,
|
this.productImage,
|
||||||
this.productVariant,
|
this.productVariant,
|
||||||
this.quantity,
|
this.quantity,
|
||||||
|
this.orderItemStatus,
|
||||||
// this.originalProductPrice,
|
// this.originalProductPrice,
|
||||||
// this.originalProductDiscountPrice,
|
// this.originalProductDiscountPrice,
|
||||||
// this.discountAmount,
|
// this.discountAmount,
|
||||||
@@ -680,6 +682,9 @@ class OrderItem {
|
|||||||
productImage: json["productImage"],
|
productImage: json["productImage"],
|
||||||
productVariant: json["productVariant"],
|
productVariant: json["productVariant"],
|
||||||
quantity: json["quantity"],
|
quantity: json["quantity"],
|
||||||
|
|
||||||
|
orderItemStatus: json["orderItemStatus"],
|
||||||
|
|
||||||
// originalProductPrice: json["originalProductPrice"],
|
// originalProductPrice: json["originalProductPrice"],
|
||||||
// originalProductDiscountPrice: json["originalProductDiscountPrice"],
|
// originalProductDiscountPrice: json["originalProductDiscountPrice"],
|
||||||
// discountAmount: json["discountAmount"],
|
// discountAmount: json["discountAmount"],
|
||||||
@@ -703,6 +708,10 @@ class OrderItem {
|
|||||||
"productImage": productImage,
|
"productImage": productImage,
|
||||||
"productVariant": productVariant,
|
"productVariant": productVariant,
|
||||||
"quantity": quantity,
|
"quantity": quantity,
|
||||||
|
"orderItemStatus": orderItemStatus,
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// "originalProductPrice": originalProductPrice,
|
// "originalProductPrice": originalProductPrice,
|
||||||
// "originalProductDiscountPrice": originalProductDiscountPrice,
|
// "originalProductDiscountPrice": originalProductDiscountPrice,
|
||||||
// "discountAmount": discountAmount,
|
// "discountAmount": discountAmount,
|
||||||
|
|||||||
32
lib/src/data/order_OTP.dart
Normal file
32
lib/src/data/order_OTP.dart
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
// To parse this JSON data, do
|
||||||
|
//
|
||||||
|
// final deliveryOtpmodel = deliveryOtpmodelFromJson(jsonString);
|
||||||
|
|
||||||
|
import 'dart:convert';
|
||||||
|
|
||||||
|
DeliveryOtpmodel deliveryOtpmodelFromJson(String str) =>
|
||||||
|
DeliveryOtpmodel.fromJson(json.decode(str));
|
||||||
|
|
||||||
|
String deliveryOtpmodelToJson(DeliveryOtpmodel data) =>
|
||||||
|
json.encode(data.toJson());
|
||||||
|
|
||||||
|
class DeliveryOtpmodel {
|
||||||
|
String? code;
|
||||||
|
DateTime? expiresAt;
|
||||||
|
|
||||||
|
DeliveryOtpmodel({
|
||||||
|
this.code,
|
||||||
|
this.expiresAt,
|
||||||
|
});
|
||||||
|
|
||||||
|
factory DeliveryOtpmodel.fromJson(Map<String, dynamic> json) =>
|
||||||
|
DeliveryOtpmodel(
|
||||||
|
code: json["code"],
|
||||||
|
expiresAt: DateTime.parse(json["expiresAt"]),
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => {
|
||||||
|
"code": code,
|
||||||
|
"expiresAt": expiresAt!.toIso8601String(),
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,7 +1,9 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:fluttertoast/fluttertoast.dart';
|
||||||
import 'package:grocery_app/src/core/network_services/service_locator.dart';
|
import 'package:grocery_app/src/core/network_services/service_locator.dart';
|
||||||
import 'package:grocery_app/src/data/myOrder.dart';
|
import 'package:grocery_app/src/data/myOrder.dart';
|
||||||
import 'package:grocery_app/src/logic/repo/order_repo.dart';
|
import 'package:grocery_app/src/logic/repo/order_repo.dart';
|
||||||
|
import 'package:grocery_app/utils/extensions/extensions.dart';
|
||||||
|
|
||||||
class OrderProvider extends ChangeNotifier {
|
class OrderProvider extends ChangeNotifier {
|
||||||
final _orderRepo = getIt<OrderRepo>();
|
final _orderRepo = getIt<OrderRepo>();
|
||||||
@@ -23,7 +25,6 @@ class OrderProvider extends ChangeNotifier {
|
|||||||
(response) {
|
(response) {
|
||||||
orderList = response.data!;
|
orderList = response.data!;
|
||||||
|
|
||||||
|
|
||||||
isloading = false;
|
isloading = false;
|
||||||
notifyListeners();
|
notifyListeners();
|
||||||
},
|
},
|
||||||
@@ -36,5 +37,119 @@ class OrderProvider extends ChangeNotifier {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isSendOtp = false;
|
||||||
|
|
||||||
|
Future<void> getAssignedOtp(BuildContext context, String assignmentId) async {
|
||||||
|
context.showLoader(show: true);
|
||||||
|
notifyListeners();
|
||||||
|
var data = {"orderItemId": assignmentId};
|
||||||
|
|
||||||
|
print("ldflkgfkgjdh ${data}");
|
||||||
|
|
||||||
|
try {
|
||||||
|
var result = await _orderRepo.getAssignedOtp(data);
|
||||||
|
|
||||||
|
return result.fold(
|
||||||
|
(error) {
|
||||||
|
context.showLoader(show: false);
|
||||||
|
},
|
||||||
|
(response) {
|
||||||
|
_showOtpPopup(context, response.code!); //
|
||||||
|
|
||||||
|
context.showLoader(show: false);
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
context.showLoader(show: false);
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: "Something went wrong",
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 14.0,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void _showOtpPopup(BuildContext context, String otp) {
|
||||||
|
showDialog(
|
||||||
|
context: context,
|
||||||
|
builder: (context) => AlertDialog(
|
||||||
|
title: Center(child: Text("Your OTP")), // Center the title
|
||||||
|
content: Column(
|
||||||
|
mainAxisSize: MainAxisSize.min, // Prevent excessive height
|
||||||
|
children: [
|
||||||
|
Center(
|
||||||
|
child: Text(
|
||||||
|
otp,
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 24,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.blue,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
actions: [
|
||||||
|
Center(
|
||||||
|
child: TextButton(
|
||||||
|
onPressed: () => Navigator.pop(context),
|
||||||
|
child: Text("OK"),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
Future<bool> updateStatus(
|
||||||
|
BuildContext context, String orderStatus, String orderItemId) async {
|
||||||
|
context.showLoader(show: true);
|
||||||
|
|
||||||
|
var data = {"status": orderStatus, "comment": "string"};
|
||||||
|
try {
|
||||||
|
var result = await _orderRepo.updateStatus(data, orderItemId);
|
||||||
|
|
||||||
|
return result.fold(
|
||||||
|
(error) {
|
||||||
|
context.showLoader(show: false);
|
||||||
|
return false;
|
||||||
|
},
|
||||||
|
(response) {
|
||||||
|
context.showLoader(show: false);
|
||||||
|
getMyOrder(context);
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: "Order cancelled successfully!",
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 14.0,
|
||||||
|
);
|
||||||
|
Navigator.pop(context);
|
||||||
|
|
||||||
|
notifyListeners();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
},
|
||||||
|
);
|
||||||
|
} catch (e) {
|
||||||
|
context.showLoader(show: false);
|
||||||
|
|
||||||
|
print("lkjdgkfjhfdkg");
|
||||||
|
|
||||||
|
Fluttertoast.showToast(
|
||||||
|
msg: "Status already updated",
|
||||||
|
toastLength: Toast.LENGTH_SHORT,
|
||||||
|
gravity: ToastGravity.BOTTOM,
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
textColor: Colors.white,
|
||||||
|
fontSize: 14.0,
|
||||||
|
);
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ import 'package:fpdart/fpdart.dart';
|
|||||||
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
|
import 'package:grocery_app/src/core/utils/custom_dio_exception.dart';
|
||||||
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
import 'package:grocery_app/src/core/utils/response_type_def.dart';
|
||||||
import 'package:grocery_app/src/data/myOrder.dart';
|
import 'package:grocery_app/src/data/myOrder.dart';
|
||||||
|
import 'package:grocery_app/src/data/order_OTP.dart';
|
||||||
import 'package:grocery_app/src/data/order_paymnet.dart';
|
import 'package:grocery_app/src/data/order_paymnet.dart';
|
||||||
import 'package:grocery_app/src/logic/services/orderSirvice.dart';
|
import 'package:grocery_app/src/logic/services/orderSirvice.dart';
|
||||||
|
|
||||||
@@ -23,4 +24,34 @@ class OrderRepo {
|
|||||||
return left(error);
|
return left(error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
FutureResult<DeliveryOtpmodel> getAssignedOtp(data) async {
|
||||||
|
try {
|
||||||
|
var response = await _orderService.getAssignedOtp(data);
|
||||||
|
|
||||||
|
DeliveryOtpmodel storeModel =
|
||||||
|
deliveryOtpmodelFromJson(response.toString());
|
||||||
|
|
||||||
|
//final String model = response.toString();
|
||||||
|
return right(storeModel);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
var error = CustomDioExceptions.handleError(e);
|
||||||
|
return left(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FutureResult<String> updateStatus(data, orderItemId) async {
|
||||||
|
try {
|
||||||
|
var response = await _orderService.updateStatus(data, orderItemId);
|
||||||
|
|
||||||
|
final String model = response.toString();
|
||||||
|
return right(model);
|
||||||
|
} on DioException catch (e) {
|
||||||
|
var error = CustomDioExceptions.handleError(e);
|
||||||
|
return left(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,4 +13,20 @@ class OrderService extends ApiService
|
|||||||
return response;
|
return response;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Future getAssignedOtp(data) async {
|
||||||
|
var response = await api.get(APIURL.getAssignedOtp,
|
||||||
|
data: jsonEncode(data), queryParameters: data);
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
|
Future updateStatus(data, orderItemId) async {
|
||||||
|
var response = await api.patch(
|
||||||
|
APIURL.updateStatus + orderItemId + "/status",
|
||||||
|
data: jsonEncode(data));
|
||||||
|
|
||||||
|
return response;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,12 @@
|
|||||||
|
import 'package:flutter/gestures.dart';
|
||||||
import 'package:flutter/material.dart';
|
import 'package:flutter/material.dart';
|
||||||
|
import 'package:gap/gap.dart';
|
||||||
import 'package:grocery_app/src/common_widget/network_image.dart';
|
import 'package:grocery_app/src/common_widget/network_image.dart';
|
||||||
import 'package:grocery_app/src/data/myOrder.dart';
|
import 'package:grocery_app/src/data/myOrder.dart';
|
||||||
|
import 'package:grocery_app/src/logic/provider/order_provider.dart';
|
||||||
|
import 'package:grocery_app/utils/extensions/extensions.dart';
|
||||||
import 'package:intl/intl.dart';
|
import 'package:intl/intl.dart';
|
||||||
|
import 'package:provider/provider.dart';
|
||||||
|
|
||||||
class OrderDetailsScreen extends StatefulWidget {
|
class OrderDetailsScreen extends StatefulWidget {
|
||||||
final Datum order;
|
final Datum order;
|
||||||
@@ -13,20 +18,16 @@ class OrderDetailsScreen extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
||||||
int currentStep = 1;
|
|
||||||
String convertUtcToIst(String utcTime) {
|
String convertUtcToIst(String utcTime) {
|
||||||
// Parse the UTC time string
|
|
||||||
DateTime utcDateTime = DateTime.parse(utcTime).toUtc();
|
DateTime utcDateTime = DateTime.parse(utcTime).toUtc();
|
||||||
|
|
||||||
// Convert to IST (UTC +5:30)
|
|
||||||
DateTime istDateTime =
|
DateTime istDateTime =
|
||||||
utcDateTime.add(const Duration(hours: 5, minutes: 30));
|
utcDateTime.add(const Duration(hours: 5, minutes: 30));
|
||||||
|
|
||||||
// Format the IST datetime with AM/PM
|
|
||||||
String formattedDateTime =
|
String formattedDateTime =
|
||||||
DateFormat("dd-MM-yyyy hh:mm a").format(istDateTime);
|
DateFormat("dd-MM-yyyy hh:mm a").format(istDateTime);
|
||||||
|
|
||||||
return formattedDateTime; // Example: 11-02-2025 10:44 AM
|
return formattedDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -34,17 +35,39 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||||||
return Scaffold(
|
return Scaffold(
|
||||||
appBar: AppBar(title: Text('Order Details')),
|
appBar: AppBar(title: Text('Order Details')),
|
||||||
body: Padding(
|
body: Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Container(
|
||||||
|
width: MediaQuery.of(context).size.width,
|
||||||
|
child: Padding(
|
||||||
padding: const EdgeInsets.all(16.0),
|
padding: const EdgeInsets.all(16.0),
|
||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
_orderInfo(),
|
Text(widget.order.orderNumber,
|
||||||
SizedBox(height: 20),
|
style: TextStyle(
|
||||||
_animatedShippingTimeline(),
|
fontSize: 16, fontWeight: FontWeight.bold)),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 5),
|
||||||
|
Text(widget.order.deliveryAddress!.addressLine ?? " ",
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16, fontWeight: FontWeight.bold)),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
Text(convertUtcToIst(widget.order.createdAt.toString())),
|
||||||
|
SizedBox(height: 5),
|
||||||
|
// Text(
|
||||||
|
// "Status: ${_getStatusText(widget.order.orderStatus)}",
|
||||||
|
// style: TextStyle(
|
||||||
|
// color: Colors.blue, fontWeight: FontWeight.bold),
|
||||||
|
// ),
|
||||||
|
// _itemsList(),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
_itemsList(),
|
_itemsList(),
|
||||||
SizedBox(height: 20),
|
SizedBox(height: 20),
|
||||||
//_cancelButton(),
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -76,6 +99,7 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||||||
style:
|
style:
|
||||||
TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
|
TextStyle(color: Colors.blue, fontWeight: FontWeight.bold),
|
||||||
),
|
),
|
||||||
|
// _itemsList(),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -83,61 +107,73 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Animated Shipping Timeline
|
final List<String> statuses = [
|
||||||
Widget _animatedShippingTimeline() {
|
"PENDING",
|
||||||
return Column(
|
"PROCESSING",
|
||||||
|
"SHIPPED",
|
||||||
|
"DELIVERED"
|
||||||
|
];
|
||||||
|
|
||||||
|
Widget _animatedShippingTimeline(orderItemStatus) {
|
||||||
|
var currentStep = statuses.indexOf(orderItemStatus);
|
||||||
|
|
||||||
|
return Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.start, // Align items properly
|
||||||
children: [
|
children: [
|
||||||
for (int i = 0; i < 3; i++) _timelineStep(i),
|
for (int i = 0; i < statuses.length; i++)
|
||||||
|
_timelineStep(i, statuses[i], currentStep),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Each Step in the Timeline
|
Widget _timelineStep(int step, String status, currentStep) {
|
||||||
Widget _timelineStep(int step) {
|
|
||||||
bool isCompleted = step <= currentStep;
|
bool isCompleted = step <= currentStep;
|
||||||
|
|
||||||
return Row(
|
return Row(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.center,
|
||||||
children: [
|
|
||||||
Column(
|
|
||||||
children: [
|
children: [
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: Duration(milliseconds: 500),
|
duration: Duration(milliseconds: 500),
|
||||||
width: 20,
|
width: 15,
|
||||||
height: 20,
|
height: 15,
|
||||||
decoration: BoxDecoration(
|
decoration: BoxDecoration(
|
||||||
color: isCompleted ? Colors.green : Colors.grey,
|
color: isCompleted ? Colors.green : Colors.grey,
|
||||||
shape: BoxShape.circle,
|
shape: BoxShape.circle,
|
||||||
),
|
),
|
||||||
child: Icon(Icons.check, size: 14, color: Colors.white),
|
child: Icon(Icons.check, size: 12, color: Colors.white),
|
||||||
),
|
),
|
||||||
if (step < 2)
|
SizedBox(width: 5),
|
||||||
|
Text(
|
||||||
|
status,
|
||||||
|
style: TextStyle(fontSize: 10, fontWeight: FontWeight.bold),
|
||||||
|
),
|
||||||
|
if (step < statuses.length - 1) ...[
|
||||||
|
SizedBox(width: 5),
|
||||||
AnimatedContainer(
|
AnimatedContainer(
|
||||||
duration: Duration(milliseconds: 500),
|
duration: Duration(milliseconds: 500),
|
||||||
width: 5,
|
width: 20,
|
||||||
height: 50,
|
height: 3,
|
||||||
color: isCompleted ? Colors.green : Colors.grey,
|
color: isCompleted ? Colors.green : Colors.grey,
|
||||||
),
|
),
|
||||||
|
SizedBox(width: 5),
|
||||||
],
|
],
|
||||||
),
|
|
||||||
SizedBox(width: 10),
|
|
||||||
Text(
|
|
||||||
_getStatusTextForStep(widget.order.orderStatus),
|
|
||||||
style: TextStyle(fontSize: 16, fontWeight: FontWeight.bold),
|
|
||||||
),
|
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Status Texts
|
// PENDING PROCESSING SHIPPED DELIVERED CANCELLED RETURNED)
|
||||||
|
|
||||||
String _getStatusTextForStep(orderStatus) {
|
String _getStatusTextForStep(orderStatus) {
|
||||||
switch (orderStatus) {
|
switch (orderStatus) {
|
||||||
case 'PENDING':
|
case 'PENDING':
|
||||||
return "PENDING";
|
return "PENDING";
|
||||||
case 'SHIPPED':
|
case 'SHIPPED':
|
||||||
return "SHIPPED";
|
return "SHIPPED";
|
||||||
case 'DELIVERD':
|
case 'PROCESSING':
|
||||||
return "DELIVERD";
|
return "PROCESSING";
|
||||||
|
case 'DELIVERED':
|
||||||
|
return "DELIVERED";
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
@@ -165,8 +201,64 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||||||
// final item = items[index];
|
// final item = items[index];
|
||||||
var orderitem = widget.order.orderItems![index];
|
var orderitem = widget.order.orderItems![index];
|
||||||
return Card(
|
return Card(
|
||||||
margin: EdgeInsets.symmetric(vertical: 8),
|
margin: EdgeInsets.symmetric(vertical: 2),
|
||||||
child: ListTile(
|
child: Column(
|
||||||
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
|
children: [
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Row(
|
||||||
|
mainAxisAlignment: MainAxisAlignment.end,
|
||||||
|
children: [
|
||||||
|
if (orderitem.orderItemStatus == "PENDING")
|
||||||
|
InkWell(
|
||||||
|
onTap: () async {
|
||||||
|
var status = await Provider.of<OrderProvider>(
|
||||||
|
context,
|
||||||
|
listen: false)
|
||||||
|
.updateStatus(
|
||||||
|
context, "CANCELLED", orderitem.id);
|
||||||
|
},
|
||||||
|
child: Container(
|
||||||
|
padding: EdgeInsets.symmetric(
|
||||||
|
horizontal: 5, vertical: 5),
|
||||||
|
decoration: BoxDecoration(
|
||||||
|
color: Colors.green.shade100,
|
||||||
|
borderRadius: BorderRadius.circular(10),
|
||||||
|
),
|
||||||
|
child: Text(" Cancel ",
|
||||||
|
style: TextStyle(color: Colors.black)),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
Gap(5),
|
||||||
|
if (orderitem.orderItemStatus != "PENDING")
|
||||||
|
RichText(
|
||||||
|
text: TextSpan(
|
||||||
|
text: " ",
|
||||||
|
style: context.buttonTestStyle.copyWith(
|
||||||
|
color: context.appColor.blackColor,
|
||||||
|
),
|
||||||
|
children: [
|
||||||
|
TextSpan(
|
||||||
|
text: "GET OTP",
|
||||||
|
style: context.buttonTestStyle.copyWith(
|
||||||
|
color: Colors.blue,
|
||||||
|
decoration: TextDecoration.underline,
|
||||||
|
),
|
||||||
|
recognizer: TapGestureRecognizer()
|
||||||
|
..onTap = () {
|
||||||
|
Provider.of<OrderProvider>(context,
|
||||||
|
listen: false)
|
||||||
|
.getAssignedOtp(context, orderitem.id);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
],
|
||||||
|
),
|
||||||
|
),
|
||||||
|
ListTile(
|
||||||
leading: Container(
|
leading: Container(
|
||||||
width: 50,
|
width: 50,
|
||||||
height: 50,
|
height: 50,
|
||||||
@@ -182,27 +274,41 @@ class _OrderDetailsScreenState extends State<OrderDetailsScreen> {
|
|||||||
trailing: Text("₹${orderitem.totalOrderItemPrice ?? ""}",
|
trailing: Text("₹${orderitem.totalOrderItemPrice ?? ""}",
|
||||||
style: TextStyle(fontWeight: FontWeight.bold)),
|
style: TextStyle(fontWeight: FontWeight.bold)),
|
||||||
),
|
),
|
||||||
|
if (orderitem.orderItemStatus == "CANCELLED") ...{
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: Text("Order Cancelled",
|
||||||
|
style: TextStyle(
|
||||||
|
color: Colors.black, fontWeight: FontWeight.bold)),
|
||||||
|
)
|
||||||
|
} else ...{
|
||||||
|
Padding(
|
||||||
|
padding: const EdgeInsets.all(8.0),
|
||||||
|
child: _animatedShippingTimeline(orderitem.orderItemStatus),
|
||||||
|
),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
),
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Cancel Order Button (Only if not delivered)
|
// Widget _cancelButton() {
|
||||||
Widget _cancelButton() {
|
// return ElevatedButton(
|
||||||
return ElevatedButton(
|
// onPressed: currentStep < 2
|
||||||
onPressed: currentStep < 2
|
// ? () {
|
||||||
? () {
|
// setState(() {
|
||||||
setState(() {
|
// currentStep = 2;
|
||||||
currentStep = 2; // Simulate cancellation
|
// });
|
||||||
});
|
// }
|
||||||
}
|
// : null,
|
||||||
: null, // Disable if already delivered
|
// style: ElevatedButton.styleFrom(
|
||||||
style: ElevatedButton.styleFrom(
|
// backgroundColor: Colors.red,
|
||||||
backgroundColor: Colors.red,
|
// disabledBackgroundColor: Colors.grey,
|
||||||
disabledBackgroundColor: Colors.grey,
|
// ),
|
||||||
),
|
// child: Text("Cancel Order", style: TextStyle(color: Colors.white)),
|
||||||
child: Text("Cancel Order", style: TextStyle(color: Colors.white)),
|
// );
|
||||||
);
|
// }
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,18 +26,15 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String convertUtcToIst(String utcTime) {
|
String convertUtcToIst(String utcTime) {
|
||||||
// Parse the UTC time string
|
|
||||||
DateTime utcDateTime = DateTime.parse(utcTime).toUtc();
|
DateTime utcDateTime = DateTime.parse(utcTime).toUtc();
|
||||||
|
|
||||||
// Convert to IST (UTC +5:30)
|
|
||||||
DateTime istDateTime =
|
DateTime istDateTime =
|
||||||
utcDateTime.add(const Duration(hours: 5, minutes: 30));
|
utcDateTime.add(const Duration(hours: 5, minutes: 30));
|
||||||
|
|
||||||
// Format the IST datetime with AM/PM
|
|
||||||
String formattedDateTime =
|
String formattedDateTime =
|
||||||
DateFormat("dd-MM-yyyy hh:mm a").format(istDateTime);
|
DateFormat("dd-MM-yyyy hh:mm a").format(istDateTime);
|
||||||
|
|
||||||
return formattedDateTime; // Example: 11-02-2025 10:44 AM
|
return formattedDateTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@@ -145,16 +142,16 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
|
|||||||
],
|
],
|
||||||
),
|
),
|
||||||
Spacer(),
|
Spacer(),
|
||||||
Container(
|
// Container(
|
||||||
padding: EdgeInsets.symmetric(
|
// padding: EdgeInsets.symmetric(
|
||||||
horizontal: 5, vertical: 5),
|
// horizontal: 5, vertical: 5),
|
||||||
decoration: BoxDecoration(
|
// decoration: BoxDecoration(
|
||||||
color: Colors.green.shade100,
|
// color: Colors.green.shade100,
|
||||||
borderRadius: BorderRadius.circular(10),
|
// borderRadius: BorderRadius.circular(10),
|
||||||
),
|
// ),
|
||||||
child: Text(order.orderStatus,
|
// child: Text(order.orderStatus,
|
||||||
style: TextStyle(color: Colors.green)),
|
// style: TextStyle(color: Colors.green)),
|
||||||
),
|
// ),
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
SizedBox(height: 10),
|
SizedBox(height: 10),
|
||||||
@@ -232,7 +229,9 @@ class _MyOrderScreenState extends State<MyOrderScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Future<void> _makePhoneCall(String number) async {
|
Future<void> _makePhoneCall(String number) async
|
||||||
|
{
|
||||||
|
|
||||||
try {
|
try {
|
||||||
final Uri phoneUri = Uri(scheme: 'tel', path: number);
|
final Uri phoneUri = Uri(scheme: 'tel', path: number);
|
||||||
if (await canLaunchUrl(phoneUri)) {
|
if (await canLaunchUrl(phoneUri)) {
|
||||||
|
|||||||
Reference in New Issue
Block a user