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

View File

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

View File

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