package com.example.pap_teste;

import com.example.pap_teste.models.Restaurant;
import com.google.firebase.firestore.CollectionReference;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class DataSeeder {

    public static void seedRestaurants() {
        CollectionReference restaurants = FirestoreManager.getInstance().getRestaurantsCollection();

        List<Restaurant> sampleRestaurants = new ArrayList<>();

        sampleRestaurants.add(createRestaurant("The Italian Job", "Italian", 
            "Authentic wood-fired pizzas and homemade pasta in a cozy setting.", 
            "https://images.unsplash.com/photo-1555396273-367ea4eb4db5", 4.8, "Rua de Itália, 123, Lisboa"));

        sampleRestaurants.add(createRestaurant("Sushi Zen", "Japanese", 
            "Premium sushi experience with fresh ingredients flown in daily.", 
            "https://images.unsplash.com/photo-1579871494447-9811cf80d66c", 4.9, "Avenida do Japão, 45, Porto"));

        sampleRestaurants.add(createRestaurant("Burger Haven", "Burgers", 
            "Gourmet burgers made with 100% aged beef and unique toppings.", 
            "https://images.unsplash.com/photo-1571091718767-18b5b1457add", 4.5, "Praça do Hambúrguer, 10, Braga"));

        sampleRestaurants.add(createRestaurant("Taco Libre", "Mexican", 
            "Vibrant street-style Mexican food and craft margaritas.", 
            "https://images.unsplash.com/photo-1565299585323-38d6b0865b47", 4.6, "Rua do México, 88, Faro"));

        sampleRestaurants.add(createRestaurant("Steakhouse Prime", "Steakhouse", 
            "Expertly grilled premium cuts and an extensive wine list.", 
            "https://images.unsplash.com/photo-1546241072-48010ad28c2c", 4.7, "Travessa do Bife, 5, Coimbra"));

        sampleRestaurants.add(createRestaurant("Le Petit Bistro", "French", 
            "A slice of Paris serving classic French dishes and fine wine.", 
            "https://images.unsplash.com/photo-1550966842-28a2a2d3efd1", 4.4, "Rua de França, 22, Évora"));

        sampleRestaurants.add(createRestaurant("Green Garden", "Vegetarian", 
            "Sustainable and delicious plant-based cuisine for everyone.", 
            "https://images.unsplash.com/photo-1512621776951-a57141f2eefd", 4.6, "Alameda Verde, 15, Aveiro"));

        sampleRestaurants.add(createRestaurant("Ocean's Catch", "Seafood", 
            "The freshest seafood and shellfish with a beautiful ocean view.", 
            "https://images.unsplash.com/photo-1551248429-42405d2d9cd8", 4.8, "Estrada da Praia, 1, Cascais"));

        for (Restaurant r : sampleRestaurants) {
            restaurants.document().set(r);
        }
    }

    private static Restaurant createRestaurant(String name, String cuisine, String desc, String url, double rating, String address) {
        Restaurant r = new Restaurant();
        r.setName(name);
        r.setCuisine(cuisine);
        r.setDescription(desc);
        r.setImageURL(url);
        r.setRating(rating);
        r.setAddress(address);
        
        Map<String, String> hours = new HashMap<>();
        hours.put("open", "12:00");
        hours.put("close", "23:00");
        r.setOpeningHours(hours);
        
        List<String> slots = new ArrayList<>();
        slots.add("12:00"); slots.add("13:00"); slots.add("14:00");
        slots.add("19:00"); slots.add("20:00"); slots.add("21:00"); slots.add("22:00");
        r.setAvailableSlots(slots);
        
        return r;
    }
}
