diff --git a/src/components/management/StuffDetail.jsx b/src/components/management/StuffDetail.jsx index 4b15c8a0..e8104548 100644 --- a/src/components/management/StuffDetail.jsx +++ b/src/components/management/StuffDetail.jsx @@ -10,15 +10,18 @@ import { globalLocaleStore } from '@/store/localeAtom' import { isEmptyArray, isNotEmptyArray, isObjectNotEmpty } from '@/util/common-utils' import { useMessage } from '@/hooks/useMessage' import { useForm } from 'react-hook-form' -import { useRecoilValue } from 'recoil' +import { useRecoilValue, useSetRecoilState } from 'recoil' import { sessionStore } from '@/store/commonAtom' import FindAddressPop from './popup/FindAddressPop' import PlanRequestPop from './popup/PlanRequestPop' import WindSelectPop from './popup/WindSelectPop' import { useCommonCode } from '@/hooks/common/useCommonCode' import StuffPlanQGrid from './StuffPlanQGrid' +import { floorPlanObjectState } from '@/store/floorPlanObjectAtom' export default function StuffDetail() { + const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) //견적서 화면용 물건번호리코일 + const inputReceiveUserEl = useRef(null) //담당자ref const inputObjectNameEl = useRef(null) //물건명ref const inputZipNoEl = useRef(null) //우편번호ref @@ -1077,6 +1080,7 @@ export default function StuffDetail() { //상세화면으로 전환 if (res.status === 201) { alert(getMessage('stuff.detail.save')) + setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) router.push(`/management/stuff/detail?objectNo=${res.data.objectNo.toString()}`) } }) @@ -1085,6 +1089,7 @@ export default function StuffDetail() { await promisePut({ url: apiUrl, data: params }).then((res) => { if (res.status === 201) { alert(getMessage('stuff.detail.save')) + setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) router.refresh() } }) @@ -1153,7 +1158,8 @@ export default function StuffDetail() { alert(getMessage('stuff.detail.delete.message1')) } else { if (confirm(getMessage('common.message.data.delete'))) { - del({ url: `/api/object/${objectNo}` }).then((res) => { + del({ url: `/api/object/${objectNo}` }).then(() => { + setFloorPlanObjectNo({ floorPlanObjectNo: '' }) router.push('/management/stuff') }) } diff --git a/src/components/management/StuffSubHeader.jsx b/src/components/management/StuffSubHeader.jsx index 1b10a149..f1103143 100644 --- a/src/components/management/StuffSubHeader.jsx +++ b/src/components/management/StuffSubHeader.jsx @@ -5,14 +5,15 @@ import Link from 'next/link' import Image from 'next/image' import { useMessage } from '@/hooks/useMessage' import { useRouter, useSearchParams } from 'next/navigation' -import { stuffSearchState } from '@/store/stuffAtom' +import { floorPlanObjectState } from '@/store/floorPlanObjectAtom' import { useSetRecoilState } from 'recoil' export default function StuffSubHeader({ type }) { const { getMessage } = useMessage() const router = useRouter() - const setSchObjectNo = useSetRecoilState(stuffSearchState) + const setFloorPlanObjectNo = useSetRecoilState(floorPlanObjectState) + useEffect(() => { window.scrollTo(0, 0) }, []) @@ -22,7 +23,7 @@ export default function StuffSubHeader({ type }) { // url에 물건번호로 도면작성화면으로 이동 const moveFloorPlan = () => { - setSchObjectNo(objectNo) + setFloorPlanObjectNo({ floorPlanObjectNo: objectNo }) router.push('/floor-plan') } diff --git a/src/store/floorPlanObjectAtom.js b/src/store/floorPlanObjectAtom.js new file mode 100644 index 00000000..50cdccf4 --- /dev/null +++ b/src/store/floorPlanObjectAtom.js @@ -0,0 +1,9 @@ +import { atom } from 'recoil' +import { v1 } from 'uuid' +export const floorPlanObjectState = atom({ + key: `floorPlanObjectState/${v1()}`, + default: { + objectNo: '', //물건번호 + }, + dangerouslyAllowMutability: true, +})