260728_03_ENH: 시나리오에 치환 문자열 적용, 현황 bar chart에 bar max width 적용, 리스트 업로드 이력에서 만료된 파일은 안나오게 수정

This commit is contained in:
2026-07-28 12:17:54 +09:00
parent 17289bf0e8
commit 0285a3fe9d
8 changed files with 95 additions and 36 deletions

View File

@@ -244,6 +244,8 @@ const ListContactPageContent = () => {
useFF={projectInfoQuery.data?.ff ?? false} useFF={projectInfoQuery.data?.ff ?? false}
useContactSenario={projectInfoQuery.data?.useContactSenario ?? false} useContactSenario={projectInfoQuery.data?.useContactSenario ?? false}
contactSenario={projectInfoQuery.data?.contactSenario} contactSenario={projectInfoQuery.data?.contactSenario}
listHeaders={listHeaders}
detail={listDetailQuery.data}
/> />
</div> </div>

View File

@@ -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.listCount.toLocaleString()}</td>
<td className="h-10 px-3 text-center">{item.uploadAtLabel}</td> <td className="h-10 px-3 text-center">{item.uploadAtLabel}</td>
<td className="h-10 px-3 text-center"> <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" /> item.schedulingDelDt ?
다운로드 <p className="text-sm text-red-600 font-medium">보관 기간 만료</p>
</Button> :
<Button type="button" size="sm" className="bg-excel" onClick={() => onDownloadHistory?.(item)}>
<Download className="h-4 w-4" />
다운로드
</Button>
}
</td> </td>
</tr> </tr>
))} ))}

View File

