260803_01_ENH: 에디터에 QR 코드 삽입 추가
This commit is contained in:
@@ -53,6 +53,7 @@ export type ListBatchEditDialogProps = {
|
||||
headerOptions: BatchEditOption[]
|
||||
resultCodes: ResultCode[]
|
||||
surveys: ProjectSurvey[]
|
||||
selectedSids: string[]
|
||||
filterSummary?: string[]
|
||||
initialRows?: BatchEditRow[]
|
||||
initialResultCodes?: BatchEditResultCodes
|
||||
@@ -80,6 +81,7 @@ const ListBatchEditDialog = ({
|
||||
headerOptions,
|
||||
resultCodes,
|
||||
surveys,
|
||||
selectedSids,
|
||||
filterSummary,
|
||||
initialRows = [],
|
||||
initialResultCodes = {},
|
||||
@@ -169,7 +171,7 @@ const ListBatchEditDialog = ({
|
||||
|
||||
const handleConfirm = async () => {
|
||||
setInvalidRowId(null)
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
if (!validateApplyFilterTarget(target, { selectedCount: selectedSids.length, filterSummary })) return
|
||||
|
||||
const normalized = rows.filter((row) => row.headerId > 0 && row.value.trim().length > 0)
|
||||
const surveyResultCodes = Object.entries(surveyResultSelections).map(([prjctSurveyIdx, resultCd]) => ({
|
||||
@@ -229,7 +231,13 @@ const ListBatchEditDialog = ({
|
||||
>
|
||||
<div className="rounded-md border p-4 space-y-4">
|
||||
<p className="text-lg font-semibold">적용 대상</p>
|
||||
<ApplyFilterOption value={target} onValueChange={setTarget} idPrefix="batch-edit-target" filterSummary={filterSummary} />
|
||||
<ApplyFilterOption
|
||||
value={target}
|
||||
onValueChange={setTarget}
|
||||
idPrefix="batch-edit-target"
|
||||
selectedSids={selectedSids}
|
||||
filterSummary={filterSummary}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="rounded-md border p-4 space-y-3">
|
||||
|
||||
@@ -7,20 +7,29 @@ import type { ListFilterTarget } from "@/types/list";
|
||||
|
||||
export type ApplyFilterOptionValue = ListFilterTarget
|
||||
|
||||
type ApplyFilterTargetValidation = {
|
||||
selectedCount: number
|
||||
filterSummary?: string[]
|
||||
}
|
||||
|
||||
/**
|
||||
* "필터 적용 대상만"을 선택했는데 실제로 적용된 필터가 없는 경우를 검사한다.
|
||||
* 선택 항목과 필터 적용 대상의 유효성을 각각 실제 상태값으로 검사한다.
|
||||
* alert 후 진행을 막아야 하는 호출부에서 공통으로 사용한다.
|
||||
*/
|
||||
export const validateApplyFilterTarget = (value: ApplyFilterOptionValue, filterSummary?: string[]): boolean => {
|
||||
if (["selected", "filtered"].includes(value) && (filterSummary?.length ?? 0) === 0) {
|
||||
const alertText: string =
|
||||
value === "selected" ?
|
||||
"선택된 항목이 없습니다. 항목을 선택해 주세요"
|
||||
: "적용된 필터가 없습니다. 필터를 적용해 주세요."
|
||||
|
||||
alert(alertText)
|
||||
export const validateApplyFilterTarget = (
|
||||
value: ApplyFilterOptionValue,
|
||||
{ selectedCount, filterSummary }: ApplyFilterTargetValidation,
|
||||
): boolean => {
|
||||
if (value === "selected" && selectedCount === 0) {
|
||||
alert("선택된 항목이 없습니다. 항목을 선택해 주세요")
|
||||
return false
|
||||
}
|
||||
|
||||
if (value === "filtered" && (filterSummary?.length ?? 0) === 0) {
|
||||
alert("적용된 필터가 없습니다. 필터를 적용해 주세요.")
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -28,11 +37,13 @@ type ApplyFilterGroupProps = {
|
||||
value: ApplyFilterOptionValue
|
||||
onValueChange: (value: ApplyFilterOptionValue) => void
|
||||
idPrefix: string
|
||||
/** 현재 선택된 리스트의 SID 목록 */
|
||||
selectedSids?: string[]
|
||||
/** '필터 적용 대상만' 선택 시 보여줄, 사람이 읽을 수 있는 현재 필터 조건 목록 */
|
||||
filterSummary?: string[]
|
||||
}
|
||||
|
||||
const ApplyFilterOption = ({ value, onValueChange, idPrefix, filterSummary }: ApplyFilterGroupProps) => {
|
||||
const ApplyFilterOption = ({ value, onValueChange, idPrefix, selectedSids, filterSummary }: ApplyFilterGroupProps) => {
|
||||
return (
|
||||
<div className="space-y-3">
|
||||
<RadioGroup
|
||||
@@ -54,6 +65,19 @@ const ApplyFilterOption = ({ value, onValueChange, idPrefix, filterSummary }: Ap
|
||||
</div>
|
||||
</RadioGroup>
|
||||
|
||||
{value === 'selected' && selectedSids !== undefined && (
|
||||
<div className="rounded-md border px-4 py-3 text-sm">
|
||||
<p className="font-semibold mb-1">선택된 SID ({selectedSids.length}개)</p>
|
||||
{selectedSids.length > 0 ? (
|
||||
<p className="text-muted-foreground max-h-40 overflow-y-auto break-words">
|
||||
{selectedSids.join(', ')}
|
||||
</p>
|
||||
) : (
|
||||
<p className="text-muted-foreground">선택된 항목이 없습니다.</p>
|
||||
)}
|
||||
</div>
|
||||
)}
|
||||
|
||||
{value === 'filtered' && filterSummary !== undefined && (
|
||||
<div className="rounded-md border px-4 py-3 text-sm">
|
||||
<p className="font-semibold mb-1">적용된 필터</p>
|
||||
|
||||
@@ -17,6 +17,7 @@ export type ListDownloadDialogProps = {
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
mode: ListDownloadMode
|
||||
selectedSids: string[]
|
||||
filterSummary?: string[]
|
||||
onDownload: (payload: ListDownloadPayload) => void | Promise<void>
|
||||
}
|
||||
@@ -33,6 +34,7 @@ const ListDownloadDialog = ({
|
||||
open,
|
||||
onOpenChange,
|
||||
mode,
|
||||
selectedSids,
|
||||
filterSummary,
|
||||
onDownload,
|
||||
}: ListDownloadDialogProps) => {
|
||||
@@ -55,7 +57,7 @@ const ListDownloadDialog = ({
|
||||
}
|
||||
|
||||
const handleDownload = async () => {
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
if (!validateApplyFilterTarget(target, { selectedCount: selectedSids.length, filterSummary })) return
|
||||
|
||||
if (mode === 'contact-history') {
|
||||
const hasFrom = contactHistoryDateFrom.length > 0
|
||||
@@ -120,7 +122,13 @@ const ListDownloadDialog = ({
|
||||
) : null}
|
||||
<div className="rounded-md border p-4 space-y-4">
|
||||
<p className="text-lg font-semibold">다운로드 범위</p>
|
||||
<ApplyFilterOption value={target} onValueChange={setTarget} idPrefix="download-scope-target" filterSummary={filterSummary} />
|
||||
<ApplyFilterOption
|
||||
value={target}
|
||||
onValueChange={setTarget}
|
||||
idPrefix="download-scope-target"
|
||||
selectedSids={selectedSids}
|
||||
filterSummary={filterSummary}
|
||||
/>
|
||||
</div>
|
||||
{mode === 'contact-history' ? (
|
||||
<div className="rounded-md border p-4 space-y-4">
|
||||
|
||||
@@ -14,6 +14,7 @@ export type ListResetDialogProps = {
|
||||
dialogId?: DialogId
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
selectedSids: string[]
|
||||
filterSummary?: string[]
|
||||
onConfirm: (payload: { target: ListFilterTarget; scope: ListResetScope }) => void | Promise<void>
|
||||
}
|
||||
@@ -22,6 +23,7 @@ const ListResetDialog = ({
|
||||
dialogId = 'listResetDialog',
|
||||
open,
|
||||
onOpenChange,
|
||||
selectedSids,
|
||||
filterSummary,
|
||||
onConfirm,
|
||||
}: ListResetDialogProps) => {
|
||||
@@ -42,7 +44,7 @@ const ListResetDialog = ({
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
if (!validateApplyFilterTarget(target, { selectedCount: selectedSids.length, filterSummary })) return
|
||||
if (target === 'all' && !confirm('전체 리스트가 초기화 됩니다. 진행하시겠습니까?')) return
|
||||
|
||||
setSubmitting(true)
|
||||
@@ -78,6 +80,7 @@ const ListResetDialog = ({
|
||||
value={target}
|
||||
onValueChange={(v) => setTarget(v)}
|
||||
idPrefix="list-reset-target"
|
||||
selectedSids={selectedSids}
|
||||
filterSummary={filterSummary}
|
||||
/>
|
||||
</div>
|
||||
|
||||
@@ -25,6 +25,8 @@ import { ListHeaderConst } from '@/const/listConst'
|
||||
import type { ListTableRow } from '@/components/table-column/ListTableColumn'
|
||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||
import { KriEditor } from '@/components/kri-editor'
|
||||
import { normalizeQrCodeForEditor, QR_CODE_ALLOWED_HTML, renderQrCodePreviewHtml } from '@/components/message-template/qrcode'
|
||||
import { applyLinkPreviewClass } from '@/components/kri-editor/utils/linkPreview'
|
||||
|
||||
export type MessageSendMode = 'email' | 'sms'
|
||||
|
||||
@@ -80,6 +82,10 @@ const MessageSendDialog = ({
|
||||
const selectedTemplate = templateDetailQuery.data ?? null
|
||||
const mainTemplateQuery = useMainTemplateIdxQuery(prjctIdx, chnnlTy, enabled)
|
||||
const mainTemplateIdx = mainTemplateQuery.data ?? null
|
||||
const selectedSids = useMemo(
|
||||
() => selectedRows.map((row) => String(row.sid ?? '')).filter((sid) => sid.length > 0),
|
||||
[selectedRows],
|
||||
)
|
||||
|
||||
const templateSenderName = selectedTemplate?.sendNm
|
||||
const templateSenderEmail = selectedTemplate && 'sendEml' in selectedTemplate ? selectedTemplate.sendEml : undefined
|
||||
@@ -151,7 +157,7 @@ const MessageSendDialog = ({
|
||||
}
|
||||
|
||||
const handleConfirm = async () => {
|
||||
if (!validateApplyFilterTarget(target, filterSummary)) return
|
||||
if (!validateApplyFilterTarget(target, { selectedCount: selectedSids.length, filterSummary })) return
|
||||
if (!selectedTemplate || !templateIdx) {
|
||||
alert('템플릿을 선택해 주세요.')
|
||||
return
|
||||
@@ -301,7 +307,13 @@ const MessageSendDialog = ({
|
||||
|
||||
<div className="space-y-2 rounded-md border p-4">
|
||||
<Label className="text-base">수신 대상</Label>
|
||||
<ApplyFilterOption value={target} onValueChange={setTarget} idPrefix="message-send-target" filterSummary={filterSummary} />
|
||||
<ApplyFilterOption
|
||||
value={target}
|
||||
onValueChange={setTarget}
|
||||
idPrefix="message-send-target"
|
||||
selectedSids={selectedSids}
|
||||
filterSummary={filterSummary}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -328,8 +340,17 @@ const MessageSendDialog = ({
|
||||
</div>
|
||||
) : (
|
||||
<div
|
||||
className={cn('rounded-md border bg-muted/30 p-3')}
|
||||
dangerouslySetInnerHTML={{ __html: sanitizeHtmlForPreview(selectedTemplate.tmplatBody || '(내용 없음)') }}
|
||||
className={cn('kri-editor-preview rounded-md border bg-muted/30 p-3')}
|
||||
dangerouslySetInnerHTML={{
|
||||
__html: renderQrCodePreviewHtml(
|
||||
applyLinkPreviewClass(
|
||||
sanitizeHtmlForPreview(
|
||||
normalizeQrCodeForEditor(selectedTemplate.tmplatBody) || '(내용 없음)',
|
||||
QR_CODE_ALLOWED_HTML,
|
||||
),
|
||||
),
|
||||
),
|
||||
}}
|
||||
/>
|
||||
)}
|
||||
</>
|
||||
|
||||
Reference in New Issue
Block a user