From e7ab754b59a3092d1009026ed985946425c74b55 Mon Sep 17 00:00:00 2001 From: basssy Date: Mon, 28 Oct 2024 14:52:19 +0900 Subject: [PATCH] =?UTF-8?q?=EB=AC=BC=EA=B1=B4=EC=A0=95=EB=B3=B4=ED=99=94?= =?UTF-8?q?=EB=A9=B4=EC=97=90=EC=84=9C=20=EA=B2=AC=EC=A0=81=EC=84=9C=20?= =?UTF-8?q?=ED=99=94=EB=A9=B4=EC=9D=B4=EB=8F=99=EC=8B=9C=20=EB=AC=BC?= =?UTF-8?q?=EA=B1=B4=EB=B2=88=ED=98=B8=20=EA=B4=80=EB=A0=A8=20atom=20?= =?UTF-8?q?=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/components/management/StuffDetail.jsx | 10 ++++++++-- src/components/management/StuffSubHeader.jsx | 7 ++++--- src/store/floorPlanObjectAtom.js | 9 +++++++++ 3 files changed, 21 insertions(+), 5 deletions(-) create mode 100644 src/store/floorPlanObjectAtom.js 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, +})