260728_02_ENH: SID String으로 교체 #14
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;
|
return Number.isSafeInteger(parsed) && parsed > 0 ? parsed : null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const toRequiredSid = (value: string): string | null =>
|
||||||
|
value.length > 0 ? value : null;
|
||||||
|
|
||||||
const buildExternalEventBody = (
|
const buildExternalEventBody = (
|
||||||
req: NextRequest,
|
req: NextRequest,
|
||||||
action: ExternalAction,
|
action: ExternalAction,
|
||||||
prjctSurveyIdx: number,
|
prjctSurveyIdx: number,
|
||||||
sid: number,
|
sid: string,
|
||||||
): ExternalEventBody => {
|
): ExternalEventBody => {
|
||||||
const pathname = req.nextUrl.pathname;
|
const pathname = req.nextUrl.pathname;
|
||||||
const h = req.headers;
|
const h = req.headers;
|
||||||
@@ -51,7 +54,7 @@ const buildExternalEventBody = (
|
|||||||
entryType: getEntryTypeCode(h),
|
entryType: getEntryTypeCode(h),
|
||||||
action: actionCode,
|
action: actionCode,
|
||||||
psidx: String(prjctSurveyIdx),
|
psidx: String(prjctSurveyIdx),
|
||||||
sid: String(sid),
|
sid,
|
||||||
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
remoteAddr: getHeader(h, "x-orig-ip") || getClientIp(req),
|
||||||
uri: getHeader(h, "x-orig-uri") || pathname,
|
uri: getHeader(h, "x-orig-uri") || pathname,
|
||||||
url: getHeader(h, "x-orig-url") || req.url,
|
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 prjctSurveyIdx = toRequiredNumber((searchParams.get("psidx") ?? "").trim());
|
||||||
const sid = toRequiredNumber((searchParams.get("sid") ?? "").trim());
|
const sid = toRequiredSid((searchParams.get("sid") ?? "").trim());
|
||||||
|
|
||||||
if (!prjctSurveyIdx || !sid) {
|
if (!prjctSurveyIdx || !sid) {
|
||||||
return NextResponse.json({ message: "psidx, sid는 필수입니다." }, { status: 400 });
|
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 contactApi = await createContactApi();
|
||||||
const result = await contactApi.put<ListCallHist>(
|
const result = await contactApi.put<ListCallHist>(
|
||||||
`/list-call-hist/${prjctIdx}/${sid}/${action}`,
|
`/list-call-hist/${prjctIdx}/${encodeURIComponent(sid)}/${action}`,
|
||||||
body,
|
body,
|
||||||
);
|
);
|
||||||
return NextResponse.json(result, { status: 200 });
|
return NextResponse.json(result, { status: 200 });
|
||||||
|
|||||||
@@ -11,12 +11,16 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
|||||||
const contactApi = await createContactApi();
|
const contactApi = await createContactApi();
|
||||||
|
|
||||||
if (action === "event" && slug.length === 3) {
|
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 });
|
return NextResponse.json(result, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === "update" && slug.length === 3) {
|
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 });
|
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) {
|
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 });
|
return NextResponse.json(result, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action === "item-file-download" && slug.length === 4) {
|
if (action === "item-file-download" && slug.length === 4) {
|
||||||
const result = await contactApi.get<ArrayBuffer>(
|
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 },
|
{ expectBinary: true },
|
||||||
);
|
);
|
||||||
return new NextResponse(result, {
|
return new NextResponse(result, {
|
||||||
@@ -94,7 +96,7 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
|||||||
|
|
||||||
if (action === "item-file-upload" && slug.length === 3) {
|
if (action === "item-file-upload" && slug.length === 3) {
|
||||||
const form = await req.formData();
|
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 });
|
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 channelTy = req.nextUrl.searchParams.get("channelTy");
|
||||||
const query = channelTy ? `?channelTy=${channelTy}` : "";
|
const query = channelTy ? `?channelTy=${channelTy}` : "";
|
||||||
const result = await notihubApi.get<SendResultInfo[]>(
|
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});
|
return NextResponse.json(result, {status: 200});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,7 +11,9 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
|||||||
const contactApi = await createContactApi();
|
const contactApi = await createContactApi();
|
||||||
|
|
||||||
if (action === "sid" && slug.length === 3) {
|
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 });
|
return NextResponse.json(result, { status: 200 });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export function usePagination({ currentPage, totalPages, paginationItemsToDispla
|
|||||||
const visibleCount = Math.max(1, paginationItemsToDisplay)
|
const visibleCount = Math.max(1, paginationItemsToDisplay)
|
||||||
const half = Math.floor(visibleCount / 2)
|
const half = Math.floor(visibleCount / 2)
|
||||||
let startPage = Math.max(1, currentPage - half)
|
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) {
|
if (endPage - startPage + 1 < visibleCount) {
|
||||||
startPage = Math.max(1, endPage - visibleCount + 1)
|
startPage = Math.max(1, endPage - visibleCount + 1)
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export type ReservationListDialogProps = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 오늘과 가장 가까운(과거/미래 무관) 예약의 sid를 찾는다.
|
// 오늘과 가장 가까운(과거/미래 무관) 예약의 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
|
if (reservations.length === 0) return null
|
||||||
|
|
||||||
return reservations.reduce((closest, current) => {
|
return reservations.reduce((closest, current) => {
|
||||||
@@ -45,8 +45,8 @@ const ReservationListDialog = ({
|
|||||||
hideDialog(dialogId)
|
hideDialog(dialogId)
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleSelect = (sid: number) => {
|
const handleSelect = (sid: string) => {
|
||||||
onSelectReservation(String(sid))
|
onSelectReservation(sid)
|
||||||
handleOpenChange(false)
|
handleOpenChange(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ const SingleMessageSendDialog = ({
|
|||||||
tmplatIdx: templateIdx,
|
tmplatIdx: templateIdx,
|
||||||
resve: scheduleType === 'reserve',
|
resve: scheduleType === 'reserve',
|
||||||
sendDt: scheduleType === 'reserve' ? new Date(reserveAt).toISOString() : undefined,
|
sendDt: scheduleType === 'reserve' ? new Date(reserveAt).toISOString() : undefined,
|
||||||
sid: Number(sid),
|
sid,
|
||||||
destHeaderIds: [destHeaderId],
|
destHeaderIds: [destHeaderId],
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ const ContactEventSection = ({
|
|||||||
const isContactType = resultCodeType === ResultCodeType.CONTACT
|
const isContactType = resultCodeType === ResultCodeType.CONTACT
|
||||||
|
|
||||||
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
|
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
|
||||||
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, Number(sid))
|
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, sid)
|
||||||
const listCallHistIdx = isContactType ? ctiLastCallHistId : null
|
const listCallHistIdx = isContactType ? ctiLastCallHistId : null
|
||||||
|
|
||||||
const handleResultCdChange = (next: string) => {
|
const handleResultCdChange = (next: string) => {
|
||||||
@@ -309,7 +309,7 @@ const ListContactEventPanel = ({
|
|||||||
|
|
||||||
await addListEventMutation.mutateAsync({
|
await addListEventMutation.mutateAsync({
|
||||||
prjctIdx,
|
prjctIdx,
|
||||||
sid: Number(sid),
|
sid,
|
||||||
resultCodeType,
|
resultCodeType,
|
||||||
resultCd,
|
resultCd,
|
||||||
listCallHistIdx,
|
listCallHistIdx,
|
||||||
@@ -321,7 +321,7 @@ const ListContactEventPanel = ({
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (resveDt) {
|
if (resveDt) {
|
||||||
await reserveMutation.mutateAsync({ prjctIdx, sid: Number(sid), userId, resveDt })
|
await reserveMutation.mutateAsync({ prjctIdx, sid, userId, resveDt })
|
||||||
}
|
}
|
||||||
|
|
||||||
alert('등록되었습니다.')
|
alert('등록되었습니다.')
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ const ListContactInfoPanel = ({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!telNum) return
|
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) => {
|
const handlePickFile = (listHderId: number) => {
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
import { useCallback, useSyncExternalStore } from "react";
|
import { useCallback, useSyncExternalStore } from "react";
|
||||||
import { ctiClient } from "@/lib/cti/ctiClient";
|
import { ctiClient } from "@/lib/cti/ctiClient";
|
||||||
|
|
||||||
export function useCtiLastCallHistId(prjctIdx: number, sid: number) {
|
export function useCtiLastCallHistId(prjctIdx: number, sid: string) {
|
||||||
const getSnapshot = useCallback(
|
const getSnapshot = useCallback(
|
||||||
() => ctiClient.getLastCallHistIdFor(prjctIdx, sid),
|
() => ctiClient.getLastCallHistIdFor(prjctIdx, sid),
|
||||||
[prjctIdx, sid],
|
[prjctIdx, sid],
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ type CtiLoginParams = {
|
|||||||
type CtiMakeCallParams = {
|
type CtiMakeCallParams = {
|
||||||
dialNumber: string;
|
dialNumber: string;
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
listHderId: number;
|
listHderId: number;
|
||||||
aniNumber: string;
|
aniNumber: string;
|
||||||
};
|
};
|
||||||
@@ -32,7 +32,7 @@ export type CtiCallPhase = "idle" | "dialing" | "active";
|
|||||||
|
|
||||||
type CtiCallContext = {
|
type CtiCallContext = {
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
listHderId: number;
|
listHderId: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -42,7 +42,7 @@ type CtiCall = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
type PersistedCtiState = {
|
type PersistedCtiState = {
|
||||||
version: 2;
|
version: 3;
|
||||||
agentLoginId: string;
|
agentLoginId: string;
|
||||||
agentStatus: string | null;
|
agentStatus: string | null;
|
||||||
activeCall: CtiCall | null;
|
activeCall: CtiCall | null;
|
||||||
@@ -54,7 +54,25 @@ type PersistedCtiState = {
|
|||||||
updatedAt: number;
|
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;
|
const CTI_STATE_TTL_MS = 24 * 60 * 60 * 1000;
|
||||||
|
|
||||||
let socket: WebSocket | null = null;
|
let socket: WebSocket | null = null;
|
||||||
@@ -92,6 +110,19 @@ const isCallInProgress = () =>
|
|||||||
const isCallContext = (value: unknown): value is CtiCallContext => {
|
const isCallContext = (value: unknown): value is CtiCallContext => {
|
||||||
if (typeof value !== "object" || value === null) return false;
|
if (typeof value !== "object" || value === null) return false;
|
||||||
const context = value as Partial<CtiCallContext>;
|
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 (
|
return (
|
||||||
typeof context.prjctIdx === "number" &&
|
typeof context.prjctIdx === "number" &&
|
||||||
Number.isFinite(context.prjctIdx) &&
|
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 => {
|
const isPersistedCtiState = (value: unknown): value is PersistedCtiState => {
|
||||||
if (typeof value !== "object" || value === null) return false;
|
if (typeof value !== "object" || value === null) return false;
|
||||||
const state = value as Partial<PersistedCtiState>;
|
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 = () => {
|
const persistCtiState = () => {
|
||||||
if (!currentAgentLoginId) return;
|
if (!currentAgentLoginId) return;
|
||||||
setLocalStorage(StorageKeys.CtiState, {
|
setLocalStorage(StorageKeys.CtiState, {
|
||||||
@@ -146,22 +228,24 @@ const persistCtiState = () => {
|
|||||||
|
|
||||||
const restoreCtiState = (agentLoginId: string) => {
|
const restoreCtiState = (agentLoginId: string) => {
|
||||||
const stored = getLocalStorage(StorageKeys.CtiState);
|
const stored = getLocalStorage(StorageKeys.CtiState);
|
||||||
|
const persistedState = toPersistedCtiState(stored);
|
||||||
if (
|
if (
|
||||||
!isPersistedCtiState(stored) ||
|
!persistedState ||
|
||||||
stored.agentLoginId !== agentLoginId ||
|
persistedState.agentLoginId !== agentLoginId ||
|
||||||
Date.now() - stored.updatedAt > CTI_STATE_TTL_MS
|
Date.now() - persistedState.updatedAt > CTI_STATE_TTL_MS
|
||||||
) {
|
) {
|
||||||
if (stored !== null) removeLocalStorage(StorageKeys.CtiState);
|
if (stored !== null) removeLocalStorage(StorageKeys.CtiState);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
agentStatus = stored.agentStatus;
|
agentStatus = persistedState.agentStatus;
|
||||||
activeCall = stored.activeCall;
|
activeCall = persistedState.activeCall;
|
||||||
closingCall = stored.closingCall;
|
closingCall = persistedState.closingCall;
|
||||||
lastCallContext = stored.lastCallContext;
|
lastCallContext = persistedState.lastCallContext;
|
||||||
lastCallHistId = stored.lastCallHistId;
|
lastCallHistId = persistedState.lastCallHistId;
|
||||||
hangupRequested = stored.hangupRequested;
|
hangupRequested = persistedState.hangupRequested;
|
||||||
callClosedReceived = stored.callClosedReceived;
|
callClosedReceived = persistedState.callClosedReceived;
|
||||||
|
if (persistedState !== stored) persistCtiState();
|
||||||
notify();
|
notify();
|
||||||
return true;
|
return true;
|
||||||
};
|
};
|
||||||
@@ -324,7 +408,7 @@ const saveCallHistory = (parsed: Record<string, unknown>, phase: "start" | "clos
|
|||||||
const action = phase === "start" ? "call-start" : "call-close";
|
const action = phase === "start" ? "call-start" : "call-close";
|
||||||
console.log(`[CTI][TEMP_LOG] saving ${action}`, { prjctIdx, sid, body }); // TEMP_CTI_LOG
|
console.log(`[CTI][TEMP_LOG] saving ${action}`, { prjctIdx, sid, body }); // TEMP_CTI_LOG
|
||||||
nextApi
|
nextApi
|
||||||
.put<ListCallHist>(`/list-call-hist/${prjctIdx}/${sid}/${action}`, body)
|
.put<ListCallHist>(`/list-call-hist/${prjctIdx}/${encodeURIComponent(sid)}/${action}`, body)
|
||||||
.then((result) => {
|
.then((result) => {
|
||||||
console.log(`[CTI][TEMP_LOG] ${action} saved, listCallHistIdx =`, result?.listCallHistIdx); // TEMP_CTI_LOG
|
console.log(`[CTI][TEMP_LOG] ${action} saved, listCallHistIdx =`, result?.listCallHistIdx); // TEMP_CTI_LOG
|
||||||
lastCallContext = callContext;
|
lastCallContext = callContext;
|
||||||
@@ -570,7 +654,7 @@ export const ctiClient = {
|
|||||||
},
|
},
|
||||||
getConnectionState: () => connectionState,
|
getConnectionState: () => connectionState,
|
||||||
getCallPhase,
|
getCallPhase,
|
||||||
getLastCallHistIdFor: (prjctIdx: number, sid: number) =>
|
getLastCallHistIdFor: (prjctIdx: number, sid: string) =>
|
||||||
lastCallContext?.prjctIdx === prjctIdx && lastCallContext.sid === sid ? lastCallHistId : null,
|
lastCallContext?.prjctIdx === prjctIdx && lastCallContext.sid === sid ? lastCallHistId : null,
|
||||||
makeCall: (params: CtiMakeCallParams) => {
|
makeCall: (params: CtiMakeCallParams) => {
|
||||||
if (!currentAgentLoginId) return;
|
if (!currentAgentLoginId) return;
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ export function useListSearchQuery(prjctIdx: number, request: ListSearchRequest,
|
|||||||
export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: qk.listDetail(prjctIdx, sid),
|
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,
|
enabled,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
refetchOnMount: "always",
|
refetchOnMount: "always",
|
||||||
@@ -92,7 +92,7 @@ export function useListDetailQuery(prjctIdx: number, sid: string, enabled: boole
|
|||||||
export function useListEventHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
export function useListEventHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: qk.listEventHistory(prjctIdx, sid),
|
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,
|
enabled,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
refetchOnMount: "always",
|
refetchOnMount: "always",
|
||||||
@@ -103,7 +103,7 @@ export function useListEventHistoryQuery(prjctIdx: number, sid: string, enabled:
|
|||||||
export function useListUpdateHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
export function useListUpdateHistoryQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: qk.listUpdateHistory(prjctIdx, sid),
|
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,
|
enabled,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
refetchOnMount: "always",
|
refetchOnMount: "always",
|
||||||
@@ -114,7 +114,7 @@ export function useListUpdateHistoryQuery(prjctIdx: number, sid: string, enabled
|
|||||||
export function useListReserveBySidQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
export function useListReserveBySidQuery(prjctIdx: number, sid: string, enabled: boolean) {
|
||||||
return useQuery({
|
return useQuery({
|
||||||
queryKey: qk.listReserveBySid(prjctIdx, sid),
|
queryKey: qk.listReserveBySid(prjctIdx, sid),
|
||||||
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/sid/${prjctIdx}/${sid}`),
|
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/sid/${prjctIdx}/${encodeURIComponent(sid)}`),
|
||||||
enabled,
|
enabled,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
refetchOnMount: "always",
|
refetchOnMount: "always",
|
||||||
@@ -154,7 +154,7 @@ export function useUploadListItemFileMutation(prjctIdx: number, sid: string) {
|
|||||||
mutationFn: ({ listHderId, file }: { listHderId: number; file: File }) => {
|
mutationFn: ({ listHderId, file }: { listHderId: number; file: File }) => {
|
||||||
const formData = new FormData();
|
const formData = new FormData();
|
||||||
formData.append(String(listHderId), file);
|
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 () => {
|
onSuccess: async () => {
|
||||||
await queryClient.invalidateQueries({ queryKey: qk.listDetail(prjctIdx, sid) });
|
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) {
|
export function useDownloadListItemFileByHeaderMutation(prjctIdx: number, sid: string) {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (listHderId: number) =>
|
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,
|
expectBinary: true,
|
||||||
}),
|
}),
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -194,7 +194,9 @@ export function useSendResultBySidQuery(
|
|||||||
queryKey: qk.sendResultBySid(sid, prjctCd, reqstSvc, channelTy),
|
queryKey: qk.sendResultBySid(sid, prjctCd, reqstSvc, channelTy),
|
||||||
queryFn: () => {
|
queryFn: () => {
|
||||||
const query = channelTy !== undefined ? `?channelTy=${channelTy}` : "";
|
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,
|
enabled: enabled && !!sid && !!prjctCd && !!reqstSvc,
|
||||||
staleTime: 0,
|
staleTime: 0,
|
||||||
|
|||||||
@@ -35,6 +35,6 @@ export type ExternalEventMeta = {
|
|||||||
export type ExternalEventBody = {
|
export type ExternalEventBody = {
|
||||||
action: ExternalActionCode;
|
action: ExternalActionCode;
|
||||||
prjctSurveyIdx: number;
|
prjctSurveyIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
meta: ExternalEventMeta;
|
meta: ExternalEventMeta;
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ export type ListEventInsertMeta = {
|
|||||||
|
|
||||||
export type ListEventInsertRequest = {
|
export type ListEventInsertRequest = {
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
resultCodeType: ResultCodeType;
|
resultCodeType: ResultCodeType;
|
||||||
resultCd: number;
|
resultCd: number;
|
||||||
listCallHistIdx?: number | null;
|
listCallHistIdx?: number | null;
|
||||||
@@ -228,7 +228,7 @@ export type ListEventHistory = {
|
|||||||
listEventHistIdx: number;
|
listEventHistIdx: number;
|
||||||
eventTy: ResultCodeType;
|
eventTy: ResultCodeType;
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
resultCd: number;
|
resultCd: number;
|
||||||
metaData?: string;
|
metaData?: string;
|
||||||
listCallHistIdx?: number;
|
listCallHistIdx?: number;
|
||||||
@@ -240,7 +240,7 @@ export type ListEventHistory = {
|
|||||||
export type ListUpdateHistory = {
|
export type ListUpdateHistory = {
|
||||||
listUpdateHistIdx: number;
|
listUpdateHistIdx: number;
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
listHderId: number;
|
listHderId: number;
|
||||||
beforeVal?: string;
|
beforeVal?: string;
|
||||||
afterVal?: string;
|
afterVal?: string;
|
||||||
@@ -251,7 +251,7 @@ export type ListUpdateHistory = {
|
|||||||
export type ListReserve = {
|
export type ListReserve = {
|
||||||
listResveIdx: number;
|
listResveIdx: number;
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
memo?: string;
|
memo?: string;
|
||||||
cnfirm: boolean;
|
cnfirm: boolean;
|
||||||
resveDt: string;
|
resveDt: string;
|
||||||
@@ -282,7 +282,7 @@ export type ListCallCloseRequest = ListCallStartRequest & {
|
|||||||
export type ListCallHist = ListCallCloseRequest & {
|
export type ListCallHist = ListCallCloseRequest & {
|
||||||
listCallHistIdx: number;
|
listCallHistIdx: number;
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
callStatus: 2 | 4 | 9;
|
callStatus: 2 | 4 | 9;
|
||||||
endDt?: string;
|
endDt?: string;
|
||||||
regUser: string;
|
regUser: string;
|
||||||
@@ -293,7 +293,7 @@ export type ListCallHistSession = ListCallHist;
|
|||||||
|
|
||||||
export type ListReserveRequest = {
|
export type ListReserveRequest = {
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
userId: string;
|
userId: string;
|
||||||
resveDt: string;
|
resveDt: string;
|
||||||
};
|
};
|
||||||
@@ -349,7 +349,7 @@ export type SurveyResult = {
|
|||||||
|
|
||||||
export type ListSearchBase = {
|
export type ListSearchBase = {
|
||||||
prjctIdx: number;
|
prjctIdx: number;
|
||||||
sid: number;
|
sid: string;
|
||||||
use: ListIsUse;
|
use: ListIsUse;
|
||||||
assignList: Record<ListHeaderAssignType, string>;
|
assignList: Record<ListHeaderAssignType, string>;
|
||||||
memo: string;
|
memo: string;
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ export type MessageSendSingleRequest = {
|
|||||||
tmplatIdx: number;
|
tmplatIdx: number;
|
||||||
resve: boolean;
|
resve: boolean;
|
||||||
sendDt?: string;
|
sendDt?: string;
|
||||||
sid: number;
|
sid: string;
|
||||||
destHeaderIds: number[];
|
destHeaderIds: number[];
|
||||||
destNameHeaderId?: number;
|
destNameHeaderId?: number;
|
||||||
};
|
};
|
||||||
@@ -21,7 +21,7 @@ export type MessageSendBulkRequest = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export type MessageFailedChunk = {
|
export type MessageFailedChunk = {
|
||||||
sidList?: number[];
|
sidList?: string[];
|
||||||
reason?: string;
|
reason?: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user