const router = require('express').Router();
const { getSupabaseClient } = require('./supabaseClient');

// Получить все дома по УК
router.get('/buildings', async (req, res) => {
  const supabase = getSupabaseClient();
  const { management_company_id } = req.query;
  if (!management_company_id) return res.status(400).json({ error: 'management_company_id required' });
  const { data, error } = await supabase.from('buildings').select('*').eq('management_company_id', management_company_id);
  if (error) return res.status(400).json({ error: error.message });
  res.json(data);
});

module.exports = router; 