From cf8dac0c6490469dab88a560004b0c07dbd48612 Mon Sep 17 00:00:00 2001 From: dujinkim Date: Thu, 18 Sep 2025 00:23:40 +0000 Subject: (대표님) rfq, 계약, 서명 등 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/[lng]/evcp/(evcp)/buyer-signature/page.tsx | 24 ++++ app/[lng]/evcp/(evcp)/general-contracts/page.tsx | 39 +----- app/[lng]/evcp/(evcp)/itb-create/page.tsx | 164 +++++++++++++++++++++++ app/api/contracts/get-template/route.ts | 16 ++- app/api/upload/purchase-request/route.ts | 56 ++++++++ app/api/upload/signed-contract/route.ts | 3 +- 6 files changed, 261 insertions(+), 41 deletions(-) create mode 100644 app/[lng]/evcp/(evcp)/buyer-signature/page.tsx create mode 100644 app/[lng]/evcp/(evcp)/itb-create/page.tsx create mode 100644 app/api/upload/purchase-request/route.ts (limited to 'app') diff --git a/app/[lng]/evcp/(evcp)/buyer-signature/page.tsx b/app/[lng]/evcp/(evcp)/buyer-signature/page.tsx new file mode 100644 index 00000000..fa3a1953 --- /dev/null +++ b/app/[lng]/evcp/(evcp)/buyer-signature/page.tsx @@ -0,0 +1,24 @@ +import { BuyerSignatureUploadForm } from '@/lib/shi-signature/upload-form'; +import { SignatureList } from '@/lib/shi-signature/signature-list'; +import { getAllSignatures } from '@/lib/shi-signature/buyer-signature'; + +export default async function BuyerSignaturePage() { + const signatures = await getAllSignatures(); + + return ( +
+
+
+

구매자 서명 관리

+

+ 계약서에 자동으로 적용될 삼성중공업 서명을 관리합니다. +

+
+ + + + +
+
+ ); +} \ No newline at end of file diff --git a/app/[lng]/evcp/(evcp)/general-contracts/page.tsx b/app/[lng]/evcp/(evcp)/general-contracts/page.tsx index 47677bb3..a6d5057c 100644 --- a/app/[lng]/evcp/(evcp)/general-contracts/page.tsx +++ b/app/[lng]/evcp/(evcp)/general-contracts/page.tsx @@ -7,6 +7,7 @@ import { getGeneralContractCategoryCounts, getVendors } from "@/lib/general-contracts/service" +import { searchParamsCache } from "@/lib/general-contracts/validation" import { GeneralContractsTable } from "@/lib/general-contracts/main/general-contracts-table" import { getValidFilters } from "@/lib/data-table" import { type SearchParams } from "@/types/table" @@ -21,43 +22,13 @@ interface IndexPageProps { searchParams: Promise } -// searchParams 파싱을 위한 기본 파서 함수 -function parseSearchParams(searchParams: SearchParams) { - const page = Number(searchParams.page) || 1 - const perPage = Number(searchParams.per_page) || 10 - const sort = searchParams.sort - ? Array.isArray(searchParams.sort) - ? searchParams.sort.map((s: string) => { - const [id, desc] = s.split('.') - return { id, desc: desc === 'desc' } - }) - : [{ id: searchParams.sort.split('.')[0], desc: searchParams.sort.split('.')[1] === 'desc' }] - : [{ id: "registeredAt", desc: true }] - - return { - page, - perPage, - sort, - filters: [], - contractNumber: searchParams.contractNumber as string, - name: searchParams.name as string, - status: searchParams.status as string, - category: searchParams.category as string, - type: searchParams.type as string, - vendorId: searchParams.vendorId ? Number(searchParams.vendorId) : undefined, - createdAtFrom: searchParams.createdAtFrom as string, - createdAtTo: searchParams.createdAtTo as string, - signedAtFrom: searchParams.signedAtFrom as string, - signedAtTo: searchParams.signedAtTo as string, - search: searchParams.search as string, - } -} - export default async function GeneralContractsPage(props: IndexPageProps) { // ✅ searchParams 파싱 const searchParams = await props.searchParams - const search = parseSearchParams(searchParams) - + const search = searchParamsCache.parse(searchParams) + + console.log("Parsed search params:", search) + const validFilters = getValidFilters(search.filters) // ✅ 모든 데이터를 병렬로 로드 diff --git a/app/[lng]/evcp/(evcp)/itb-create/page.tsx b/app/[lng]/evcp/(evcp)/itb-create/page.tsx new file mode 100644 index 00000000..54040e7f --- /dev/null +++ b/app/[lng]/evcp/(evcp)/itb-create/page.tsx @@ -0,0 +1,164 @@ +// app/[lng]/purchase-requests/page.tsx + +import * as React from "react"; +import { type SearchParams } from "@/types/table"; +import { getValidFilters } from "@/lib/data-table"; +import { Shell } from "@/components/shell"; +import { DataTableSkeleton } from "@/components/data-table/data-table-skeleton"; +import { Button } from "@/components/ui/button"; +import { Card, CardContent, CardHeader, CardTitle } from "@/components/ui/card"; +import { Plus, FileText, Clock, CheckCircle, XCircle, Send } from "lucide-react"; +import Link from "next/link"; +import { searchParamsPurchaseRequestCache } from "@/lib/itb/validations"; +import { getAllPurchaseRequests, getPurchaseRequestStats } from "@/lib/itb/service"; +import { PurchaseRequestsTable } from "@/lib/itb/table/purchase-requests-table"; + +interface PurchaseRequestsPageProps { + params: { + lng: string; + }; + searchParams: Promise; +} + +export default async function PurchaseRequestsPage(props: PurchaseRequestsPageProps) { + const resolvedParams = await props.params; + const lng = resolvedParams.lng; + + const searchParams = await props.searchParams; + + // Parse search params + const search = searchParamsPurchaseRequestCache.parse(searchParams); + const validFilters = getValidFilters(search.filters); + + // Load data + const promises = Promise.all([ + getAllPurchaseRequests({ + ...search, + filters: validFilters, + }), + getPurchaseRequestStats(), + ]); + + return ( + +
+
+

