status
This commit is contained in:
@@ -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 {
|
||||
static const String baseUrl = "http://10.119.0.74:8000/api";
|
||||
static const String fileBaseUrl = "http://10.119.0.74:8000/";
|
||||
|
||||
@@ -5,6 +5,9 @@ class AppConfig {
|
||||
// For Android Emulator
|
||||
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)
|
||||
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 = {};
|
||||
final Map<String, bool> _expanded = {};
|
||||
|
||||
bool confirming = false;
|
||||
|
||||
bool get isOrderPlaced => order['status'] == 'order_placed';
|
||||
bool get isConfirmed => order['status'] != 'order_placed';
|
||||
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
super.initState();
|
||||
@@ -65,6 +71,10 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
||||
_itemsSection(items, scale),
|
||||
SizedBox(height: 18 * 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
|
||||
// -----------------------------
|
||||
@@ -267,7 +340,7 @@ class _OrderDetailScreenState extends State<OrderDetailScreen> {
|
||||
child: Column(
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text("Totals",
|
||||
Text("Totalss",
|
||||
style: TextStyle(fontSize: 18 * scale, fontWeight: FontWeight.bold)),
|
||||
SizedBox(height: 12 * scale),
|
||||
_totalRow("Total Qty", order['ttl_qty'], scale),
|
||||
|
||||
@@ -8,6 +8,7 @@ import 'token_interceptor.dart';
|
||||
class DioClient {
|
||||
static Dio? _dio;
|
||||
|
||||
// static const String baseUrl = "http://103.248.30.24:3030";
|
||||
static const String baseUrl = "http://10.119.0.74:8000";
|
||||
|
||||
static Dio getInstance(BuildContext context) {
|
||||
|
||||
@@ -29,4 +29,10 @@ class OrderService {
|
||||
final res = await _dio.get('/user/order/$id/track');
|
||||
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'
|
||||
'?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");
|
||||
|
||||
|
||||
Reference in New Issue
Block a user