261019_01_ENH: 리스트 비동기 작업 동시 실행 제한 및 진행 상태 UI 개선, 미사용 참조 정리

This commit is contained in:
2026-10-19 14:22:07 +09:00
parent 4e51530922
commit d2e826702e
46 changed files with 1398 additions and 406 deletions

View File

@@ -1,6 +1,8 @@
'use client'
import { useEffect, useMemo, useState } from 'react'
import { useAtom } from 'jotai'
import { listJobOpenRequestAtom } from '@/store/jotai/list-job'
import { useMounted } from '@kri/common/hooks'
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
import { useAuth } from '@/hooks/useAuth'
@@ -13,7 +15,9 @@ import { AssignTargetList, useAssignTargetRows } from '@/components/assign/Assig
import { ListSearchTable } from '@/components/list/ListSearchTable'
import { useProjectInfoQuery, useResultCodesQuery } from '@/query/project'
import { useListHeaderQuery } from '@/query/list'
import { useResetListAssignMutation, useUpsertListAssignMutation } from '@/query/assign'
import { ListJobPageQueryContext, useSubmitListJob } from '@/query/list-job'
import { ListJobGatePanel } from '@/components/list/ListJobGate'
import { useListJobPageMonitor } from '@/hooks/useListJobPageMonitor'
import { ListHeaderAssignConst, LIST_HEADER_TYPE_LABEL } from '@/const/listConst'
import { createEmptyListFilter, type ListFilter, type ListHeaderAssignType, type listHeader } from '@/types/list'
import type { ResultCode } from '@/types/project'
@@ -55,8 +59,9 @@ const ListAssignPage = () => {
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled)
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled)
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
const upsertListAssignMutation = useUpsertListAssignMutation(prjctIdx)
const resetListAssignMutation = useResetListAssignMutation(prjctIdx)
const assignMutation = useSubmitListJob(prjctIdx)
const { gate: assignGate, dataRevision } = useListJobPageMonitor(prjctIdx, 'LIST_ASSIGN', enabled)
const [openRequest, setOpenRequest] = useAtom(listJobOpenRequestAtom)
const assignTargetRows = useAssignTargetRows({ prjctIdx, enabled, assignType: effectiveAssignType })
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data])
@@ -122,7 +127,15 @@ const ListAssignPage = () => {
const hasNoAppliedFilter = () => filterSummary.length === 0 && assignFilterIds.length === 0
useEffect(() => {
if (enabled && openRequest && !openRequest.opened && openRequest.jobType === 'LIST_ASSIGN'
&& openRequest.userId === auth.user?.userId && openRequest.prjctIdx === prjctIdx) {
setOpenRequest({ ...openRequest, opened: true })
}
}, [enabled, openRequest, auth.user?.userId, prjctIdx, setOpenRequest])
const handleAssign = async () => {
if (assignGate.submitBlocked || assignMutation.isPending) return
if (!selectedAssignId) {
alert('배정할 대상을 선택해주세요.')
return
@@ -131,33 +144,38 @@ const ListAssignPage = () => {
return
}
await upsertListAssignMutation.mutateAsync({
assignId: selectedAssignId,
request: {
await assignMutation.mutateAsync({
jobType: 'LIST_ASSIGN',
path: `mutations/assign/${encodeURIComponent(selectedAssignId)}`,
body: {
assignType: effectiveAssignType,
transferResve: effectiveAssignType === ListHeaderAssignConst.OUTSOURCE? false : transferResve,
listFilter: currentListFilter,
},
})
alert('배정되었습니다.')
}
const handleResetAssign = async () => {
if (assignGate.submitBlocked || assignMutation.isPending) return
if (hasNoAppliedFilter() && !confirm('적용된 필터가 없습니다. 전체 리스트를 대상으로 진행 하시겠습니까?')) {
return
}
if (!confirm('정말 배정을 초기화 하시겠습니까?')) return
await resetListAssignMutation.mutateAsync({
await assignMutation.mutateAsync({
jobType: 'LIST_ASSIGN',
path: 'mutations/assign-reset',
body: {
assignType: effectiveAssignType,
listFilter: currentListFilter,
},
})
alert('배정이 초기화 되었습니다.')
}
if (!mounted || !selectedProject) return <LoadingOverlayAdapter force />
return (
<ListJobPageQueryContext.Provider value="LIST_ASSIGN">
<div className="flex gap-4 text-sm">
<div className="w-72 shrink-0 space-y-2">
<Tabs value={String(effectiveAssignType)} onValueChange={handleTabChange}>
@@ -180,8 +198,10 @@ const ListAssignPage = () => {
/>
</div>
<div className="min-w-0 flex-1">
<div className="min-w-0 flex-1 space-y-2">
<ListJobGatePanel gate={assignGate} />
<ListSearchTable
dataRevision={dataRevision}
prjctIdx={prjctIdx}
enabled={enabled}
userRole={userRole}
@@ -219,10 +239,10 @@ const ListAssignPage = () => {
예약 이관
</label>
)}
<Button type="button" onClick={handleAssign}>
<Button type="button" onClick={handleAssign} disabled={assignMutation.isPending || assignGate.submitBlocked}>
배정
</Button>
<Button type="button" variant="outline" onClick={handleResetAssign}>
<Button type="button" variant="outline" onClick={handleResetAssign} disabled={assignMutation.isPending || assignGate.submitBlocked}>
배정 초기화
</Button>
</>
@@ -230,6 +250,7 @@ const ListAssignPage = () => {
/>
</div>
</div>
</ListJobPageQueryContext.Provider>
)
}

View File

@@ -1,6 +1,9 @@
'use client'
import { useEffect, useMemo, useRef, useState } from 'react'
import { useAtom } from 'jotai'
import { toast } from 'sonner'
import { listJobOpenRequestAtom } from '@/store/jotai/list-job'
import type { PaginationState } from '@tanstack/react-table'
import { useQueryClient } from '@tanstack/react-query'
import { useRouter } from 'next/navigation'
@@ -11,21 +14,22 @@ import { useDialog } from '@/hooks/useDialog'
import { useSelectedProject } from '@/hooks/useSelectedProject'
import { useStorage } from '@/hooks/useStorage'
import { StorageKeys } from '@/store/storage/storage-keys'
import { ListManageActions } from '@/components/list/ListManageActions'
import { ListManageActions, type ListManageActionKey } from '@/components/list/ListManageActions'
import { ListSearchTable } from '@/components/list/ListSearchTable'
import {
useDownloadListEventHistoryMutation,
useDownloadListExcelTemplateMutation,
useDownloadListItemFileMutation,
useDownloadListMutation,
useDownloadListUpdateHistoryMutation,
useDownloadUploadHistoryFileMutation,
useListHeaderQuery,
useListUploadHistoryQuery,
useResetListMutation,
useUpdateListHeaderMutation,
useUploadListExcelMutation,
} from '@/query/list'
import { ListJobPageQueryContext, useMyActiveListJobs, useSubmitListJob } from '@/query/list-job'
import { ListJobGatePanel } from '@/components/list/ListJobGate'
import { useListJobPageMonitor } from '@/hooks/useListJobPageMonitor'
import { useTrackedListJobs } from '@/store/list-job-tracker'
import { isListPageActionBlocked } from '@/utils/listJobAvailability'
import type { ListJobType } from '@/types/list-job'
import { LIST_DOWNLOAD_JOB_TYPE, LIST_JOB_VIEW, MESSAGE_JOB_TYPE } from '@/const/listJobConst'
import { useProjectInfoQuery, useResultCodesQuery } from '@/query/project'
import type { ListTableRow } from '@/components/table-column/ListTableColumn'
import {
@@ -50,7 +54,7 @@ import ListHeaderManageDialog from '@/components/dialog/ListHeaderManageDialog'
import ListDownloadDialog from '@/components/dialog/ListDownloadDialog'
import MessageSendDialog, { type MessageSendMode } from '@/components/dialog/MessageSendDialog'
import MessageHistoryDialog from '@/components/dialog/MessageHistoryDialog'
import { downloadBase64File, downloadFile, XLSX_MIME_TYPE } from '@kri/common/browser'
import { downloadFile } from '@kri/common/browser'
import {CONTACT_INTERVIEWER_ROLE} from "@/const/userConst";
import { isInternalManager, isManager } from "@/utils/userRole";
import { applyListAccessFilter } from "@/utils/listAccess";
@@ -84,6 +88,7 @@ const ListManagePage = () => {
const { auth } = useAuth()
const { showDialog } = useDialog()
const { selectedProject, isSelectedProjectHydrated } = useSelectedProject()
const [openRequest, setOpenRequest] = useAtom(listJobOpenRequestAtom)
const [downloadMode, setDownloadMode] = useState<ListDownloadMode>('list')
const [messageSendMode, setMessageSendMode] = useState<MessageSendMode>('email')
@@ -110,19 +115,55 @@ const ListManagePage = () => {
const canManageList = isManager(userRole);
// 리스트 초기화/헤더 관리/업로드는 내부 관리자 전용 — 외주사 계정에는 노출되면 안 됨.
const isInternal = isInternalManager(userRole);
const { gate: pageGate, dataRevision } = useListJobPageMonitor(prjctIdx, 'LIST_RESET', enabled)
const trackedJobs = useTrackedListJobs()
useEffect(() => {
if (!mounted || !restoreResolved || !enabled || !openRequest || openRequest.opened
|| openRequest.userId !== userId || openRequest.prjctIdx !== prjctIdx) return
const view = LIST_JOB_VIEW[openRequest.jobType]
if (view.path !== '/list/manage' || !view.dialogId) return
if (!canManageList || (!isInternal && (openRequest.jobType === 'LIST_UPLOAD' || openRequest.jobType === 'LIST_RESET'))) {
toast.error('해당 작업 화면을 열 권한이 없습니다.')
setOpenRequest(null)
return
}
if (view.downloadMode) setDownloadMode(view.downloadMode)
if (view.messageMode) setMessageSendMode(view.messageMode)
showDialog(view.dialogId)
setOpenRequest({ ...openRequest, opened: true })
}, [mounted, restoreResolved, enabled, openRequest, userId, prjctIdx, canManageList, isInternal, setOpenRequest, showDialog])
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled)
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled)
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
const uploadHistoryQuery = useListUploadHistoryQuery(prjctIdx, enabled)
const downloadListExcelTemplateMutation = useDownloadListExcelTemplateMutation()
const uploadListExcelMutation = useUploadListExcelMutation(prjctIdx)
const submitJob = useSubmitListJob(prjctIdx)
// 전역 ListJobWatcher가 갱신하는 동일 쿼리를 구독하고 별도 폴링은 만들지 않는다.
const myActiveJobsQuery = useMyActiveListJobs(prjctIdx, false)
const myActiveJobTypes = new Set<string>((myActiveJobsQuery.data ?? []).map((job) => job.jobType))
const inspectableJobTypes = new Set([
...trackedJobs.filter(job => job.userId === userId && job.prjctIdx === prjctIdx).map(job => job.jobType),
...myActiveJobTypes,
...(pageGate.availability?.blockers.filter(blocker => blocker.mine && blocker.jobKey).map(blocker => blocker.jobType) ?? []),
])
const isActionDisabled = (jobType: ListJobType) => !inspectableJobTypes.has(jobType) && isListPageActionBlocked(
pageGate.status === 'unsupported' ? undefined : pageGate.availability,
jobType,
pageGate.status === 'checking' || pageGate.status === 'error',
)
const actionJobTypes: Record<ListManageActionKey, ListJobType> = {
reset: 'LIST_RESET', upload: 'LIST_UPLOAD', ...LIST_DOWNLOAD_JOB_TYPE, ...MESSAGE_JOB_TYPE,
}
const disabledActions = new Set((Object.keys(actionJobTypes) as ListManageActionKey[]).filter(action => isActionDisabled(actionJobTypes[action])))
const runningActions = new Set<ListManageActionKey>([
...(myActiveJobTypes.has('LIST_RESET') ? ['reset' as const] : []),
...(myActiveJobTypes.has('LIST_UPLOAD') ? ['upload' as const] : []),
...(Object.keys(LIST_DOWNLOAD_JOB_TYPE) as ListDownloadMode[]).filter((mode) => myActiveJobTypes.has(LIST_DOWNLOAD_JOB_TYPE[mode])),
...(Object.keys(MESSAGE_JOB_TYPE) as MessageSendMode[]).filter((mode) => myActiveJobTypes.has(MESSAGE_JOB_TYPE[mode])),
])
const updateListHeaderMutation = useUpdateListHeaderMutation(prjctIdx)
const resetListMutation = useResetListMutation(prjctIdx)
const downloadListMutation = useDownloadListMutation(prjctIdx)
const downloadListUpdateHistoryMutation = useDownloadListUpdateHistoryMutation(prjctIdx)
const downloadListEventHistoryMutation = useDownloadListEventHistoryMutation(prjctIdx)
const downloadListItemFileMutation = useDownloadListItemFileMutation(prjctIdx)
const downloadUploadHistoryFileMutation = useDownloadUploadHistoryFileMutation(prjctIdx)
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data])
@@ -140,7 +181,6 @@ const ListManagePage = () => {
removeLastListVisit()
}
setRestoreResolved(true)
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [mounted, isSelectedProjectHydrated, restoreResolved])
useEffect(() => {
@@ -223,27 +263,14 @@ const ListManagePage = () => {
}
const handleResetConfirm = async (payload: { target: ListFilterTarget; scope: ListResetScope }) => {
const listFilter = buildTargetFilter(payload.target)
const resetCount = await resetListMutation.mutateAsync({
await submitJob.mutateAsync({ jobType: 'LIST_RESET', path: 'reset', body: {
resetMode: payload.scope === 'result-and-history' ? ListResetMode.HIST : ListResetMode.ALL,
listFilter,
})
alert(`${resetCount}건 삭제 되었습니다.`)
refreshList()
listFilter: buildTargetFilter(payload.target),
} })
}
const handleUploadConfirm = async (file: File, request: ListUploadRequest) => {
const res = await uploadListExcelMutation.mutateAsync({ file, request })
if (res.hasErrorFile && res.errorFileBase64) {
alert("업로드 중 오류가 발생하여 오류 파일을 다운로드합니다.");
downloadBase64File(res.errorFileBase64, res.errorFileName ?? "error.xlsx", XLSX_MIME_TYPE);
}
else{
alert(`${res.successCount}개의 리스트를 업로드했습니다.`);
}
refreshList()
await submitJob.mutateAsync({ jobType: 'LIST_UPLOAD', path: 'upload', file, body: request })
}
const handleDownloadTemplate = async () => {
@@ -262,45 +289,46 @@ const ListManagePage = () => {
const handleDownloadConfirm = async (payload: ListDownloadPayload) => {
const listFilter = buildTargetFilter(payload.target)
const jobType = LIST_DOWNLOAD_JOB_TYPE[payload.mode]
if (payload.mode === 'list') {
const buffer = await downloadListMutation.mutateAsync({ listFilter, includeResult: payload.includeResult })
downloadArrayBuffer(buffer, `${prjctName} list.xlsx`)
await submitJob.mutateAsync({ jobType, path: `downloads/list?includeResult=${payload.includeResult}`, body: listFilter })
return
}
if (payload.mode === 'list-change-history') {
const buffer = await downloadListUpdateHistoryMutation.mutateAsync(listFilter)
downloadArrayBuffer(buffer, `${prjctName} update-history.xlsx`)
await submitJob.mutateAsync({ jobType, path: 'downloads/update-history', body: listFilter })
return
}
if (payload.mode === 'upload-file') {
const buffer = await downloadListItemFileMutation.mutateAsync(listFilter)
downloadArrayBuffer(buffer, `${prjctName} upload-files.zip`, 'application/zip')
await submitJob.mutateAsync({ jobType, path: 'downloads/item-files', body: listFilter })
return
}
const buffer = await downloadListEventHistoryMutation.mutateAsync({
includeResult: payload.includeResult,
await submitJob.mutateAsync({ jobType, path: `downloads/event-history?includeResult=${payload.includeResult}`, body: {
listFilter,
resultCodeTypes: [ResultCodeType.CONTACT, ResultCodeType.INTERVIEW, ResultCodeType.SURVEY],
searchBase: payload.contactHistoryType === 'latest' ? ListEventHistoryBase.LATEST : ListEventHistoryBase.ALL,
historyOrder: payload.historyOrder ?? ListEventHistoryOrder.DESC,
dateRange: toDateTimeRange(payload.contactHistoryDateFrom, payload.contactHistoryDateTo),
})
downloadArrayBuffer(buffer, `${prjctName} contact-history.xlsx`)
} })
}
if (!mounted || !restoreResolved) return <LoadingOverlayAdapter force />
return (
<ListJobPageQueryContext.Provider value="LIST_RESET">
<div className="space-y-6 text-sm">
<ListJobGatePanel gate={pageGate} showCurrentJob={false} />
{canManageList && (
<ListManageActions
showAdminActions={isInternal}
runningActions={runningActions}
disabledActions={disabledActions}
headerManageDisabled={pageGate.submitBlocked}
onReset={() => showDialog('listResetDialog')}
onHeaderManage={() => showDialog('listHeaderManageDialog')}
onHeaderManage={() => { if (!pageGate.submitBlocked) showDialog('listHeaderManageDialog') }}
onUpload={() => showDialog('listUploadDialog')}
onDownload={openDownloadDialog}
onMessageSend={openMessageDialog}
@@ -320,6 +348,8 @@ const ListManagePage = () => {
listHeaders={headerManageRows}
fieldInterviewEnabled={selectedProject?.ff !== false}
enableBatchEdit={canManageList}
batchEditDisabled={isActionDisabled('LIST_UPDATE')}
dataRevision={dataRevision}
selectMode={canManageList ? 'multi' : 'click-event'}
refreshKey={listRefreshKey}
onCurrentFilterChange={setCurrentListFilter}
@@ -342,11 +372,13 @@ const ListManagePage = () => {
{isInternal && (
<>
<ListResetDialog
prjctIdx={prjctIdx}
selectedSids={selectedSidSet}
filterSummary={filterSummary}
onConfirm={handleResetConfirm}
/>
<ListUploadDialog
prjctIdx={prjctIdx}
onUpload={handleUploadConfirm}
onDownloadTemplate={handleDownloadTemplate}
uploadHistory={uploadHistoryQuery.data ?? []}
@@ -356,13 +388,14 @@ const ListManagePage = () => {
}}
headerRows={headerManageRows}
/>
<ListHeaderManageDialog prjctIdx={prjctIdx} rows={headerManageRows} onConfirm={handleHeaderManageConfirm} />
<ListHeaderManageDialog prjctIdx={prjctIdx} rows={headerManageRows} onConfirm={handleHeaderManageConfirm} saveDisabled={pageGate.submitBlocked} />
</>
)}
{canManageList && (
<>
<ListDownloadDialog
prjctIdx={prjctIdx}
mode={downloadMode}
selectedSids={selectedSidSet}
filterSummary={filterSummary}
@@ -380,6 +413,7 @@ const ListManagePage = () => {
</>
)}
</div>
</ListJobPageQueryContext.Provider>
)
}

View File

@@ -31,7 +31,6 @@ import {useCreateProjectMutation, useProjectListQuery, useProjectOwnerListQuery}
import {useGroupCodeListQuery} from "@/query/intranet";
import {PROJECT_STATUS_LABEL} from "@/const/projectConst";
import {isInternalManager, isManager} from "@/utils/userRole";
import {CONTACT_INTERVIEWER_ROLE} from "@/const/userConst";
const MainPage = () => {
const router = useRouter();

View File

@@ -444,7 +444,7 @@ const ProjectInfoPage = () => {
const updateMutation = useUpdateProjectMutation(prjctIdx);
const deleteMutation = useDeleteProjectMutation(prjctIdx);
const uploadScenarioMutation = useUploadScenarioImageMutation(prjctIdx, projectInfo.prjctCd);
const uploadScenarioMutation = useUploadScenarioImageMutation(projectInfo.prjctCd);
const [resultCodeArray, setResultCodeArray] = useState<ResultCode[]>([]);
const [assignCmpnIdArray, setAssignCmpnIdArray] = useState<string[]>([]);

View File

@@ -14,10 +14,8 @@ const toRedirectSlug = (slug: string): RedirectSlug | null => {
const redirectPage = async ({
params,
searchParams,
}: redirectPageProps) => {
const { slug } = await params;
const sp = searchParams ? await searchParams : undefined;
const redirectSlug = toRedirectSlug(slug);
if (!redirectSlug) notFound();

View File

@@ -64,37 +64,6 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
return new NextResponse(null, { status: 204 });
}
if (action === "list" && slug.length === 3) {
const body = await req.json().catch(() => null);
if (!body) {
return NextResponse.json(
{ message: "요청 바디가 없습니다." },
{ status: 400 }
);
}
const result = await contactApi.put<number>(`/assign/list/${slug[1]}/${slug[2]}`, body);
return NextResponse.json(result, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
}
};
export const DELETE = async (req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
if (action === "list" && slug[1] === "reset" && slug.length === 3) {
const body = await req.json().catch(() => null);
const result = await contactApi.del<number>(`/assign/list/reset/${slug[2]}`, { json: body });
return NextResponse.json(result, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);

View File

@@ -4,7 +4,7 @@ import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import type {ListEventHistory, ListUpdateHistory} from "@/types/list";
export const GET = async (req: NextRequest, context: RouteContext) => {
export const GET = async (_req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [action] = slug;
@@ -30,7 +30,7 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
}
};
export const DELETE = async (req: NextRequest, context: RouteContext) => {
export const DELETE = async (_req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [action] = slug;

View File

@@ -0,0 +1,59 @@
import { NextRequest, NextResponse } from 'next/server'
import { cookies } from 'next/headers'
import { errorToResponse } from '@kri/common/http'
import { createContactApi } from '@/lib/http-server'
import { serverEnv } from '@/lib/env.server'
import { CookieKeys } from '@/store/cookie/cookie-keys'
import type { RouteContext } from '@/types/common'
const project = '[1-9][0-9]*'
const key = '[a-f0-9]{32}'
const getPath = new RegExp(`^${project}/(?:availability|upload-reset-active|my-active|${key}(?:/(?:sid-failures|range-failures|validation-errors|source-file|files/[0-9]+|message-report/(?:batches|preparation-failures)))?)$`)
const postPath = new RegExp(`^${project}/(?:upload|reset|${key}/cancel|mutations/(?:update|assign-reset|assign/[^/]+)|downloads/(?:list|event-history|update-history|item-files)|messages/(?:email|sms|kko))$`)
// The shared HTTP client decodes binary bodies. Forward file bodies as streams instead.
async function forwardFile(req: NextRequest, path: string) {
const token = (await cookies()).get(CookieKeys.AuthToken)?.value
if (!token) return NextResponse.json({ message: '로그인이 필요합니다.' }, { status: 401 })
const headers = new Headers({ Authorization: `Bearer ${token}` })
if (req.method === 'POST') {
const type = req.headers.get('content-type')
if (!type?.startsWith('multipart/form-data;')) return NextResponse.json({ message: '파일 요청 형식이 올바르지 않습니다.' }, { status: 400 })
headers.set('Content-Type', type)
}
const options: RequestInit & { duplex?: 'half' } = {
method: req.method, headers, cache: 'no-store', redirect: 'error',
signal: AbortSignal.any([req.signal, AbortSignal.timeout(300_000)]),
...(req.method === 'POST' ? { body: req.body, duplex: 'half' as const } : {}),
}
const upstream = await fetch(`${serverEnv.API_CONTACT_SERVER.replace(/\/$/, '')}/list/jobs/${path}`, options)
const responseHeaders = new Headers({ 'Cache-Control': 'no-store' })
for (const name of ['Content-Type', 'Content-Disposition', 'Content-Length']) {
const value = upstream.headers.get(name)
if (value) responseHeaders.set(name, value)
}
return new NextResponse(upstream.body, { status: upstream.status, headers: responseHeaders })
}
async function proxy(req: NextRequest, context: RouteContext) {
try {
const { slug = [] } = await context.params
const path = slug.map(encodeURIComponent).join('/')
if (!(req.method === 'GET' ? getPath : postPath).test(path)) return NextResponse.json({ message: '지원하지 않는 작업 경로입니다.' }, { status: 404 })
if (/\/(source-file|files\/[0-9]+|upload)$/.test(path)) return await forwardFile(req, path)
const query = new URLSearchParams()
for (const name of ['offset', 'limit', 'includeResult', 'jobType']) {
const value = req.nextUrl.searchParams.get(name)
if (value !== null) query.set(name, value)
}
const url = `/list/jobs/${path}${query.size ? `?${query}` : ''}`
const api = await createContactApi()
const value = req.method === 'GET'
? await api.get(url, { cache: 'no-store' })
: await api.post(url, await req.json().catch(() => undefined))
return NextResponse.json(value, { headers: { 'Cache-Control': 'no-store' } })
} catch (error: unknown) { return errorToResponse(error) }
}
export const GET = proxy
export const POST = proxy

View File

@@ -4,13 +4,12 @@ import {RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import {listHeader, ListSearchRequest, ListSearchWithFullResult} from "@/types/list";
import {LIST_EXCEL_TIMEOUT_MS} from "@/const/listConst";
const excelHeaders = {
"Content-Type": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
};
export const GET = async (req: NextRequest, context: RouteContext) => {
export const GET = async (_req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action] = slug;
@@ -101,52 +100,6 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
return new NextResponse(null, { status: 204 });
}
if (action === "excel-upload") {
const form = await req.formData();
const result = await contactApi.postForm(`/list/excel/upload/${slug[1]}`, form, {
timeoutMs: LIST_EXCEL_TIMEOUT_MS,
});
return NextResponse.json(result, { status: 200 });
}
if (action === "excel-download") {
const body = await req.json().catch(() => null);
const includeResult = req.nextUrl.searchParams.get("includeResult") !== "false";
const result = await contactApi.post<ArrayBuffer>(
`/list/excel/download/${slug[1]}?includeResult=${includeResult}`,
body,
{ expectBinary: true, timeoutMs: LIST_EXCEL_TIMEOUT_MS },
);
return new NextResponse(result, { status: 200, headers: excelHeaders });
}
if (action === "excel-download-update") {
const body = await req.json().catch(() => null);
const result = await contactApi.post<ArrayBuffer>(`/list/excel/download/update/${slug[1]}`, body, {
expectBinary: true,
});
return new NextResponse(result, { status: 200, headers: excelHeaders });
}
if (action === "event-history-download") {
const body = await req.json().catch(() => null);
const includeResult = req.nextUrl.searchParams.get("includeResult") !== "false";
const result = await contactApi.post<ArrayBuffer>(
`/list-hist/excel/download/event/${slug[1]}?includeResult=${includeResult}`,
body,
{ expectBinary: true, timeoutMs: LIST_EXCEL_TIMEOUT_MS },
);
return new NextResponse(result, { status: 200, headers: excelHeaders });
}
if (action === "item-file-download") {
const body = await req.json().catch(() => null);
const result = await contactApi.post<ArrayBuffer>(`/list/item-file/download/${slug[1]}`, body, {
expectBinary: true,
});
return new NextResponse(result, { status: 200, headers: { "Content-Type": "application/zip" } });
}
if (action === "upload-history-file") {
const result = await contactApi.post<ArrayBuffer>(
`/list/excel/upload-history/file/${slug[1]}/${slug[2]}`,
@@ -184,15 +137,3 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
return errorToResponse(error);
}
};
export const DELETE = async (req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const body = await req.json().catch(() => null);
const contactApi = await createContactApi();
const result = await contactApi.del<number>(`/list/${slug[0]}`, { json: body });
return NextResponse.json(result, { status: 200 });
} catch (error: unknown) {
return errorToResponse(error);
}
};

View File

@@ -6,7 +6,7 @@ import {RouteContext} from "@/types/common";
import {CookieKeys} from "@/store/cookie/cookie-keys";
export async function POST(
req: NextRequest,
_req: NextRequest,
context: RouteContext
) {
try {

View File

@@ -2,7 +2,6 @@ import {NextRequest, NextResponse} from "next/server";
import {RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import type {BulkSendResult} from "@kri/common/noti-hub";
import type {MessageSendChannel, SendSingleResponse} from "@/types/message";
const isChannel = (value: string): value is MessageSendChannel =>
@@ -28,11 +27,6 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
return NextResponse.json(result, {status: 200});
}
if (action === "bulk") {
const result = await contactApi.post<BulkSendResult>(`/message-send/${channel}/bulk/${prjctIdx}`, body);
return NextResponse.json(result, {status: 200});
}
return NextResponse.json({message: "Not found"}, {status: 404});
} catch (error: unknown) {
return errorToResponse(error);

View File

@@ -70,7 +70,6 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
export const PUT = async (req: NextRequest, context: RouteContext) => {
try{
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
@@ -117,7 +116,6 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
export const PATCH = async (req: NextRequest, context: RouteContext) => {
try{
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();

View File

@@ -1,5 +1,5 @@
import {NextRequest, NextResponse} from "next/server";
import {createContactApi, createIntranetApi} from "@/lib/http-server";
import {createContactApi} from "@/lib/http-server";
import {errorToResponse} from "@kri/common/http";
import type {PageResponse} from "@kri/common";
import {RouteContext} from "@/types/common";
@@ -172,10 +172,9 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
}
};
export const DELETE = async (req: NextRequest, context: RouteContext) => {
export const DELETE = async (_req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
if(slug.length === 1){

View File

@@ -48,7 +48,7 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
}
};
export const PUT = async (req: NextRequest, context: RouteContext) => {
export const PUT = async (req: NextRequest) => {
try {
const body = await req.json().catch(() => null);
if (!body) {

View File

@@ -1,14 +1,12 @@
import {NextRequest, NextResponse} from "next/server";
import {RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/http-server";
import {ProjectInfo, ProjectOwnerResponse, ResultCode} from "@/types/project";
import {ResultCode} from "@/types/project";
import {errorToResponse} from "@kri/common/http";
export const GET = async (req: NextRequest, context: RouteContext) => {
export const GET = async (_req: NextRequest, context: RouteContext) => {
try {
const { searchParams } = new URL(req.url);
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
if(slug.length === 1){

View File

@@ -4,7 +4,7 @@ import {RoleInfo} from "@/types/role";
import {errorToResponse} from "@kri/common/http";
import {RouteContext} from "@/types/common";
export const GET = async (req: NextRequest, context: RouteContext) => {
export const GET = async (_req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [action] = slug;

View File

@@ -149,7 +149,7 @@ export const PATCH = async (req: NextRequest, context: RouteContext) => {
}
};
export const DELETE = async (req: NextRequest, context: RouteContext) => {
export const DELETE = async (_req: NextRequest, context: RouteContext) => {
try {
const { slug = [] } = await context.params;
const [userId] = slug ?? [];

View File

@@ -2,7 +2,7 @@ import type { Metadata } from "next";
import {Geist, Geist_Mono} from "next/font/google";
import { AppProvider } from "@/components/providers/AppProvider";
import "./globals.css";
import {Toaster} from "sonner";
import {Toaster} from "@/components/ui/sonner";
const geistSans = Geist({
variable: "--font-geist-sans",