import { createClient } from '@supabase/supabase-js';

const supabaseUrl = 'https://jqklhhpyykzrktikjnmb.supabase.co';
const supabaseAnonKey = 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZSIsInJlZiI6Impxa2xoaHB5eWt6cmt0aWtqbm1iIiwicm9sZSI6ImFub24iLCJpYXQiOjE3NjgzODQ0MDgsImV4cCI6MjA4Mzk2MDQwOH0.QsPuBnyUtRPSavlqKj3IGR9c8juT02LY_hSi-j3c6M0';

const supabase = createClient(supabaseUrl, supabaseAnonKey);

async function check() {
    console.log("Listing some tables...");

    // Auth with a test user to test RLS
    await supabase.auth.signInWithPassword({
        email: 'test_shop_1773154696588@test.com',
        password: 'Password123!'
    });

    const tablesToCheck = ['appointments', 'events', 'bookings', 'orders'];
    for (const t of tablesToCheck) {
        const { error } = await supabase.from(t).select('id').limit(1);
        if (error) {
            console.log(`Table ${t} error:`, error.message);
        } else {
            console.log(`Table ${t} EXISTS!`);
            const { data } = await supabase.from(t).select('*').limit(1);
            if (data && data.length > 0) {
                console.log(`${t} columns:`, Object.keys(data[0]));
            }
        }
    }
}

check();
