import { fail } from '@sveltejs/kit';
import type { Actions } from './$types';

export const actions = {
	default: async ({ request }) => {
		const formData = await request.formData();
		const name = formData.get('name') as string;
		const email = formData.get('email') as string;
		const subject = formData.get('subject') as string;
		const message = formData.get('message') as string;

		if (!name || !email || !subject || !message) {
			return fail(400, { error: 'All fields are required' });
		}

		// TODO: Implement email service integration
		// For now, log the contact form submission
		console.log('Contact form submission:', {
			name,
			email,
			subject,
			message: message.substring(0, 100) + (message.length > 100 ? '...' : '')
		});

		// Simulate success for now
		return { success: true };
	}
} satisfies Actions;
