From 2650b7c0bb0ea12b68a58c0439f72d61df04b2f1 Mon Sep 17 00:00:00 2001
From: dujinkim
Date: Fri, 25 Jul 2025 07:51:15 +0000
Subject: (대표님) 정기평가 대상, 미들웨어 수정, nextauth 토큰 처리 개선, GTC
등 (최겸) 기술영업
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../quotation-contacts-view-dialog.tsx | 6 +
.../detail-table/quotation-history-dialog.tsx | 163 ++++++++-----
.../table/detail-table/rfq-detail-column.tsx | 18 ++
.../table/detail-table/rfq-detail-table.tsx | 4 +-
.../detail-table/vendor-communication-drawer.tsx | 6 +-
.../vendor-contact-selection-dialog.tsx | 6 +
lib/techsales-rfq/table/rfq-filter-sheet.tsx | 135 +++++------
lib/techsales-rfq/table/rfq-table-column.tsx | 33 +++
lib/techsales-rfq/table/rfq-table.tsx | 28 ++-
lib/techsales-rfq/table/update-rfq-sheet.tsx | 267 +++++++++++++++++++++
10 files changed, 523 insertions(+), 143 deletions(-)
create mode 100644 lib/techsales-rfq/table/update-rfq-sheet.tsx
(limited to 'lib/techsales-rfq/table')
diff --git a/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx b/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx
index 3e793b62..61c97b1b 100644
--- a/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx
+++ b/lib/techsales-rfq/table/detail-table/quotation-contacts-view-dialog.tsx
@@ -20,6 +20,7 @@ interface QuotationContact {
contactId: number
contactName: string
contactPosition: string | null
+ contactTitle: string | null
contactEmail: string
contactPhone: string | null
contactCountry: string | null
@@ -129,6 +130,11 @@ export function QuotationContactsViewDialog({
{contact.contactPosition}
)}
+ {contact.contactTitle && (
+
+ {contact.contactTitle}
+
+ )}
{contact.contactCountry && (
{contact.contactCountry}
diff --git a/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx b/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx
index 0f5158d9..7d972b91 100644
--- a/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx
+++ b/lib/techsales-rfq/table/detail-table/quotation-history-dialog.tsx
@@ -1,5 +1,4 @@
"use client"
-
import * as React from "react"
import { useState, useEffect } from "react"
import {
@@ -16,6 +15,8 @@ import { Skeleton } from "@/components/ui/skeleton"
import { Clock, User, AlertCircle, Paperclip } from "lucide-react"
import { formatDate } from "@/lib/utils"
import { toast } from "sonner"
+import { Button } from "@/components/ui/button"
+import { updateSHIComment } from "@/lib/techsales-rfq/service";
interface QuotationAttachment {
id: number
@@ -37,7 +38,7 @@ interface QuotationSnapshot {
totalPrice: string | null
validUntil: Date | null
remark: string | null
- status: string | null
+ status: string
quotationVersion: number | null
submittedAt: Date | null
acceptedAt: Date | null
@@ -93,7 +94,9 @@ function QuotationCard({
isCurrent = false,
revisedBy,
revisedAt,
- attachments
+ attachments,
+ revisionId,
+ revisionNote,
}: {
data: QuotationSnapshot | QuotationHistoryData["current"]
version: number
@@ -101,9 +104,36 @@ function QuotationCard({
revisedBy?: string | null
revisedAt?: Date
attachments?: QuotationAttachment[]
+ revisionId?: number
+ revisionNote?: string | null
}) {
const statusInfo = statusConfig[data.status as keyof typeof statusConfig] ||
{ label: data.status || "알 수 없음", color: "bg-gray-100 text-gray-800" }
+
+ const [editValue, setEditValue] = React.useState(revisionNote || "");
+ const [isSaving, setIsSaving] = React.useState(false);
+
+ React.useEffect(() => {
+ setEditValue(revisionNote || "");
+ }, [revisionNote]);
+
+ const handleSave = async () => {
+ if (!revisionId) return;
+
+ setIsSaving(true);
+ try {
+ const result = await updateSHIComment(revisionId, editValue);
+ if (result.error) {
+ toast.error(result.error);
+ } else {
+ toast.success("저장 완료");
+ }
+ } catch (error) {
+ toast.error("저장 중 오류가 발생했습니다");
+ } finally {
+ setIsSaving(false);
+ }
+ };
return (
@@ -117,12 +147,6 @@ function QuotationCard({
{statusInfo.label}
- {/* {changeReason && (
-
-
- {changeReason}
-
- )} */}
@@ -147,6 +171,21 @@ function QuotationCard({
)}
+ {revisionId && (
+
+)}
+
{/* 첨부파일 섹션 */}
{attachments && attachments.length > 0 && (
@@ -209,16 +248,15 @@ export function QuotationHistoryDialog({
}: QuotationHistoryDialogProps) {
const [data, setData] = useState
(null)
const [isLoading, setIsLoading] = useState(false)
-
+
useEffect(() => {
if (open && quotationId) {
loadQuotationHistory()
}
}, [open, quotationId])
-
+
const loadQuotationHistory = async () => {
if (!quotationId) return
-
try {
setIsLoading(true)
const { getTechSalesVendorQuotationWithRevisions } = await import("@/lib/techsales-rfq/service")
@@ -238,14 +276,14 @@ export function QuotationHistoryDialog({
setIsLoading(false)
}
}
-
+
const handleOpenChange = (newOpen: boolean) => {
onOpenChange(newOpen)
if (!newOpen) {
setData(null) // 다이얼로그 닫을 때 데이터 초기화
}
}
-
+
return (
)
-}
\ No newline at end of file
+}
\ No newline at end of file
diff --git a/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx b/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx
index e4141520..7ece2406 100644
--- a/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx
+++ b/lib/techsales-rfq/table/detail-table/rfq-detail-column.tsx
@@ -46,6 +46,7 @@ export interface RfqDetailView {
createdByName: string | null
quotationCode?: string | null
rfqCode?: string | null
+ quotationVersion?: number | null
quotationAttachments?: Array<{
id: number
revisionId: number
@@ -185,6 +186,22 @@ export function getRfqDetailColumns({
enableResizing: true,
size: 160,
},
+ // [Rev 컬럼 추가]
+ {
+ id: "rev",
+ header: ({ column }) => (
+
+ ),
+ cell: ({ row }) => {
+ const version = row.original.quotationVersion ?? 0;
+ return {version}
;
+ },
+ meta: {
+ excelHeader: "Rev"
+ },
+ enableResizing: false,
+ size: 60,
+ },
{
accessorKey: "totalPrice",
header: ({ column }) => (
@@ -227,6 +244,7 @@ export function getRfqDetailColumns({
enableResizing: true,
size: 140,
},
+
{
accessorKey: "quotationAttachments",
header: ({ column }) => (
diff --git a/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx b/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx
index acf67497..8bfb8299 100644
--- a/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx
+++ b/lib/techsales-rfq/table/detail-table/rfq-detail-table.tsx
@@ -730,8 +730,8 @@ export function RfqDetailTables({ selectedRfq, maxHeight }: RfqDetailTablesProps
onSuccess={handleRefreshData}
/>
- {/* 다중 벤더 삭제 확인 다이얼로그
- {
- const { downloadFile } = await import("@/lib/file-download");
- await downloadFile(attachment.filePath, attachment.originalFileName);
+ const handleAttachmentDownload = (attachment: Attachment) => {
+ // TODO: 실제 다운로드 구현
+ window.open(attachment.filePath, '_blank');
};
// 파일 아이콘 선택
diff --git a/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx b/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx
index aa6f6c2f..031f4aa2 100644
--- a/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx
+++ b/lib/techsales-rfq/table/detail-table/vendor-contact-selection-dialog.tsx
@@ -21,6 +21,7 @@ interface VendorContact {
id: number
contactName: string
contactPosition: string | null
+ contactTitle: string | null
contactEmail: string
contactPhone: string | null
isPrimary: boolean
@@ -283,6 +284,11 @@ export function VendorContactSelectionDialog({
{contact.contactPosition}
)}
+ {contact.contactTitle && (
+
+ {contact.contactTitle}
+
+ )}
diff --git a/lib/techsales-rfq/table/rfq-filter-sheet.tsx b/lib/techsales-rfq/table/rfq-filter-sheet.tsx
index a03e6167..7db8305d 100644
--- a/lib/techsales-rfq/table/rfq-filter-sheet.tsx
+++ b/lib/techsales-rfq/table/rfq-filter-sheet.tsx
@@ -48,7 +48,32 @@ const filterSchema = z.object({
from: z.date().optional(),
to: z.date().optional(),
}).optional(),
+ workTypes: z.array(z.string()).optional(),
})
+// 공종 옵션 정의 (tech-vendors와 동일)
+const workTypeOptions = [
+ // 조선 workTypes
+ { value: "기장", label: "기장" },
+ { value: "전장", label: "전장" },
+ { value: "선실", label: "선실" },
+ { value: "배관", label: "배관" },
+ { value: "철의", label: "철의" },
+ { value: "선체", label: "선체" },
+ // 해양TOP workTypes
+ { value: "TM", label: "TM" },
+ { value: "TS", label: "TS" },
+ { value: "TE", label: "TE" },
+ { value: "TP", label: "TP" },
+ { value: "TA", label: "TA" },
+ // 해양HULL workTypes
+ { value: "HA", label: "HA" },
+ { value: "HE", label: "HE" },
+ { value: "HH", label: "HH" },
+ { value: "HM", label: "HM" },
+ { value: "NC", label: "NC" },
+ { value: "HO", label: "HO" },
+ { value: "HP", label: "HP" },
+];
// 상태 옵션 정의 (TechSales RFQ 상태에 맞게 수정)
const statusOptions = [
@@ -89,13 +114,13 @@ export function RFQFilterSheet({
// nuqs로 URL 상태 관리 - 파라미터명을 'basicFilters'로 변경
const [filters, setFilters] = useQueryState(
- "basicFilters",
+ "filters",
getFiltersStateParser().withDefault([])
)
// joinOperator 설정
const [joinOperator, setJoinOperator] = useQueryState(
- "basicJoinOperator",
+ "joinOperator",
parseAsStringEnum(["and", "or"]).withDefault("and")
)
@@ -118,6 +143,7 @@ export function RFQFilterSheet({
from: undefined,
to: undefined,
},
+ workTypes: [],
},
})
@@ -274,6 +300,16 @@ export function RFQFilterSheet({
})
}
+ if (data.workTypes && data.workTypes.length > 0) {
+ newFilters.push({
+ id: "workTypes",
+ value: data.workTypes,
+ type: "multi-select" as const,
+ operator: "eq" as const,
+ rowId: generateId()
+ })
+ }
+
console.log("기본 필터 적용:", newFilters);
// 마지막 적용된 필터 업데이트
@@ -313,6 +349,7 @@ export function RFQFilterSheet({
createdByName: "",
status: "",
dateRange: { from: undefined, to: undefined },
+ workTypes: [],
});
// 필터와 조인 연산자를 초기화
@@ -446,6 +483,7 @@ export function RFQFilterSheet({
)}
/>
+
{/* 자재명 */}
- {/* 선종명 */}
- (
-
- {t("선종명")}
-
-
-
- {field.value && (
-
- )}
-
-
-
-
- )}
- />
-
{/* 요청자 */}
- {/* RFQ 전송일 */}
+ {/* 공종 */}
(
- {t("RFQ 전송일")}
-
-
-
- {(field.value?.from || field.value?.to) && (
-
)}
diff --git a/lib/techsales-rfq/table/rfq-table-column.tsx b/lib/techsales-rfq/table/rfq-table-column.tsx
index f41857cd..2bc5b5b4 100644
--- a/lib/techsales-rfq/table/rfq-table-column.tsx
+++ b/lib/techsales-rfq/table/rfq-table-column.tsx
@@ -9,6 +9,9 @@ import { DataTableRowAction } from "@/types/table"
import { Paperclip, Package, FileText, BarChart3 } from "lucide-react"
import { Button } from "@/components/ui/button"
import { TechSalesRfq } from "./rfq-table"
+import { DropdownMenu, DropdownMenuContent, DropdownMenuItem, DropdownMenuTrigger } from "@/components/ui/dropdown-menu"
+import { MoreHorizontal } from "lucide-react"
+import { Edit } from "lucide-react"
interface GetColumnsProps {
setRowAction: React.Dispatch | null>>;
@@ -409,5 +412,35 @@ export function getColumns({
excelHeader: "CBE 결과"
},
},
+ // getColumns 함수 내 컬럼 배열 마지막에 추가
+{
+ id: "actions",
+ header: ({ column }) => (
+
+ ),
+ cell: ({ row }) => {
+ return (
+
+
+
+
+
+ setRowAction({ row, type: "update" })}>
+ 수정하기
+
+
+
+ )
+ },
+ enableSorting: false,
+ enableResizing: false,
+ size: 60,
+}
]
}
\ No newline at end of file
diff --git a/lib/techsales-rfq/table/rfq-table.tsx b/lib/techsales-rfq/table/rfq-table.tsx
index e3551625..e1e511c8 100644
--- a/lib/techsales-rfq/table/rfq-table.tsx
+++ b/lib/techsales-rfq/table/rfq-table.tsx
@@ -17,7 +17,7 @@ import {
import { useDataTable } from "@/hooks/use-data-table"
import { DataTable } from "@/components/data-table/data-table"
import { getColumns } from "./rfq-table-column"
-import { useEffect, useMemo } from "react"
+import { useEffect, useMemo, useState } from "react"
import { DataTableAdvancedToolbar } from "@/components/data-table/data-table-advanced-toolbar"
import { RFQTableToolbarActions } from "./rfq-table-toolbar-actions"
import { getTechSalesRfqsWithJoin, getTechSalesRfqAttachments } from "@/lib/techsales-rfq/service"
@@ -29,6 +29,7 @@ import { ProjectDetailDialog } from "./project-detail-dialog"
import { RFQFilterSheet } from "./rfq-filter-sheet"
import { TechSalesRfqAttachmentsSheet, ExistingTechSalesAttachment } from "./tech-sales-rfq-attachments-sheet"
import { RfqItemsViewDialog } from "./rfq-items-view-dialog"
+import UpdateSheet from "./update-rfq-sheet"
// 기본적인 RFQ 타입 정의 (repository selectTechSalesRfqsWithJoin 반환 타입에 맞춤)
export interface TechSalesRfq {
id: number
@@ -103,7 +104,10 @@ export function RFQListTable({
// 패널 collapse 상태
const [panelHeight, setPanelHeight] = React.useState(55)
-
+ // RFQListTable 컴포넌트 내부의 rowAction 처리 부분 수정
+ const [updateSheetOpen, setUpdateSheetOpen] = useState(false);
+ const [selectedRfqIdForUpdate, setSelectedRfqIdForUpdate] = useState(null);
+
// 고정 높이 설정을 위한 상수 (실제 측정값으로 조정 필요)
const LAYOUT_HEADER_HEIGHT = 64 // Layout Header 높이
const LAYOUT_FOOTER_HEIGHT = 60 // Layout Footer 높이 (있다면 실제 값)
@@ -246,8 +250,10 @@ export function RFQListTable({
setIsProjectDetailOpen(true);
break;
case "update":
- console.log("Update rfq:", rowAction.row.original)
- break;
+ // RFQ 수정 시트 열기
+ setSelectedRfqIdForUpdate(rowAction.row.original.id);
+ setUpdateSheetOpen(true);
+ break;
case "delete":
console.log("Delete rfq:", rowAction.row.original)
break;
@@ -391,6 +397,7 @@ export function RFQListTable({
{ label: "TS", value: "TS" },
{ label: "TE", value: "TE" },
{ label: "TP", value: "TP" },
+ { label: "TA", value: "TA" },
// 해양HULL workTypes
{ label: "HA", value: "HA" },
{ label: "HE", value: "HE" },
@@ -450,8 +457,6 @@ export function RFQListTable({
}
}
- console.log(panelHeight)
-
return (
+ {updateSheetOpen && selectedRfqIdForUpdate && (
+ {
+ // 테이블 새로고침 로직
+ // 필요한 경우 여기에 추가
+ }}
+ />
+ )}
)
}
\ No newline at end of file
diff --git a/lib/techsales-rfq/table/update-rfq-sheet.tsx b/lib/techsales-rfq/table/update-rfq-sheet.tsx
new file mode 100644
index 00000000..7dcc0e0e
--- /dev/null
+++ b/lib/techsales-rfq/table/update-rfq-sheet.tsx
@@ -0,0 +1,267 @@
+"use client";
+import * as React from "react";
+import { useForm } from "react-hook-form";
+import { zodResolver } from "@hookform/resolvers/zod";
+import { z } from "zod";
+import { format } from "date-fns";
+import { ko } from "date-fns/locale/ko";
+import { toast } from "sonner";
+import { Loader2, CalendarIcon } from "lucide-react";
+
+import { Button } from "@/components/ui/button";
+import { Form, FormControl, FormField, FormItem, FormLabel, FormMessage } from "@/components/ui/form";
+import { Input } from "@/components/ui/input";
+import { Sheet, SheetContent, SheetHeader, SheetTitle, SheetDescription, SheetFooter, SheetClose } from "@/components/ui/sheet";
+import { Popover, PopoverTrigger, PopoverContent } from "@/components/ui/popover";
+import { Calendar } from "@/components/ui/calendar";
+import { cn } from "@/lib/utils";
+import { updateTechSalesRfq, getTechSalesRfqById } from "@/lib/techsales-rfq/service";
+
+// Zod schema for form validation
+const updateRfqSchema = z.object({
+ rfqId: z.number().min(1, "RFQ ID is required"),
+ description: z.string(),
+ dueDate: z.string(),
+});
+
+type UpdateRfqSchema = z.infer;
+
+interface UpdateSheetProps {
+ open: boolean;
+ onOpenChange?: (open: boolean) => void;
+ rfqId: number;
+ onUpdated?: () => void;
+}
+
+export default function UpdateSheet({ open, onOpenChange, rfqId, onUpdated }: UpdateSheetProps) {
+ const [isPending, startTransition] = React.useTransition();
+ const [projectInfo, setProjectInfo] = React.useState({
+ projNm: "",
+ sector: "",
+ projMsrm: "",
+ ptypeNm: "",
+ rfqNo: "",
+ });
+ const [isLoading, setIsLoading] = React.useState(false);
+
+ // Initialize form with React Hook Form and Zod
+ const form = useForm({
+ resolver: zodResolver(updateRfqSchema),
+ defaultValues: {
+ rfqId,
+ description: "",
+ dueDate: "",
+ },
+ });
+
+ // Load RFQ data when sheet opens
+ React.useEffect(() => {
+ if (open && rfqId) {
+ loadRfqData();
+ }
+ }, [open, rfqId]);
+
+ const loadRfqData = async () => {
+ try {
+ setIsLoading(true);
+ const result = await getTechSalesRfqById(rfqId);
+ if (result.error) {
+ toast.error(result.error);
+ onOpenChange?.(false);
+ return;
+ }
+ if (result.data) {
+ form.reset({
+ rfqId,
+ description: result.data.description || "",
+ dueDate: result.data.dueDate ? new Date(result.data.dueDate).toISOString().slice(0, 10) : "",
+ });
+ setProjectInfo({
+ projNm: result.data.project[0].projectName || "",
+ sector: result.data.project[0].pjtType || "",
+ projMsrm: result.data.project[0].projMsrm || "",
+ ptypeNm: result.data.project[0].ptypeNm || "",
+ rfqNo: result.data.rfqCode || "",
+ });
+ }
+ } catch (error: any) {
+ toast.error("RFQ 정보를 불러오는 중 오류가 발생했습니다: " + error.message);
+ onOpenChange?.(false);
+ } finally {
+ setIsLoading(false);
+ }
+ };
+
+ // Form submission handler with debug logs
+ async function onSubmit(values: UpdateRfqSchema) {
+ console.log("Form submitted with values:", values);
+ startTransition(async () => {
+ try {
+ console.log("Submitting RFQ update for ID:", values.rfqId);
+ const result = await updateTechSalesRfq({
+ id: values.rfqId,
+ description: values.description,
+ dueDate: new Date(values.dueDate),
+ updatedBy: 1, // Replace with actual user ID
+ });
+ if (result.error) {
+ console.error("Update error:", result.error);
+ toast.error(result.error);
+ } else {
+ console.log("RFQ updated successfully");
+ toast.success("RFQ가 성공적으로 업데이트되었습니다!");
+ onUpdated?.();
+ onOpenChange?.(false);
+ form.reset();
+ }
+ } catch (error: any) {
+ console.error("Update failed with error:", error.message);
+ toast.error("업데이트 중 오류 발생: " + error.message);
+ }
+ });
+ }
+
+ // Debug form errors on change
+ React.useEffect(() => {
+ const subscription = form.watch(() => {
+ console.log("Form values changed:", form.getValues());
+ console.log("Form errors:", form.formState.errors);
+ });
+ return () => subscription.unsubscribe();
+ }, [form]);
+
+ return (
+
+
+
+ RFQ 수정
+
+ RFQ 정보를 수정합니다. 모든 필드를 입력한 후 저장 버튼을 클릭하세요.
+
+
+
+
+ {isLoading ? (
+
+
+
+ ) : (
+
+
+
+
+ 프로젝트명: {projectInfo.projNm}
+
+
+ 섹터: {projectInfo.sector}
+
+
+ 척수: {projectInfo.projMsrm}
+
+
+ 선종: {projectInfo.ptypeNm}
+
+
+ RFQ No: {projectInfo.rfqNo}
+
+
+
+
+
+
+
+ )}
+
+
+
+
+
+
+
+
+
+
+ );
+}
\ No newline at end of file
--
cgit v1.2.3