#!/bin/bash

# Ensure we exit if any command fails
set -e

PROJECT_ID="siro-a6957"

echo "=========================================="
echo "🔧 Setting up Firebase for Siro Applications"
echo "Project ID: $PROJECT_ID"
echo "=========================================="

echo -e "\n📦 1. Configuring Siro Rider..."
cd siro_rider
flutterfire configure --project=$PROJECT_ID --out=lib/firebase_options.dart --ios-bundle-id=com.siro.rider --android-package-name=com.siro.rider --platforms=android,ios -y
cd ..
echo "✅ Siro Rider configured successfully!"

echo -e "\n📦 2. Configuring Siro Driver..."
cd siro_driver
flutterfire configure --project=$PROJECT_ID --out=lib/firebase_options.dart --ios-bundle-id=com.siro.driver --android-package-name=com.siro.driver --platforms=android,ios -y
cd ..
echo "✅ Siro Driver configured successfully!"

echo -e "\n📦 3. Configuring Siro Admin..."
cd siro_admin
flutterfire configure --project=$PROJECT_ID --out=lib/firebase_options.dart --ios-bundle-id=com.siro.admin --android-package-name=com.siro.admin --platforms=android,ios -y
cd ..
echo "✅ Siro Admin configured successfully!"

echo -e "\n📦 4. Configuring Siro Service..."
cd siro_service
flutterfire configure --project=$PROJECT_ID --out=lib/firebase_options.dart --ios-bundle-id=com.siro.service --android-package-name=com.siro.service --platforms=android,ios -y
cd ..
echo "✅ Siro Service configured successfully!"

echo -e "\n🎉 All applications have been successfully configured with Firebase!"
