261019_01_ENH: 리스트 비동기 작업 동시 실행 제한 및 진행 상태 UI 개선, 미사용 참조 정리
This commit is contained in:
@@ -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>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user