260722_01_ENH: 버그 수정 및 개선 사항 수정
This commit is contained in:
78
src/components/message-template/MessageVariableList.tsx
Normal file
78
src/components/message-template/MessageVariableList.tsx
Normal file
@@ -0,0 +1,78 @@
|
||||
import { Label } from "@/components/ui/label";
|
||||
import type { listHeader } from "@/types/list";
|
||||
import type { ProjectSurvey } from "@/types/project";
|
||||
|
||||
type MessageVariableListProps = {
|
||||
listHeaders: listHeader[];
|
||||
surveys: ProjectSurvey[];
|
||||
onInsert: (value: string) => void;
|
||||
};
|
||||
|
||||
type VariableRowProps = {
|
||||
id: string;
|
||||
name: string;
|
||||
value: string;
|
||||
onInsert: (value: string) => void;
|
||||
};
|
||||
|
||||
const VariableRow = ({ id, name, value, onInsert }: VariableRowProps) => (
|
||||
<div
|
||||
key={id}
|
||||
className="grid cursor-pointer grid-cols-2 border-b transition-colors last:border-b-0 hover:bg-blue-50"
|
||||
onPointerDown={(event) => {
|
||||
event.preventDefault();
|
||||
onInsert(value);
|
||||
}}
|
||||
>
|
||||
<div className="px-3 py-2 text-center text-sm border-r">{name}</div>
|
||||
<div className="min-w-0 break-all px-3 py-2 text-center text-sm" title={value}>
|
||||
{value}
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
|
||||
export const MessageVariableList = ({ listHeaders, surveys, onInsert }: MessageVariableListProps) => {
|
||||
const availableSurveys = surveys.filter((survey) => survey.surveyUrl?.trim());
|
||||
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<div className="flex items-center">
|
||||
<Label className="text-base">변수 리스트</Label>
|
||||
</div>
|
||||
|
||||
<div className="overflow-hidden rounded-md border">
|
||||
<div className="grid grid-cols-2 border-b bg-blue-100">
|
||||
<div className="border-r px-3 py-2 text-center text-base font-medium">리스트 헤더명</div>
|
||||
<div className="px-3 py-2 text-center text-base font-medium">치환 문자</div>
|
||||
</div>
|
||||
|
||||
<div className="max-h-50 overflow-y-auto">
|
||||
{listHeaders.map((header) => {
|
||||
const placeholder = `[$${header.listHderNm}]`;
|
||||
return (
|
||||
<VariableRow
|
||||
key={`header-${header.listHderId}`}
|
||||
id={`header-${header.listHderId}`}
|
||||
name={header.listHderNm}
|
||||
value={placeholder}
|
||||
onInsert={onInsert}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
{availableSurveys.map((survey) => {
|
||||
const surveyUrl = survey.surveyUrl?.trim() ?? "";
|
||||
return (
|
||||
<VariableRow
|
||||
key={`survey-${survey.prjctSurveyIdx ?? survey.surveyOrder}`}
|
||||
id={`survey-${survey.prjctSurveyIdx ?? survey.surveyOrder}`}
|
||||
name={survey.surveyName}
|
||||
value={surveyUrl}
|
||||
onInsert={onInsert}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
Reference in New Issue
Block a user