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