summaryrefslogtreecommitdiff
path: root/lib/tech-vendors/utils.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/tech-vendors/utils.ts')
-rw-r--r--lib/tech-vendors/utils.ts84
1 files changed, 56 insertions, 28 deletions
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),
+ };
+}
+
+