From 4e2cfcb45d94efbd74a949923a50fae153026761 Mon Sep 17 00:00:00 2001 From: PaarasPurohit Date: Tue, 1 Oct 2024 16:50:18 -0700 Subject: [PATCH] set variable for base url --- lib/ui/BarcodeScanner.dart | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/lib/ui/BarcodeScanner.dart b/lib/ui/BarcodeScanner.dart index 96c321d..9497775 100644 --- a/lib/ui/BarcodeScanner.dart +++ b/lib/ui/BarcodeScanner.dart @@ -12,7 +12,8 @@ class _BarcodeScannerPageState extends State { String barcode = ''; Map inventoryEntry = {}; List tools = []; - String userID = "yourUserID"; // Replace with actual user ID + String userID = "deltameters"; // Replace with actual user ID + String baseUrl = "https://optixtoolkit-backend-production-abcd.up.railway.app/"; // Replace this variable later with the actual base URL @override void initState() { @@ -48,7 +49,7 @@ class _BarcodeScannerPageState extends State { // Step 4: POST inventory check Future _postInventoryCheck() async { - var url = Uri.parse('http://localhost:4000/inventory-check'); + var url = Uri.parse('$baseUrl/inventory-check'); try { var response = await http.post( @@ -78,7 +79,7 @@ class _BarcodeScannerPageState extends State { // Step 5: POST inventory decrease count Future _postInventoryDecreaseCount() async { - var url = Uri.parse('http://localhost:4000/decrease-count'); + var url = Uri.parse('$baseUrl/decrease-count'); try { var response = await http.post( @@ -101,7 +102,7 @@ class _BarcodeScannerPageState extends State { // Step 6: POST tool reservation Future _postToolReservation() async { - var url = Uri.parse('http://localhost:4000/reserve-tool'); + var url = Uri.parse('$baseUrl/reserve-tool'); try { var response = await http.post( @@ -126,7 +127,7 @@ class _BarcodeScannerPageState extends State { // Step 7: Fetch tools Future _fetchTools() async { - var url = Uri.parse('http://localhost:4000/tools'); + var url = Uri.parse('$baseUrl/tools'); try { var response = await http.get(url); @@ -146,13 +147,13 @@ class _BarcodeScannerPageState extends State { // Step 8: Check In function Future _checkInTool(String toolName) async { - var deleteUrl = Uri.parse('http://localhost:4000/tools/$userID/$toolName'); + var deleteUrl = Uri.parse('$baseUrl/tools/$userID/$toolName'); try { var deleteResponse = await http.delete(deleteUrl); if (deleteResponse.statusCode == 200) { - var postUrl = Uri.parse('http://localhost:4000/increase-count'); + var postUrl = Uri.parse('$baseUrl/increase-count'); await http.post( postUrl, body: jsonEncode({