260812_01_ENH: 배정·진행 현황 개선 및 예약/이벤트 이력 기능 추가

- 프로젝트별 외주사·필드워커 배정 현황 및 미배정 건수 UI 추가
- 현장 면접 진행 여부와 사용자 권한에 따른 배정 탭·필터·컬럼 노출 제어
- 컨택 마지막 이벤트 일자 필터·정렬 및 결과/일자 컬럼 분리
- 컨택·면접·발송 현황의 날짜 범위 선택 optional 처리
- 진행 현황의 미배정 표시 및 일자별 미사용 결과 제외
- 전역 예약 기간 조회·이동 및 5분 단위 예약 알림 추가
- 내부 관리자용 이벤트 이력 단건 삭제 기능 추가
- 리스트 필터 UI 및 일반 헤더 정렬 기준 개선
- 프로젝트 저장 시 선택 프로젝트 정보 동기화
This commit is contained in:
2026-08-12 08:41:27 +09:00
parent e8f3308814
commit 081b53945a
34 changed files with 852 additions and 331 deletions

View File

@@ -1,12 +1,12 @@
'use client'
import { useState } from 'react'
import { RefreshCw } from 'lucide-react'
import { RefreshCw, Trash2 } from 'lucide-react'
import { Button } from '@/components/ui/button'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
import { KriDateTimePicker } from '@/components/common/KriDateTimePicker'
import CollapsibleHistorySection from '@/components/list-contact/CollapsibleHistorySection'
import { useAddListEventMutation, useListEventHistoryQuery, useReserveMutation } from '@/query/list'
import { useAddListEventMutation, useDeleteListEventMutation, useListEventHistoryQuery, useReserveMutation } from '@/query/list'
import { useSendResultBySidQuery } from '@/query/message'
import { useInternalInfoQuery } from '@/query/internal'
import { clientEnv } from '@/lib/env.client'
@@ -24,6 +24,7 @@ import type { listHeader, ListSearchWithFullResult } from '@/types/list'
import { buildListContactVariableValues } from '@/components/list-contact/listContactVariables'
import { escapeHtml, substituteVariables } from '@/lib/variableSubstitution'
import { sanitizeHtml } from '@/components/kri-editor/utils/sanitizeHtml'
import { isInternalManager } from '@/utils/userRole'
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
<Button
@@ -51,6 +52,7 @@ type ContactEventSectionProps = {
showInput?: boolean
submitting: boolean
onSubmit: (resultCd: number, memo: string, resveDt: string, listCallHistIdx: number | null) => Promise<void>
canDelete: boolean
}
const EventHistoryList = ({
@@ -58,11 +60,17 @@ const EventHistoryList = ({
history,
resultCodeType,
resultCodes,
canDelete = false,
onDelete,
isDeleting = false,
}: {
isLoading: boolean
history: ReturnType<typeof useListEventHistoryQuery>['data']
resultCodeType: ResultCodeType
resultCodes: ResultCode[]
canDelete?: boolean
onDelete?: (listEventHistIdx: number) => void
isDeleting?: boolean
}) => {
const filteredHistory = (history ?? [])
.filter((item) => item.eventTy === resultCodeType)
@@ -72,6 +80,11 @@ const EventHistoryList = ({
resultCodes.find((code) => code.resultCdTy === resultCodeType && code.resultCd === resultCd)?.resultCdLbl ??
String(resultCd)
const handleDelete = (listEventHistIdx: number) => {
if (!confirm('이력을 삭제하시겠습니까?')) return
onDelete?.(listEventHistIdx)
}
if (isLoading) {
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
}
@@ -89,6 +102,7 @@ const EventHistoryList = ({
<th className="p-2 text-left">메모</th>
<th className="p-2 text-left">등록자</th>
<th className="p-2 text-left">일시</th>
{canDelete ? <th className="p-2 text-left">삭제</th> : null}
</tr>
</thead>
<tbody>
@@ -100,6 +114,20 @@ const EventHistoryList = ({
<td className="p-2">{item.memo || '-'}</td>
<td className="p-2">{item.regUser}</td>
<td className="p-2">{formatKst(item.regDt, 'dateHourMin')}</td>
{canDelete ? (
<td className="p-2">
<Button
type="button"
variant="ghost"
size="icon-sm"
aria-label="이력 삭제"
disabled={isDeleting}
onClick={() => handleDelete(item.listEventHistIdx)}
>
<Trash2 className="h-4 w-4" />
</Button>
</td>
) : null}
</tr>
))}
</tbody>
@@ -118,6 +146,7 @@ const ContactEventSection = ({
showInput = true,
submitting,
onSubmit,
canDelete,
}: ContactEventSectionProps) => {
const [resultCd, setResultCd] = useState('')
const [memo, setMemo] = useState('')
@@ -130,6 +159,7 @@ const ContactEventSection = ({
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, sid)
const listCallHistIdx = isContactType ? ctiLastCallHistId : null
const deleteEventMutation = useDeleteListEventMutation(prjctIdx, sid)
const handleResultCdChange = (next: string) => {
setResultCd(next)
@@ -179,7 +209,7 @@ const ContactEventSection = ({
/>
{showReservation && isReservationSelected ? (
<KriDateTimePicker value={resveDt} onChange={setResveDt} placeholder="예약 날짜/시간" />
<KriDateTimePicker value={resveDt} onChange={setResveDt} startHour={9} endHour={20} placeholder="예약 날짜/시간" />
) : null}
<Button type="button" className="w-full" disabled={submitting} onClick={handleAdd}>
@@ -194,7 +224,15 @@ const ContactEventSection = ({
showDivider={showInput}
headerExtra={<RefreshIconButton onRefresh={() => historyQuery.refetch()} isFetching={historyQuery.isFetching} />}
>
<EventHistoryList isLoading={historyQuery.isLoading} history={historyQuery.data} resultCodeType={resultCodeType} resultCodes={resultCodes} />
<EventHistoryList
isLoading={historyQuery.isLoading}
history={historyQuery.data}
resultCodeType={resultCodeType}
resultCodes={resultCodes}
canDelete={canDelete}
isDeleting={deleteEventMutation.isPending}
onDelete={(listEventHistIdx) => deleteEventMutation.mutate(listEventHistIdx)}
/>
</CollapsibleHistorySection>
</div>
)
@@ -311,6 +349,7 @@ const ListContactEventPanel = ({
const internalInfoQuery = useInternalInfoQuery()
const showContactInput = userRole !== FIELD_INTERVIEWER_ROLE
const showInterviewInput = userRole !== CONTACT_INTERVIEWER_ROLE
const canDeleteEvent = isInternalManager(userRole)
const contactSenarioValues = Object.fromEntries(
Object.entries(buildListContactVariableValues(listHeaders, detail, sid)).map(([key, value]) => [
key,
@@ -358,6 +397,7 @@ const ListContactEventPanel = ({
showInput={showContactInput}
submitting={addListEventMutation.isPending || reserveMutation.isPending}
onSubmit={handleAddEvent(ResultCodeType.CONTACT)}
canDelete={canDeleteEvent}
/>
<SendResultHistory sid={sid} prjctCd={prjctCd} />
@@ -372,6 +412,7 @@ const ListContactEventPanel = ({
showInput={showInterviewInput}
submitting={addListEventMutation.isPending}
onSubmit={handleAddEvent(ResultCodeType.INTERVIEW)}
canDelete={canDeleteEvent}
/>
}