📃fix: customHooks 주석 추가

This commit is contained in:
yoosangwook 2024-12-02 16:01:50 +09:00
parent 47e5b62e9c
commit d305877d2d

View File

@ -5,14 +5,28 @@ import { globalLocaleStore } from '@/store/localeAtom'
import { isObjectNotEmpty } from '@/util/common-utils'
import { useAxios } from '../useAxios'
/**
* 공통코드 관리를 위한 커스텀
*
* @description
* - 공통코드를 전역 상태로 관리하고 필요한 곳에서 사용할 있도록
* - 최초 1회만 API를 호출하여 공통코드를 가져옴
* - 언어 설정에 따라 한국어/일본어 코드명을 자동으로 변환
*
* @returns {Object}
* - commonCode: 전체 공통코드 객체(recoil state)
* - findCommonCode: 특정 공통코드 그룹을 조회하는 함수
*
* @example
* const { commonCode, findCommonCode } = useCommonCode();
* const honorificCodes = findCommonCode(200800);
*/
export const useCommonCode = () => {
const [commonCode, setCommonCode] = useRecoilState(commonCodeState)
const globalLocale = useRecoilValue(globalLocaleStore)
const { promiseGet } = useAxios()
const findCommonCode = (key) => {
// const arr = commonCode[key]
// return arr.sort((a, b) => a.clPriority - b.clPriority)
const resultCodes = commonCode[key]?.map((code) => {
const result = {
clHeadCd: code.clHeadCd,