260723_01_ENH: 설문 URL 치환시 모든 헤더 정보에 대해서 치환 가능하게 수정
This commit is contained in:
@@ -9,11 +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 { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { isAssignHeaderType, isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteSurveyUrl } from '@/lib/surveyUrl'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
@@ -41,17 +42,24 @@ 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
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||
values[header.listHderId] = detail?.memo ?? ''
|
||||
continue
|
||||
}
|
||||
values[header.listHderId] = detail?.itemList?.[header.listHderId] ?? ''
|
||||
values[header.listHderId] = resolveHeaderValue(header, detail)
|
||||
}
|
||||
|
||||
return values
|
||||
@@ -115,14 +123,22 @@ 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 handleStartSurvey = (survey: ProjectSurvey) => {
|
||||
if (!survey.surveyUrl) return
|
||||
window.open(substituteSurveyUrl(survey.surveyUrl, sid), '_blank', 'noopener,noreferrer')
|
||||
window.open(substituteSurveyUrl(survey.surveyUrl, surveyUrlValues), '_blank', 'noopener,noreferrer')
|
||||
}
|
||||
|
||||
const handleShowQr = (survey: ProjectSurvey) => {
|
||||
if (!survey.surveyUrl) return
|
||||
setQrTargetUrl(substituteSurveyUrl(survey.surveyUrl, sid))
|
||||
setQrTargetUrl(substituteSurveyUrl(survey.surveyUrl, surveyUrlValues))
|
||||
showDialog('surveyQrDialog')
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user