+ 구매 요청 관리 +

+

+ 프로젝트별 자재 구매 요청을 생성하고 관리합니다. +

+
+
+ + {/* 통계 카드 */} + + {[...Array(6)].map((_, i) => ( + + + +
+ + + +
+ + + ))} +
+ } + > + + + + + } + > + + + + ); +} + +// 통계 컴포넌트 +async function PurchaseRequestStats({ + promises +}: { + promises: Promise<[any, any]> +}) { + const [, stats] = await promises; + + const statCards = [ + { + title: "전체", + value: stats?.total || 0, + icon: FileText, + color: "text-blue-500", + }, + { + title: "작성중", + value: stats?.draft || 0, + icon: Clock, + color: "text-gray-500", + }, + + { + title: "RFQ 생성", + value: stats?.rfqCreated || 0, + icon: Send, + color: "text-red-500", + }, + ]; + + return ( +
+ {statCards.map((card, index) => { + const Icon = card.icon; + return ( + + + + {card.title} + + + + +
{card.value}
+
+
+ ); + })} +
+ ); +} + +// Metadata +export const metadata = { + title: "Purchase Request Management", + description: "Create and manage material purchase requests for projects", +}; \ No newline at end of file diff --git a/app/api/contracts/get-template/route.ts b/app/api/contracts/get-template/route.ts index ff42196f..b7965481 100644 --- a/app/api/contracts/get-template/route.ts +++ b/app/api/contracts/get-template/route.ts @@ -12,14 +12,18 @@ export async function POST(request: NextRequest) { { status: 400 } ); } + + // /api/files로 시작하는 경우 제거 + const cleanPath = templatePath.startsWith('/api/files') + ? templatePath.slice('/api/files'.length) + : templatePath; + const isDev = process.env.NODE_ENV === 'development'; - const fullPath = - isDev ? - path.join(process.cwd(), `public`, templatePath) - : - path.join(`${process.env.NAS_PATH}`, templatePath); - + const fullPath = isDev + ? path.join(process.cwd(), `public`, cleanPath) + : path.join(`${process.env.NAS_PATH}`, cleanPath); + const fileBuffer = await readFile(fullPath); return new NextResponse(fileBuffer, { diff --git a/app/api/upload/purchase-request/route.ts b/app/api/upload/purchase-request/route.ts new file mode 100644 index 00000000..8e49afcd --- /dev/null +++ b/app/api/upload/purchase-request/route.ts @@ -0,0 +1,56 @@ +// app/api/upload/purchase-request/route.ts +import { NextRequest, NextResponse } from "next/server"; +import { saveDRMFile } from "@/lib/file-stroage"; +import { getServerSession } from 'next-auth/next' +import { authOptions } from '@/app/api/auth/[...nextauth]/route' +import { decryptWithServerAction } from '@/components/drm/drmUtils' + +export async function POST(request: NextRequest) { + try { + const session = await getServerSession(authOptions) + if (!session?.user?.id) { + return NextResponse.json({ error: "Unauthorized" }, { status: 401 }); + } + + const formData = await request.formData(); + const files = formData.getAll("files") as File[]; + + if (!files || files.length === 0) { + return NextResponse.json({ error: "No files provided" }, { status: 400 }); + } + + const uploadResults = []; + + for (const file of files) { + const result = await saveDRMFile( + file, + decryptWithServerAction, + "purchase-requests", + session.user.id, + ); + + if (!result.success) { + return NextResponse.json( + { error: result.error || "파일 업로드 실패" }, + { status: 400 } + ); + } + + uploadResults.push({ + fileName: result.fileName!, + originalFileName: file.name, + filePath: result.publicPath!, + fileSize: result.fileSize!, + fileType: file.type, + }); + } + + return NextResponse.json({ files: uploadResults }); + } catch (error) { + console.error("Upload error:", error); + return NextResponse.json( + { error: "파일 업로드 중 오류가 발생했습니다" }, + { status: 500 } + ); + } +} \ No newline at end of file diff --git a/app/api/upload/signed-contract/route.ts b/app/api/upload/signed-contract/route.ts index 873f21e5..880f54b2 100644 --- a/app/api/upload/signed-contract/route.ts +++ b/app/api/upload/signed-contract/route.ts @@ -48,8 +48,9 @@ export async function POST(request: NextRequest) { status: "VENDOR_SIGNED", fileName: saveResult.originalName || originalFileName, // 원본 파일명 filePath: saveResult.publicPath, // 웹 접근 가능한 경로 + vendorSignedAt:new Date(), updatedAt: new Date(), - completedAt: null + completedAt:templateName.includes("GTC")? null : new Date() }) .where(eq(basicContract.id, tableRowId)); }); -- cgit v1.2.3