.PHONY: update-config build deploy

update-config:
	sudo git pull
	./select-api-url.sh
	sudo bash run-and-watch.sh 
	sudo cp .htaccess build
	@echo "Server is running. Press Ctrl+C to terminate."



deploy: update-config
	# Extract the apiUrl value from constants.js
	API_URL := $(shell grep -oP "apiUrl: '\K[^']+" app/js/constants.js)
	
	# Select the appropriate destination based on the apiUrl value
	if [ "$(API_URL)" = "https://api.plsfax.natilait.online/api/v1/" ]; then \
		scp -r /var/www/nomadis/maj/nomadis_maj/build/ root@178.33.229.28893:/var/www/nomadis/bizerte/nomadis_dashboard; \
	elif [ "$(API_URL)" = "https://api.sfax.natilait.online/api/v1/" ]; then \
		scp -r /var/www/nomadis/maj/nomadis_maj/build/ root@178.33.229.28893:/var/www/nomadis/sfax/nomadis_dashboard; \
	# Add more conditions as needed for other apiUrl values
	else \
		echo "Invalid API_URL value in constants.js"; \
	fi
