import { PrismaClient } from '../../lib/generated/prisma/index'
import { seedGeneral } from './seedGeneral'
import { seedFirms } from './seedFirms'
import { seedLiterals } from './seedLiterals'
import { seedProducts } from './seedProducts'
import { seedWallets } from './seedWallets'
import { seedSettings } from './seedSettings'

const prisma = new PrismaClient()

async function main() {
    await seedLiterals(prisma)
    await seedSettings(prisma)  
    console.log('🔥 Settings and Literals seeded successfully!')
    
    if (process.env.NEXT_PUBLIC_PANEL_TEMPLATE === 'prop_firms') {
        try {
            await seedGeneral(prisma)
            await seedFirms(prisma)
            await seedProducts(prisma)
            await seedWallets(prisma)
            console.log('🔥 Database seeding completed!')
        } catch (error) {
            console.error('Error in seeding:', error)
            throw error
        }
    } else {
        console.log('🔥 Database seeding completed!')
    }
}

main()
    .catch((e) => {
        console.error('Error seeding database:', e)
        process.exit(1)
    })
    .finally(async () => {
        await prisma.$disconnect()
    })