
import pkg from 'pg';
const { Client } = pkg;
import 'dotenv/config';

async function check() {
    const client = new Client({
        user: process.env.DB_USER || 'postgres',
        password: process.env.DB_PASSWORD || 'Admin@123',
        host: process.env.DB_HOST || 'localhost',
        database: process.env.DB_NAME || 'royal_enfield_onboarding',
        port: parseInt(process.env.DB_PORT || '5432'),
    });

    try {
        await client.connect();
        const res = await client.query('SELECT * FROM request_participants WHERE "requestType" = $1', ['resignation']);
        console.log(`Found ${res.rows.length} participants for Resignations.`);
        
        const termRes = await client.query('SELECT * FROM request_participants WHERE "requestType" = $1', ['termination']);
        console.log(`Found ${termRes.rows.length} participants for Terminations.`);

        if (res.rows.length > 0) {
            console.log('Sample Resignation Participant:', JSON.stringify(res.rows[0], null, 2));
        }
        
        if (termRes.rows.length > 0) {
            console.log('Sample Termination Participant:', JSON.stringify(termRes.rows[0], null, 2));
        }

        const resignations = await client.query('SELECT id, "resignationId" FROM resignations LIMIT 5');
        console.log('Resignations in DB:', resignations.rows.map(r => r.resignationId));

    } catch (err) {
        console.error('Error:', err.message);
    } finally {
        await client.end();
    }
}

check();
