fix: 문의 유형 공통코드 조회 로직 수정
- 기존 구현 되어 있던 공통코드 조회 api 사용
This commit is contained in:
parent
5a08c9067f
commit
5a49b86205
@ -2,7 +2,7 @@
|
||||
|
||||
import { useInquiry } from '@/hooks/useInquiry'
|
||||
import { useSessionStore } from '@/store/session'
|
||||
import { InquiryRequest } from '@/types/Inquiry'
|
||||
import { InquiryCommCode, InquiryRequest } from '@/types/Inquiry'
|
||||
import { useEffect, useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { CONFIRM_MESSAGE, SUCCESS_MESSAGE, useAlertMsg, WARNING_MESSAGE } from '@/hooks/useAlertMsg'
|
||||
@ -152,15 +152,15 @@ export default function RegistForm() {
|
||||
選択してください
|
||||
</option>
|
||||
{commonCodeList
|
||||
.filter((code) => code.headId === 'QNA_CLS_LRG_CD')
|
||||
.filter((code) => code.headCd === InquiryCommCode.QNA_CLS_LRG_CD.headCd)
|
||||
.map((code) => (
|
||||
<option key={code.code} value={code.code}>
|
||||
{code.name}
|
||||
{code.codeJp}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
{commonCodeList.filter((code) => code.refChar1 === inquiryRequest.qnaClsLrgCd).length > 0 && inquiryRequest.qnaClsLrgCd && (
|
||||
{commonCodeList.filter((code) => code.refChr1 === inquiryRequest.qnaClsLrgCd).length > 0 && inquiryRequest.qnaClsLrgCd && (
|
||||
<div className="data-input mt5">
|
||||
<select
|
||||
className="select-form"
|
||||
@ -173,16 +173,16 @@ export default function RegistForm() {
|
||||
選択してください
|
||||
</option>
|
||||
{commonCodeList
|
||||
.filter((code) => code.refChar1 === inquiryRequest.qnaClsLrgCd)
|
||||
.filter((code) => code.refChr1 === inquiryRequest.qnaClsLrgCd)
|
||||
.map((code) => (
|
||||
<option key={code.code} value={code.code}>
|
||||
{code.name}
|
||||
{code.codeJp}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
</div>
|
||||
)}
|
||||
{commonCodeList.filter((code) => code.refChar1 === inquiryRequest.qnaClsMidCd).length > 0 && inquiryRequest.qnaClsMidCd && (
|
||||
{commonCodeList.filter((code) => code.refChr1 === inquiryRequest.qnaClsMidCd).length > 0 && inquiryRequest.qnaClsMidCd && (
|
||||
<div className="data-input mt5">
|
||||
<select
|
||||
className="select-form"
|
||||
@ -195,10 +195,10 @@ export default function RegistForm() {
|
||||
選択してください
|
||||
</option>
|
||||
{commonCodeList
|
||||
.filter((code) => code.refChar1 === inquiryRequest.qnaClsMidCd)
|
||||
.filter((code) => code.refChr1 === inquiryRequest.qnaClsMidCd)
|
||||
.map((code) => (
|
||||
<option key={code.code} value={code.code}>
|
||||
{code.name}
|
||||
{code.codeJp}
|
||||
</option>
|
||||
))}
|
||||
</select>
|
||||
|
||||
@ -1,11 +1,12 @@
|
||||
import { InquiryList, Inquiry, InquirySaveResponse, CommonCode } from '@/types/Inquiry'
|
||||
import { InquiryList, Inquiry, InquirySaveResponse, InquiryCommCode } from '@/types/Inquiry'
|
||||
import { useAxios } from '@/hooks/useAxios'
|
||||
import { useMutation, useQuery, useQueryClient } from '@tanstack/react-query'
|
||||
import { useInquiryFilterStore } from '@/store/inquiryFilterStore'
|
||||
import { useMemo } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useAlertMsg } from '@/hooks/useAlertMsg'
|
||||
|
||||
import { useCommCode } from './useCommCode'
|
||||
import { CommCode } from '@/types/CommCode'
|
||||
|
||||
/**
|
||||
* @description 문의사항 관련 기능을 제공하는 커스텀 훅
|
||||
@ -20,7 +21,7 @@ import { useAlertMsg } from '@/hooks/useAlertMsg'
|
||||
* @returns {boolean} isSavingInquiry - 문의사항 저장 중 상태
|
||||
* @returns {Function} saveInquiry - 문의사항 저장 함수
|
||||
* @returns {Function} downloadFile - 파일 다운로드 함수
|
||||
* @returns {CommonCode[]} commonCodeList - 공통 코드 목록
|
||||
* @returns {CommCode[]} commonCodeList - 공통 코드 목록
|
||||
*/
|
||||
export function useInquiry(
|
||||
qnoNo?: number,
|
||||
@ -33,7 +34,7 @@ export function useInquiry(
|
||||
isSavingInquiry: boolean
|
||||
saveInquiry: (formData: FormData) => Promise<InquirySaveResponse>
|
||||
downloadFile: (encodeFileNo: number, srcFileNm: string) => Promise<Blob | null>
|
||||
commonCodeList: CommonCode[]
|
||||
commonCodeList: CommCode[]
|
||||
} {
|
||||
const queryClient = useQueryClient()
|
||||
const { inquiryListRequest, offset, isMyInquiry } = useInquiryFilterStore()
|
||||
@ -216,7 +217,8 @@ export function useInquiry(
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 공통 코드 목록 조회
|
||||
* @description 문의 공통 코드 목록 조회
|
||||
* - 문의 유형 대분류, 중분류, 소분류 코드 조회 이후 데이터 리로드 하지 않음
|
||||
*
|
||||
* @returns {Object} 공통 코드 목록 데이터
|
||||
* @returns {CommonCode[]} data - 공통 코드 목록
|
||||
@ -225,15 +227,13 @@ export function useInquiry(
|
||||
const { data: commonCodeList, isLoading: isLoadingCommonCodeList } = useQuery({
|
||||
queryKey: ['commonCodeList'],
|
||||
queryFn: async () => {
|
||||
const isListQuery = false
|
||||
const shouldThrowError = false
|
||||
|
||||
const resp = await tryFunction(
|
||||
() => axiosInstance(null).get<CommonCode[]>('/api/comm-code', { params: { headId: 'QNA_CD' } }),
|
||||
isListQuery,
|
||||
shouldThrowError,
|
||||
)
|
||||
return resp?.data ?? []
|
||||
const { getCommCode } = useCommCode()
|
||||
const resp = await Promise.all([
|
||||
getCommCode(InquiryCommCode.QNA_CLS_LRG_CD.headId),
|
||||
getCommCode(InquiryCommCode.QNA_CLS_MID_CD.headId),
|
||||
getCommCode(InquiryCommCode.QNA_CLS_SML_CD.headId),
|
||||
])
|
||||
return resp.flat()
|
||||
},
|
||||
staleTime: Infinity,
|
||||
gcTime: Infinity,
|
||||
|
||||
@ -180,13 +180,17 @@ export type InquirySaveResponse = {
|
||||
mailYn: string
|
||||
}
|
||||
|
||||
/**
|
||||
* @description 공통 코드 타입
|
||||
*/
|
||||
export type CommonCode = {
|
||||
headCd: string
|
||||
headId: string
|
||||
code: string
|
||||
name: string
|
||||
refChar1: string
|
||||
export const InquiryCommCode = {
|
||||
QNA_CLS_LRG_CD: {
|
||||
headCd: '204200',
|
||||
headId: 'QNA_CLS_LRG_CD',
|
||||
},
|
||||
QNA_CLS_MID_CD: {
|
||||
headCd: '204300',
|
||||
headId: 'QNA_CLS_MID_CD',
|
||||
},
|
||||
QNA_CLS_SML_CD: {
|
||||
headCd: '204400',
|
||||
headId: 'QNA_CLS_SML_CD',
|
||||
},
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user