import { db } from '../../index';
import { psa } from '../../../drizzle/schema';
import { eq, lt, gte, ne } from 'drizzle-orm';
import CATEGORY from '@src/data/parts_cats.json';

export async function getPSA(page = 1) {
  const limit = 20;
  const offset = (page - 1) * limit;
  
  return await db.select()
    .from(psa)
    .limit(limit)
    .where(eq(psa.fineline, "Lower Build Kits"))
    .offset(offset);
} 

export async function getLowerBuildKits(page = 1) {
  const limit = 20;
  const offset = (page - 1) * limit;
  
  return await db.select()
    .from(psa)
    .limit(limit)
    .where(eq(psa.fineline, "Lower Build Kits"))
    .offset(offset);
}

export async function getARCompleteLowers(page = 1) {
  const limit = 40;
  const offset = (page - 1) * limit;
  
  return await db.select()
    .from(psa)
    .limit(limit)
    .where(eq(psa.fineline, "AR Complete Lowers"))
    .offset(offset);
}

export async function getProductType(productType : any,  page = 1) {
  const limit = 40;
  const offset = (page - 1) * limit;
  
  return await db.select()
    .from(psa)
    .limit(limit)
    .where(eq(psa.fineline, productType.name))
    .offset(offset);
}
