From c8cccaf1198ae48754ac036b579732018f5b448a Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 23 Oct 2025 03:30:01 +0000 Subject: (최겸) 기술영업 조선 rfq 수정(벤더, 담당자 임시삭제기능 추가) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/tech-vendors/utils.ts | 84 +++++++++++++++++++++++++++++++---------------- 1 file changed, 56 insertions(+), 28 deletions(-) (limited to 'lib/tech-vendors/utils.ts') diff --git a/lib/tech-vendors/utils.ts b/lib/tech-vendors/utils.ts index ac91cd8d..ea8cdbd3 100644 --- a/lib/tech-vendors/utils.ts +++ b/lib/tech-vendors/utils.ts @@ -1,28 +1,56 @@ -import { LucideIcon, CheckCircle2, CircleAlert, Clock, ShieldAlert, Mail, BarChart2 } from "lucide-react"; -import type { TechVendor } from "@/db/schema/techVendors"; - -type StatusType = TechVendor["status"]; - -/** - * 기술벤더 상태에 대한 아이콘을 반환합니다. - */ -export function getVendorStatusIcon(status: StatusType): LucideIcon { - switch (status) { - case "PENDING_INVITE": - return Clock; - case "INVITED": - return Mail; - case "QUOTE_COMPARISON": - return BarChart2; - case "ACTIVE": - return CheckCircle2; - case "INACTIVE": - return CircleAlert; - case "BLACKLISTED": - return ShieldAlert; - default: - return CircleAlert; - } -} - - +import { LucideIcon, CheckCircle2, CircleAlert, Clock, ShieldAlert, Mail, BarChart2 } from "lucide-react"; +import type { TechVendor } from "@/db/schema/techVendors"; + +type StatusType = TechVendor["status"]; + +/** + * 기술벤더 상태에 대한 아이콘을 반환합니다. + */ +export function getVendorStatusIcon(status: StatusType): LucideIcon { + switch (status) { + case "PENDING_INVITE": + return Clock; + case "INVITED": + return Mail; + case "QUOTE_COMPARISON": + return BarChart2; + case "ACTIVE": + return CheckCircle2; + case "INACTIVE": + return CircleAlert; + case "BLACKLISTED": + return ShieldAlert; + default: + return CircleAlert; + } +} + +/** + * 이메일을 소문자로 변환합니다. + * null, undefined, 또는 빈 문자열인 경우 null을 반환합니다. + */ +export function normalizeEmail(email: string | null | undefined): string | null { + if (!email || typeof email !== 'string' || email.trim() === '') { + return null; + } + return email.toLowerCase().trim(); +} + +/** + * 여러 이메일 필드들을 소문자로 변환합니다. + */ +export function normalizeEmailFields(data: { + email?: string | null; + agentEmail?: string | null; + representativeEmail?: string | null; + contactEmail?: string | null; +}) { + return { + email: normalizeEmail(data.email), + agentEmail: normalizeEmail(data.agentEmail), + representativeEmail: normalizeEmail(data.representativeEmail), + contactEmail: normalizeEmail(data.contactEmail), + }; +} + + -- cgit v1.2.3