feat: get inquiry type common code
This commit is contained in:
parent
333f06bb64
commit
50a2335590
19
src/app/api/qna/route.ts
Normal file
19
src/app/api/qna/route.ts
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
import { NextResponse } from 'next/server'
|
||||||
|
import axios from 'axios'
|
||||||
|
import { CommonCode } from '@/types/Inquiry'
|
||||||
|
|
||||||
|
export async function GET() {
|
||||||
|
const response = await axios.get(`${process.env.NEXT_PUBLIC_INQUIRY_API_URL}/api/system/commonCodeListData`)
|
||||||
|
const codeList: CommonCode[] = []
|
||||||
|
response.data.data.apiCommCdList.forEach((item: any) => {
|
||||||
|
if (item.headCd === '204200' || item.headCd === '204300' || item.headCd === '204400') {
|
||||||
|
codeList.push({
|
||||||
|
headCd: item.headCd,
|
||||||
|
code: item.code,
|
||||||
|
name: item.codeJp,
|
||||||
|
refChar1: item.refChr1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return NextResponse.json({ data: codeList })
|
||||||
|
}
|
||||||
@ -40,6 +40,8 @@ export default function RegistForm() {
|
|||||||
}
|
}
|
||||||
}, [session])
|
}, [session])
|
||||||
|
|
||||||
|
const { commonCodeList } = useInquiry()
|
||||||
|
|
||||||
const [attachedFiles, setAttachedFiles] = useState<File[]>([])
|
const [attachedFiles, setAttachedFiles] = useState<File[]>([])
|
||||||
|
|
||||||
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
const handleFileChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||||
@ -113,9 +115,14 @@ export default function RegistForm() {
|
|||||||
value={inquiryRequest.qnaClsLrgCd}
|
value={inquiryRequest.qnaClsLrgCd}
|
||||||
onChange={(e) => setInquiryRequest({ ...inquiryRequest, qnaClsLrgCd: e.target.value })}
|
onChange={(e) => setInquiryRequest({ ...inquiryRequest, qnaClsLrgCd: e.target.value })}
|
||||||
>
|
>
|
||||||
<option value="">選択してください</option>
|
<option value="" hidden>選択してください</option>
|
||||||
<option value="A01">A01</option>
|
{commonCodeList
|
||||||
<option value="204200">204200</option>
|
.filter((code) => code.headCd === '204200')
|
||||||
|
.map((code) => (
|
||||||
|
<option key={code.code} value={code.code}>
|
||||||
|
{code.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="data-input mt5">
|
<div className="data-input mt5">
|
||||||
@ -126,9 +133,14 @@ export default function RegistForm() {
|
|||||||
value={inquiryRequest.qnaClsMidCd}
|
value={inquiryRequest.qnaClsMidCd}
|
||||||
onChange={(e) => setInquiryRequest({ ...inquiryRequest, qnaClsMidCd: e.target.value })}
|
onChange={(e) => setInquiryRequest({ ...inquiryRequest, qnaClsMidCd: e.target.value })}
|
||||||
>
|
>
|
||||||
<option value="">選択してください</option>
|
<option value="" hidden>選択してください</option>
|
||||||
<option value="B02">B02</option>
|
{commonCodeList
|
||||||
<option value="204300">204300</option>
|
.filter((code) => code.refChar1 === inquiryRequest.qnaClsLrgCd)
|
||||||
|
.map((code) => (
|
||||||
|
<option key={code.code} value={code.code}>
|
||||||
|
{code.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
<div className="data-input mt5">
|
<div className="data-input mt5">
|
||||||
@ -139,9 +151,14 @@ export default function RegistForm() {
|
|||||||
value={inquiryRequest.qnaClsSmlCd ?? ''}
|
value={inquiryRequest.qnaClsSmlCd ?? ''}
|
||||||
onChange={(e) => setInquiryRequest({ ...inquiryRequest, qnaClsSmlCd: e.target.value })}
|
onChange={(e) => setInquiryRequest({ ...inquiryRequest, qnaClsSmlCd: e.target.value })}
|
||||||
>
|
>
|
||||||
<option value="">選択してください</option>
|
<option value="" hidden>選択してください</option>
|
||||||
<option value="C05">C05</option>
|
{commonCodeList
|
||||||
<option value="204400">204400</option>
|
.filter((code) => code.refChar1 === inquiryRequest.qnaClsMidCd)
|
||||||
|
.map((code) => (
|
||||||
|
<option key={code.code} value={code.code}>
|
||||||
|
{code.name}
|
||||||
|
</option>
|
||||||
|
))}
|
||||||
</select>
|
</select>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@ -46,9 +46,7 @@ export default function ListTable() {
|
|||||||
if (!session.isLoggedIn || !inquiryList) return
|
if (!session.isLoggedIn || !inquiryList) return
|
||||||
if (session.isLoggedIn) {
|
if (session.isLoggedIn) {
|
||||||
setInquiryListRequest({ ...inquiryListRequest, storeId: session.storeId ?? '', loginId: session.userId ?? '' })
|
setInquiryListRequest({ ...inquiryListRequest, storeId: session.storeId ?? '', loginId: session.userId ?? '' })
|
||||||
// setInquiryListRequest({ ...inquiryListRequest, storeId: 'X112', loginId: 'x112' })
|
|
||||||
}
|
}
|
||||||
console.log('inquiryListRequest', inquiryListRequest)
|
|
||||||
if (inquiryList.length > 0 && inquiryList[0].totCnt > 0) {
|
if (inquiryList.length > 0 && inquiryList[0].totCnt > 0) {
|
||||||
if (inquiryListRequest.startRow > 1) {
|
if (inquiryListRequest.startRow > 1) {
|
||||||
const isDuplicate = inquiryList.every((newItem) => heldInquiryList.some((existingItem) => existingItem.qnaNo === newItem.qnaNo))
|
const isDuplicate = inquiryList.every((newItem) => heldInquiryList.some((existingItem) => existingItem.qnaNo === newItem.qnaNo))
|
||||||
|
|||||||
@ -1,4 +1,4 @@
|
|||||||
import { InquiryList, Inquiry, InquirySaveResponse } from '@/types/Inquiry'
|
import { InquiryList, Inquiry, InquirySaveResponse, CommonCode } 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'
|
||||||
@ -16,6 +16,7 @@ export function useInquiry(
|
|||||||
isSavingInquiry: boolean
|
isSavingInquiry: boolean
|
||||||
saveInquiry: (formData: FormData) => Promise<InquirySaveResponse>
|
saveInquiry: (formData: FormData) => Promise<InquirySaveResponse>
|
||||||
downloadFile: (encodeFileNo: number) => Promise<File>
|
downloadFile: (encodeFileNo: number) => Promise<File>
|
||||||
|
commonCodeList: CommonCode[]
|
||||||
} {
|
} {
|
||||||
const queryClient = useQueryClient()
|
const queryClient = useQueryClient()
|
||||||
const { inquiryListRequest } = useInquiryFilterStore()
|
const { inquiryListRequest } = useInquiryFilterStore()
|
||||||
@ -78,6 +79,16 @@ export function useInquiry(
|
|||||||
return resp.data
|
return resp.data
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const { data: commonCodeList, isLoading: isLoadingCommonCodeList } = useQuery({
|
||||||
|
queryKey: ['commonCodeList'],
|
||||||
|
queryFn: async () => {
|
||||||
|
const resp = await axiosInstance(null).get<{ data: CommonCode[] }>(`/api/qna`)
|
||||||
|
return resp.data
|
||||||
|
},
|
||||||
|
staleTime: Infinity,
|
||||||
|
gcTime: Infinity,
|
||||||
|
})
|
||||||
|
|
||||||
return {
|
return {
|
||||||
inquiryList: inquriyListData.inquiryList,
|
inquiryList: inquriyListData.inquiryList,
|
||||||
inquiryDetail: inquiryDetail ?? null,
|
inquiryDetail: inquiryDetail ?? null,
|
||||||
@ -86,5 +97,6 @@ export function useInquiry(
|
|||||||
isSavingInquiry,
|
isSavingInquiry,
|
||||||
saveInquiry,
|
saveInquiry,
|
||||||
downloadFile,
|
downloadFile,
|
||||||
|
commonCodeList: commonCodeList?.data ?? [],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -89,3 +89,10 @@ export type InquirySaveResponse = {
|
|||||||
qnaNo: number //qna number
|
qnaNo: number //qna number
|
||||||
mailYn: string //mail yn - Y / N
|
mailYn: string //mail yn - Y / N
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type CommonCode = {
|
||||||
|
headCd: string
|
||||||
|
code: string
|
||||||
|
name: string
|
||||||
|
refChar1: string
|
||||||
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user