260722_01_ENH: 버그 수정 및 개선 사항 수정
This commit is contained in:
@@ -124,7 +124,7 @@ const ContactEventSection = ({
|
||||
const isContactType = resultCodeType === ResultCodeType.CONTACT
|
||||
|
||||
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
|
||||
const ctiLastCallHistId = useCtiLastCallHistId()
|
||||
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, Number(sid))
|
||||
const listCallHistIdx = isContactType ? ctiLastCallHistId : null
|
||||
|
||||
const handleResultCdChange = (next: string) => {
|
||||
@@ -280,6 +280,7 @@ export type ListContactEventPanelProps = {
|
||||
userId: string
|
||||
userRole: number
|
||||
resultCodes: ResultCode[]
|
||||
useFF: boolean
|
||||
useContactSenario: boolean
|
||||
contactSenario?: string
|
||||
}
|
||||
@@ -291,6 +292,7 @@ const ListContactEventPanel = ({
|
||||
userId,
|
||||
userRole,
|
||||
resultCodes,
|
||||
useFF,
|
||||
useContactSenario,
|
||||
contactSenario,
|
||||
}: ListContactEventPanelProps) => {
|
||||
@@ -341,16 +343,19 @@ const ListContactEventPanel = ({
|
||||
|
||||
<SendResultHistory sid={sid} prjctCd={prjctCd} />
|
||||
|
||||
<ContactEventSection
|
||||
title="인터뷰 요원 확인사항"
|
||||
prjctIdx={prjctIdx}
|
||||
sid={sid}
|
||||
resultCodeType={ResultCodeType.INTERVIEW}
|
||||
resultCodes={resultCodes}
|
||||
showInput={showInterviewInput}
|
||||
submitting={addListEventMutation.isPending}
|
||||
onSubmit={handleAddEvent(ResultCodeType.INTERVIEW)}
|
||||
/>
|
||||
{useFF &&
|
||||
<ContactEventSection
|
||||
title="인터뷰 요원 확인사항"
|
||||
prjctIdx={prjctIdx}
|
||||
sid={sid}
|
||||
resultCodeType={ResultCodeType.INTERVIEW}
|
||||
resultCodes={resultCodes}
|
||||
showInput={showInterviewInput}
|
||||
submitting={addListEventMutation.isPending}
|
||||
onSubmit={handleAddEvent(ResultCodeType.INTERVIEW)}
|
||||
/>
|
||||
}
|
||||
|
||||
|
||||
{useContactSenario && contactSenario ? (
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
'use client'
|
||||
|
||||
import { useRef, useState, type ReactNode } from 'react'
|
||||
import { useEffect, useRef, useState, type ReactNode } from 'react'
|
||||
import { Mail, MessageSquare, Paperclip, Phone, QrCode } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Label } from '@/components/ui/label'
|
||||
import { KriSingleSelect } from '@/components/common/KriAutoComplete'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import { useUploadListItemFileMutation } from '@/query/list'
|
||||
import { useDownloadListItemFileByHeaderMutation, useUploadListItemFileMutation } from '@/query/list'
|
||||
import { ListHeaderConst } from '@/const/listConst'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import type { MessageSendChannel } from '@/types/message'
|
||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteSurveyUrl } from '@/lib/surveyUrl'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||
import { ctiClient } from '@/lib/cti/ctiClient'
|
||||
@@ -22,6 +23,7 @@ import { useCtiConnectionStatus } from '@/hooks/useCtiConnectionStatus'
|
||||
import { useCtiAgentStatus } from '@/hooks/useCtiAgentStatus'
|
||||
import { CTI_ON_CALL_STATUSES } from '@/const/ctiConst'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { downloadFile } from '@kri/common/browser'
|
||||
|
||||
export type ListContactInfoPanelProps = {
|
||||
prjctIdx: number
|
||||
@@ -31,7 +33,7 @@ export type ListContactInfoPanelProps = {
|
||||
isEditing: boolean
|
||||
listHeaders: listHeader[]
|
||||
detail?: ListSearchWithFullResult
|
||||
surveyUrl?: string
|
||||
surveys: ProjectSurvey[]
|
||||
callerTelNum?: string
|
||||
resultCodes: ResultCode[]
|
||||
formValues: Record<number, string>
|
||||
@@ -72,7 +74,7 @@ const ListContactInfoPanel = ({
|
||||
isEditing,
|
||||
listHeaders,
|
||||
detail,
|
||||
surveyUrl,
|
||||
surveys,
|
||||
callerTelNum,
|
||||
resultCodes,
|
||||
formValues,
|
||||
@@ -81,29 +83,47 @@ const ListContactInfoPanel = ({
|
||||
}: ListContactInfoPanelProps) => {
|
||||
const { showDialog } = useDialog()
|
||||
const uploadItemFileMutation = useUploadListItemFileMutation(prjctIdx, sid)
|
||||
const downloadItemFileMutation = useDownloadListItemFileByHeaderMutation(prjctIdx, sid)
|
||||
const fileInputRef = useRef<HTMLInputElement | null>(null)
|
||||
const [uploadingHeaderId, setUploadingHeaderId] = useState<number | null>(null)
|
||||
const [sendTarget, setSendTarget] = useState<{ channel: MessageSendChannel; headerId: number } | null>(null)
|
||||
const [qrTargetUrl, setQrTargetUrl] = useState('')
|
||||
const ctiConnectionStatus = useCtiConnectionStatus()
|
||||
const isCtiReady = ctiConnectionStatus === 'open'
|
||||
const ctiAgentStatus = useCtiAgentStatus()
|
||||
const isOnCall = ctiAgentStatus !== null && (CTI_ON_CALL_STATUSES as readonly string[]).includes(ctiAgentStatus)
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOnCall) return
|
||||
|
||||
const handleBeforeUnload = (event: BeforeUnloadEvent) => {
|
||||
event.preventDefault()
|
||||
event.returnValue = true
|
||||
}
|
||||
|
||||
window.addEventListener('beforeunload', handleBeforeUnload)
|
||||
return () => window.removeEventListener('beforeunload', handleBeforeUnload)
|
||||
}, [isOnCall])
|
||||
|
||||
const visibleHeaders = listHeaders
|
||||
.filter((header) => isListFieldVisibleForContact(header))
|
||||
.sort((a, b) => a.listHderOrder - b.listHderOrder)
|
||||
.sort((a, b) => {
|
||||
if (a.listHderTy === ListHeaderConst.MEMO) return 1
|
||||
if (b.listHderTy === ListHeaderConst.MEMO) return -1
|
||||
return a.listHderOrder - b.listHderOrder
|
||||
})
|
||||
|
||||
const substitutedSurveyUrl = surveyUrl ? substituteSurveyUrl(surveyUrl, sid) : ''
|
||||
const surveyResult = detail?.surveyResult
|
||||
const hasSurveyResponse = surveyResult?.lastResultCd !== undefined
|
||||
const surveyResultLabel = hasSurveyResponse
|
||||
? resultCodes.find((rc) => rc.resultCdTy === ResultCodeType.SURVEY && rc.resultCd === surveyResult?.lastResultCd)
|
||||
?.resultCdLbl ?? String(surveyResult?.lastResultCd)
|
||||
: ''
|
||||
const surveyResultByIdx = new Map((detail?.surveyResults ?? []).map((result) => [result.prjctSurveyIdx, result]))
|
||||
|
||||
const handleStartSurvey = () => {
|
||||
if (!substitutedSurveyUrl) return
|
||||
window.open(substitutedSurveyUrl, '_blank', 'noopener,noreferrer')
|
||||
const handleStartSurvey = (survey: ProjectSurvey) => {
|
||||
if (!survey.surveyUrl) return
|
||||
window.open(substituteSurveyUrl(survey.surveyUrl, sid), '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
const handleShowQr = (survey: ProjectSurvey) => {
|
||||
if (!survey.surveyUrl) return
|
||||
setQrTargetUrl(substituteSurveyUrl(survey.surveyUrl, sid))
|
||||
showDialog('surveyQrDialog')
|
||||
}
|
||||
|
||||
const handleSend = (channel: MessageSendChannel, headerId: number) => {
|
||||
@@ -112,7 +132,13 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
const handleCall = (telNum: string, listHderId: number) => {
|
||||
if (!telNum || !isCtiReady || isOnCall) return
|
||||
if (!isCtiReady) return
|
||||
// CTI_HANGUP_PENDING_VENDOR: 외주사 Hangup 명령 동작 확인 후 통화 중 버튼을 활성화하면 즉시 사용할 수 있다.
|
||||
if (isOnCall) {
|
||||
ctiClient.hangup()
|
||||
return
|
||||
}
|
||||
if (!telNum) return
|
||||
ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid: Number(sid), listHderId, aniNumber: callerTelNum ?? '' })
|
||||
}
|
||||
|
||||
@@ -121,6 +147,11 @@ const ListContactInfoPanel = ({
|
||||
fileInputRef.current?.click()
|
||||
}
|
||||
|
||||
const handleDownloadFile = async (listHderId: number, fileName: string) => {
|
||||
const buffer = await downloadItemFileMutation.mutateAsync(listHderId)
|
||||
downloadFile(new Blob([buffer], { type: 'application/octet-stream' }), fileName)
|
||||
}
|
||||
|
||||
const handleFileSelected = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0]
|
||||
e.target.value = ''
|
||||
@@ -136,11 +167,11 @@ const ListContactInfoPanel = ({
|
||||
<div className="space-y-4 rounded-lg border bg-white p-4">
|
||||
<h2 className="text-lg font-bold">리스트 정보</h2>
|
||||
<input type="file" ref={fileInputRef} className="hidden" onChange={handleFileSelected} />
|
||||
|
||||
{visibleHeaders.map((header) => {
|
||||
if (header.listHderTy === ListHeaderConst.SID) return null
|
||||
|
||||
const editable = isEditing && isListFieldEditableForContact(header, userRole)
|
||||
const canEditField = isListFieldEditableForContact(header, userRole)
|
||||
const editable = isEditing && canEditField
|
||||
const value = formValues[header.listHderId] ?? ''
|
||||
const onChange = (next: string) => onFieldChange(header.listHderId, next)
|
||||
|
||||
@@ -162,9 +193,9 @@ const ListContactInfoPanel = ({
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
value={value}
|
||||
value={formatKoreanPhoneNumber(value)}
|
||||
disabled={!editable}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
onChange={(e) => onChange(e.target.value.replace(/\D/g, ''))}
|
||||
className={disabledContrastClass}
|
||||
/>
|
||||
<Button
|
||||
@@ -220,17 +251,38 @@ const ListContactInfoPanel = ({
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<div className="flex items-center gap-2">
|
||||
<span className="min-w-0 flex-1 truncate text-sm">{value || '업로드된 파일 없음'}</span>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="shrink-0 gap-2"
|
||||
disabled={!editable || uploadItemFileMutation.isPending}
|
||||
onClick={() => handlePickFile(header.listHderId)}
|
||||
>
|
||||
<Paperclip className="h-4 w-4" />
|
||||
업로드
|
||||
</Button>
|
||||
<div className="min-w-0 flex-1 truncate text-sm">
|
||||
{value ? (
|
||||
<button
|
||||
type="button"
|
||||
className="max-w-full cursor-pointer text-left text-primary hover:text-primary/80 disabled:cursor-wait disabled:opacity-60"
|
||||
disabled={downloadItemFileMutation.isPending}
|
||||
title={value}
|
||||
onClick={() => handleDownloadFile(header.listHderId, value)}
|
||||
>
|
||||
<span
|
||||
className="block truncate"
|
||||
style={{ textDecorationLine: 'underline', textUnderlineOffset: '3px' }}
|
||||
>
|
||||
{value}
|
||||
</span>
|
||||
</button>
|
||||
) : (
|
||||
<span>업로드된 파일 없음</span>
|
||||
)}
|
||||
</div>
|
||||
{canEditField ? (
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="shrink-0 gap-2"
|
||||
disabled={uploadItemFileMutation.isPending}
|
||||
onClick={() => handlePickFile(header.listHderId)}
|
||||
>
|
||||
<Paperclip className="h-4 w-4" />
|
||||
업로드
|
||||
</Button>
|
||||
) : null}
|
||||
</div>
|
||||
</FieldRow>
|
||||
)
|
||||
@@ -266,31 +318,37 @@ const ListContactInfoPanel = ({
|
||||
)
|
||||
})}
|
||||
|
||||
{surveyUrl ? (
|
||||
<FieldRow label="Web">
|
||||
<div className="flex items-center gap-2">
|
||||
<Button type="button" className="gap-2" onClick={handleStartSurvey}>
|
||||
조사 시작
|
||||
</Button>
|
||||
<Button type="button" variant="outline" className="gap-2" onClick={() => showDialog('surveyQrDialog')}>
|
||||
<QrCode className="h-4 w-4" />
|
||||
QR
|
||||
</Button>
|
||||
{hasSurveyResponse ? (
|
||||
<span className="text-sm">
|
||||
[{surveyResultLabel}]{' '}
|
||||
<span className="text-muted-foreground">
|
||||
({formatKst(surveyResult?.lastResultDt ?? '', 'dateHourMin')})
|
||||
</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">[응답없음]</span>
|
||||
)}
|
||||
</div>
|
||||
</FieldRow>
|
||||
) : null}
|
||||
{surveys
|
||||
.filter((survey) => !!survey.surveyUrl)
|
||||
.map((survey) => {
|
||||
const result = survey.prjctSurveyIdx != null ? surveyResultByIdx.get(survey.prjctSurveyIdx) : undefined
|
||||
const hasSurveyResponse = result !== undefined
|
||||
|
||||
<SurveyQrDialog url={substitutedSurveyUrl} />
|
||||
return (
|
||||
<FieldRow key={survey.prjctSurveyIdx ?? survey.surveyOrder} label={survey.surveyName || 'Web'}>
|
||||
<div className="flex items-center gap-2">
|
||||
<Button type="button" className="gap-2" onClick={() => handleStartSurvey(survey)}>
|
||||
조사 시작
|
||||
</Button>
|
||||
<Button type="button" variant="outline" className="gap-2" onClick={() => handleShowQr(survey)}>
|
||||
<QrCode className="h-4 w-4" />
|
||||
QR
|
||||
</Button>
|
||||
{hasSurveyResponse ? (
|
||||
<span className="text-sm">
|
||||
[{resultCodes.find((rc) => rc.resultCdTy === ResultCodeType.SURVEY && rc.resultCd === result.lastResultCd)
|
||||
?.resultCdLbl ?? String(result.lastResultCd)}]{' '}
|
||||
<span className="text-muted-foreground">({formatKst(result.lastResultDt, 'dateHourMin')})</span>
|
||||
</span>
|
||||
) : (
|
||||
<span className="text-sm text-muted-foreground">[응답없음]</span>
|
||||
)}
|
||||
</div>
|
||||
</FieldRow>
|
||||
)
|
||||
})}
|
||||
|
||||
<SurveyQrDialog url={qrTargetUrl} />
|
||||
<SingleMessageSendDialog
|
||||
channel={sendTarget?.channel ?? 'sms'}
|
||||
prjctIdx={prjctIdx}
|
||||
|
||||
Reference in New Issue
Block a user