Compare commits
No commits in common. "cdfe211203d0d625d1e2806fa9d5a53079ca96a9" and "f51b03cab742a504d3f076c440e555295e00dcc1" have entirely different histories.
cdfe211203
...
f51b03cab7
@ -12,7 +12,7 @@ import { Suitable } from '@/types/Suitable'
|
|||||||
*
|
*
|
||||||
* @apiBody {FormData} form-data
|
* @apiBody {FormData} form-data
|
||||||
* @apiBody {String} form-data.ids 메인 ID 목록 (쉼표로 구분된 문자열)
|
* @apiBody {String} form-data.ids 메인 ID 목록 (쉼표로 구분된 문자열)
|
||||||
* @apiBody {String} [form-data.detailIds] 상세 ID 목록 (쉼표로 구분된 문자열)
|
* @apiBody {String} form-data.detailIds 상세 ID 목록 (쉼표로 구분된 문자열)
|
||||||
*
|
*
|
||||||
* @apiExample {curl} Example usage:
|
* @apiExample {curl} Example usage:
|
||||||
* curl -X POST \
|
* curl -X POST \
|
||||||
@ -44,10 +44,10 @@ export async function POST(request: NextRequest) {
|
|||||||
try {
|
try {
|
||||||
const body: Record<string, string> = await request.json()
|
const body: Record<string, string> = await request.json()
|
||||||
const ids = body.ids
|
const ids = body.ids
|
||||||
const detailIds = body.detailIds || ''
|
const detailIds = body.detailIds
|
||||||
|
|
||||||
/* 파라미터 체크 */
|
/* 파라미터 체크 */
|
||||||
if (ids === '') {
|
if (ids === '' || detailIds === '') {
|
||||||
return NextResponse.json({ error: '필수 파라미터가 누락되었습니다' }, { status: 400 })
|
return NextResponse.json({ error: '필수 파라미터가 누락되었습니다' }, { status: 400 })
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ export async function POST(request: NextRequest) {
|
|||||||
, msd_json.memo
|
, msd_json.memo
|
||||||
FROM ms_suitable_detail msd_json
|
FROM ms_suitable_detail msd_json
|
||||||
WHERE msd.main_id = msd_json.main_id
|
WHERE msd.main_id = msd_json.main_id
|
||||||
--detailIds AND msd_json.id IN (:detailIds)
|
AND msd_json.id IN (:detailIds)
|
||||||
FOR JSON PATH
|
FOR JSON PATH
|
||||||
) AS detail
|
) AS detail
|
||||||
FROM ms_suitable_detail msd
|
FROM ms_suitable_detail msd
|
||||||
@ -86,10 +86,7 @@ export async function POST(request: NextRequest) {
|
|||||||
|
|
||||||
/* 검색 조건 설정 */
|
/* 검색 조건 설정 */
|
||||||
query = query.replaceAll(':mainIds', ids)
|
query = query.replaceAll(':mainIds', ids)
|
||||||
if (detailIds) {
|
query = query.replaceAll(':detailIds', detailIds)
|
||||||
query = query.replace('--detailIds ', '')
|
|
||||||
query = query.replace(':detailIds', detailIds)
|
|
||||||
}
|
|
||||||
|
|
||||||
const suitable: Suitable[] = await prisma.$queryRawUnsafe(query)
|
const suitable: Suitable[] = await prisma.$queryRawUnsafe(query)
|
||||||
|
|
||||||
|
|||||||
@ -68,7 +68,7 @@ export default function SuitableDetailPopup() {
|
|||||||
<div className="check-pop-data-txt">{toCodeName(SUITABLE_HEAD_CODE.ROOF_SH_CD, item.roofShCd)}</div>
|
<div className="check-pop-data-txt">{toCodeName(SUITABLE_HEAD_CODE.ROOF_SH_CD, item.roofShCd)}</div>
|
||||||
</div>
|
</div>
|
||||||
<div className="check-pop-data-table-wrap">
|
<div className="check-pop-data-table-wrap">
|
||||||
{toSuitableDetail(item.detail)?.map((subItem: SuitableDetail) => (
|
{toSuitableDetail(item.detail).map((subItem: SuitableDetail) => (
|
||||||
<div className="check-pop-data-table" key={subItem.id}>
|
<div className="check-pop-data-table" key={subItem.id}>
|
||||||
<div className="pop-data-table-head">
|
<div className="pop-data-table-head">
|
||||||
<div className="pop-data-table-head-name">{toCodeName(SUITABLE_HEAD_CODE.TRESTLE_MFPC_CD, subItem.trestleMfpcCd)}</div>
|
<div className="pop-data-table-head-name">{toCodeName(SUITABLE_HEAD_CODE.TRESTLE_MFPC_CD, subItem.trestleMfpcCd)}</div>
|
||||||
|
|||||||
@ -83,7 +83,7 @@ export default function SuitableList() {
|
|||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<ul className="reference-list check">
|
<ul className="reference-list check">
|
||||||
{toSuitableDetail(item.detail)?.map((subItem: SuitableDetail) => (
|
{toSuitableDetail(item.detail).map((subItem: SuitableDetail) => (
|
||||||
<li className="reference-item" key={subItem.id}>
|
<li className="reference-item" key={subItem.id}>
|
||||||
<div className="check-item-wrap">
|
<div className="check-item-wrap">
|
||||||
<div className="check-form-box light">
|
<div className="check-form-box light">
|
||||||
|
|||||||
@ -146,9 +146,6 @@ export default function ButtonForm({ mode, setMode, data }: ButtonFormProps) {
|
|||||||
})
|
})
|
||||||
if (!isUpdatingSurvey) {
|
if (!isUpdatingSurvey) {
|
||||||
setMode('READ')
|
setMode('READ')
|
||||||
if (isSubmitProcess) {
|
|
||||||
popupController.setSurveySaleSubmitPopup(true)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/** 제출 로직인 경우 search param 추가 */
|
/** 제출 로직인 경우 search param 추가 */
|
||||||
@ -252,7 +249,7 @@ export default function ButtonForm({ mode, setMode, data }: ButtonFormProps) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Button Components */
|
// Button Components
|
||||||
const ListButton = () => {
|
const ListButton = () => {
|
||||||
const router = useRouter()
|
const router = useRouter()
|
||||||
return (
|
return (
|
||||||
|
|||||||
@ -97,11 +97,11 @@ export default function DetailForm() {
|
|||||||
/** 제출 팝업 처리 - createSurvey 이후 popup 처리 시 노드 삽입 오류로 인해 별도 처리 */
|
/** 제출 팝업 처리 - createSurvey 이후 popup 처리 시 노드 삽입 오류로 인해 별도 처리 */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
const show = searchParams.get('show')
|
const show = searchParams.get('show')
|
||||||
if (show === 'true' && !isLoadingSurveyDetail) {
|
if (show === 'true') {
|
||||||
popupController.setSurveySaleSubmitPopup(true)
|
popupController.setSurveySaleSubmitPopup(true)
|
||||||
router.replace(pathname)
|
router.replace(pathname)
|
||||||
}
|
}
|
||||||
}, [searchParams, pathname, isLoadingSurveyDetail])
|
}, [searchParams, pathname])
|
||||||
|
|
||||||
/** 세션 데이터가 변경될 때 기본 정보 업데이트 */
|
/** 세션 데이터가 변경될 때 기본 정보 업데이트 */
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
|||||||
76790
src/data.ts
Normal file
76790
src/data.ts
Normal file
File diff suppressed because it is too large
Load Diff
@ -84,7 +84,7 @@ export function useSuitable() {
|
|||||||
const getSuitableDetails = async (ids: string, detailIds?: string): Promise<Suitable[]> => {
|
const getSuitableDetails = async (ids: string, detailIds?: string): Promise<Suitable[]> => {
|
||||||
try {
|
try {
|
||||||
const params: Record<string, string> = { ids: ids }
|
const params: Record<string, string> = { ids: ids }
|
||||||
if (detailIds?.trim()) params.detailIds = detailIds
|
if (detailIds) params.detailIds = detailIds
|
||||||
const response = await axiosInstance(null).post<Suitable[]>('/api/suitable', params)
|
const response = await axiosInstance(null).post<Suitable[]>('/api/suitable', params)
|
||||||
return response.data
|
return response.data
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
@ -150,7 +150,6 @@ export function useSuitable() {
|
|||||||
*/
|
*/
|
||||||
const toSuitableDetailIds = (suitableDetailString: string): Set<number> => {
|
const toSuitableDetailIds = (suitableDetailString: string): Set<number> => {
|
||||||
try {
|
try {
|
||||||
if (!suitableDetailString) return new Set()
|
|
||||||
return new Set<number>(JSON.parse(suitableDetailString).map(({ id }: { id: number }) => id))
|
return new Set<number>(JSON.parse(suitableDetailString).map(({ id }: { id: number }) => id))
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error(`지붕재 적합성 detail 데이터 파싱 실패: ${error}`)
|
console.error(`지붕재 적합성 detail 데이터 파싱 실패: ${error}`)
|
||||||
|
|||||||
@ -110,19 +110,19 @@ export function useSurvey(
|
|||||||
const status = error.response?.status
|
const status = error.response?.status
|
||||||
alert(error.response?.data.error)
|
alert(error.response?.data.error)
|
||||||
switch (status) {
|
switch (status) {
|
||||||
/** session 없는 경우 */
|
// session 없는 경우
|
||||||
case 401:
|
case 401:
|
||||||
router.replace('/login')
|
router.replace('/login')
|
||||||
break
|
break
|
||||||
/** 조회 권한 없는 경우 */
|
// 조회 권한 없는 경우
|
||||||
case 403:
|
case 403:
|
||||||
router.replace('/survey-sale')
|
router.replace('/survey-sale')
|
||||||
break
|
break
|
||||||
/** 데이터 DB상 존재하지 않는 경우 */
|
// 데이터 DB상 존재하지 않는 경우
|
||||||
case 404:
|
case 404:
|
||||||
router.replace('/survey-sale')
|
router.replace('/survey-sale')
|
||||||
break
|
break
|
||||||
/** 서버 오류 */
|
// 서버 오류
|
||||||
case 500:
|
case 500:
|
||||||
router.back()
|
router.back()
|
||||||
break
|
break
|
||||||
@ -268,8 +268,8 @@ export function useSurvey(
|
|||||||
* @throws {Error} id가 없는 경우 에러 발생
|
* @throws {Error} id가 없는 경우 에러 발생
|
||||||
*
|
*
|
||||||
* @example
|
* @example
|
||||||
*
|
* // 삭제 성공 시 목록 데이터만 갱신하고, 상세 데이터는 갱신하지 않음
|
||||||
*
|
* // 상세 데이터를 갱신하면 404 에러가 발생할 수 있음
|
||||||
*/
|
*/
|
||||||
const { mutateAsync: deleteSurvey, isPending: isDeletingSurvey } = useMutation({
|
const { mutateAsync: deleteSurvey, isPending: isDeletingSurvey } = useMutation({
|
||||||
mutationFn: async () => {
|
mutationFn: async () => {
|
||||||
|
|||||||
@ -36,12 +36,12 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
|
|||||||
* 사용자 이벤트 트래킹 처리
|
* 사용자 이벤트 트래킹 처리
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
// const handlePageEvent = (path: string) => {
|
const handlePageEvent = (path: string) => {
|
||||||
// tracking({
|
tracking({
|
||||||
// url: path,
|
url: path,
|
||||||
// data: '',
|
data: '',
|
||||||
// })
|
})
|
||||||
// }
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* alert 함수 - window.alert 함수 대체
|
* alert 함수 - window.alert 함수 대체
|
||||||
@ -69,6 +69,17 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
|
|||||||
}
|
}
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
|
if (pathname === '/login') {
|
||||||
|
if (session?.isLoggedIn) {
|
||||||
|
router.push('/')
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pathname === '/') {
|
||||||
|
if (!session?.isLoggedIn) {
|
||||||
|
router.push('/login')
|
||||||
|
}
|
||||||
|
}
|
||||||
//alert 함수 변경해서 바인딩
|
//alert 함수 변경해서 바인딩
|
||||||
window.alert = function (msg, alertBtn = () => setAlert(false)) {
|
window.alert = function (msg, alertBtn = () => setAlert(false)) {
|
||||||
alertFunc(msg, alertBtn)
|
alertFunc(msg, alertBtn)
|
||||||
@ -83,13 +94,6 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
|
|||||||
alertFunc2(msg, alertBtn2Yes || (() => {}), alertBtn2No || (() => {}))
|
alertFunc2(msg, alertBtn2Yes || (() => {}), alertBtn2No || (() => {}))
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if (sessionData === '') {
|
|
||||||
router.push('/login')
|
|
||||||
} else {
|
|
||||||
if (pathname === '/login') {
|
|
||||||
router.push('/')
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 서버 세션이 있으면 zuatand 세션 데이터 갱신
|
// 서버 세션이 있으면 zuatand 세션 데이터 갱신
|
||||||
if (sessionData && sessionData !== '') {
|
if (sessionData && sessionData !== '') {
|
||||||
setSession({
|
setSession({
|
||||||
@ -112,7 +116,7 @@ export default function EdgeProvider({ children, sessionData }: EdgeProviderProp
|
|||||||
//사이드바 초기화
|
//사이드바 초기화
|
||||||
reset()
|
reset()
|
||||||
// 페이지 이벤트 트래킹
|
// 페이지 이벤트 트래킹
|
||||||
// handlePageEvent(pathname)
|
handlePageEvent(pathname)
|
||||||
}, [pathname])
|
}, [pathname])
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user