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

const provinces = [
    "Aceh", "Bali", "Banten", "Bengkulu", "DI Yogyakarta", "DKI Jakarta", "Gorontalo",
    "Jambi", "Jawa Barat", "Jawa Tengah", "Jawa Timur", "Kalimantan Barat",
    "Kalimantan Selatan", "Kalimantan Tengah", "Kalimantan Timur", "Kalimantan Utara",
    "Kepulauan Bangka Belitung", "Kepulauan Riau", "Lampung", "Maluku",
    "Maluku Utara", "Nusa Tenggara Barat", "Nusa Tenggara Timur", "Papua",
    "Papua Barat", "Papua Barat Daya", "Papua Pegunungan", "Papua Selatan",
    "Papua Tengah", "Riau", "Sulawesi Barat", "Sulawesi Selatan", "Sulawesi Tengah",
    "Sulawesi Tenggara", "Sulawesi Utara", "Sumatera Barat", "Sumatera Selatan", "Sumatera Utara"
];

exports.seedProvinces = async () => {
    for (const name of provinces.sort()) {
        await prisma.province.upsert({
            where: { name },
            create: {
                name,
                createdAt: timeLocal.now().toDate(),
            },
            update: {
                updatedAt: timeLocal.now().toDate()
            }
        });
    }

    console.log('✅ Provinces seeded!');
};