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') }