260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
44
src/components/list-contact/CollapsibleHistorySection.tsx
Normal file
44
src/components/list-contact/CollapsibleHistorySection.tsx
Normal file
@@ -0,0 +1,44 @@
|
||||
'use client'
|
||||
|
||||
import { useId, useState, type ReactNode } from 'react'
|
||||
import { ChevronDown, ChevronRight } from 'lucide-react'
|
||||
|
||||
export type CollapsibleHistorySectionProps = {
|
||||
title: string
|
||||
defaultOpen?: boolean
|
||||
showDivider?: boolean
|
||||
headerExtra?: ReactNode
|
||||
children: ReactNode
|
||||
}
|
||||
|
||||
const CollapsibleHistorySection = ({
|
||||
title,
|
||||
defaultOpen = false,
|
||||
showDivider = true,
|
||||
headerExtra,
|
||||
children,
|
||||
}: CollapsibleHistorySectionProps) => {
|
||||
const [open, setOpen] = useState(defaultOpen)
|
||||
const contentId = useId()
|
||||
|
||||
return (
|
||||
<div className={`space-y-2 ${showDivider ? 'border-t pt-3' : ''}`}>
|
||||
<div className="flex w-full items-center justify-between gap-2">
|
||||
<button
|
||||
type="button"
|
||||
className="flex min-w-0 flex-1 items-center gap-2 text-left text-sm font-semibold cursor-pointer"
|
||||
aria-expanded={open}
|
||||
aria-controls={contentId}
|
||||
onClick={() => setOpen((prev) => !prev)}
|
||||
>
|
||||
{open ? <ChevronDown className="h-4 w-4" /> : <ChevronRight className="h-4 w-4" />}
|
||||
{title}
|
||||
</button>
|
||||
{headerExtra}
|
||||
</div>
|
||||
{open ? <div id={contentId}>{children}</div> : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default CollapsibleHistorySection
|
||||
346
src/components/list-contact/ListContactEventPanel.tsx
Normal file
346
src/components/list-contact/ListContactEventPanel.tsx
Normal file
@@ -0,0 +1,346 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { RefreshCw } 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 { useSendResultBySidQuery } from '@/query/message'
|
||||
import { clientEnv } from '@/lib/env.client'
|
||||
import { ChannelType } from '@kri/common/noti-hub'
|
||||
import type { SendResultInfo } from '@/types/message'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { CONTACT_INTERVIEWER_ROLE, FIELD_INTERVIEWER_ROLE } from '@/const/userConst'
|
||||
import { RESULT_CODE_RESERVATION, RESULT_CODE_UNUSED } from '@/const/projectConst'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { getNearestFutureDateTime } from '@/lib/datetime'
|
||||
|
||||
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
aria-label="새로고침"
|
||||
disabled={isFetching}
|
||||
onClick={(e) => {
|
||||
e.stopPropagation()
|
||||
onRefresh()
|
||||
}}
|
||||
>
|
||||
<RefreshCw className={cn('h-4 w-4', isFetching && 'animate-spin')} />
|
||||
</Button>
|
||||
)
|
||||
|
||||
type ContactEventSectionProps = {
|
||||
title: string
|
||||
prjctIdx: number
|
||||
sid: string
|
||||
resultCodeType: ResultCodeType
|
||||
resultCodes: ResultCode[]
|
||||
showReservation?: boolean
|
||||
showInput?: boolean
|
||||
submitting: boolean
|
||||
onSubmit: (resultCd: number, memo: string, resveDt: string) => Promise<void>
|
||||
}
|
||||
|
||||
const EventHistoryList = ({
|
||||
isLoading,
|
||||
history,
|
||||
resultCodeType,
|
||||
resultCodes,
|
||||
}: {
|
||||
isLoading: boolean
|
||||
history: ReturnType<typeof useListEventHistoryQuery>['data']
|
||||
resultCodeType: ResultCodeType
|
||||
resultCodes: ResultCode[]
|
||||
}) => {
|
||||
const filteredHistory = (history ?? [])
|
||||
.filter((item) => item.eventTy === resultCodeType)
|
||||
.sort((a, b) => new Date(b.regDt).getTime() - new Date(a.regDt).getTime())
|
||||
|
||||
const resolveLabel = (resultCd: number) =>
|
||||
resultCodes.find((code) => code.resultCdTy === resultCodeType && code.resultCd === resultCd)?.resultCdLbl ??
|
||||
String(resultCd)
|
||||
|
||||
if (isLoading) {
|
||||
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
}
|
||||
|
||||
if (filteredHistory.length === 0) {
|
||||
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">이력이 없습니다.</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-h-60 overflow-y-auto rounded-md border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">결과</th>
|
||||
<th className="p-2 text-left">메모</th>
|
||||
<th className="p-2 text-left">등록자</th>
|
||||
<th className="p-2 text-left">일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{filteredHistory.map((item) => (
|
||||
<tr key={item.listEventHistIdx} className="border-t">
|
||||
<td className="p-2">
|
||||
{item.resultCd}.{resolveLabel(item.resultCd)}
|
||||
</td>
|
||||
<td className="p-2">{item.memo || '-'}</td>
|
||||
<td className="p-2">{item.regUser}</td>
|
||||
<td className="p-2">{formatKst(item.regDt, 'dateHourMin')}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const ContactEventSection = ({
|
||||
title,
|
||||
prjctIdx,
|
||||
sid,
|
||||
resultCodeType,
|
||||
resultCodes,
|
||||
showReservation = false,
|
||||
showInput = true,
|
||||
submitting,
|
||||
onSubmit,
|
||||
}: ContactEventSectionProps) => {
|
||||
const [resultCd, setResultCd] = useState('')
|
||||
const [memo, setMemo] = useState('')
|
||||
const [resveDt, setResveDt] = useState('')
|
||||
|
||||
const codes = resultCodes.filter((code) => code.resultCdTy === resultCodeType && code.resultCd !== RESULT_CODE_UNUSED)
|
||||
const isReservationSelected = resultCd === String(RESULT_CODE_RESERVATION)
|
||||
|
||||
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
|
||||
|
||||
const handleResultCdChange = (next: string) => {
|
||||
setResultCd(next)
|
||||
if (next === String(RESULT_CODE_RESERVATION) && !resveDt) {
|
||||
setResveDt(getNearestFutureDateTime())
|
||||
}
|
||||
}
|
||||
|
||||
const handleAdd = async () => {
|
||||
if (!resultCd) {
|
||||
alert('결과 코드를 선택해주세요.')
|
||||
return
|
||||
}
|
||||
if (isReservationSelected && !resveDt) {
|
||||
alert('예약 날짜/시간을 선택해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
await onSubmit(Number(resultCd), memo, isReservationSelected ? resveDt : '')
|
||||
setMemo('')
|
||||
setResveDt('')
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-3 rounded-lg border bg-white p-4">
|
||||
<h2 className="text-lg font-bold">{title}</h2>
|
||||
|
||||
{showInput ? (
|
||||
<>
|
||||
<RadioGroup value={resultCd} onValueChange={handleResultCdChange} className="grid grid-cols-2 gap-2">
|
||||
{codes.map((code) => (
|
||||
<label key={code.resultCdUUID} className="flex items-center gap-2 text-sm font-bold cursor-pointer">
|
||||
<RadioGroupItem value={String(code.resultCd)} />
|
||||
{code.resultCd}.{code.resultCdLbl}
|
||||
</label>
|
||||
))}
|
||||
</RadioGroup>
|
||||
|
||||
<textarea
|
||||
placeholder="메모"
|
||||
value={memo}
|
||||
onChange={(e) => setMemo(e.target.value)}
|
||||
className="flex min-h-[70px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2"
|
||||
/>
|
||||
|
||||
{showReservation && isReservationSelected ? (
|
||||
<KriDateTimePicker value={resveDt} onChange={setResveDt} placeholder="예약 날짜/시간" />
|
||||
) : null}
|
||||
|
||||
<Button type="button" className="w-full" disabled={submitting} onClick={handleAdd}>
|
||||
{title} 추가
|
||||
</Button>
|
||||
</>
|
||||
) : null}
|
||||
|
||||
<CollapsibleHistorySection
|
||||
title={`${title}(최근순)`}
|
||||
showDivider={showInput}
|
||||
headerExtra={<RefreshIconButton onRefresh={() => historyQuery.refetch()} isFetching={historyQuery.isFetching} />}
|
||||
>
|
||||
<EventHistoryList isLoading={historyQuery.isLoading} history={historyQuery.data} resultCodeType={resultCodeType} resultCodes={resultCodes} />
|
||||
</CollapsibleHistorySection>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const SendResultTable = ({ isLoading, results }: { isLoading: boolean; results: SendResultInfo[] }) => {
|
||||
if (isLoading) {
|
||||
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
}
|
||||
|
||||
if (results.length === 0) {
|
||||
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">발송 이력이 없습니다.</div>
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="max-h-60 overflow-y-auto rounded-md border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">수신처</th>
|
||||
<th className="p-2 text-left">결과</th>
|
||||
<th className="p-2 text-left">발송일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{results.map((item) => (
|
||||
<tr key={item.cmid} className="border-t">
|
||||
<td className="p-2">{item.destEml || item.destTel || '-'}</td>
|
||||
<td className="p-2">{item.resultViewLabel || item.resultLabel || item.resultCode}</td>
|
||||
<td className="p-2">{formatKst(item.sendDt, 'dateHourMin')}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const SendResultHistory = ({ sid, prjctCd }: { sid: string; prjctCd: string }) => {
|
||||
const [tab, setTab] = useState<'email' | 'sms'>('email')
|
||||
|
||||
const emailQuery = useSendResultBySidQuery(sid, prjctCd, clientEnv.REQUEST_SVC, ChannelType.EMAIL, tab === 'email')
|
||||
const smsQuery = useSendResultBySidQuery(sid, prjctCd, clientEnv.REQUEST_SVC, ChannelType.SMS, tab === 'sms')
|
||||
const activeQuery = tab === 'email' ? emailQuery : smsQuery
|
||||
|
||||
const handleTabClick = (e: React.MouseEvent, next: 'email' | 'sms') => {
|
||||
e.stopPropagation()
|
||||
setTab(next)
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<CollapsibleHistorySection
|
||||
title="발송 현황(최근순)"
|
||||
showDivider={false}
|
||||
headerExtra={
|
||||
<div className="flex items-center gap-1">
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={tab === 'email' ? 'default' : 'outline'}
|
||||
onClick={(e) => handleTabClick(e, 'email')}
|
||||
>
|
||||
이메일
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
size="sm"
|
||||
variant={tab === 'sms' ? 'default' : 'outline'}
|
||||
onClick={(e) => handleTabClick(e, 'sms')}
|
||||
>
|
||||
문자
|
||||
</Button>
|
||||
<RefreshIconButton onRefresh={() => activeQuery.refetch()} isFetching={activeQuery.isFetching} />
|
||||
</div>
|
||||
}
|
||||
>
|
||||
<SendResultTable isLoading={activeQuery.isLoading} results={activeQuery.data ?? []} />
|
||||
</CollapsibleHistorySection>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export type ListContactEventPanelProps = {
|
||||
prjctIdx: number
|
||||
sid: string
|
||||
prjctCd: string
|
||||
userId: string
|
||||
userRole: number
|
||||
resultCodes: ResultCode[]
|
||||
useContactSenario: boolean
|
||||
contactSenario?: string
|
||||
}
|
||||
|
||||
const ListContactEventPanel = ({
|
||||
prjctIdx,
|
||||
sid,
|
||||
prjctCd,
|
||||
userId,
|
||||
userRole,
|
||||
resultCodes,
|
||||
useContactSenario,
|
||||
contactSenario,
|
||||
}: ListContactEventPanelProps) => {
|
||||
const addListEventMutation = useAddListEventMutation(prjctIdx, sid)
|
||||
const reserveMutation = useReserveMutation(prjctIdx, sid)
|
||||
const showContactInput = userRole !== FIELD_INTERVIEWER_ROLE
|
||||
const showInterviewInput = userRole !== CONTACT_INTERVIEWER_ROLE
|
||||
|
||||
const handleAddEvent = (resultCodeType: ResultCodeType) => async (resultCd: number, memo: string, resveDt: string) => {
|
||||
await addListEventMutation.mutateAsync({
|
||||
prjctIdx,
|
||||
sid: Number(sid),
|
||||
resultCodeType,
|
||||
resultCd,
|
||||
memo,
|
||||
})
|
||||
|
||||
if (resveDt) {
|
||||
await reserveMutation.mutateAsync({ prjctIdx, sid: Number(sid), userId, resveDt })
|
||||
}
|
||||
|
||||
alert('등록되었습니다.')
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="h-[80vh] space-y-4 overflow-y-auto pr-1">
|
||||
<ContactEventSection
|
||||
title="컨택결과"
|
||||
prjctIdx={prjctIdx}
|
||||
sid={sid}
|
||||
resultCodeType={ResultCodeType.CONTACT}
|
||||
resultCodes={resultCodes}
|
||||
showReservation
|
||||
showInput={showContactInput}
|
||||
submitting={addListEventMutation.isPending || reserveMutation.isPending}
|
||||
onSubmit={handleAddEvent(ResultCodeType.CONTACT)}
|
||||
/>
|
||||
|
||||
<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)}
|
||||
/>
|
||||
|
||||
{useContactSenario && contactSenario ? (
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<h2 className="text-lg font-bold border-b pb-2">컨택 시나리오</h2>
|
||||
<div className="text-base leading-relaxed" dangerouslySetInnerHTML={{ __html: contactSenario }} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListContactEventPanel
|
||||
285
src/components/list-contact/ListContactInfoPanel.tsx
Normal file
285
src/components/list-contact/ListContactInfoPanel.tsx
Normal file
@@ -0,0 +1,285 @@
|
||||
'use client'
|
||||
|
||||
import { 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 { ListHeaderConst } from '@/const/listConst'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import type { MessageSendChannel } from '@/types/message'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteSurveyUrl } from '@/lib/surveyUrl'
|
||||
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 { cn } from '@/lib/utils'
|
||||
|
||||
export type ListContactInfoPanelProps = {
|
||||
prjctIdx: number
|
||||
sid: string
|
||||
itrntPrjctCd: string
|
||||
userRole: number
|
||||
isEditing: boolean
|
||||
listHeaders: listHeader[]
|
||||
detail?: ListSearchWithFullResult
|
||||
surveyUrl?: string
|
||||
formValues: Record<number, string>
|
||||
onFieldChange: (listHderId: number, value: string) => void
|
||||
onSaved?: () => void
|
||||
}
|
||||
|
||||
export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearchWithFullResult) => {
|
||||
const values: Record<number, string> = {}
|
||||
|
||||
for (const header of listHeaders) {
|
||||
if (header.listHderTy === ListHeaderConst.SID) continue
|
||||
if (!isListFieldVisibleForContact(header)) continue
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||
values[header.listHderId] = detail?.memo ?? ''
|
||||
continue
|
||||
}
|
||||
values[header.listHderId] = detail?.itemList?.[header.listHderId] ?? ''
|
||||
}
|
||||
|
||||
return values
|
||||
}
|
||||
|
||||
const disabledContrastClass = 'disabled:opacity-100 disabled:text-foreground disabled:bg-muted/60'
|
||||
|
||||
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>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
|
||||
const ListContactInfoPanel = ({
|
||||
prjctIdx,
|
||||
sid,
|
||||
itrntPrjctCd,
|
||||
userRole,
|
||||
isEditing,
|
||||
listHeaders,
|
||||
detail,
|
||||
surveyUrl,
|
||||
formValues,
|
||||
onFieldChange,
|
||||
onSaved,
|
||||
}: ListContactInfoPanelProps) => {
|
||||
const { showDialog } = useDialog()
|
||||
const uploadItemFileMutation = useUploadListItemFileMutation(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 ctiConnectionStatus = useCtiConnectionStatus()
|
||||
const isCtiReady = ctiConnectionStatus === 'open'
|
||||
const ctiAgentStatus = useCtiAgentStatus()
|
||||
const isOnCall = ctiAgentStatus !== null && (CTI_ON_CALL_STATUSES as readonly string[]).includes(ctiAgentStatus)
|
||||
|
||||
const visibleHeaders = listHeaders
|
||||
.filter((header) => isListFieldVisibleForContact(header))
|
||||
.sort((a, b) => a.listHderOrder - b.listHderOrder)
|
||||
|
||||
const substitutedSurveyUrl = surveyUrl ? substituteSurveyUrl(surveyUrl, sid) : ''
|
||||
const hasSurveyResponse = detail?.surveyResult?.lastResultCd !== undefined
|
||||
|
||||
const handleStartSurvey = () => {
|
||||
if (!substitutedSurveyUrl) return
|
||||
window.open(substitutedSurveyUrl, '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
const handleSend = (channel: MessageSendChannel, headerId: number) => {
|
||||
setSendTarget({ channel, headerId })
|
||||
showDialog('singleMessageSendDialog')
|
||||
}
|
||||
|
||||
const handleCall = (telNum: string, listHderId: number) => {
|
||||
if (!telNum || !isCtiReady || isOnCall) return
|
||||
ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid: Number(sid), listHderId })
|
||||
}
|
||||
|
||||
const handlePickFile = (listHderId: number) => {
|
||||
setUploadingHeaderId(listHderId)
|
||||
fileInputRef.current?.click()
|
||||
}
|
||||
|
||||
const handleFileSelected = async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
const file = e.target.files?.[0]
|
||||
e.target.value = ''
|
||||
if (!file || uploadingHeaderId === null) return
|
||||
|
||||
await uploadItemFileMutation.mutateAsync({ listHderId: uploadingHeaderId, file })
|
||||
setUploadingHeaderId(null)
|
||||
alert('파일이 업로드되었습니다.')
|
||||
onSaved?.()
|
||||
}
|
||||
|
||||
return (
|
||||
<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 value = formValues[header.listHderId] ?? ''
|
||||
const onChange = (next: string) => onFieldChange(header.listHderId, next)
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<textarea
|
||||
className={`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 disabled:cursor-not-allowed ${disabledContrastClass}`}
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
/>
|
||||
</FieldRow>
|
||||
)
|
||||
}
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.TEL_NUM) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className={disabledContrastClass}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className={cn('shrink-0 gap-2', isOnCall && 'bg-accent text-accent-foreground')}
|
||||
disabled={!isCtiReady || isOnCall}
|
||||
title={!isCtiReady ? '전화 시스템에 연결되어 있지 않습니다.' : undefined}
|
||||
onClick={() => handleCall(value, header.listHderId)}
|
||||
>
|
||||
<Phone className="h-4 w-4" />
|
||||
{isOnCall ? '통화중' : '전화'}
|
||||
</Button>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="shrink-0 gap-2"
|
||||
onClick={() => handleSend('sms', header.listHderId)}
|
||||
>
|
||||
<MessageSquare className="h-4 w-4" />
|
||||
발송
|
||||
</Button>
|
||||
</div>
|
||||
</FieldRow>
|
||||
)
|
||||
}
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.EMAIL) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<div className="flex gap-2">
|
||||
<Input
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className={disabledContrastClass}
|
||||
/>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
className="shrink-0 gap-2"
|
||||
onClick={() => handleSend('email', header.listHderId)}
|
||||
>
|
||||
<Mail className="h-4 w-4" />
|
||||
발송
|
||||
</Button>
|
||||
</div>
|
||||
</FieldRow>
|
||||
)
|
||||
}
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.FILE) {
|
||||
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>
|
||||
</FieldRow>
|
||||
)
|
||||
}
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.CONTENT_ITEM && (header.filterContents?.length ?? 0) > 0) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<KriSingleSelect
|
||||
items={header.filterContents ?? []}
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={onChange}
|
||||
getValue={(item) => item}
|
||||
getLabel={(item) => item}
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
className={disabledContrastClass}
|
||||
/>
|
||||
</FieldRow>
|
||||
)
|
||||
}
|
||||
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm}>
|
||||
<Input
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={(e) => onChange(e.target.value)}
|
||||
className={disabledContrastClass}
|
||||
/>
|
||||
</FieldRow>
|
||||
)
|
||||
})}
|
||||
|
||||
{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 text-muted-foreground">[응답없음]</span>}
|
||||
</div>
|
||||
</FieldRow>
|
||||
) : null}
|
||||
|
||||
<SurveyQrDialog url={substitutedSurveyUrl} />
|
||||
<SingleMessageSendDialog
|
||||
channel={sendTarget?.channel ?? 'sms'}
|
||||
prjctIdx={prjctIdx}
|
||||
itrntPrjctCd={itrntPrjctCd}
|
||||
sid={sid}
|
||||
destHeaderId={sendTarget?.headerId ?? 0}
|
||||
/>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListContactInfoPanel
|
||||
61
src/components/list-contact/ListUpdateHistoryPanel.tsx
Normal file
61
src/components/list-contact/ListUpdateHistoryPanel.tsx
Normal file
@@ -0,0 +1,61 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import { useListUpdateHistoryQuery } from '@/query/list'
|
||||
import type { listHeader } from '@/types/list'
|
||||
import CollapsibleHistorySection from '@/components/list-contact/CollapsibleHistorySection'
|
||||
import { formatKst } from '@kri/common'
|
||||
|
||||
export type ListUpdateHistoryPanelProps = {
|
||||
prjctIdx: number
|
||||
sid: string
|
||||
listHeaders: listHeader[]
|
||||
}
|
||||
|
||||
const ListUpdateHistoryPanel = ({ prjctIdx, sid, listHeaders }: ListUpdateHistoryPanelProps) => {
|
||||
const headerNameById = useMemo(
|
||||
() => new Map(listHeaders.map((header) => [header.listHderId, header.listHderNm])),
|
||||
[listHeaders],
|
||||
)
|
||||
const historyQuery = useListUpdateHistoryQuery(prjctIdx, sid, true)
|
||||
const history = historyQuery.data ?? []
|
||||
|
||||
return (
|
||||
<div className="space-y-2 rounded-lg border bg-white p-4">
|
||||
<CollapsibleHistorySection title="수정 이력" showDivider={false}>
|
||||
{historyQuery.isLoading ? (
|
||||
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
) : history.length === 0 ? (
|
||||
<div className="rounded-md border p-4 text-center text-sm text-muted-foreground">수정 이력이 없습니다.</div>
|
||||
) : (
|
||||
<div className="max-h-60 overflow-y-auto rounded-md border">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">항목</th>
|
||||
<th className="p-2 text-left">변경 전</th>
|
||||
<th className="p-2 text-left">변경 후</th>
|
||||
<th className="p-2 text-left">수정자</th>
|
||||
<th className="p-2 text-left">일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{history.map((item) => (
|
||||
<tr key={item.listUpdateHistIdx} className="border-t">
|
||||
<td className="p-2">{headerNameById.get(item.listHderId) ?? item.listHderId}</td>
|
||||
<td className="p-2">{item.beforeVal || '-'}</td>
|
||||
<td className="p-2">{item.afterVal || '-'}</td>
|
||||
<td className="p-2">{item.regUser}</td>
|
||||
<td className="p-2">{formatKst(item.regDt, 'dateHourMin')}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
)}
|
||||
</CollapsibleHistorySection>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListUpdateHistoryPanel
|
||||
Reference in New Issue
Block a user