import { Router } from 'express';
import { db } from '../db.js';

const router = Router();

router.post('/', (req, res) => {
  const { fullName, phone, email, currentJob, businessName, message } = req.body;
  if (!fullName || !phone || !email || !message) {
    return res.status(400).json({ error: 'فیلدهای الزامی را پر کنید' });
  }
  db.prepare(`
    INSERT INTO cooperation_requests (full_name, phone, email, current_job, business_name, message)
    VALUES (?, ?, ?, ?, ?, ?)
  `).run(fullName, phone, email, currentJob || null, businessName || null, message);
  res.status(201).json({ message: 'درخواست همکاری با موفقیت ارسال شد' });
});

export default router;
