
const db = require('./src/database/models/index.js').default;
const { User, Resignation, FnF } = db;

async function checkState() {
    const email = 'ramesh_1776053291272@gmail.com';
    const user = await User.findOne({ where: { email } });
    console.log('--- USER STATE ---');
    if (user) {
        console.log(`ID: ${user.id}`);
        console.log(`DealerID: ${user.dealerId}`);
        console.log(`Status: ${user.status}`);
        console.log(`Role: ${user.roleCode}`);
    } else {
        console.log('User not found');
    }

    const resignation = await Resignation.findOne({ 
        where: { resignationId: 'RES-2026-7033' }, // From nomenclature or E2E logs if available
        // Wait, the id from logs was d4e1a5ed-011d-415d-89b4-bde65cbf5d58
        include: ['fnf']
    }).catch(() => null);

    if (!resignation) {
        // Try by UUID
        const resByUuid = await Resignation.findByPk('d4e1a5ed-011d-415d-89b4-bde65cbf5d58', { include: ['fnf'] });
        console.log('\n--- RESIGNATION STATE ---');
        if (resByUuid) {
            console.log(`ID: ${resByUuid.id}`);
            console.log(`Status: ${resByUuid.status}`);
            console.log(`Stage: ${resByUuid.currentStage}`);
            console.log(`DealerID: ${resByUuid.dealerId}`);
            if (resByUuid.fnf) {
                console.log(`FnF ID: ${resByUuid.fnf.id}`);
                console.log(`FnF Status: ${resByUuid.fnf.status}`);
            }
        } else {
            console.log('Resignation not found');
        }
    }

    process.exit(0);
}

checkState();
