import { PrismaClient } from '@prisma/client';
import { hash } from 'bcryptjs';

const prisma = new PrismaClient();

async function createTestUser() {
    try {
        const email = 'test@martin-bierschenk.de';
        const password = 'Test2026';

        // Check if user exists
        const existing = await prisma.user.findUnique({
            where: { email }
        });

        if (existing) {
            console.log('User already exists:', email);
            return;
        }

        // Hash password
        const passwordHash = await hash(password, 12);

        // Create user
        const user = await prisma.user.create({
            data: {
                email,
                passwordHash,
                emailVerified: new Date(),
            }
        });

        console.log('✅ User created successfully!');
        console.log('Email:', email);
        console.log('Password:', password);
        console.log('User ID:', user.id);
    } catch (error) {
        console.error('Error creating user:', error);
    } finally {
        await prisma.$disconnect();
    }
}

createTestUser();
