#!/bin/bash
# Script to generate Firebase configuration files for different environments/flavors

if [[ $# -eq 0 ]]; then
  echo "Error: No environment specified. Use 'dev', 'staging', or 'prod'."
  exit 1
fi

case $1 in
  dev)
    flutterfire config \
      --project=krow-workforce-dev \
      --out=lib/firebase_options_dev.dart \
      --ios-bundle-id=com.krow.app.business.dev \
      --ios-out=ios/flavors/dev/GoogleService-Info.plist \
      --android-package-name=com.krow.app.business.dev \
      --android-out=android/app/src/dev/google-services.json
    ;;
  staging)
    flutterfire config \
      --project=krow-workforce-staging \
      --out=lib/firebase_options_staging.dart \
      --ios-bundle-id=com.krow.app.business.staging \
      --ios-out=ios/flavors/staging/GoogleService-Info.plist \
      --android-package-name=com.krow.app.business.staging \
      --android-out=android/app/src/staging/google-services.json
    ;;
    prod)
    flutterfire config \
      --project=krow-workforce-dev \
      --out=lib/firebase_options_dev.dart \
      --ios-bundle-id=com.krow.app.business.dev \
      --ios-out=ios/flavors/dev/GoogleService-Info.plist \
      --android-package-name=com.krow.app.business.dev \
      --android-out=android/app/src/dev/google-services.json
    ;;
  *)
    echo "Error: Invalid environment specified. Use 'dev', 'staging', or 'prod'."
    exit 1
    ;;
esac