@@ -20,6 +20,23 @@ import { cn } from '@/lib/utils'
import { getNearestFutureDateTime } from '@/lib/datetime' import { getNearestFutureDateTime } from '@/lib/datetime'
import { useCtiLastCallHistId } from '@/hooks/useCtiLastCallHistId' import { useCtiLastCallHistId } from '@/hooks/useCtiLastCallHistId'
import { getCurrentPositionMeta } from '@kri/common/browser' 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) =>
({
'&': '&amp;',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#39;',
})[character] ?? character,
)
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => ( const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
<Button <Button
@@ -283,6 +300,8 @@ export type ListContactEventPanelProps = {
useFF: boolean useFF: boolean
useContactSenario: boolean useContactSenario: boolean
contactSenario?: string contactSenario?: string
listHeaders: listHeader[]
detail?: ListSearchWithFullResult
} }
const ListContactEventPanel = ({ const ListContactEventPanel = ({
@@ -295,12 +314,23 @@ const ListContactEventPanel = ({
useFF, useFF,
useContactSenario, useContactSenario,
contactSenario, contactSenario,
listHeaders,
detail,
}: ListContactEventPanelProps) => { }: ListContactEventPanelProps) => {
const addListEventMutation = useAddListEventMutation(prjctIdx, sid) const addListEventMutation = useAddListEventMutation(prjctIdx, sid)
const reserveMutation = useReserveMutation(prjctIdx, sid) const reserveMutation = useReserveMutation(prjctIdx, sid)
const internalInfoQuery = useInternalInfoQuery() const internalInfoQuery = useInternalInfoQuery()
const showContactInput = userRole !== FIELD_INTERVIEWER_ROLE const showContactInput = userRole !== FIELD_INTERVIEWER_ROLE
const showInterviewInput = userRole !== CONTACT_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 = const handleAddEvent =
(resultCodeType: ResultCodeType) => (resultCodeType: ResultCodeType) =>
@@ -357,10 +387,10 @@ const ListContactEventPanel = ({
} }
{useContactSenario && contactSenario ? ( {useContactSenario && resolvedContactSenario ? (
<div className="space-y-2 rounded-lg border bg-white p-4"> <div className="space-y-2 rounded-lg border bg-white p-4">
<h2 className="text-lg font-bold border-b pb-2">컨택 시나리오</h2> <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> </div>
) : null} ) : null}
</div> </div>

View File

@@ -9,13 +9,12 @@ import { KriSingleSelect } from '@/components/common/KriAutoComplete'
import { useDialog } from '@/hooks/useDialog' import { useDialog } from '@/hooks/useDialog'
import { useDownloadListItemFileByHeaderMutation, useUploadListItemFileMutation } from '@/query/list' import { useDownloadListItemFileByHeaderMutation, useUploadListItemFileMutation } from '@/query/list'
import { ListHeaderConst } from '@/const/listConst' import { ListHeaderConst } from '@/const/listConst'
import { LIST_IS_USE_LABEL } from '@/components/table-column/ListTableColumn'
import type { listHeader, ListSearchWithFullResult } from '@/types/list' import type { listHeader, ListSearchWithFullResult } from '@/types/list'
import type { MessageSendChannel } from '@/types/message' import type { MessageSendChannel } from '@/types/message'
import { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project' import { type ProjectSurvey, type ResultCode, ResultCodeType } from '@/types/project'
import { formatKst } from '@kri/common' import { formatKst } from '@kri/common'
import { isAssignHeaderType, isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess' import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
import { substituteSurveyUrl } from '@/lib/surveyUrl' import { substituteVariables } from '@/lib/surveyUrl'
import { formatKoreanPhoneNumber } from '@/utils/phone' import { formatKoreanPhoneNumber } from '@/utils/phone'
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog' import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog' import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
@@ -24,6 +23,10 @@ import { useCtiConnectionStatus } from '@/hooks/useCtiConnectionStatus'
import { useCtiCallPhase } from '@/hooks/useCtiCallPhase' import { useCtiCallPhase } from '@/hooks/useCtiCallPhase'
import { cn } from '@/lib/utils' import { cn } from '@/lib/utils'
import { downloadFile } from '@kri/common/browser' import { downloadFile } from '@kri/common/browser'
import {
buildListContactVariableValues,
resolveListHeaderValue,
} from '@/components/list-contact/listContactVariables'
export type ListContactInfoPanelProps = { export type ListContactInfoPanelProps = {
prjctIdx: number prjctIdx: number
@@ -41,24 +44,13 @@ export type ListContactInfoPanelProps = {
onSaved?: () => void 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) => { export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearchWithFullResult) => {
const values: Record<number, string> = {} const values: Record<number, string> = {}
for (const header of listHeaders) { for (const header of listHeaders) {
if (header.listHderTy === ListHeaderConst.SID) continue if (header.listHderTy === ListHeaderConst.SID) continue
if (!isListFieldVisibleForContact(header)) continue if (!isListFieldVisibleForContact(header)) continue
values[header.listHderId] = resolveHeaderValue(header, detail) values[header.listHderId] = resolveListHeaderValue(header, detail)
} }
return values return values
@@ -123,22 +115,16 @@ const ListContactInfoPanel = ({
const surveyResultByIdx = new Map((detail?.surveyResults ?? []).map((result) => [result.prjctSurveyIdx, result])) const surveyResultByIdx = new Map((detail?.surveyResults ?? []).map((result) => [result.prjctSurveyIdx, result]))
// 설문 URL 치환은 화면 노출(면접원 노출) 여부와 무관하게 전체 헤더 값을 대상으로 한다. const surveyUrlValues = buildListContactVariableValues(listHeaders, detail, sid)
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 handleStartSurvey = (survey: ProjectSurvey) => { const handleStartSurvey = (survey: ProjectSurvey) => {
if (!survey.surveyUrl) return 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) => { const handleShowQr = (survey: ProjectSurvey) => {
if (!survey.surveyUrl) return if (!survey.surveyUrl) return
setQrTargetUrl(substituteSurveyUrl(survey.surveyUrl, surveyUrlValues)) setQrTargetUrl(substituteVariables(survey.surveyUrl, surveyUrlValues))
showDialog('surveyQrDialog') showDialog('surveyQrDialog')
} }

View 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
}

View File

@@ -26,7 +26,7 @@ export function DateProgressSection({ title, subtitle, rows, resultCodeColumns }
const totalSeries = { const totalSeries = {
name: 'Total', name: 'Total',
data: sortedRows.map((row) => row.totalCount ?? 0), data: sortedRows.map((row) => row.totalCount ?? 0),
option: { type: 'bar' }, option: { type: 'bar', barMaxWidth: 48 },
} }
const resultSeries = resultCodeColumns.map(({ resultCd, label }) => ({ const resultSeries = resultCodeColumns.map(({ resultCd, label }) => ({

View File

@@ -1,5 +1,4 @@
// project.surveyUrl에 들어있는 [$SID], [$헤더명] 치환 토큰을 values에 있는 값으로 바꾼다. // 문자열에 들어있는 [$SID], [$헤더명] 치환 토큰을 values에 있는 값으로 바꾼다.
// 값이 없는 토큰은 빈 문자열로 치환한다(URL에 인코딩되지 않은 대괄호가 남지 않도록). // 값이 없는 토큰은 빈 문자열로 치환한다.
// 참고: src/app/(pages)/(main)/project/info/page.tsx의 sidParam = 'sid=[$SID]'와 동일한 토큰. export const substituteVariables = (contents: string, values: Record<string, string>) =>
export const substituteSurveyUrl = (surveyUrl: string, values: Record<string, string>) => contents.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");
surveyUrl.replace(/\[\$([^\]]+)\]/g, (_, key: string) => values[key] ?? "");

View File

@@ -198,6 +198,7 @@ export type ListUploadHistory = {
uploadMode: ListUploadMode; uploadMode: ListUploadMode;
regUser: string; regUser: string;
regDt: string; regDt: string;
schedulingDelDt: string;
}; };
export type ListUpdateRequest = { export type ListUpdateRequest = {