feat: add estimateState context

This commit is contained in:
yoosangwook 2024-11-20 16:40:01 +09:00
parent d39f55c366
commit 97354fea77

View File

@ -2,7 +2,25 @@
// import { ErrorBoundary } from 'next/dist/client/components/error-boundary' // import { ErrorBoundary } from 'next/dist/client/components/error-boundary'
// import ServerError from '../error' // import ServerError from '../error'
import { createContext, useEffect, useState } from 'react' import { createContext, useEffect, useReducer, useState } from 'react'
const reducer = (prevState, nextState) => {
return { ...prevState, ...nextState }
}
const defaultEstimateData = {
estimateDate: new Date(), //견적일
charger: '', //담당자
objectName: '', //안건명
objectNameOmit: '', //경칭코드
estimateType: '', //주문분류
remarks: '', //비고
estimateOption: '', //견적특이사항
itemList: [],
fileList: [],
fileFlg: '0', //후일 자료 제출 (체크 1 노체크 0)
priceCd: '',
}
export const FloorPlanContext = createContext({ export const FloorPlanContext = createContext({
floorPlanState: {}, floorPlanState: {},
@ -17,11 +35,15 @@ const FloorPlanProvider = ({ children }) => {
toggleRotate: false, toggleRotate: false,
}) })
const [estimateState, setEstimateState] = useReducer(reducer, defaultEstimateData)
useEffect(() => { useEffect(() => {
console.log('🚀 ~ floorPlanState:', floorPlanState) console.log('🚀 ~ floorPlanState:', floorPlanState)
}, [floorPlanState]) }, [floorPlanState])
return <FloorPlanContext.Provider value={{ floorPlanState, setFloorPlanState }}>{children}</FloorPlanContext.Provider> return (
<FloorPlanContext.Provider value={{ floorPlanState, setFloorPlanState, estimateState, setEstimateState }}>{children}</FloorPlanContext.Provider>
)
} }
export default FloorPlanProvider export default FloorPlanProvider