This commit is contained in:
hyojun.choi 2025-01-15 18:46:30 +09:00
commit cbc97960da
9 changed files with 120 additions and 47 deletions

View File

@ -2,7 +2,7 @@
import { correntObjectNoState } from '@/store/settingAtom'
import { notFound, usePathname, useSearchParams } from 'next/navigation'
import { createContext, useReducer, useState } from 'react'
import { createContext, useReducer, useState, useEffect } from 'react'
import { useSetRecoilState } from 'recoil'
const reducer = (prevState, nextState) => {
@ -48,12 +48,14 @@ const FloorPlanProvider = ({ children }) => {
const objectNo = searchParams.get('objectNo')
const pid = searchParams.get('pid')
if (pathname === '/floor-plan') {
if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
notFound()
useEffect(() => { // 오류 발생으로 useEffect 사용
if (pathname === '/floor-plan') {
if (pid === undefined || pid === '' || pid === null || objectNo === undefined || objectNo === '' || objectNo === null) {
notFound()
}
setCurrentObjectNo(objectNo)
}
setCurrentObjectNo(objectNo)
}
}, [pid, objectNo])
const [floorPlanState, setFloorPlanState] = useState({
// 플랜 파일 업로드 모달 오픈 제어

View File

@ -254,10 +254,19 @@ export default function Playground() {
})
}
const [getFetcherCallFlag, setGetFetcherCallFlag] = useState(false)
const { data: tutoData, error, isLoading } = useSWR('http://localhost:8080/api/tutorial', getFetcher)
const [callFlag, setCallFlag] = useState(false)
// const { data: tutoData, error, isLoading } = useSWR('http://localhost:8080/api/tutorial', getFetcher)
const { data: tutoData, error, isLoading } = useSWR(callFlag ? 'http://localhost:8080/api/tutorial' : null, getFetcher)
const { trigger, isMutating } = useSWRMutation('http://localhost:8080/api/tutorial', postFetcher)
if (isLoading) {
return <div>Loading...</div>
}
if (error) {
return <div>Error...</div>
}
return (
<>
<div className="container mx-auto p-4 m-4 border">
@ -571,7 +580,12 @@ export default function Playground() {
))}
</div>
<div className="my-2">
<Button onClick={() => trigger({ id: 3, name: 'seulda kim', email: 'seulda.kim@interplug.co.kr' })}>insert data</Button>
<Button onClick={() => setCallFlag(true)}>getFetcher call</Button>
</div>
<div className="my-2">
<Button disabled={isMutating} onClick={() => trigger({ id: 3, name: 'seulda kim', email: 'seulda.kim@interplug.co.kr' })}>
insert data
</Button>
</div>
</div>
</>

View File

@ -74,7 +74,6 @@ export default function Estimate({}) {
const { estimateContextState, setEstimateContextState, addItem, handleEstimateFileDownload } = useEstimateController(currentPid)
const { selectedPlan } = usePlan()
const router = useRouter()
// List
const [specialNoteList, setSpecialNoteList] = useState([])
@ -299,12 +298,16 @@ export default function Estimate({}) {
} else {
if (originFiles.length > 0) {
if (isEmptyArray(files)) {
let file
file = originFiles.filter((item) => item.delFlg === '0')
setEstimateContextState({
originFiles: file,
})
setOriginFiles(file)
if (originFiles[0].planNo !== estimateContextState.planNo) {
setOriginFiles([])
} else {
let file
file = originFiles.filter((item) => item.delFlg === '0')
setEstimateContextState({
originFiles: file,
})
setOriginFiles(file)
}
}
}
}
@ -1002,6 +1005,7 @@ export default function Estimate({}) {
<div className="estimate-box">
<div className="estimate-tit">{getMessage('estimate.detail.objectNo')}</div>
<div className="estimate-name">
{/* {objectNo} (Plan No: {estimateContextState.planNo}) */}
{objectNo} (Plan No: {planNo})
</div>
</div>

View File

@ -2,7 +2,7 @@
import { useContext, useEffect, useState } from 'react'
import { usePathname, useRouter } from 'next/navigation'
import { usePathname, useRouter, useSearchParams } from 'next/navigation'
import { useRecoilState, useRecoilValue, useSetRecoilState } from 'recoil'
@ -63,7 +63,7 @@ export default function CanvasMenu(props) {
const canvas = useRecoilValue(canvasState)
const { handleZoomClear, handleZoom } = useCanvasEvent()
const { handleMenu } = useMenu()
// const urlParams = useSearchParams()
const { handleEstimateSubmit, fetchSetting } = useEstimateController()
const estimateRecoilState = useRecoilValue(estimateState)
const [estimatePopupOpen, setEstimatePopupOpen] = useState(false)
@ -85,7 +85,6 @@ export default function CanvasMenu(props) {
const selectedRoofMaterial = useRecoilValue(selectedRoofMaterialSelector)
//
const [buttonStyle, setButtonStyle] = useState('') //
const [buttonStyle1, setButtonStyle1] = useState('') //
const [buttonStyle2, setButtonStyle2] = useState('') //
const [buttonStyle3, setButtonStyle3] = useState('') //
@ -173,6 +172,7 @@ export default function CanvasMenu(props) {
setType('module')
break
case 5:
// let pid = urlParams.get('pid')
promiseGet({ url: `/api/estimate/${objectNo}/${pid}/detail` }).then((res) => {
if (res.status === 200) {
const estimateDetail = res.data
@ -309,10 +309,9 @@ export default function CanvasMenu(props) {
}, [type, globalLocale])
useEffect(() => {
console.log('🚀 ~ useEffect ~ basicSetting:', basicSetting)
if (Object.keys(basicSetting).length === 0 || !basicSetting.roofSizeSet) return
// setMenuNumber(1)
if (!selectedRoofMaterial) return
//if (Object.keys(basicSetting).length === 0 || !basicSetting.roofSizeSet) return
setMenuNumber(1)
// if ([2, 3].some((num) => num === canvasSetting?.roofSizeSet)) {
// setMenuNumber(3)
// setType('surface')
@ -322,7 +321,8 @@ export default function CanvasMenu(props) {
// setType('outline')
// setCurrentMenu(MENU.ROOF_COVERING.EXTERIOR_WALL_LINE)
// }
}, [basicSetting])
}, [selectedRoofMaterial])
const checkMenuState = (menu) => {
return (['2', '3'].includes(canvasSetting?.roofSizeSet) && menu.index === 2) || (menuNumber === 4 && menu.index === 2)
}

View File

@ -43,15 +43,15 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
// (//)
const roofSizeSetArray = [
{ id: 'ra01', name: 'roofSizeSet', value: '1', checked: 'ture', message: 'modal.placement.initial.setting.size.roof' },
{ id: 'ra02', name: 'roofSizeSet', value: '2', checked: 'false', message: 'modal.placement.initial.setting.size.actual' },
{ id: 'ra03', name: 'roofSizeSet', value: '3', checked: 'false', message: 'modal.placement.initial.setting.size.none.pitch' },
{ id: 'ra01', name: 'roofSizeSet', value: '1', message: 'modal.placement.initial.setting.size.roof' },
{ id: 'ra02', name: 'roofSizeSet', value: '2', message: 'modal.placement.initial.setting.size.actual' },
{ id: 'ra03', name: 'roofSizeSet', value: '3', message: 'modal.placement.initial.setting.size.none.pitch' },
]
// (/)
const roofAngleSetArray = [
{ id: 'ra04', name: 'roofAngleSet', value: 'slope', checked: 'true', message: 'modal.placement.initial.setting.roof.pitch'},
{ id: 'ra05', name: 'roofAngleSet', value: 'flat', checked: 'false', message: 'modal.placement.initial.setting.roof.angle' },
{ id: 'ra04', name: 'roofAngleSet', value: 'slope', message: 'modal.placement.initial.setting.roof.pitch'},
{ id: 'ra05', name: 'roofAngleSet', value: 'flat', message: 'modal.placement.initial.setting.roof.angle' },
]
//
@ -59,12 +59,17 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
if (!basicSetting || !currentRoof || Object.keys(currentRoof).length === 0 || Object.keys(basicSetting).length === 0) return
const raftCodeList = findCommonCode('203800')
setRaftCodes(raftCodeList)
setCurrentRoof({ ...currentRoof, roofSizeSet: basicSetting.roofSizeSet, roofAngleSet: basicSetting.roofAngleSet })
console.log('🚀 ~ fetchBasicSettings ~ currentRoof 11:', currentRoof)
if (addedRoofs[0].roofAngleSet && addedRoofs[0].roofAngleSet?.length > 0) {
setCurrentRoof({ ...currentRoof, roofSizeSet: String(addedRoofs[0].roofSizeSet), roofAngleSet: addedRoofs[0].roofAngleSet })
} else if (basicSetting.roofAngleSet && basicSetting.roofAngleSet?.length > 0) {
setCurrentRoof({ ...currentRoof, roofSizeSet: String(basicSetting.roofSizeSet), roofAngleSet: basicSetting.roofAngleSet })
}
}, [])
useEffect(() => {
console.log('🚀 ~ fetchBasicSettings ~ currentRoof 22:', currentRoof)
console.log('🚀 ~ fetchBasicSettings ~ currentRoof :', currentRoof)
if(!currentRoof) return
setBasicSettings({
...basicSetting,
roofSizeSet: String(currentRoof.roofSizeSet),
@ -194,14 +199,12 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<div className="pop-form-radio">
{currentRoof &&
roofSizeSetArray.map((item) => (
<div className="d-check-radio pop">
<div className="d-check-radio pop" key={item.id}>
<input type="radio"
key={item.id}
id={item.id}
name={item.name}
value={item.value}
checked={currentRoof?.roofSizeSet === item.value}
defaultChecked={'1'}
onChange={(e) => setCurrentRoof({ ...currentRoof, roofSizeSet: e.target.value })}
/>
<label htmlFor={item.id}>{getMessage(item.message)}</label>
@ -217,14 +220,12 @@ export default function PlacementShapeSetting({ id, pos = { x: 50, y: 180 }, set
<div className="pop-form-radio">
{currentRoof &&
roofAngleSetArray.map((item) => (
<div className="d-check-radio pop">
<div className="d-check-radio pop" key={item.id}>
<input type="radio"
key={item.id}
id={item.id}
name={item.name}
value={item.value}
checked={currentRoof?.roofAngleSet === item.value}
defaultChecked={'slope'}
onChange={(e) => setCurrentRoof({ ...currentRoof, roofAngleSet: e.target.value })}
/>
<label htmlFor={item.id}>{getMessage(item.message)}</label>

View File

@ -19,6 +19,8 @@ import { globalLocaleStore } from '@/store/localeAtom'
import { stuffSearchState } from '@/store/stuffAtom'
import { QcastContext } from '@/app/QcastProvider'
import { usePopup } from '@/hooks/usePopup'
export const ToggleonMouse = (e, act, target) => {
const listWrap = e.target.closest(target)
const ListItem = Array.from(listWrap.childNodes)
@ -39,6 +41,8 @@ export default function Header(props) {
const [stuffSearch, setStuffSearch] = useRecoilState(stuffSearchState)
const { closeAll } = usePopup()
const { userSession } = props
const [sessionState, setSessionState] = useRecoilState(sessionStore)
const { getMessage } = useMessage()
@ -176,6 +180,9 @@ export default function Header(props) {
onClick={() => {
// moveHome()
removeStuffRecoil(menu)
if (pathName === '/') {
window.location.reload()
}
}}
>
{getMessage(menu.name)}
@ -226,6 +233,9 @@ export default function Header(props) {
...stuffSearch,
code: 'DELETE',
})
if (pathName === '/') {
window.location.reload()
}
}}
></Link>
</h1>
@ -239,6 +249,7 @@ export default function Header(props) {
href="#"
onClick={() => {
setUserInfoModal(true)
closeAll()
}}
>
<button className="profile">{userSession.userNm}</button>

View File

@ -88,6 +88,8 @@ export const useEstimateController = (planNo) => {
setIsGlobalLoading(false)
} catch (error) {
console.error('견적서 상세조회 Error: ', error)
swalFire({ text: getMessage('estimate.menu.move.valid1') })
setIsLoading(true)
setIsGlobalLoading(false)
}

View File

@ -156,7 +156,13 @@ export function useRoofAllocationSetting(id) {
}
setCurrentRoofList(selectRoofs)
setBasicSetting({ ...basicSetting, roofsData: roofsArray })
//setBasicSetting({ ...basicSetting, roofsData: roofsArray })
setBasicSetting({
...basicSetting,
roofSizeSet: res[0].roofSizeSet,
roofAngleSet: res[0].roofAngleSet,
roofsData: roofsArray,
})
})
} catch (error) {
console.error('Data fetching error:', error)

View File

@ -14,7 +14,7 @@ import { useCanvas } from '@/hooks/useCanvas'
import { SAVE_KEY } from '@/common/common'
import { readImage, removeImage } from '@/lib/fileAction'
import { FloorPlanContext } from '@/app/floor-plan/FloorPlanProvider'
import { useEstimateController } from '@/hooks/floorPlan/estimate/useEstimateController'
export function usePlan(params = {}) {
const { floorPlanState } = useContext(FloorPlanContext)
@ -31,8 +31,9 @@ export function usePlan(params = {}) {
const { swalFire } = useSwal()
const { getMessage } = useMessage()
const { get, promisePost, promisePut, promiseDel } = useAxios()
const { get, promisePost, promisePut, promiseDel, promiseGet } = useAxios()
const { setEstimateContextState } = useEstimateController()
/**
* 마우스 포인터의 가이드라인을 제거합니다.
*/
@ -203,12 +204,44 @@ export function usePlan(params = {}) {
* 현재 plan의 작업상태를 저장 이동
*/
const handleCurrentPlan = async (newCurrentId) => {
if (pathname === '/floor-plan') {
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
await saveCanvas()
}
}
updateCurrentPlan(newCurrentId)
const orderingNo = plans?.find((obj) => obj.id === newCurrentId).ordering
const objectNo = floorPlanState.objectNo
await promiseGet({ url: `/api/estimate/${objectNo}/${orderingNo}/detail` })
.then((res) => {
if (res.status === 200) {
const estimateDetail = res.data
if (estimateDetail.docNo) {
res.data.resetFlag = 'N'
if (res.data.itemList.length > 0) {
res.data.itemList.map((item) => {
item.delFlg = '0'
})
}
if (res.data.pkgAsp === null || res.data.pkgAsp == undefined) {
res.data.pkgAsp = '0.00'
} else {
const number = parseFloat(res.data.pkgAsp)
const roundedNumber = isNaN(number) ? '0.00' : number.toFixed(2)
res.data.pkgAsp = roundedNumber.toString()
}
setEstimateContextState(res.data)
if (pathname === '/floor-plan') {
if (!currentCanvasPlan || currentCanvasPlan.id !== newCurrentId) {
saveCanvas()
}
}
updateCurrentPlan(newCurrentId)
} else {
swalFire({ text: getMessage('estimate.menu.move.valid1') })
}
}
})
.catch((error) => {
swalFire({ text: getMessage('estimate.menu.move.valid1') })
})
}
const updateCurrentPlan = (newCurrentId) => {