Merge pull request 'develop' (#15) from develop into master
Reviewed-on: #15
This commit is contained in:
@@ -244,6 +244,8 @@ const ListContactPageContent = () => {
|
||||
useFF={projectInfoQuery.data?.ff ?? false}
|
||||
useContactSenario={projectInfoQuery.data?.useContactSenario ?? false}
|
||||
contactSenario={projectInfoQuery.data?.contactSenario}
|
||||
listHeaders={listHeaders}
|
||||
detail={listDetailQuery.data}
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
9
src/app/api/external/[[...slug]]/route.ts
vendored
9
src/app/api/external/[[...slug]]/route.ts
vendored
@@ -33,11 +33,14 @@ const toRequiredNumber = (value: string): number | null => {
|
||||
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
|
||||
};
|
||||
|
||||
const toRequiredSid = (value: string): string | null =>
|
||||
value.length > 0 ? value : null;
|
||||
|
||||
const buildExternalEventBody = (
|
||||
req: NextRequest,
|
||||
action: ExternalAction,
|
||||
prjctSurveyIdx: number,
|
||||
sid: number,
|
||||
sid: string,
|
||||
): ExternalEventBody => {
|
||||
const pathname = req.nextUrl.pathname;
|
||||
const h = req.headers;
|
||||
@@ -51,7 +54,7 @@ const buildExternalEventBody = (
|
||||
entryType: getEntryTypeCode(h),
|
||||
action: actionCode,
|
||||
psidx: String(prjctSurveyIdx),
|
||||
sid: String(sid),
|
||||
sid,
|
||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||
uri: getHeader(h, "x-orig-uri") || pathname,
|
||||
url: getHeader(h, "x-orig-url") || req.url,
|
||||
@@ -75,7 +78,7 @@ const handleExternalEvent = async (req: NextRequest, context: RouteContext) => {
|
||||
}
|
||||
|
||||
const prjctSurveyIdx = toRequiredNumber((searchParams.get("psidx") ?? "").trim());
|
||||
const sid = toRequiredNumber((searchParams.get("sid") ?? "").trim());
|
||||
const sid = toRequiredSid((searchParams.get("sid") ?? "").trim());
|
||||
|
||||
if (!prjctSurveyIdx || !sid) {
|
||||
return NextResponse.json({ message: "psidx, sid는 필수입니다." }, { status: 400 });
|
||||
|
||||
@@ -37,7 +37,7 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
|
||||
const contactApi = await createContactApi();
|
||||
const result = await contactApi.put<ListCallHist>(
|
||||
`/list-call-hist/${prjctIdx}/${sid}/${action}`,
|
||||
`/list-call-hist/${prjctIdx}/${encodeURIComponent(sid)}/${action}`,
|
||||
body,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
|
||||
@@ -11,12 +11,16 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "event" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListEventHistory[]>(`/list-hist/event/${slug[1]}/${slug[2]}`);
|
||||
const result = await contactApi.get<ListEventHistory[]>(
|
||||
`/list-hist/event/${slug[1]}/${encodeURIComponent(slug[2])}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "update" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListUpdateHistory[]>(`/list-hist/update/${slug[1]}/${slug[2]}`);
|
||||
const result = await contactApi.get<ListUpdateHistory[]>(
|
||||
`/list-hist/update/${slug[1]}/${encodeURIComponent(slug[2])}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
|
||||
@@ -28,13 +28,15 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
}
|
||||
|
||||
if (action === "search-sid" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListSearchWithFullResult>(`/list/search-sid/${slug[1]}/${slug[2]}`);
|
||||
const result = await contactApi.get<ListSearchWithFullResult>(
|
||||
`/list/search-sid/${slug[1]}/${encodeURIComponent(slug[2])}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "item-file-download" && slug.length === 4) {
|
||||
const result = await contactApi.get<ArrayBuffer>(
|
||||
`/list/item-file/download/${slug[1]}/${slug[2]}/${slug[3]}`,
|
||||
`/list/item-file/download/${slug[1]}/${encodeURIComponent(slug[2])}/${slug[3]}`,
|
||||
{ expectBinary: true },
|
||||
);
|
||||
return new NextResponse(result, {
|
||||
@@ -94,7 +96,7 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
|
||||
if (action === "item-file-upload" && slug.length === 3) {
|
||||
const form = await req.formData();
|
||||
await contactApi.postForm(`/list/item-file/upload/${slug[1]}/${slug[2]}`, form);
|
||||
await contactApi.postForm(`/list/item-file/upload/${slug[1]}/${encodeURIComponent(slug[2])}`, form);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
|
||||
@@ -24,7 +24,7 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
const channelTy = req.nextUrl.searchParams.get("channelTy");
|
||||
const query = channelTy ? `?channelTy=${channelTy}` : "";
|
||||
const result = await notihubApi.get<SendResultInfo[]>(
|
||||
`/report/send-result/${sid}/${prjctCdParam}/${reqstSvcParam}${query}`,
|
||||
`/report/send-result/${encodeURIComponent(sid)}/${prjctCdParam}/${reqstSvcParam}${query}`,
|
||||
);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
@@ -11,7 +11,9 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "sid" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListReserve[]>(`/reserve/${slug[1]}/sid/${slug[2]}`);
|
||||
const result = await contactApi.get<ListReserve[]>(
|
||||
`/reserve/${slug[1]}/sid/${encodeURIComponent(slug[2])}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ export function usePagination({ currentPage, totalPages, paginationItemsToDispla
|
||||
const visibleCount = Math.max(1, paginationItemsToDisplay)
|
||||
const half = Math.floor(visibleCount / 2)
|
||||
let startPage = Math.max(1, currentPage - half)
|
||||
let endPage = Math.min(totalPages, startPage + visibleCount - 1)
|
||||
const endPage = Math.min(totalPages, startPage + visibleCount - 1)
|
||||
|
||||
if (endPage - startPage + 1 < visibleCount) {
|
||||
startPage = Math.max(1, endPage - visibleCount + 1)
|
||||
|
||||
@@ -406,10 +406,15 @@ const ListUploadDialog = ({
|
||||
<td className="h-10 px-3 text-center">{item.listCount.toLocaleString()}</td>
|
||||
<td className="h-10 px-3 text-center">{item.uploadAtLabel}</td>
|
||||
<td className="h-10 px-3 text-center">
|
||||
<Button type="button" size="sm" className="bg-excel" onClick={() => onDownloadHistory?.(item)}>
|
||||
<Download className="h-4 w-4" />
|
||||
다운로드
|
||||
</Button>
|
||||
{
|
||||
item.schedulingDelDt ?
|
||||
<p className="text-sm text-red-600 font-medium">보관 기간 만료</p>
|
||||
:
|
||||
<Button type="button" size="sm" className="bg-excel" onClick={() => onDownloadHistory?.(item)}>
|
||||
<Download className="h-4 w-4" />
|
||||
다운로드
|
||||
</Button>
|
||||
}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
|
||||
@@ -15,7 +15,7 @@ export type ReservationListDialogProps = {
|
||||
}
|
||||
|
||||
// 오늘과 가장 가까운(과거/미래 무관) 예약의 sid를 찾는다.
|
||||
export const findClosestReservationSid = (reservations: ListReserve[], now: Date = new Date()): number | null => {
|
||||
export const findClosestReservationSid = (reservations: ListReserve[], now: Date = new Date()): string | null => {
|
||||
if (reservations.length === 0) return null
|
||||
|
||||
return reservations.reduce((closest, current) => {
|
||||
@@ -45,8 +45,8 @@ const ReservationListDialog = ({
|
||||
hideDialog(dialogId)
|
||||
}
|
||||
|
||||
const handleSelect = (sid: number) => {
|
||||
onSelectReservation(String(sid))
|
||||
const handleSelect = (sid: string) => {
|
||||
onSelectReservation(sid)
|
||||
handleOpenChange(false)
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ const SingleMessageSendDialog = ({
|
||||
tmplatIdx: templateIdx,
|
||||
resve: scheduleType === 'reserve',
|
||||
sendDt: scheduleType === 'reserve' ? new Date(reserveAt).toISOString() : undefined,
|
||||
sid: Number(sid),
|
||||
sid,
|
||||
destHeaderIds: [destHeaderId],
|
||||
})
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
const htmlTi = useTextareaInsert(htmlTextareaRef);
|
||||
|
||||
const [view, setView] = useState<ViewMode>("wysiwyg");
|
||||
const [wysiwygKey, setWysiwygKey] = useState<number>(0);
|
||||
const [previewSource, setPreviewSource] = useState(value ?? "");
|
||||
const viewRef = useRef<ViewMode>("wysiwyg");
|
||||
|
||||
@@ -252,7 +251,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
},
|
||||
},
|
||||
},
|
||||
},[wysiwygKey]);
|
||||
}, []);
|
||||
|
||||
const restoreSelection = useCallback(() => {
|
||||
if (!editor) return;
|
||||
@@ -482,21 +481,20 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
const current = editor.getHTML();
|
||||
|
||||
if (normalizedValue !== current && normalizedValue !== optimisticHtmlRef.current) {
|
||||
// 이미지가 포함된 HTML 업데이트면, 아예 editor를 새로 생성
|
||||
// 외부에서 본문이 변경된 경우에만 기존 editor 문서를 갱신한다.
|
||||
editor.commands.setContent(normalizedValue, {
|
||||
emitUpdate: false,
|
||||
parseOptions: {preserveWhitespace: "full"},
|
||||
});
|
||||
|
||||
// resize가 활성화된 TipTap 이미지 NodeView는 노드의 src 변경을 기존 DOM에 반영하지 않는다.
|
||||
// editor 전체 대신 NodeView만 다시 생성해 이미지를 갱신하고 편집 포커스는 유지한다.
|
||||
if (normalizedValue.includes("<img")) {
|
||||
editor.createNodeViews();
|
||||
}
|
||||
}
|
||||
}, [value, editor, view]);
|
||||
|
||||
useEffect(() => {
|
||||
if (value.includes("<img")) {
|
||||
setWysiwygKey((k) => k + 1);
|
||||
return;
|
||||
}
|
||||
}, [value]);
|
||||
|
||||
useEffect(() => {
|
||||
if (!editor) return;
|
||||
|
||||
|
||||
@@ -20,6 +20,23 @@ import { cn } from '@/lib/utils'
|
||||
import { getNearestFutureDateTime } from '@/lib/datetime'
|
||||
import { useCtiLastCallHistId } from '@/hooks/useCtiLastCallHistId'
|
||||
import { getCurrentPositionMeta } from '@kri/common/browser'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import { buildListContactVariableValues } from '@/components/list-contact/listContactVariables'
|
||||
import { substituteVariables } from '@/lib/surveyUrl'
|
||||
import { sanitizeHtml } from '@/components/kri-editor/utils/sanitizeHtml'
|
||||
|
||||
const escapeHtml = (value: string) =>
|
||||
value.replace(
|
||||
/[&<>"']/g,
|
||||
(character) =>
|
||||
({
|
||||
'&': '&',
|
||||
'<': '<',
|
||||
'>': '>',
|
||||
'"': '"',
|
||||
"'": ''',
|
||||
})[character] ?? character,
|
||||
)
|
||||
|
||||
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
|
||||
<Button
|
||||
@@ -124,7 +141,7 @@ const ContactEventSection = ({
|
||||
const isContactType = resultCodeType === ResultCodeType.CONTACT
|
||||
|
||||
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
|
||||
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, Number(sid))
|
||||
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, sid)
|
||||
const listCallHistIdx = isContactType ? ctiLastCallHistId : null
|
||||
|
||||
const handleResultCdChange = (next: string) => {
|
||||
@@ -283,6 +300,8 @@ export type ListContactEventPanelProps = {
|
||||
useFF: boolean
|
||||
useContactSenario: boolean
|
||||
contactSenario?: string
|
||||
listHeaders: listHeader[]
|
||||
detail?: ListSearchWithFullResult
|
||||
}
|
||||
|
||||
const ListContactEventPanel = ({
|
||||
@@ -295,12 +314,23 @@ const ListContactEventPanel = ({
|
||||
useFF,
|
||||
useContactSenario,
|
||||
contactSenario,
|
||||
listHeaders,
|
||||
detail,
|
||||
}: ListContactEventPanelProps) => {
|
||||
const addListEventMutation = useAddListEventMutation(prjctIdx, sid)
|
||||
const reserveMutation = useReserveMutation(prjctIdx, sid)
|
||||
const internalInfoQuery = useInternalInfoQuery()
|
||||
const showContactInput = userRole !== FIELD_INTERVIEWER_ROLE
|
||||
const showInterviewInput = userRole !== CONTACT_INTERVIEWER_ROLE
|
||||
const contactSenarioValues = Object.fromEntries(
|
||||
Object.entries(buildListContactVariableValues(listHeaders, detail, sid)).map(([key, value]) => [
|
||||
key,
|
||||
escapeHtml(value),
|
||||
]),
|
||||
)
|
||||
const resolvedContactSenario = contactSenario
|
||||
? sanitizeHtml(substituteVariables(contactSenario, contactSenarioValues))
|
||||
: ''
|
||||
|
||||
const handleAddEvent =
|
||||
(resultCodeType: ResultCodeType) =>
|
||||
@@ -309,7 +339,7 @@ const ListContactEventPanel = ({
|
||||
|
||||
await addListEventMutation.mutateAsync({
|
||||
prjctIdx,
|
||||
sid: Number(sid),
|
||||
sid,
|
||||
resultCodeType,
|
||||
resultCd,
|
||||
listCallHistIdx,
|
||||
@@ -321,7 +351,7 @@ const ListContactEventPanel = ({
|
||||
})
|
||||
|
||||
if (resveDt) {
|
||||
await reserveMutation.mutateAsync({ prjctIdx, sid: Number(sid), userId, resveDt })
|
||||
await reserveMutation.mutateAsync({ prjctIdx, sid, userId, resveDt })
|
||||
}
|
||||
|
||||
alert('등록되었습니다.')
|
||||
@@ -357,10 +387,10 @@ const ListContactEventPanel = ({
|
||||
}
|
||||
|
||||
|
||||
{useContactSenario && contactSenario ? (
|
||||
{useContactSenario && resolvedContactSenario ? (
|
||||
<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 className="text-base leading-relaxed" dangerouslySetInnerHTML={{ __html: resolvedContactSenario }} />
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
@@ -9,13 +9,12 @@ import { KriSingleSelect } from '@/components/common/KriAutoComplete'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import { useDownloadListItemFileByHeaderMutation, useUploadListItemFileMutation } from '@/query/list'
|
||||
import { ListHeaderConst } from '@/const/listConst'
|
||||
import { LIST_IS_USE_LABEL } from '@/components/table-column/ListTableColumn'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import type { MessageSendChannel } from '@/types/message'
|
||||
import { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { isAssignHeaderType, isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteSurveyUrl } from '@/lib/surveyUrl'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteVariables } from '@/lib/surveyUrl'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||
@@ -24,6 +23,10 @@ import { useCtiConnectionStatus } from '@/hooks/useCtiConnectionStatus'
|
||||
import { useCtiCallPhase } from '@/hooks/useCtiCallPhase'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { downloadFile } from '@kri/common/browser'
|
||||
import {
|
||||
buildListContactVariableValues,
|
||||
resolveListHeaderValue,
|
||||
} from '@/components/list-contact/listContactVariables'
|
||||
|
||||
export type ListContactInfoPanelProps = {
|
||||
prjctIdx: number
|
||||
@@ -41,24 +44,13 @@ export type ListContactInfoPanelProps = {
|
||||
onSaved?: () => void
|
||||
}
|
||||
|
||||
const resolveHeaderValue = (header: listHeader, detail?: ListSearchWithFullResult): string => {
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) return detail?.memo ?? ''
|
||||
if (header.listHderTy === ListHeaderConst.IS_USE) {
|
||||
return detail?.use != null ? (LIST_IS_USE_LABEL[detail.use] ?? '') : ''
|
||||
}
|
||||
if (isAssignHeaderType(header.listHderTy)) {
|
||||
return detail?.assignList?.[header.listHderTy] ?? ''
|
||||
}
|
||||
return detail?.itemList?.[header.listHderId] ?? ''
|
||||
}
|
||||
|
||||
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
|
||||
values[header.listHderId] = resolveHeaderValue(header, detail)
|
||||
values[header.listHderId] = resolveListHeaderValue(header, detail)
|
||||
}
|
||||
|
||||
return values
|
||||
@@ -123,22 +115,16 @@ const ListContactInfoPanel = ({
|
||||
|
||||
const surveyResultByIdx = new Map((detail?.surveyResults ?? []).map((result) => [result.prjctSurveyIdx, result]))
|
||||
|
||||
// 설문 URL 치환은 화면 노출(면접원 노출) 여부와 무관하게 전체 헤더 값을 대상으로 한다.
|
||||
const surveyUrlValues: Record<string, string> = {}
|
||||
for (const header of listHeaders) {
|
||||
if (header.listHderTy === ListHeaderConst.SID) continue
|
||||
surveyUrlValues[header.listHderNm] = resolveHeaderValue(header, detail)
|
||||
}
|
||||
surveyUrlValues.SID = sid // 예약 토큰: 헤더명이 'SID'인 커스텀 헤더가 있어도 항상 실제 sid로 치환한다.
|
||||
const surveyUrlValues = buildListContactVariableValues(listHeaders, detail, sid)
|
||||
|
||||
const handleStartSurvey = (survey: ProjectSurvey) => {
|
||||
if (!survey.surveyUrl) return
|
||||
window.open(substituteSurveyUrl(survey.surveyUrl, surveyUrlValues), '_blank', 'noopener,noreferrer')
|
||||
window.open(substituteVariables(survey.surveyUrl, surveyUrlValues), '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
const handleShowQr = (survey: ProjectSurvey) => {
|
||||
if (!survey.surveyUrl) return
|
||||
setQrTargetUrl(substituteSurveyUrl(survey.surveyUrl, surveyUrlValues))
|
||||
setQrTargetUrl(substituteVariables(survey.surveyUrl, surveyUrlValues))
|
||||
showDialog('surveyQrDialog')
|
||||
}
|
||||
|
||||
@@ -156,7 +142,7 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
if (!telNum) return
|
||||
ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid: Number(sid), listHderId, aniNumber: callerTelNum ?? '' })
|
||||
ctiClient.makeCall({ dialNumber: telNum, prjctIdx, sid, listHderId, aniNumber: callerTelNum ?? '' })
|
||||
}
|
||||
|
||||
const handlePickFile = (listHderId: number) => {
|
||||
|
||||
36
src/components/list-contact/listContactVariables.ts
Normal file
36
src/components/list-contact/listContactVariables.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { LIST_IS_USE_LABEL } from '@/components/table-column/ListTableColumn'
|
||||
import { ListHeaderConst } from '@/const/listConst'
|
||||
import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import { isAssignHeaderType } from '@/utils/listAccess'
|
||||
|
||||
export const resolveListHeaderValue = (
|
||||
header: listHeader,
|
||||
detail?: ListSearchWithFullResult,
|
||||
): string => {
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) return detail?.memo ?? ''
|
||||
if (header.listHderTy === ListHeaderConst.IS_USE) {
|
||||
return detail?.use != null ? (LIST_IS_USE_LABEL[detail.use] ?? '') : ''
|
||||
}
|
||||
if (isAssignHeaderType(header.listHderTy)) {
|
||||
return detail?.assignList?.[header.listHderTy] ?? ''
|
||||
}
|
||||
return detail?.itemList?.[header.listHderId] ?? ''
|
||||
}
|
||||
|
||||
export const buildListContactVariableValues = (
|
||||
listHeaders: listHeader[],
|
||||
detail: ListSearchWithFullResult | undefined,
|
||||
sid: string,
|
||||
): Record<string, string> => {
|
||||
const values: Record<string, string> = {}
|
||||
|
||||
// 화면 노출 여부와 무관하게 전체 헤더 값을 치환 대상으로 사용한다.
|
||||
for (const header of listHeaders) {
|
||||
if (header.listHderTy === ListHeaderConst.SID) continue
|
||||
values[header.listHderNm] = resolveListHeaderValue(header, detail)
|
||||
}
|
||||
|
||||
// 같은 이름의 커스텀 헤더가 있어도 예약 토큰 SID에는 실제 SID를 사용한다.
|
||||
values.SID = sid
|
||||
return values
|
||||
}
|
||||
@@ -26,7 +26,7 @@ export function DateProgressSection({ title, subtitle, rows, resultCodeColumns }
|
||||
const totalSeries = {
|
||||
name: 'Total',
|
||||
data: sortedRows.map((row) => row.totalCount ?? 0),
|
||||
option: { type: 'bar' },
|
||||
option: { type: 'bar', barMaxWidth: 48 },
|
||||
}
|
||||
|
||||
const resultSeries = resultCodeColumns.map(({ resultCd, label }) => ({
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useCallback, useSyncExternalStore } from "react";
|
||||
import { ctiClient } from "@/lib/cti/ctiClient";
|
||||
|
||||
export function useCtiLastCallHistId(prjctIdx: number, sid: number) {
|
||||
export function useCtiLastCallHistId(prjctIdx: number, sid: string) {
|
||||
const getSnapshot = useCallback(
|
||||
() => ctiClient.getLastCallHistIdFor(prjctIdx, sid),
|
||||
[prjctIdx, sid],
|
||||
|
||||
@@ -22,7 +22,7 @@ type CtiLoginParams = {
|
||||
type CtiMakeCallParams = {
|
||||
dialNumber: string;
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
listHderId: number;
|
||||
aniNumber: string;
|
||||
};
|
||||
@@ -32,7 +32,7 @@ export type CtiCallPhase = "idle" | "dialing" | "active";
|
||||
|
||||
type CtiCallContext = {
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
listHderId: number;
|
||||
};
|
||||
|
||||
@@ -42,7 +42,7 @@ type CtiCall = {
|
||||
};
|
||||
|
||||
type PersistedCtiState = {
|
||||
version: 2;
|
||||
version: 3;
|
||||
agentLoginId: string;
|
||||
agentStatus: string | null;
|
||||
activeCall: CtiCall | null;
|
||||
@@ -54,7 +54,25 @@ type PersistedCtiState = {
|
||||
updatedAt: number;
|
||||
};
|
||||
|
||||
const CTI_STATE_VERSION = 2;
|
||||
type LegacyCtiCallContext = Omit<CtiCallContext, "sid"> & {
|
||||
sid: number;
|
||||
};
|
||||
|
||||
type LegacyCtiCall = Omit<CtiCall, "context"> & {
|
||||
context: LegacyCtiCallContext;
|
||||
};
|
||||
|
||||
type LegacyPersistedCtiState = Omit<
|
||||
PersistedCtiState,
|
||||
"version" | "activeCall" | "closingCall" | "lastCallContext"
|
||||
> & {
|
||||
version: 2;
|
||||
activeCall: LegacyCtiCall | null;
|
||||
closingCall: LegacyCtiCall | null;
|
||||
lastCallContext: LegacyCtiCallContext | null;
|
||||
};
|
||||
|
||||
const CTI_STATE_VERSION = 3;
|
||||
const CTI_STATE_TTL_MS = 24 * 60 * 60 * 1000;
|
||||
|
||||
let socket: WebSocket | null = null;
|
||||
@@ -92,6 +110,19 @@ const isCallInProgress = () =>
|
||||
const isCallContext = (value: unknown): value is CtiCallContext => {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
const context = value as Partial<CtiCallContext>;
|
||||
return (
|
||||
typeof context.prjctIdx === "number" &&
|
||||
Number.isFinite(context.prjctIdx) &&
|
||||
typeof context.sid === "string" &&
|
||||
context.sid.length > 0 &&
|
||||
typeof context.listHderId === "number" &&
|
||||
Number.isFinite(context.listHderId)
|
||||
);
|
||||
};
|
||||
|
||||
const isLegacyCallContext = (value: unknown): value is LegacyCtiCallContext => {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
const context = value as Partial<LegacyCtiCallContext>;
|
||||
return (
|
||||
typeof context.prjctIdx === "number" &&
|
||||
Number.isFinite(context.prjctIdx) &&
|
||||
@@ -111,6 +142,15 @@ const isCtiCall = (value: unknown): value is CtiCall => {
|
||||
);
|
||||
};
|
||||
|
||||
const isLegacyCtiCall = (value: unknown): value is LegacyCtiCall => {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
const call = value as Partial<LegacyCtiCall>;
|
||||
return (
|
||||
isLegacyCallContext(call.context) &&
|
||||
(call.agentSessionId === null || typeof call.agentSessionId === "string")
|
||||
);
|
||||
};
|
||||
|
||||
const isPersistedCtiState = (value: unknown): value is PersistedCtiState => {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
const state = value as Partial<PersistedCtiState>;
|
||||
@@ -128,6 +168,48 @@ const isPersistedCtiState = (value: unknown): value is PersistedCtiState => {
|
||||
);
|
||||
};
|
||||
|
||||
const isLegacyPersistedCtiState = (value: unknown): value is LegacyPersistedCtiState => {
|
||||
if (typeof value !== "object" || value === null) return false;
|
||||
const state = value as Partial<LegacyPersistedCtiState>;
|
||||
return (
|
||||
state.version === 2 &&
|
||||
typeof state.agentLoginId === "string" &&
|
||||
(state.agentStatus === null || typeof state.agentStatus === "string") &&
|
||||
(state.activeCall === null || isLegacyCtiCall(state.activeCall)) &&
|
||||
(state.closingCall === null || isLegacyCtiCall(state.closingCall)) &&
|
||||
(state.lastCallContext === null || isLegacyCallContext(state.lastCallContext)) &&
|
||||
(state.lastCallHistId === null || typeof state.lastCallHistId === "number") &&
|
||||
typeof state.hangupRequested === "boolean" &&
|
||||
typeof state.callClosedReceived === "boolean" &&
|
||||
typeof state.updatedAt === "number"
|
||||
);
|
||||
};
|
||||
|
||||
const migrateLegacyCallContext = (context: LegacyCtiCallContext): CtiCallContext => ({
|
||||
...context,
|
||||
sid: String(context.sid),
|
||||
});
|
||||
|
||||
const migrateLegacyCall = (call: LegacyCtiCall | null): CtiCall | null =>
|
||||
call
|
||||
? {
|
||||
...call,
|
||||
context: migrateLegacyCallContext(call.context),
|
||||
}
|
||||
: null;
|
||||
|
||||
const toPersistedCtiState = (value: unknown): PersistedCtiState | null => {
|
||||
if (isPersistedCtiState(value)) return value;
|
||||
if (!isLegacyPersistedCtiState(value)) return null;
|
||||
return {
|
||||
...value,
|
||||
version: CTI_STATE_VERSION,
|
||||
activeCall: migrateLegacyCall(value.activeCall),
|
||||
closingCall: migrateLegacyCall(value.closingCall),
|
||||
lastCallContext: value.lastCallContext ? migrateLegacyCallContext(value.lastCallContext) : null,
|
||||
};
|
||||
};
|
||||
|
||||
const persistCtiState = () => {
|
||||
if (!currentAgentLoginId) return;
|
||||
setLocalStorage(StorageKeys.CtiState, {
|
||||
@@ -146,22 +228,24 @@ const persistCtiState = () => {
|
||||
|
||||
const restoreCtiState = (agentLoginId: string) => {
|
||||
const stored = getLocalStorage(StorageKeys.CtiState);
|
||||
const persistedState = toPersistedCtiState(stored);
|
||||
if (
|
||||
!isPersistedCtiState(stored) ||
|
||||
stored.agentLoginId !== agentLoginId ||
|
||||
Date.now() - stored.updatedAt > CTI_STATE_TTL_MS
|
||||
!persistedState ||
|
||||
persistedState.agentLoginId !== agentLoginId ||
|
||||
Date.now() - persistedState.updatedAt > CTI_STATE_TTL_MS
|
||||
) {
|
||||
if (stored !== null) removeLocalStorage(StorageKeys.CtiState);
|
||||
return false;
|
||||
}
|
||||
|
||||
agentStatus = stored.agentStatus;
|
||||
activeCall = stored.activeCall;
|
||||
closingCall = stored.closingCall;
|
||||
lastCallContext = stored.lastCallContext;
|
||||
lastCallHistId = stored.lastCallHistId;
|
||||
hangupRequested = stored.hangupRequested;
|
||||
callClosedReceived = stored.callClosedReceived;
|
||||
agentStatus = persistedState.agentStatus;
|
||||
activeCall = persistedState.activeCall;
|
||||
closingCall = persistedState.closingCall;
|
||||
lastCallContext = persistedState.lastCallContext;
|
||||
lastCallHistId = persistedState.lastCallHistId;
|
||||
hangupRequested = persistedState.hangupRequested;
|
||||
callClosedReceived = persistedState.callClosedReceived;
|
||||
if (persistedState !== stored) persistCtiState();
|
||||
notify();
|
||||
return true;
|
||||
};
|
||||
@@ -324,7 +408,7 @@ const saveCallHistory = (parsed: Record<string, unknown>, phase: "start" | "clos
|
||||
const action = phase === "start" ? "call-start" : "call-close";
|
||||
console.log(`[CTI][TEMP_LOG] saving ${action}`, { prjctIdx, sid, body }); // TEMP_CTI_LOG
|
||||
nextApi
|
||||
.put<ListCallHist>(`/list-call-hist/${prjctIdx}/${sid}/${action}`, body)
|
||||
.put<ListCallHist>(`/list-call-hist/${prjctIdx}/${encodeURIComponent(sid)}/${action}`, body)
|
||||
.then((result) => {
|
||||
console.log(`[CTI][TEMP_LOG] ${action} saved, listCallHistIdx =`, result?.listCallHistIdx); // TEMP_CTI_LOG
|
||||
lastCallContext = callContext;
|
||||
@@ -570,7 +654,7 @@ export const ctiClient = {
|
||||
},
|
||||
getConnectionState: () => connectionState,
|
||||
getCallPhase,
|
||||
getLastCallHistIdFor: (prjctIdx: number, sid: number) =>
|
||||
getLastCallHistIdFor: (prjctIdx: number, sid: string) =>
|
||||
lastCallContext?.prjctIdx === prjctIdx && lastCallContext.sid === sid ? lastCallHistId : null,
|
||||
makeCall: (params: CtiMakeCallParams) => {
|
||||
if (!currentAgentLoginId) return;
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
// project.surveyUrl에 들어있는 [$SID], [$헤더명] 치환 토큰을 values에 있는 값으로 바꾼다.
|
||||
// 값이 없는 토큰은 빈 문자열로 치환한다(URL에 인코딩되지 않은 대괄호가 남지 않도록).
|
||||
// 참고: src/app/(pages)/(main)/project/info/page.tsx의 sidParam = 'sid=[$SID]'와 동일한 토큰.
|
||||
export const substituteSurveyUrl = (surveyUrl: string, values: Record<string, string>) =>
|
||||
surveyUrl.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");
|
||||
// 문자열에 들어있는 [$SID], [$헤더명] 치환 토큰을 values에 있는 값으로 바꾼다.
|
||||
// 값이 없는 토큰은 빈 문자열로 치환한다.
|
||||
export const substituteVariables = (contents: string, values: Record<string, string>) =>
|
||||
contents.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");
|
||||
|
||||
@@ -79,7 +79,7 @@ export function useListSearchQuery(prjctIdx: number, request: ListSearchRequest,
|
||||
export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listDetail(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListSearchWithFullResult>(`/list/search-sid/${prjctIdx}/${sid}`),
|
||||
queryFn: () => nextApi.get<ListSearchWithFullResult>(`/list/search-sid/${prjctIdx}/${encodeURIComponent(sid)}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
@@ -92,7 +92,7 @@ export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boole
|
||||
export function useListEventHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listEventHistory(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListEventHistory[]>(`/list-hist/event/${prjctIdx}/${sid}`),
|
||||
queryFn: () => nextApi.get<ListEventHistory[]>(`/list-hist/event/${prjctIdx}/${encodeURIComponent(sid)}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
@@ -103,7 +103,7 @@ export function useListEventHistoryQuery(prjctIdx: number, sid: string, enabled:
|
||||
export function useListUpdateHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listUpdateHistory(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListUpdateHistory[]>(`/list-hist/update/${prjctIdx}/${sid}`),
|
||||
queryFn: () => nextApi.get<ListUpdateHistory[]>(`/list-hist/update/${prjctIdx}/${encodeURIComponent(sid)}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
@@ -114,7 +114,7 @@ export function useListUpdateHistoryQuery(prjctIdx: number, sid: string, enabled
|
||||
export function useListReserveBySidQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listReserveBySid(prjctIdx, sid),
|
||||
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/sid/${prjctIdx}/${sid}`),
|
||||
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/sid/${prjctIdx}/${encodeURIComponent(sid)}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
@@ -154,7 +154,7 @@ export function useUploadListItemFileMutation(prjctIdx: number, sid: string) {
|
||||
mutationFn: ({ listHderId, file }: { listHderId: number; file: File }) => {
|
||||
const formData = new FormData();
|
||||
formData.append(String(listHderId), file);
|
||||
return nextApi.postForm<void>(`/list/item-file-upload/${prjctIdx}/${sid}`, formData);
|
||||
return nextApi.postForm<void>(`/list/item-file-upload/${prjctIdx}/${encodeURIComponent(sid)}`, formData);
|
||||
},
|
||||
onSuccess: async () => {
|
||||
await queryClient.invalidateQueries({ queryKey: qk.listDetail(prjctIdx, sid) });
|
||||
@@ -165,7 +165,7 @@ export function useUploadListItemFileMutation(prjctIdx: number, sid: string) {
|
||||
export function useDownloadListItemFileByHeaderMutation(prjctIdx: number, sid: string) {
|
||||
return useMutation({
|
||||
mutationFn: (listHderId: number) =>
|
||||
nextApi.get<ArrayBuffer>(`/list/item-file-download/${prjctIdx}/${sid}/${listHderId}`, {
|
||||
nextApi.get<ArrayBuffer>(`/list/item-file-download/${prjctIdx}/${encodeURIComponent(sid)}/${listHderId}`, {
|
||||
expectBinary: true,
|
||||
}),
|
||||
});
|
||||
|
||||
@@ -194,7 +194,9 @@ export function useSendResultBySidQuery(
|
||||
queryKey: qk.sendResultBySid(sid, prjctCd, reqstSvc, channelTy),
|
||||
queryFn: () => {
|
||||
const query = channelTy !== undefined ? `?channelTy=${channelTy}` : "";
|
||||
return nextApi.get<SendResultInfo[]>(`/message-report/send-result/${sid}/${prjctCd}/${reqstSvc}${query}`);
|
||||
return nextApi.get<SendResultInfo[]>(
|
||||
`/message-report/send-result/${encodeURIComponent(sid)}/${prjctCd}/${reqstSvc}${query}`,
|
||||
);
|
||||
},
|
||||
enabled: enabled && !!sid && !!prjctCd && !!reqstSvc,
|
||||
staleTime: 0,
|
||||
|
||||
@@ -35,6 +35,6 @@ export type ExternalEventMeta = {
|
||||
export type ExternalEventBody = {
|
||||
action: ExternalActionCode;
|
||||
prjctSurveyIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
meta: ExternalEventMeta;
|
||||
};
|
||||
|
||||
@@ -198,6 +198,7 @@ export type ListUploadHistory = {
|
||||
uploadMode: ListUploadMode;
|
||||
regUser: string;
|
||||
regDt: string;
|
||||
schedulingDelDt: string;
|
||||
};
|
||||
|
||||
export type ListUpdateRequest = {
|
||||
@@ -216,7 +217,7 @@ export type ListEventInsertMeta = {
|
||||
|
||||
export type ListEventInsertRequest = {
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
resultCodeType: ResultCodeType;
|
||||
resultCd: number;
|
||||
listCallHistIdx?: number | null;
|
||||
@@ -228,7 +229,7 @@ export type ListEventHistory = {
|
||||
listEventHistIdx: number;
|
||||
eventTy: ResultCodeType;
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
resultCd: number;
|
||||
metaData?: string;
|
||||
listCallHistIdx?: number;
|
||||
@@ -240,7 +241,7 @@ export type ListEventHistory = {
|
||||
export type ListUpdateHistory = {
|
||||
listUpdateHistIdx: number;
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
listHderId: number;
|
||||
beforeVal?: string;
|
||||
afterVal?: string;
|
||||
@@ -251,7 +252,7 @@ export type ListUpdateHistory = {
|
||||
export type ListReserve = {
|
||||
listResveIdx: number;
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
memo?: string;
|
||||
cnfirm: boolean;
|
||||
resveDt: string;
|
||||
@@ -282,7 +283,7 @@ export type ListCallCloseRequest = ListCallStartRequest & {
|
||||
export type ListCallHist = ListCallCloseRequest & {
|
||||
listCallHistIdx: number;
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
callStatus: 2 | 4 | 9;
|
||||
endDt?: string;
|
||||
regUser: string;
|
||||
@@ -293,7 +294,7 @@ export type ListCallHistSession = ListCallHist;
|
||||
|
||||
export type ListReserveRequest = {
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
userId: string;
|
||||
resveDt: string;
|
||||
};
|
||||
@@ -349,7 +350,7 @@ export type SurveyResult = {
|
||||
|
||||
export type ListSearchBase = {
|
||||
prjctIdx: number;
|
||||
sid: number;
|
||||
sid: string;
|
||||
use: ListIsUse;
|
||||
assignList: Record<ListHeaderAssignType, string>;
|
||||
memo: string;
|
||||
|
||||
@@ -6,7 +6,7 @@ export type MessageSendSingleRequest = {
|
||||
tmplatIdx: number;
|
||||
resve: boolean;
|
||||
sendDt?: string;
|
||||
sid: number;
|
||||
sid: string;
|
||||
destHeaderIds: number[];
|
||||
destNameHeaderId?: number;
|
||||
};
|
||||
@@ -21,7 +21,7 @@ export type MessageSendBulkRequest = {
|
||||
};
|
||||
|
||||
export type MessageFailedChunk = {
|
||||
sidList?: number[];
|
||||
sidList?: string[];
|
||||
reason?: string;
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user