summaryrefslogtreecommitdiff
path: root/lib/vendors/service.ts
diff options
context:
space:
mode:
Diffstat (limited to 'lib/vendors/service.ts')
-rw-r--r--lib/vendors/service.ts30
1 files changed, 30 insertions, 0 deletions
diff --git a/lib/vendors/service.ts b/lib/vendors/service.ts
index 98c72349..6813f717 100644
--- a/lib/vendors/service.ts
+++ b/lib/vendors/service.ts
@@ -45,6 +45,7 @@ import type {
GetVendorContactsSchema,
CreateVendorContactSchema,
UpdateVendorContactSchema,
+ DeleteVendorContactSchema,
GetVendorItemsSchema,
CreateVendorItemSchema,
GetRfqHistorySchema,
@@ -3680,4 +3681,33 @@ export async function getBidHistory(input: GetBidHistorySchema, vendorId: number
console.error("Error fetching bid history:", err);
return { data: [], pageCount: 0 };
}
+}
+
+// deleteVendorContact 함수 추가
+export async function deleteVendorContact(input: DeleteVendorContactSchema) {
+ unstable_noStore(); // Next.js 서버 액션 캐싱 방지
+ try {
+ await db.transaction(async (tx) => {
+ // DB Delete
+ await tx
+ .delete(vendorContacts)
+ .where(and(
+ eq(vendorContacts.id, input.id),
+ eq(vendorContacts.vendorId, input.vendorId)
+ ));
+ });
+
+ // 캐시 무효화 (협력업체 연락처 목록 등)
+ revalidateTag(`vendor-contacts-${input.vendorId}`);
+
+ return { success: true, message: "Contact deleted successfully" };
+ } catch (error) {
+ console.error("Error deleting vendor contact:", error);
+ return {
+ success: false,
+ message: error instanceof z.ZodError
+ ? error.errors[0].message
+ : "Failed to delete contact"
+ };
+ }
} \ No newline at end of file