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

const cityNames = [
    'Kabupaten Berau',
    'Kabupaten Kutai Barat',
    'Kabupaten Kutai Kartanegara',
    'Kabupaten Kutai Timur',
    'Kabupaten Mahakam Ulu',
    'Kabupaten Paser',
    'Kabupaten Penajam Paser Utara',
    'Kota Balikpapan',
    'Kota Bontang',
    'Kota Samarinda'

    // 10
];

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

    if (!province) {
        console.error('❌ Province Kalimantan Timur 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('✅ Kalimantan Timur City seeded!.');
};