'use server'

import db from "@/db/db"
import { placeOfShipping } from "@/db/schema"
import { eq } from "drizzle-orm"


/**
 * @returns 활성화된 모든 선적지/하역지 코드 및 장소명
 */
export async function getPlaceOfShippingForSelection(): Promise<{ code: string; description: string }[]> {
  const data = await db.select().from(placeOfShipping).where(eq(placeOfShipping.isActive, true)).orderBy(placeOfShipping.code)
  return data.map((item) => ({
    code: item.code,
    description: item.description
  }))
}