import { prisma } from "@/lib/db";
import type { Product } from "@prisma/client";

export async function getAllProducts(locale: string): Promise<Product[]> {
  return prisma.product.findMany({
    where: { locale },
    orderBy: [{ sortOrder: "asc" }, { createdAt: "desc" }],
  });
}

export async function getProductBySlug(slug: string): Promise<Product | null> {
  return prisma.product.findUnique({ where: { slug } });
}
