Skip to content

Commit

Permalink
set variable for base url
Browse files Browse the repository at this point in the history
  • Loading branch information
PaarasPurohit committed Oct 1, 2024
1 parent 665da6d commit 4e2cfcb
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions lib/ui/BarcodeScanner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@ class _BarcodeScannerPageState extends State<BarcodeScannerPage> {
String barcode = '';
Map<String, dynamic> inventoryEntry = {};
List<dynamic> 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() {
Expand Down Expand Up @@ -48,7 +49,7 @@ class _BarcodeScannerPageState extends State<BarcodeScannerPage> {

// Step 4: POST inventory check
Future<void> _postInventoryCheck() async {
var url = Uri.parse('http://localhost:4000/inventory-check');
var url = Uri.parse('$baseUrl/inventory-check');

try {
var response = await http.post(
Expand Down Expand Up @@ -78,7 +79,7 @@ class _BarcodeScannerPageState extends State<BarcodeScannerPage> {

// Step 5: POST inventory decrease count
Future<void> _postInventoryDecreaseCount() async {
var url = Uri.parse('http://localhost:4000/decrease-count');
var url = Uri.parse('$baseUrl/decrease-count');

try {
var response = await http.post(
Expand All @@ -101,7 +102,7 @@ class _BarcodeScannerPageState extends State<BarcodeScannerPage> {

// Step 6: POST tool reservation
Future<void> _postToolReservation() async {
var url = Uri.parse('http://localhost:4000/reserve-tool');
var url = Uri.parse('$baseUrl/reserve-tool');

try {
var response = await http.post(
Expand All @@ -126,7 +127,7 @@ class _BarcodeScannerPageState extends State<BarcodeScannerPage> {

// Step 7: Fetch tools
Future<void> _fetchTools() async {
var url = Uri.parse('http://localhost:4000/tools');
var url = Uri.parse('$baseUrl/tools');

try {
var response = await http.get(url);
Expand All @@ -146,13 +147,13 @@ class _BarcodeScannerPageState extends State<BarcodeScannerPage> {

// Step 8: Check In function
Future<void> _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({
Expand Down

0 comments on commit 4e2cfcb

Please sign in to comment.