261116_02_ENH: 여러 줄 텍스트(98) 헤더 타입 추가 및 컨택 진행 화면 textarea 입력 적용
This commit is contained in:
@@ -17,6 +17,7 @@ import { formatKst } from '@kri/common'
|
||||
import { isListFieldEditableForContact, isListFieldVisibleForContact } from '@/utils/listAccess'
|
||||
import { substituteVariables } from '@/lib/variableSubstitution'
|
||||
import { formatKoreanPhoneNumber } from '@/utils/phone'
|
||||
import { isLightHexColor, normalizeHexColor } from '@/utils/color'
|
||||
import SurveyQrDialog from '@/components/dialog/SurveyQrDialog'
|
||||
import SingleMessageSendDialog from '@/components/dialog/SingleMessageSendDialog'
|
||||
import { ctiClient } from '@/lib/cti/ctiClient'
|
||||
@@ -52,12 +53,20 @@ export const buildInitialValues = (listHeaders: listHeader[], detail?: ListSearc
|
||||
for (const header of listHeaders) {
|
||||
if (header.listHderTy === ListHeaderConst.SID) continue
|
||||
if (!isListFieldVisibleForContact(header)) continue
|
||||
// 사용 허용은 저장 시 코드("0"/"1"/"9")로 보내야 하므로 폼 값은 코드로 둔다.
|
||||
// 문자·알림톡 변수 치환은 resolveListHeaderValue의 라벨을 그대로 사용한다.
|
||||
if (header.listHderTy === ListHeaderConst.IS_USE) {
|
||||
values[header.listHderId] = detail?.use != null ? String(detail.use) : ''
|
||||
continue
|
||||
}
|
||||
values[header.listHderId] = resolveListHeaderValue(header, detail)
|
||||
}
|
||||
|
||||
return values
|
||||
}
|
||||
|
||||
const IS_USE_OPTIONS = Object.entries(LIST_IS_USE_LABEL).map(([value, label]) => ({ value, label }))
|
||||
|
||||
const disabledContrastClass = 'bg-white disabled:opacity-100 disabled:text-foreground disabled:bg-muted/60'
|
||||
// Input/textarea는 수정 불가 상태에서도 드래그 선택/복사가 가능해야 해서 disabled 대신 readOnly를 쓴다.
|
||||
// disabled는 공용 Input 컴포넌트의 disabled:pointer-events-none 때문에 마우스 이벤트 자체를 못 받는다.
|
||||
@@ -77,19 +86,27 @@ const getCallButtonTitle = (isCtiReady: boolean, isDialing: boolean, isEnding: b
|
||||
return undefined
|
||||
}
|
||||
|
||||
const FieldRow = ({ label, editable, children }: { label: string; editable?: boolean; children: ReactNode }) => (
|
||||
<div className="flex items-center gap-3">
|
||||
<Label
|
||||
className={cn(
|
||||
'w-24 shrink-0 wrap-anywhere rounded-md px-2 py-2.5 text-sm leading-snug font-bold text-foreground',
|
||||
editable && 'bg-blue-100',
|
||||
)}
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
const FieldRow = ({ label, color, children }: { label: string; color?: string | null; children: ReactNode }) => {
|
||||
// 헤더에 지정한 색상(투명도 포함)이 기본색보다 우선한다. 형식이 잘못된 값은 기본색으로 표시한다.
|
||||
const headerColor = normalizeHexColor(color)
|
||||
const isDarkHeaderColor = headerColor !== null && !isLightHexColor(headerColor)
|
||||
|
||||
return (
|
||||
<div className="flex items-center gap-3">
|
||||
<Label
|
||||
className={cn(
|
||||
'w-24 shrink-0 wrap-anywhere rounded-md px-2 py-2.5 text-sm leading-snug font-bold',
|
||||
headerColor === null && 'bg-blue-100',
|
||||
isDarkHeaderColor ? 'text-white' : 'text-foreground',
|
||||
)}
|
||||
style={headerColor ? { backgroundColor: headerColor } : undefined}
|
||||
>
|
||||
{label}
|
||||
</Label>
|
||||
<div className="min-w-0 flex-1">{children}</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
const ListContactInfoPanel = ({
|
||||
prjctIdx,
|
||||
@@ -202,9 +219,9 @@ const ListContactInfoPanel = ({
|
||||
const value = formValues[header.listHderId] ?? ''
|
||||
const onChange = (next: string) => onFieldChange(header.listHderId, next)
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.MEMO) {
|
||||
if (header.listHderTy === ListHeaderConst.MEMO || header.listHderTy === ListHeaderConst.MULTILINE_TEXT) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<textarea
|
||||
className={`flex min-h-[80px] w-full rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-ring focus-visible:ring-offset-2 ${readOnlyContrastClass}`}
|
||||
value={value}
|
||||
@@ -217,7 +234,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.TEL_NUM) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
{/* 모바일(md 미만)은 버튼을 입력란 아래 줄로 내린다. */}
|
||||
<div className="flex flex-col gap-2 md:flex-row">
|
||||
<Input
|
||||
@@ -271,7 +288,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.EMAIL) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<div className="flex flex-col gap-2 md:flex-row">
|
||||
<Input
|
||||
value={value}
|
||||
@@ -298,7 +315,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.FILE) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="min-w-0 flex-1 truncate text-sm">
|
||||
{value ? (
|
||||
@@ -339,14 +356,14 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.IS_USE) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<KriSingleSelect
|
||||
items={Object.values(LIST_IS_USE_LABEL)}
|
||||
items={IS_USE_OPTIONS}
|
||||
value={value}
|
||||
disabled={!editable}
|
||||
onChange={onChange}
|
||||
getValue={(item) => item}
|
||||
getLabel={(item) => item}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
searchable={false}
|
||||
preventDeselect
|
||||
widthClassName="w-full"
|
||||
@@ -359,7 +376,7 @@ const ListContactInfoPanel = ({
|
||||
|
||||
if (header.listHderTy === ListHeaderConst.CONTENT_ITEM && (header.filterContents?.length ?? 0) > 0) {
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<KriSingleSelect
|
||||
items={header.filterContents ?? []}
|
||||
value={value}
|
||||
@@ -376,7 +393,7 @@ const ListContactInfoPanel = ({
|
||||
}
|
||||
|
||||
return (
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} editable={canEditField}>
|
||||
<FieldRow key={header.listHderId} label={header.listHderNm} color={header.listHderColor}>
|
||||
<Input
|
||||
value={value}
|
||||
readOnly={!editable}
|
||||
|
||||
Reference in New Issue
Block a user