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