#!/bin/bash

echo "Select Platform"
echo " 1. android"
echo " 2. ios"

read -p "Select Platform: " PLATFORM
echo ""

if [ $PLATFORM == "1" ]; then
  export RUN_PLATFORM=run-android
elif [ $PLATFORM == "2" ]; then
  export RUN_PLATFORM=run-ios
else
  exit 1
fi

echo "Select AIRBRIDGE_ENVIRONMENT"
echo " 1. default"
echo " 2. development"
echo " 3. test-dev200"
echo " 4. test_dev201"
echo " 5. test-dev@notsupport"
echo " 6. test-not-exist"

read -p "Enter your environment (default: 1): " INPUT
echo ""

if [ $INPUT == "1" ]; then
  echo "select default env"
elif [ $INPUT == "2" ]; then
  export AIRBRIDGE_ENVIRONMENT=development
elif [ $INPUT == "3" ]; then
  export AIRBRIDGE_ENVIRONMENT=test-dev200
elif [ $INPUT == "4" ]; then
  export AIRBRIDGE_ENVIRONMENT=test_dev201
elif [ $INPUT == "5" ]; then
  export AIRBRIDGE_ENVIRONMENT=test-dev@notsupport
elif [ $INPUT == "6" ]; then
  export AIRBRIDGE_ENVIRONMENT=test-not-exist
else
  echo "select wrong. set default env"
fi

cp "test/airbridge.$AIRBRIDGE_ENVIRONMENT.json" .

echo ""
echo "###############################################"
echo "## RUN_PLATFORM: $RUN_PLATFORM"
echo "## AIRBRIDGE_ENVIRONMENT: $AIRBRIDGE_ENVIRONMENT"
echo "###############################################"
echo ""

npx react-native $RUN_PLATFORM --port=9000