diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-25 07:51:15 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-07-25 07:51:15 +0000 |
| commit | 2650b7c0bb0ea12b68a58c0439f72d61df04b2f1 (patch) | |
| tree | 17156183fd74b69d78178065388ac61a18ac07b4 /lib/tech-vendors/contacts-table | |
| parent | d32acea05915bd6c1ed4b95e56c41ef9204347bc (diff) | |
(대표님) 정기평가 대상, 미들웨어 수정, nextauth 토큰 처리 개선, GTC 등
(최겸) 기술영업
Diffstat (limited to 'lib/tech-vendors/contacts-table')
| -rw-r--r-- | lib/tech-vendors/contacts-table/add-contact-dialog.tsx | 15 | ||||
| -rw-r--r-- | lib/tech-vendors/contacts-table/contact-table.tsx | 55 | ||||
| -rw-r--r-- | lib/tech-vendors/contacts-table/update-contact-sheet.tsx | 16 |
3 files changed, 85 insertions, 1 deletions
diff --git a/lib/tech-vendors/contacts-table/add-contact-dialog.tsx b/lib/tech-vendors/contacts-table/add-contact-dialog.tsx index 93ea6761..90ba4e04 100644 --- a/lib/tech-vendors/contacts-table/add-contact-dialog.tsx +++ b/lib/tech-vendors/contacts-table/add-contact-dialog.tsx @@ -37,6 +37,7 @@ export function AddContactDialog({ vendorId }: AddContactDialogProps) { vendorId,
contactName: "",
contactPosition: "",
+ contactTitle: "",
contactEmail: "",
contactPhone: "",
contactCountry: "",
@@ -120,6 +121,20 @@ export function AddContactDialog({ vendorId }: AddContactDialogProps) { <FormField
control={form.control}
+ name="contactTitle"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>Contact Title</FormLabel>
+ <FormControl>
+ <Input placeholder="예: 기술영업 담당자" {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
name="contactEmail"
render={({ field }) => (
<FormItem>
diff --git a/lib/tech-vendors/contacts-table/contact-table.tsx b/lib/tech-vendors/contacts-table/contact-table.tsx index 6029fe16..5a49cf8d 100644 --- a/lib/tech-vendors/contacts-table/contact-table.tsx +++ b/lib/tech-vendors/contacts-table/contact-table.tsx @@ -15,6 +15,9 @@ import { getTechVendorContacts } from "../service" import { TechVendorContact } from "@/db/schema/techVendors"
import { TechVendorContactsTableToolbarActions } from "./contact-table-toolbar-actions"
import { UpdateContactSheet } from "./update-contact-sheet"
+import { toast } from "sonner"
+import { AlertDialog, AlertDialogContent, AlertDialogHeader, AlertDialogTitle, AlertDialogDescription, AlertDialogFooter, AlertDialogCancel, AlertDialogAction } from "@/components/ui/alert-dialog"
+import { deleteTechVendorContact } from "../service"
interface TechVendorContactsTableProps {
promises: Promise<
@@ -31,6 +34,32 @@ export function TechVendorContactsTable({ promises , vendorId}: TechVendorContac const [{ data, pageCount }] = React.use(promises)
const [rowAction, setRowAction] = React.useState<DataTableRowAction<TechVendorContact> | null>(null)
+ const [isDeleting, setIsDeleting] = React.useState(false)
+ const [showDeleteAlert, setShowDeleteAlert] = React.useState(false)
+
+ React.useEffect(() => {
+ if (rowAction?.type === "delete") {
+ setShowDeleteAlert(true)
+ }
+ }, [rowAction])
+
+ async function handleDeleteContact() {
+ if (!rowAction || rowAction.type !== "delete") return
+ setIsDeleting(true)
+ try {
+ const contactId = rowAction.row.original.id
+ const vId = rowAction.row.original.vendorId
+ const { data, error } = await deleteTechVendorContact(contactId, vId)
+ if (error) throw new Error(error)
+ toast.success("연락처가 삭제되었습니다.")
+ setShowDeleteAlert(false)
+ setRowAction(null)
+ } catch (err) {
+ toast.error(err instanceof Error ? err.message : "삭제 중 오류가 발생했습니다.")
+ } finally {
+ setIsDeleting(false)
+ }
+ }
// getColumns() 호출 시, router를 주입
const columns = React.useMemo(
@@ -47,7 +76,7 @@ export function TechVendorContactsTable({ promises , vendorId}: TechVendorContac { id: "contactPosition", label: "Contact Position", type: "text" },
{ id: "contactEmail", label: "Contact Email", type: "text" },
{ id: "contactPhone", label: "Contact Phone", type: "text" },
- { id: "country", label: "Country", type: "text" },
+ { id: "contactCountry", label: "Country", type: "text" },
{ id: "createdAt", label: "Created at", type: "date" },
{ id: "updatedAt", label: "Updated at", type: "date" },
]
@@ -88,6 +117,30 @@ export function TechVendorContactsTable({ promises , vendorId}: TechVendorContac contact={rowAction?.type === "update" ? rowAction.row.original : null}
vendorId={vendorId}
/>
+
+ {/* Delete Confirmation Dialog */}
+ <AlertDialog open={showDeleteAlert} onOpenChange={setShowDeleteAlert}>
+ <AlertDialogContent>
+ <AlertDialogHeader>
+ <AlertDialogTitle>연락처 삭제</AlertDialogTitle>
+ <AlertDialogDescription>
+ 이 연락처를 삭제하시겠습니까? 이 작업은 되돌릴 수 없습니다.
+ </AlertDialogDescription>
+ </AlertDialogHeader>
+ <AlertDialogFooter>
+ <AlertDialogCancel onClick={() => setRowAction(null)}>
+ 취소
+ </AlertDialogCancel>
+ <AlertDialogAction
+ onClick={handleDeleteContact}
+ disabled={isDeleting}
+ className="bg-destructive text-destructive-foreground hover:bg-destructive/90"
+ >
+ {isDeleting ? "삭제 중..." : "삭제"}
+ </AlertDialogAction>
+ </AlertDialogFooter>
+ </AlertDialogContent>
+ </AlertDialog>
</>
)
}
\ No newline at end of file diff --git a/lib/tech-vendors/contacts-table/update-contact-sheet.tsx b/lib/tech-vendors/contacts-table/update-contact-sheet.tsx index b75ddd1e..4713790c 100644 --- a/lib/tech-vendors/contacts-table/update-contact-sheet.tsx +++ b/lib/tech-vendors/contacts-table/update-contact-sheet.tsx @@ -46,6 +46,7 @@ export function UpdateContactSheet({ contact, vendorId, ...props }: UpdateContac contactEmail: contact?.contactEmail ?? "",
contactPhone: contact?.contactPhone ?? "",
contactCountry: contact?.contactCountry ?? "",
+ contactTitle: contact?.contactTitle ?? "",
isPrimary: contact?.isPrimary ?? false,
},
})
@@ -58,6 +59,7 @@ export function UpdateContactSheet({ contact, vendorId, ...props }: UpdateContac contactEmail: contact.contactEmail,
contactPhone: contact.contactPhone ?? "",
contactCountry: contact.contactCountry ?? "",
+ contactTitle: contact.contactTitle ?? "",
isPrimary: contact.isPrimary,
})
}
@@ -128,6 +130,20 @@ export function UpdateContactSheet({ contact, vendorId, ...props }: UpdateContac <FormField
control={form.control}
+ name="contactTitle"
+ render={({ field }) => (
+ <FormItem>
+ <FormLabel>직책</FormLabel>
+ <FormControl>
+ <Input placeholder="직책을 입력하세요" {...field} />
+ </FormControl>
+ <FormMessage />
+ </FormItem>
+ )}
+ />
+
+ <FormField
+ control={form.control}
name="contactEmail"
render={({ field }) => (
<FormItem>
|
