const prisma = require('../../../src/prisma/PrismaClient.js');
const timeLocal = require('../../../src/utils/TimeLocal.js')

const cityNames = [
    'Kabupaten Batang Hari',
    'Kabupaten Bungo',
    'Kabupaten Kerinci',
    'Kabupaten Merangin',
    'Kabupaten Muaro Jambi',
    'Kabupaten Sarolangun',
    'Kabupaten Tanjung Jabung Barat',
    'Kabupaten Tanjung Jabung Timur',
    'Kabupaten Tebo',
    'Kota Jambi',
    'Kota Sungai Penuh'

    // 11
];

exports.seedJambiCities = async () => {
    const province = await prisma.province.findFirst({
        where: { name: 'Jambi' },
    });

    if (!province) {
        console.error('❌ Province Jambi not found. Seed it first.');
        return;
    }

    for (const name of cityNames) {
        await prisma.city.upsert({
            where: {
                name_province_id: {
                    name,
                    province_id: province.id,
                },
            },
            update: {
                updatedAt: timeLocal.now().toDate()
            },
            create: {
                name,
                province_id: province.id,
                createdAt: timeLocal.now().toDate()
            },
        });
    }

    console.log('✅ Jambi City seeded!.');
};