status
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -1,3 +1,7 @@
|
|||||||
|
// class ApiConfig {
|
||||||
|
// static const String baseUrl = "http://103.248.30.24:3030/api";
|
||||||
|
// static const String fileBaseUrl = "http://103.248.30.24:3030/";
|
||||||
|
// }
|
||||||
class ApiConfig {
|
class ApiConfig {
|
||||||
static const String baseUrl = "http://10.119.0.74:8000/api";
|
static const String baseUrl = "http://10.119.0.74:8000/api";
|
||||||
static const String fileBaseUrl = "http://10.119.0.74:8000/";
|
static const String fileBaseUrl = "http://10.119.0.74:8000/";
|
||||||
|
|||||||
@@ -5,6 +5,9 @@ class AppConfig {
|
|||||||
// For Android Emulator
|
// For Android Emulator
|
||||||
static const String logoUrlEmulator = "http://10.0.2.2:8000/images/kent_logo2.png";
|
static const String logoUrlEmulator = "http://10.0.2.2:8000/images/kent_logo2.png";
|
||||||
|
|
||||||
|
// For Physical Device (Replace with your actual PC local IP)
|
||||||
|
//static const String logoUrlDevice = "http://103.248.30.24:3030/images/kent_logo2.png";
|
||||||
|
|
||||||
// For Physical Device (Replace with your actual PC local IP)
|
// For Physical Device (Replace with your actual PC local IP)
|
||||||
static const String logoUrlDevice = "http://10.119.0.74:8000/images/kent_logo2.png";
|
static const String logoUrlDevice = "http://10.119.0.74:8000/images/kent_logo2.png";
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,12 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
|||||||
Map order = {};
|
Map order = {};
|
||||||
final Map<String, bool> _expanded = {};
|
final Map<String, bool> _expanded = {};
|
||||||
|
|
||||||
|
bool confirming = false;
|
||||||
|
|
||||||
|
bool get isOrderPlaced => order['status'] == 'order_placed';
|
||||||
|
bool get isConfirmed => order['status'] != 'order_placed';
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
void initState() {
|
void initState() {
|
||||||
super.initState();
|
super.initState();
|
||||||
@@ -65,6 +71,10 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
|||||||
_itemsSection(items, scale),
|
_itemsSection(items, scale),
|
||||||
SizedBox(height: 18 * scale),
|
SizedBox(height: 18 * scale),
|
||||||
_totalsSection(scale),
|
_totalsSection(scale),
|
||||||
|
|
||||||
|
SizedBox(height: 24 * scale),
|
||||||
|
_confirmOrderButton(scale),
|
||||||
|
|
||||||
],
|
],
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
@@ -72,6 +82,69 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Widget _confirmOrderButton(double scale) {
|
||||||
|
final isPlaced = order['status'] == 'order_placed';
|
||||||
|
|
||||||
|
return SizedBox(
|
||||||
|
width: double.infinity,
|
||||||
|
height: 52 * scale,
|
||||||
|
child: ElevatedButton(
|
||||||
|
style: ElevatedButton.styleFrom(
|
||||||
|
backgroundColor: isPlaced ? Colors.orange : Colors.green,
|
||||||
|
shape: RoundedRectangleBorder(
|
||||||
|
borderRadius: BorderRadius.circular(14 * scale),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
onPressed: (!isPlaced || confirming)
|
||||||
|
? null
|
||||||
|
: () async {
|
||||||
|
setState(() => confirming = true);
|
||||||
|
|
||||||
|
final service =
|
||||||
|
OrderService(DioClient.getInstance(context));
|
||||||
|
|
||||||
|
final res =
|
||||||
|
await service.confirmOrder(order['order_id']);
|
||||||
|
|
||||||
|
confirming = false;
|
||||||
|
|
||||||
|
if (res['success'] == true) {
|
||||||
|
setState(() {
|
||||||
|
order['status'] = 'order_confirmed';
|
||||||
|
});
|
||||||
|
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
const SnackBar(
|
||||||
|
content: Text('Order confirmed successfully'),
|
||||||
|
backgroundColor: Colors.green,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
ScaffoldMessenger.of(context).showSnackBar(
|
||||||
|
SnackBar(
|
||||||
|
content: Text(res['message'] ?? 'Failed to confirm order'),
|
||||||
|
backgroundColor: Colors.red,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
setState(() {});
|
||||||
|
},
|
||||||
|
child: confirming
|
||||||
|
? const CircularProgressIndicator(color: Colors.white)
|
||||||
|
: Text(
|
||||||
|
isPlaced ? 'Confirm Order' : 'Order Confirmed',
|
||||||
|
style: TextStyle(
|
||||||
|
fontSize: 16 * scale,
|
||||||
|
fontWeight: FontWeight.bold,
|
||||||
|
color: Colors.white,
|
||||||
|
),
|
||||||
|
),
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
// SUMMARY CARD
|
// SUMMARY CARD
|
||||||
// -----------------------------
|
// -----------------------------
|
||||||
@@ -267,7 +340,7 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
|||||||
child: Column(
|
child: Column(
|
||||||
crossAxisAlignment: CrossAxisAlignment.start,
|
crossAxisAlignment: CrossAxisAlignment.start,
|
||||||
children: [
|
children: [
|
||||||
Text("Totals",
|
Text("Totalss",
|
||||||
style: TextStyle(fontSize: 18 * scale, fontWeight: FontWeight.bold)),
|
style: TextStyle(fontSize: 18 * scale, fontWeight: FontWeight.bold)),
|
||||||
SizedBox(height: 12 * scale),
|
SizedBox(height: 12 * scale),
|
||||||
_totalRow("Total Qty", order['ttl_qty'], scale),
|
_totalRow("Total Qty", order['ttl_qty'], scale),
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import 'token_interceptor.dart';
|
|||||||
class DioClient {
|
class DioClient {
|
||||||
static Dio? _dio;
|
static Dio? _dio;
|
||||||
|
|
||||||
|
// static const String baseUrl = "http://103.248.30.24:3030";
|
||||||
static const String baseUrl = "http://10.119.0.74:8000";
|
static const String baseUrl = "http://10.119.0.74:8000";
|
||||||
|
|
||||||
static Dio getInstance(BuildContext context) {
|
static Dio getInstance(BuildContext context) {
|
||||||
|
|||||||
@@ -29,4 +29,10 @@ class OrderService {
|
|||||||
final res = await _dio.get('/user/order/$id/track');
|
final res = await _dio.get('/user/order/$id/track');
|
||||||
return res.data;
|
return res.data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<Map<String, dynamic>> confirmOrder(String orderId) async {
|
||||||
|
final res = await _dio.post('/user/orders/$orderId/confirm');
|
||||||
|
return res.data;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,6 +39,10 @@ class ReverbSocketService {
|
|||||||
'ws://10.119.0.74:8080/app/q5fkk5rvcnatvbgadwvl'
|
'ws://10.119.0.74:8080/app/q5fkk5rvcnatvbgadwvl'
|
||||||
'?protocol=7&client=flutter&version=1.0',
|
'?protocol=7&client=flutter&version=1.0',
|
||||||
);
|
);
|
||||||
|
// final uri = Uri.parse(
|
||||||
|
// 'ws://103.248.30.24:8080/app/q5fkk5rvcnatvbgadwvl'
|
||||||
|
// '?protocol=7&client=flutter&version=1.0',
|
||||||
|
// );
|
||||||
|
|
||||||
debugPrint("🔌 CONNECTING SOCKET → $uri");
|
debugPrint("🔌 CONNECTING SOCKET → $uri");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user