fix: 견적서/발전 시뮬레이션 메뉴 컨트롤 수정

This commit is contained in:
yoosangwook 2025-01-13 20:09:03 +09:00
parent 86ac607f0c
commit aa153ecea0
3 changed files with 40 additions and 9 deletions

View File

@ -19,7 +19,10 @@ import { convertNumberToPriceDecimal, convertNumberToPriceDecimalToFixed } from
import ProductFeaturesPop from './popup/ProductFeaturesPop'
import { v4 as uuidv4 } from 'uuid'
import { correntObjectNoState } from '@/store/settingAtom'
import { useSearchParams } from 'next/navigation'
import { useRouter, useSearchParams } from 'next/navigation'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
import { usePlan } from '@/hooks/usePlan'
import { usePopup } from '@/hooks/usePopup'
export default function Estimate({}) {
const [uniqueData, setUniqueData] = useState([])
@ -70,6 +73,9 @@ export default function Estimate({}) {
//
const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(currentPid)
const { selectedPlan } = usePlan()
const router = useRouter()
// List
const [specialNoteList, setSpecialNoteList] = useState([])
const [popShowSpecialNoteList, setPopShowSpecialNoteList] = useState([])
@ -81,6 +87,8 @@ export default function Estimate({}) {
const { setMenuNumber } = useCanvasMenu()
const { closeAll } = usePopup()
const currentObjectNo = searchParams.get('objectNo')
setCurrentObjectNo(currentObjectNo)
@ -90,11 +98,12 @@ export default function Estimate({}) {
setUploadFiles: setFiles,
}
useEffect(() => {
const initEstimate = (currPid = currentPid) => {
console.log('🚀 ~ initEstimate ~ currPid:', currPid)
setMenuNumber(5)
setObjectNo(objectRecoil.floorPlanObjectNo)
setPlanNo(currentPid)
setPlanNo(currPid)
//
const code1 = findCommonCode(200800)
@ -121,6 +130,16 @@ export default function Estimate({}) {
setPopShowSpecialNoteList(res)
}
})
}
useEffect(() => {
console.log('🚀 ~ Estimate ~ selectedPlan:', selectedPlan)
if (selectedPlan) initEstimate(selectedPlan.ordering)
}, [selectedPlan])
useEffect(() => {
closeAll()
initEstimate()
}, [])
useEffect(() => {

View File

@ -15,6 +15,8 @@ import { useMessage } from '@/hooks/useMessage'
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
import { convertNumberToPriceDecimal } from '@/util/common-utils'
import { usePlan } from '@/hooks/usePlan'
import { usePopup } from '@/hooks/usePopup'
// import { useSearchParams } from 'next/navigation'
export default function Simulator() {
@ -24,6 +26,7 @@ export default function Simulator() {
// const searchParams = useSearchParams()
// const objectNo = searchParams.get('objectNo')
// const pid = searchParams.get('pid')
const { selectedPlan } = usePlan()
const chartRef = useRef(null)
@ -40,6 +43,12 @@ export default function Simulator() {
//
const [chartData, setChartData] = useState([])
const { closeAll } = usePopup()
useEffect(() => {
closeAll()
}, [])
const data = {
labels: ['1月', '2月', '3月', '4月', '5月', '6月', '7月', '8月', '9月', '10月', '11月', '12月'],
datasets: [
@ -105,6 +114,7 @@ export default function Simulator() {
}
useEffect(() => {
console.log('🚀 ~ useEffect ~ selectedPlan:', selectedPlan)
/* 초기화 작업 */
setChartData([])
setObjectDetail({})
@ -121,7 +131,7 @@ export default function Simulator() {
setPwrGnrSimType('D')
setPwrRecoil({ ...pwrRecoil, type: 'D' })
}
}, [objectNo, pid])
}, [objectNo, pid, selectedPlan])
//
const [objectDetail, setObjectDetail] = useState({})

View File

@ -1,7 +1,7 @@
'use client'
import { useContext, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
import { useRecoilState } from 'recoil'
import { v4 as uuidv4 } from 'uuid'
@ -218,16 +218,18 @@ export function usePlan(params = {}) {
}),
)
}
useEffect(() => {
setCurrentCanvasPlan(plans.find((plan) => plan.isCurrent) || null)
setSelectedPlan(plans.find((plan) => plan.isCurrent))
handleCurrentPlanUrl()
// setBgImage()
}, [plans])
// 현재 plan이 변경될 때 마다 현재 plan의 링크로 이동
useEffect(() => {
handlePlanMove()
}, [currentCanvasPlan])
const handleCurrentPlanUrl = () => {
const currentPlan = plans.find((plan) => plan.isCurrent)
if (currentPlan) router.push(`${pathname}?pid=${currentPlan?.ordering}&objectNo=${floorPlanState?.objectNo}`)
}
const setBgImage = () => {
// readImage(selectedPlan?.id)