260727_01_ENH: 전화 걸기 ws 틀어막기, 선택 항목만인경우 선택된 것이 없으면 오류
This commit is contained in:
@@ -21,8 +21,7 @@ import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||
import { ctiClient } from '@/lib/cti/ctiClient'
|
||||
import { useCtiConnectionStatus } from '@/hooks/useCtiConnectionStatus'
|
||||
import { useCtiAgentStatus } from '@/hooks/useCtiAgentStatus'
|
||||
import { CTI_ON_CALL_STATUSES } from '@/const/ctiConst'
|
||||
import { useCtiCallPhase } from '@/hooks/useCtiCallPhase'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { downloadFile } from '@kri/common/browser'
|
||||
|
||||
@@ -67,6 +66,18 @@ export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearc
|
||||
|
||||
const disabledContrastClass = 'disabled:opacity-100 disabled:text-foreground disabled:bg-muted/60'
|
||||
|
||||
const getCallButtonLabel = (isDialing: boolean, isOnCall: boolean) => {
|
||||
if (isDialing) return '거는 중'
|
||||
if (isOnCall) return '전화 끊기'
|
||||
return '전화'
|
||||
}
|
||||
|
||||
const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean) => {
|
||||
if (!isCtiReady) return '전화 시스템에 연결되어 있지 않습니다.'
|
||||
if (isDialing) return '전화를 거는 중입니다.'
|
||||
return undefined
|
||||
}
|
||||
|
||||
const FieldRow = ({ label, children }: { label: string; children: ReactNode }) => (
|
||||
<div className="flex items-center gap-3">
|
||||
<Label className="w-24 shrink-0 text-sm font-bold text-foreground">{label}</Label>
|
||||
@@ -98,8 +109,9 @@ const ListContactInfoPanel = ({
|
||||
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)
|
||||
const ctiCallPhase = useCtiCallPhase()
|
||||
const isDialing = ctiCallPhase === 'dialing'
|
||||
const isOnCall = ctiCallPhase === 'active'
|
||||
|
||||
useEffect(() => {
|
||||
if (!isOnCall) return
|
||||
@@ -148,12 +160,13 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
const handleCall = (telNum: string, listHderId: number) => {
|
||||
if (!isCtiReady) return
|
||||
if (!isCtiReady || isDialing) 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 ?? '' })
|
||||
}
|
||||
@@ -218,12 +231,12 @@ const ListContactInfoPanel = ({
|
||||
type="button"
|
||||
variant="outline"
|
||||
className={cn('shrink-0 gap-2', isOnCall && 'bg-accent text-accent-foreground')}
|
||||
disabled={!isCtiReady || isOnCall}
|
||||
title={!isCtiReady ? '전화 시스템에 연결되어 있지 않습니다.' : undefined}
|
||||
disabled={!isCtiReady || isDialing}
|
||||
title={getCallButtonTitle(isCtiReady, isDialing)}
|
||||
onClick={() => handleCall(value, header.listHderId)}
|
||||
>
|
||||
<Phone className="h-4 w-4" />
|
||||
{isOnCall ? '통화중' : '전화'}
|
||||
{getCallButtonLabel(isDialing, isOnCall)}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
@@ -235,6 +248,11 @@ const ListContactInfoPanel = ({
|
||||
발송
|
||||
</Button>
|
||||
</div>
|
||||
{(isDialing || isOnCall) &&
|
||||
<p className="text-sm text-red-600 font-medium mt-1">
|
||||
⚠️ 전화를 끊어야만 통화 종료가 기록됩니다.
|
||||
</p>
|
||||
}
|
||||
</FieldRow>
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user