From ba35e67845f935c8ce0151c9ef1fefa0b0510faf Mon Sep 17 00:00:00 2001 From: joonhoekim <26rote@gmail.com> Date: Mon, 22 Sep 2025 18:59:13 +0900 Subject: (김준회) AVL 피드백 반영 (이진용 프로 건) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/selectors/place-of-shipping/index.ts | 2 + .../place-of-shipping-selector.tsx | 75 ++++++++++++++++++++++ .../place-of-shipping-service.tsx | 17 +++++ components/common/selectors/vendor-tier/index.ts | 2 + .../selectors/vendor-tier/vendor-tier-selector.tsx | 46 +++++++++++++ 5 files changed, 142 insertions(+) create mode 100644 components/common/selectors/place-of-shipping/index.ts create mode 100644 components/common/selectors/place-of-shipping/place-of-shipping-selector.tsx create mode 100644 components/common/selectors/place-of-shipping/place-of-shipping-service.tsx create mode 100644 components/common/selectors/vendor-tier/index.ts create mode 100644 components/common/selectors/vendor-tier/vendor-tier-selector.tsx (limited to 'components/common/selectors') diff --git a/components/common/selectors/place-of-shipping/index.ts b/components/common/selectors/place-of-shipping/index.ts new file mode 100644 index 00000000..8d157b4d --- /dev/null +++ b/components/common/selectors/place-of-shipping/index.ts @@ -0,0 +1,2 @@ +export { PlaceOfShippingSelector } from './place-of-shipping-selector' +export type { PlaceOfShippingSelectorProps } from './place-of-shipping-selector' diff --git a/components/common/selectors/place-of-shipping/place-of-shipping-selector.tsx b/components/common/selectors/place-of-shipping/place-of-shipping-selector.tsx new file mode 100644 index 00000000..8230e265 --- /dev/null +++ b/components/common/selectors/place-of-shipping/place-of-shipping-selector.tsx @@ -0,0 +1,75 @@ + + + +'use client' + +/** + * 선적지/하역지 선택기 + * + * placeOfShipping 테이블 기준으로 선적지/하역지에 쓰이는 장소코드 및 장소명 선택 + */ + +import { Select, SelectItem, SelectContent } from "@/components/ui/select" +import { SelectTrigger } from "@/components/ui/select" +import { SelectValue } from "@/components/ui/select" +import { useState, useEffect } from "react" +import { getPlaceOfShippingForSelection } from "./place-of-shipping-service" + +interface PlaceOfShippingData { + code: string + description: string +} + +interface PlaceOfShippingSelectorProps { + value?: string + onValueChange?: (value: string) => void + placeholder?: string + disabled?: boolean + className?: string +} + +export function PlaceOfShippingSelector({ + value = "", + onValueChange, + placeholder = "선적지/하역지 선택", + disabled = false, + className +}: PlaceOfShippingSelectorProps) { + const [placeOfShippingData, setPlaceOfShippingData] = useState([]) + const [isLoading, setIsLoading] = useState(true) + + useEffect(() => { + const loadData = async () => { + try { + const data = await getPlaceOfShippingForSelection() + setPlaceOfShippingData(data) + } catch (error) { + console.error('선적지/하역지 데이터 로드 실패:', error) + setPlaceOfShippingData([]) + } finally { + setIsLoading(false) + } + } + + loadData() + }, []) + + return ( + + ) +} \ No newline at end of file diff --git a/components/common/selectors/place-of-shipping/place-of-shipping-service.tsx b/components/common/selectors/place-of-shipping/place-of-shipping-service.tsx new file mode 100644 index 00000000..22026739 --- /dev/null +++ b/components/common/selectors/place-of-shipping/place-of-shipping-service.tsx @@ -0,0 +1,17 @@ +'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 + })) +} \ No newline at end of file diff --git a/components/common/selectors/vendor-tier/index.ts b/components/common/selectors/vendor-tier/index.ts new file mode 100644 index 00000000..15b71410 --- /dev/null +++ b/components/common/selectors/vendor-tier/index.ts @@ -0,0 +1,2 @@ +export { VendorTierSelector } from './vendor-tier-selector' +export type { VendorTierSelectorProps } from './vendor-tier-selector' diff --git a/components/common/selectors/vendor-tier/vendor-tier-selector.tsx b/components/common/selectors/vendor-tier/vendor-tier-selector.tsx new file mode 100644 index 00000000..ba33c9cf --- /dev/null +++ b/components/common/selectors/vendor-tier/vendor-tier-selector.tsx @@ -0,0 +1,46 @@ +"use client" + +import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@/components/ui/select" +import { useState } from "react" + + + +/** + * 하드코딩된 티어 셀렉터 + * + * 벤더의 티어 + * + * 코드, 의미 + * Tier 1, "당사 협조도 우수, 필수 견적 의뢰 업체" + * Tier 2, "해당 품목 주요 제작사, Tier 1 후보군" + * 등급 외 "(Tier 1, 2 미해당 업체)" + */ + +interface VendorTierSelectorProps { + value?: string + onValueChange?: (value: string) => void + placeholder?: string + disabled?: boolean + className?: string +} + +export function VendorTierSelector({ + value = "", + onValueChange, + placeholder = "티어 선택", + disabled = false, + className +}: VendorTierSelectorProps) { + return ( + + ) +} \ No newline at end of file -- cgit v1.2.3