dev_ysCha #590

Merged
ysCha merged 4 commits from dev_ysCha into dev 2026-01-19 15:39:36 +09:00

View File

@ -3,8 +3,11 @@ import { useMessage } from '@/hooks/useMessage'
import { useSwal } from '@/hooks/useSwal'
import { sessionStore } from '@/store/commonAtom'
import { getQueryString } from '@/util/common-utils'
import { useRecoilValue } from 'recoil'
import { atom, useRecoilState, useRecoilValue } from 'recoil'
// API 요청을 저장할 모듈 레벨 변수 (Hook 외부)
let roofMaterialPromise = null;
/**
* 마스터 컨트롤러
* @returns
@ -20,10 +23,23 @@ export function useMasterController() {
* @returns
*/
const getRoofMaterialList = async () => {
return await get({ url: '/api/v1/master/getRoofMaterialList' }).then((res) => {
// console.log('🚀🚀 ~ getRoofMaterialList ~ res:', res)
return res
})
// 1. 이미 진행 중이거나 완료된 Promise가 있으면 그것을 반환
if (roofMaterialPromise) {
return roofMaterialPromise;
}
// 2. 처음 호출될 때 Promise를 생성하여 변수에 할당
roofMaterialPromise = get({ url: '/api/v1/master/getRoofMaterialList' })
.then((res) => {
return res;
})
.catch((error) => {
// 에러 발생 시 다음 호출을 위해 초기화
roofMaterialPromise = null;
throw error;
});
return roofMaterialPromise;
}
/**