resetCommonUtils 위치 수정
This commit is contained in:
parent
c65615465a
commit
5c1c50bd46
@ -4,7 +4,7 @@ import { useContext, useEffect, useState } from 'react'
|
||||
|
||||
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
|
||||
|
||||
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
|
||||
import { useRecoilState, useRecoilValue, useResetRecoilState, useSetRecoilState } from 'recoil'
|
||||
|
||||
import { v4 as uuidv4 } from 'uuid'
|
||||
|
||||
@ -98,7 +98,7 @@ export default function CanvasMenu(props) {
|
||||
const [lockButtonStyle, setLockButtonStyle] = useState('') //잠금 버튼
|
||||
|
||||
const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //견적서 화면용 물건번호리코일
|
||||
|
||||
const resetCommonUtils = useResetRecoilState(commonUtilsState)
|
||||
// 발전시뮬레이션 메뉴 이동
|
||||
const { objectNo, pid } = floorPlanState
|
||||
|
||||
@ -166,6 +166,7 @@ export default function CanvasMenu(props) {
|
||||
}
|
||||
|
||||
const onClickNav = async (menu) => {
|
||||
resetCommonUtils()
|
||||
switch (menu.type) {
|
||||
case 'drawing':
|
||||
swalFire({
|
||||
@ -241,7 +242,7 @@ export default function CanvasMenu(props) {
|
||||
return
|
||||
}
|
||||
setIsGlobalLoading(true)
|
||||
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan?.planNo??pid}/detail` }).then((res) => {
|
||||
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan?.planNo ?? pid}/detail` }).then((res) => {
|
||||
if (res.status === 200) {
|
||||
const estimateDetail = res.data
|
||||
if (estimateDetail.estimateDate !== null) {
|
||||
@ -249,7 +250,7 @@ export default function CanvasMenu(props) {
|
||||
setCurrentMenu(menu.title)
|
||||
setFloorPlanObjectNo({ floorPlanObjectNo: objectNo })
|
||||
setIsGlobalLoading(false)
|
||||
router.push(`/floor-plan/estimate/5?pid=${selectedPlan?.planNo??pid}&objectNo=${objectNo}`)
|
||||
router.push(`/floor-plan/estimate/5?pid=${selectedPlan?.planNo ?? pid}&objectNo=${objectNo}`)
|
||||
if (pathname === '/floor-plan/estimate/5') {
|
||||
setIsGlobalLoading(false)
|
||||
}
|
||||
@ -262,13 +263,13 @@ export default function CanvasMenu(props) {
|
||||
break
|
||||
case 'simulation':
|
||||
setIsGlobalLoading(true)
|
||||
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan?.planNo??pid}/detail` }).then((res) => {
|
||||
promiseGet({ url: `/api/estimate/${objectNo}/${selectedPlan?.planNo ?? pid}/detail` }).then((res) => {
|
||||
if (res.status === 200) {
|
||||
const estimateDetail = res.data
|
||||
if (estimateDetail.estimateDate !== null && estimateDetail.docNo) {
|
||||
setSelectedMenu(menu.type)
|
||||
setCurrentMenu(menu.title)
|
||||
router.push(`/floor-plan/simulator/6?pid=${selectedPlan?.planNo??pid}&objectNo=${objectNo}`)
|
||||
router.push(`/floor-plan/simulator/6?pid=${selectedPlan?.planNo ?? pid}&objectNo=${objectNo}`)
|
||||
if (pathname === '/floor-plan/simulator/6') {
|
||||
setIsGlobalLoading(false)
|
||||
}
|
||||
|
||||
@ -5,9 +5,10 @@ import { useEffect } from 'react'
|
||||
import { useMessage } from '@/hooks/useMessage'
|
||||
import useMenu from '@/hooks/common/useMenu'
|
||||
import { canvasState, currentMenuState } from '@/store/canvasAtom'
|
||||
import { useRecoilState, useRecoilValue } from 'recoil'
|
||||
import { useRecoilState, useRecoilValue, useResetRecoilState } from 'recoil'
|
||||
import { subMenusState } from '@/store/menuAtom'
|
||||
import { useCanvasMenu } from '@/hooks/common/useCanvasMenu'
|
||||
import { commonUtilsState } from '@/store/commonUtilsAtom'
|
||||
|
||||
export default function MenuDepth01() {
|
||||
const canvas = useRecoilValue(canvasState)
|
||||
@ -16,8 +17,10 @@ export default function MenuDepth01() {
|
||||
const { selectedMenu, setSelectedMenu } = useCanvasMenu()
|
||||
const [currentMenu, setCurrentMenu] = useRecoilState(currentMenuState)
|
||||
const subMenus = useRecoilValue(subMenusState)
|
||||
const resetCommonUtils = useResetRecoilState(commonUtilsState)
|
||||
|
||||
const onClickMenu = ({ id, menu }) => {
|
||||
resetCommonUtils()
|
||||
if (menu === currentMenu) {
|
||||
handleMenu(selectedMenu)
|
||||
} else {
|
||||
|
||||
@ -8,7 +8,6 @@ import { commonUtilsState } from '@/store/commonUtilsAtom'
|
||||
* @returns
|
||||
*/
|
||||
export function usePopup() {
|
||||
const resetCommonUtils = useResetRecoilState(commonUtilsState)
|
||||
const [popup, setPopup] = useRecoilState(popupState)
|
||||
const [contextMenuPopup, setContextMenuPopup] = useRecoilState(contextPopupState)
|
||||
|
||||
@ -20,9 +19,6 @@ export function usePopup() {
|
||||
* @param {*} isConfig 팝업 타입
|
||||
*/
|
||||
const addPopup = (id, depth, component, isConfig = false) => {
|
||||
//팝업 전 처리
|
||||
resetCommonUtils()
|
||||
//
|
||||
setPopup({
|
||||
config: isConfig ? [...filterDepth(depth, isConfig), { id, depth, component, isConfig }] : [...popup.config],
|
||||
other: !isConfig ? [...filterDepth(depth, isConfig), { id, depth, component, isConfig }] : [...popup.other],
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user