import crypto from "crypto";

export function generateOrderId(prefix: string): string {
  const stamp = Date.now().toString(36).toUpperCase();
  const rand = crypto.randomBytes(4).toString("hex").toUpperCase();
  const orderId = `${prefix}${stamp}${rand}`;
  if (orderId.length > 100 || !/^[A-Z0-9]+$/.test(orderId)) {
    throw new Error("Could not generate an order id");
  }
  return orderId;
}
