parent
bd07a4aff2
commit
520c96eabf
@ -74,7 +74,7 @@ export default function CanvasMenu(props) {
|
|||||||
const [estimateCopyPopupOpen, setEstimateCopyPopupOpen] = useState(false)
|
const [estimateCopyPopupOpen, setEstimateCopyPopupOpen] = useState(false)
|
||||||
|
|
||||||
const { getMessage } = useMessage()
|
const { getMessage } = useMessage()
|
||||||
const { saveCanvas } = usePlan()
|
const { saveCanvas, reloadCanvasStatus } = usePlan()
|
||||||
const { swalFire } = useSwal()
|
const { swalFire } = useSwal()
|
||||||
const { initEvent, addCanvasMouseEventListener, addDocumentEventListener } = useEvent()
|
const { initEvent, addCanvasMouseEventListener, addDocumentEventListener } = useEvent()
|
||||||
// const { initEvent, addCanvasMouseEventListener, addDocumentEventListener } = useContext(EventContext)
|
// const { initEvent, addCanvasMouseEventListener, addDocumentEventListener } = useContext(EventContext)
|
||||||
@ -149,7 +149,7 @@ export default function CanvasMenu(props) {
|
|||||||
setIsGlobalLoading(false)
|
setIsGlobalLoading(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
const onClickNav = (menu) => {
|
const onClickNav = async (menu) => {
|
||||||
switch (menu.index) {
|
switch (menu.index) {
|
||||||
case 0:
|
case 0:
|
||||||
swalFire({
|
swalFire({
|
||||||
@ -164,10 +164,11 @@ export default function CanvasMenu(props) {
|
|||||||
case 1:
|
case 1:
|
||||||
setType('placementShape')
|
setType('placementShape')
|
||||||
onClickPlacementInitialMenu()
|
onClickPlacementInitialMenu()
|
||||||
|
await reloadCanvasStatus(objectNo, pid)
|
||||||
break
|
break
|
||||||
case 2:
|
case 2:
|
||||||
setType('outline')
|
setType('outline')
|
||||||
|
await reloadCanvasStatus(objectNo, pid)
|
||||||
break
|
break
|
||||||
case 3:
|
case 3:
|
||||||
console.log('🚀 ~ onClickNav ~ menu:', menu)
|
console.log('🚀 ~ onClickNav ~ menu:', menu)
|
||||||
@ -199,6 +200,7 @@ export default function CanvasMenu(props) {
|
|||||||
} else {
|
} else {
|
||||||
setType('surface')
|
setType('surface')
|
||||||
}
|
}
|
||||||
|
await reloadCanvasStatus(objectNo, pid)
|
||||||
break
|
break
|
||||||
case 4:
|
case 4:
|
||||||
if (menuNumber < menu.index) {
|
if (menuNumber < menu.index) {
|
||||||
@ -211,7 +213,7 @@ export default function CanvasMenu(props) {
|
|||||||
} else {
|
} else {
|
||||||
router.push(`/floor-plan?pid=${pid}&objectNo=${objectNo}`)
|
router.push(`/floor-plan?pid=${pid}&objectNo=${objectNo}`)
|
||||||
}
|
}
|
||||||
|
await reloadCanvasStatus(objectNo, pid)
|
||||||
break
|
break
|
||||||
case 5:
|
case 5:
|
||||||
setIsGlobalLoading(true)
|
setIsGlobalLoading(true)
|
||||||
@ -617,10 +619,10 @@ export default function CanvasMenu(props) {
|
|||||||
<li
|
<li
|
||||||
key={`canvas-menu-${menu.index}`}
|
key={`canvas-menu-${menu.index}`}
|
||||||
className={`canvas-menu-item ${menuNumber === menu.index ? 'active' : ''}`}
|
className={`canvas-menu-item ${menuNumber === menu.index ? 'active' : ''}`}
|
||||||
onClick={() => {
|
onClick={async () => {
|
||||||
if (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) return
|
if (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) return
|
||||||
if (menuNumber === 4 && [1, 2].includes(menu.index)) return
|
if (menuNumber === 4 && [1, 2].includes(menu.index)) return
|
||||||
onClickNav(menu)
|
await onClickNav(menu)
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<button className={checkMenuState(menu) ? 'no-click' : ''}>
|
<button className={checkMenuState(menu) ? 'no-click' : ''}>
|
||||||
|
|||||||
@ -134,7 +134,7 @@ export function usePlan(params = {}) {
|
|||||||
/**
|
/**
|
||||||
* objectNo에 해당하는 canvas 목록을 조회
|
* objectNo에 해당하는 canvas 목록을 조회
|
||||||
*/
|
*/
|
||||||
const getCanvasByObjectNo = async (userId, objectNo, planNo) => {
|
const getCanvasByObjectNo = async (objectNo, planNo) => {
|
||||||
return await get({ url: `/api/canvas-management/canvas-statuses/by-object/${objectNo}` }).then((res) =>
|
return await get({ url: `/api/canvas-management/canvas-statuses/by-object/${objectNo}` }).then((res) =>
|
||||||
res.map((item) => ({
|
res.map((item) => ({
|
||||||
id: item.id,
|
id: item.id,
|
||||||
@ -397,7 +397,7 @@ export function usePlan(params = {}) {
|
|||||||
*/
|
*/
|
||||||
const loadCanvasPlanData = async (userId, objectNo, planNo) => {
|
const loadCanvasPlanData = async (userId, objectNo, planNo) => {
|
||||||
console.log('🚀 ~ loadCanvasPlanData ~ userId, objectNo, planNo:', userId, objectNo, planNo)
|
console.log('🚀 ~ loadCanvasPlanData ~ userId, objectNo, planNo:', userId, objectNo, planNo)
|
||||||
await getCanvasByObjectNo(userId, objectNo, planNo).then(async (res) => {
|
await getCanvasByObjectNo(objectNo, planNo).then(async (res) => {
|
||||||
if (res.length > 0) {
|
if (res.length > 0) {
|
||||||
setCurrentCanvasPlan(res.find((plan) => plan.planNo === planNo))
|
setCurrentCanvasPlan(res.find((plan) => plan.planNo === planNo))
|
||||||
setPlans(res)
|
setPlans(res)
|
||||||
@ -415,6 +415,22 @@ export function usePlan(params = {}) {
|
|||||||
setPlans((plans) => plans.map((plan) => ({ ...plan, canvasStatus: null })))
|
setPlans((plans) => plans.map((plan) => ({ ...plan, canvasStatus: null })))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* plan canvasStatus 불러오기
|
||||||
|
*
|
||||||
|
* 견적서/발전시뮬레이션에서 플랜 이동 시 현재 플랜의 canvasStatus를 불러오기 위해 사용
|
||||||
|
*/
|
||||||
|
const reloadCanvasStatus = async (objectNo, planNo) => {
|
||||||
|
if (pathname === '/floor-plan/estimate/5' || pathname === '/floor-plan/simulator/6') {
|
||||||
|
await getCanvasByObjectNo(objectNo, planNo).then((res) => {
|
||||||
|
if (res.length > 0) {
|
||||||
|
setCurrentCanvasPlan((prev) => ({ ...prev, canvasStatus: res.find((plan) => plan.planNo === planNo).canvasStatus }))
|
||||||
|
setPlans((plans) => plans.map((plan) => ({ ...plan, canvasStatus: res.find((plan) => plan.planNo === planNo).canvasStatus })))
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 현재 plan 이동 -> 새로운 링크로 이동
|
* 현재 plan 이동 -> 새로운 링크로 이동
|
||||||
*/
|
*/
|
||||||
@ -434,5 +450,6 @@ export function usePlan(params = {}) {
|
|||||||
handleDeletePlan,
|
handleDeletePlan,
|
||||||
loadCanvasPlanData,
|
loadCanvasPlanData,
|
||||||
resetCanvasStatus,
|
resetCanvasStatus,
|
||||||
|
reloadCanvasStatus,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user