From 16c97ae041c268badb2ba54b1bd2b45bba90851e Mon Sep 17 00:00:00 2001 From: yjnoh Date: Tue, 3 Jun 2025 10:26:08 +0900 Subject: [PATCH] =?UTF-8?q?=ED=94=8C=EB=9E=9C=20=EB=B3=B5=EC=82=AC?= =?UTF-8?q?=EC=8B=9C=20=EA=B2=AC=EC=A0=81=EC=84=9C=20=EC=9D=B4=EB=AF=B8?= =?UTF-8?q?=EC=A7=80=20=EB=B3=B5=EC=82=AC=20=EB=A1=9C=EC=A7=81=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../api/image/estimate-image-copy/route.js | 19 ++++++++++++++++++- .../estimate/useEstimateController.js | 1 + src/hooks/usePlan.js | 6 ++++-- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/src/app/api/image/estimate-image-copy/route.js b/src/app/api/image/estimate-image-copy/route.js index 720dd5f0..16984c8c 100644 --- a/src/app/api/image/estimate-image-copy/route.js +++ b/src/app/api/image/estimate-image-copy/route.js @@ -1,5 +1,5 @@ import { NextResponse } from 'next/server' -import { S3Client, CopyObjectCommand } from '@aws-sdk/client-s3' +import { S3Client, CopyObjectCommand, GetObjectCommand } from '@aws-sdk/client-s3' import sharp from 'sharp' import { v4 as uuidv4 } from 'uuid' const Bucket = process.env.AMPLIFY_BUCKET @@ -17,6 +17,23 @@ export async function POST(req) { const responseArray = [] + // const isExistImage1 = await s3.send( + // new GetObjectCommand({ + // Bucket, + // Key: `Drawing/${objectNo}_${planNo}_1.png`, + // }), + // ) + + // const isExistImage2 = await s3.send( + // new GetObjectCommand({ + // Bucket, + // Key: `Drawing/${objectNo}_${planNo}_1.png`, + // }), + // ) + + // console.log('🚀 ~ isExistImage1:', isExistImage1.$metadata.httpStatusCode === 200) + // console.log('🚀 ~ isExistImage2:', isExistImage2.$metadata.httpStatusCode === 200) + const copyCommand = new CopyObjectCommand({ Bucket, CopySource: encodeURI(`${Bucket}/Drawing/${objectNo}_${planNo}_1.png`), diff --git a/src/hooks/floorPlan/estimate/useEstimateController.js b/src/hooks/floorPlan/estimate/useEstimateController.js index 64ff13e9..9acb79f7 100644 --- a/src/hooks/floorPlan/estimate/useEstimateController.js +++ b/src/hooks/floorPlan/estimate/useEstimateController.js @@ -535,5 +535,6 @@ export const useEstimateController = (planNo, flag) => { handleEstimateFileDownload, handleEstimateCopy, handleDeleteEstimate, + handleEstimateImageCopy, } } diff --git a/src/hooks/usePlan.js b/src/hooks/usePlan.js index 81d66455..52c60f80 100644 --- a/src/hooks/usePlan.js +++ b/src/hooks/usePlan.js @@ -55,7 +55,7 @@ export function usePlan(params = {}) { const { getMessage } = useMessage() const { get, post, promisePost, promisePut, promiseDel, promiseGet } = useAxios() - const { setEstimateContextState, handleDeleteEstimate } = useEstimateController() + const { setEstimateContextState, handleDeleteEstimate, handleEstimateImageCopy } = useEstimateController() const resetOuterLinePoints = useResetRecoilState(outerLinePointsState) const resetPlacementShapeDrawingPoints = useResetRecoilState(placementShapeDrawingPointsState) @@ -79,7 +79,6 @@ export function usePlan(params = {}) { const resetCurrentObject = useResetRecoilState(currentObjectState) //선택된 모듈 배치면 초기화 const resetModuleSetupSurface = useResetRecoilState(moduleSetupSurfaceState) - const { isAllComplete } = useTrestle() /** @@ -308,6 +307,9 @@ export function usePlan(params = {}) { setModuleSelectionDataStore(copyData) if (copyData.module) setSelectedModules(copyData.module) setSelectedMenu(currentSelectedMenu) + + //이미지 복사 + handleEstimateImageCopy(planData.objectNo, planData.planNo, planData.objectNo, newPlan.planNo) } else { setSelectedMenu('placement') }