// Next.js API route support: https://nextjs.org/docs/api-routes/introduction
import { QueryError, RowDataPacket } from 'mysql2';
import type { NextApiRequest, NextApiResponse } from 'next';
import { db } from "../../server/db/connect";

const queryString = "INSERT INTO ProductOrder (product_id, customer_id, product_quantity) VALUES (?, ?, ?)"

type Data = {
    QueryError: string,
    RowDataPacket: string
}

export default function handler(
  req: NextApiRequest,
  res: NextApiResponse<Data>
) {
    if (req.method === 'POST') {
        db.query(
            queryString,
            [order.product.id, order.customer.id, order.productQuantity],
            (err: QueryError, rows: RowDataPacket[]) => {
            console.log('The solution is: ', rows[0]['solution']);
        });
      }
}
