260702_01_ENH: 리스트 작업 도중 공용 ui를 적용하기 위한 중간 커밋

This commit is contained in:
2026-07-02 17:02:17 +09:00
parent 6944064377
commit a8ce35f5bf
111 changed files with 2833 additions and 2557 deletions

View File

@@ -8,15 +8,16 @@ import { Label } from '@/components/ui/label'
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
import { useDialog } from '@/hooks/useDialog'
import type { DialogId } from '@/store/jotai/dialog'
export type ListDownloadMode = 'list' | 'contact-history' | 'list-change-history' | 'upload-file'
import ApplyFilterOption from './ListDialogOption/ApplyFilterOption'
import KriDateRangePicker from '@/components/common/KriDateRangePicker'
import type { ContactHistoryDownloadType, ListDownloadMode, ListDownloadPayload, ListFilterTarget } from '@/types/list'
export type ListDownloadDialogProps = {
dialogId?: DialogId
open?: boolean
onOpenChange?: (open: boolean) => void
mode: ListDownloadMode
onDownload: (payload: { mode: ListDownloadMode; onlyFiltered: boolean }) => void | Promise<void>
onDownload: (payload: ListDownloadPayload) => void | Promise<void>
}
const titleMap: Record<ListDownloadMode, string> = {
@@ -34,7 +35,10 @@ const ListDownloadDialog = ({
onDownload,
}: ListDownloadDialogProps) => {
const { isDialogOpen, showDialog, hideDialog } = useDialog()
const [scope, setScope] = useState<'filtered' | 'all'>('filtered')
const [target, setTarget] = useState<ListFilterTarget>('filtered')
const [contactHistoryDateFrom, setContactHistoryDateFrom] = useState('')
const [contactHistoryDateTo, setContactHistoryDateTo] = useState('')
const [contactHistoryType, setContactHistoryType] = useState<ContactHistoryDownloadType>('all')
const [submitting, setSubmitting] = useState(false)
const resolvedOpen = open ?? isDialogOpen(dialogId)
@@ -49,9 +53,29 @@ const ListDownloadDialog = ({
}
const handleDownload = async () => {
if (mode === 'contact-history') {
const hasFrom = contactHistoryDateFrom.length > 0
const hasTo = contactHistoryDateTo.length > 0
if (hasFrom !== hasTo) {
alert('조회 기간은 시작일과 종료일을 모두 입력해 주세요.')
return
}
if (hasFrom && hasTo && contactHistoryDateFrom > contactHistoryDateTo) {
alert('조회 시작일은 종료일보다 이후일 수 없습니다.')
return
}
}
setSubmitting(true)
try {
await onDownload({ mode, onlyFiltered: scope === 'filtered' })
await onDownload({
mode,
target,
onlyFiltered: target === 'filtered',
contactHistoryDateFrom: mode === 'contact-history' ? contactHistoryDateFrom || undefined : undefined,
contactHistoryDateTo: mode === 'contact-history' ? contactHistoryDateTo || undefined : undefined,
contactHistoryType: mode === 'contact-history' ? contactHistoryType : undefined,
})
handleOpenChange(false)
} finally {
setSubmitting(false)
@@ -62,23 +86,47 @@ const ListDownloadDialog = ({
<Dialog open={resolvedOpen} onOpenChange={handleOpenChange}>
<DialogContent className="sm:max-w-[560px]">
<DialogHeader>
<DialogTitle className="content-text-2xl font-bold">{titleMap[mode]}</DialogTitle>
<DialogTitle className="text-2xl font-bold">{titleMap[mode]}</DialogTitle>
</DialogHeader>
<div className="rounded-md border p-4 space-y-4">
<p className="content-text-lg font-semibold">다운로드 범위</p>
<RadioGroup value={scope} onValueChange={(v) => setScope(v as 'filtered' | 'all')} className="space-y-2">
<div className="flex items-center gap-2">
<RadioGroupItem value="filtered" id="download-scope-filtered" />
<Label htmlFor="download-scope-filtered">필터 적용 대상만</Label>
<div className="space-y-4">
{mode === 'contact-history' ? (
<div className="rounded-md border p-4 space-y-4">
<p className="text-lg font-semibold">조회 기간</p>
<KriDateRangePicker
value={{ from: contactHistoryDateFrom, to: contactHistoryDateTo }}
onChange={(range) => {
setContactHistoryDateFrom(range.from)
setContactHistoryDateTo(range.to)
}}
/>
<p className="text-xs text-muted-foreground">비워두면 전체 기간으로 다운로드됩니다.</p>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem value="all" id="download-scope-all" />
<Label htmlFor="download-scope-all">전체 대상</Label>
) : 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" />
</div>
{mode === 'contact-history' ? (
<div className="rounded-md border p-4 space-y-4">
<p className="text-lg font-semibold">이력 기준</p>
<RadioGroup
value={contactHistoryType}
onValueChange={(v) => setContactHistoryType(v as ContactHistoryDownloadType)}
className="flex items-center gap-6 flex-wrap"
>
<div className="flex items-center gap-2">
<RadioGroupItem value="all" id="download-contact-history-all" />
<Label htmlFor="download-contact-history-all">전체 이력</Label>
</div>
<div className="flex items-center gap-2">
<RadioGroupItem value="latest" id="download-contact-history-latest" />
<Label htmlFor="download-contact-history-latest">마지막 이력만</Label>
</div>
</RadioGroup>
</div>
</RadioGroup>
) : null}
</div>
<DialogFooter>
<Button type="button" variant="outline" onClick={() => handleOpenChange(false)} disabled={submitting}>
취소