260728_03_ENH: 시나리오에 치환 문자열 적용, 현황 bar chart에 bar max width 적용, 리스트 업로드 이력에서 만료된 파일은 안나오게 수정
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>
|
||||
|
||||
|
||||
@@ -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>
|
||||
))}
|
||||
|
||||
@@ -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
|
||||
@@ -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) =>
|
||||
@@ -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')
|
||||
}
|
||||
|
||||
|
||||
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 }) => ({
|
||||
|
||||
@@ -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] ?? "");
|
||||
|
||||
@@ -198,6 +198,7 @@ export type ListUploadHistory = {
|
||||
uploadMode: ListUploadMode;
|
||||
regUser: string;
|
||||
regDt: string;
|
||||
schedulingDelDt: string;
|
||||
};
|
||||
|
||||
export type ListUpdateRequest = {
|
||||
|
||||
Reference in New Issue
Block a user