260915_01_ENH: 다운로드 결과값 포함 및 컨택 이력 정렬 옵션 추가
This commit is contained in:
@@ -31,6 +31,7 @@ import type { ListTableRow } from '@/components/table-column/ListTableColumn'
|
|||||||
import {
|
import {
|
||||||
createEmptyListFilter,
|
createEmptyListFilter,
|
||||||
ListEventHistoryBase,
|
ListEventHistoryBase,
|
||||||
|
ListEventHistoryOrder,
|
||||||
type LastListVisit,
|
type LastListVisit,
|
||||||
type ListDownloadMode,
|
type ListDownloadMode,
|
||||||
type ListDownloadPayload,
|
type ListDownloadPayload,
|
||||||
@@ -263,7 +264,7 @@ const ListManagePage = () => {
|
|||||||
const listFilter = buildTargetFilter(payload.target)
|
const listFilter = buildTargetFilter(payload.target)
|
||||||
|
|
||||||
if (payload.mode === 'list') {
|
if (payload.mode === 'list') {
|
||||||
const buffer = await downloadListMutation.mutateAsync(listFilter)
|
const buffer = await downloadListMutation.mutateAsync({ listFilter, includeResult: payload.includeResult })
|
||||||
downloadArrayBuffer(buffer, `${prjctName} list.xlsx`)
|
downloadArrayBuffer(buffer, `${prjctName} list.xlsx`)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
@@ -281,9 +282,11 @@ const ListManagePage = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const buffer = await downloadListEventHistoryMutation.mutateAsync({
|
const buffer = await downloadListEventHistoryMutation.mutateAsync({
|
||||||
|
includeResult: payload.includeResult,
|
||||||
listFilter,
|
listFilter,
|
||||||
resultCodeTypes: [ResultCodeType.CONTACT, ResultCodeType.INTERVIEW, ResultCodeType.SURVEY],
|
resultCodeTypes: [ResultCodeType.CONTACT, ResultCodeType.INTERVIEW, ResultCodeType.SURVEY],
|
||||||
searchBase: payload.contactHistoryType === 'latest' ? ListEventHistoryBase.LATEST : ListEventHistoryBase.ALL,
|
searchBase: payload.contactHistoryType === 'latest' ? ListEventHistoryBase.LATEST : ListEventHistoryBase.ALL,
|
||||||
|
historyOrder: payload.historyOrder ?? ListEventHistoryOrder.DESC,
|
||||||
dateRange: toDateTimeRange(payload.contactHistoryDateFrom, payload.contactHistoryDateTo),
|
dateRange: toDateTimeRange(payload.contactHistoryDateFrom, payload.contactHistoryDateTo),
|
||||||
})
|
})
|
||||||
downloadArrayBuffer(buffer, `${prjctName} contact-history.xlsx`)
|
downloadArrayBuffer(buffer, `${prjctName} contact-history.xlsx`)
|
||||||
|
|||||||
@@ -108,7 +108,12 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
|||||||
|
|
||||||
if (action === "excel-download") {
|
if (action === "excel-download") {
|
||||||
const body = await req.json().catch(() => null);
|
const body = await req.json().catch(() => null);
|
||||||
const result = await contactApi.post<ArrayBuffer>(`/list/excel/download/${slug[1]}`, body, { expectBinary: true });
|
const includeResult = req.nextUrl.searchParams.get("includeResult") !== "false";
|
||||||
|
const result = await contactApi.post<ArrayBuffer>(
|
||||||
|
`/list/excel/download/${slug[1]}?includeResult=${includeResult}`,
|
||||||
|
body,
|
||||||
|
{ expectBinary: true },
|
||||||
|
);
|
||||||
return new NextResponse(result, { status: 200, headers: excelHeaders });
|
return new NextResponse(result, { status: 200, headers: excelHeaders });
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -122,9 +127,12 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
|||||||
|
|
||||||
if (action === "event-history-download") {
|
if (action === "event-history-download") {
|
||||||
const body = await req.json().catch(() => null);
|
const body = await req.json().catch(() => null);
|
||||||
const result = await contactApi.post<ArrayBuffer>(`/list-hist/excel/download/event/${slug[1]}`, body, {
|
const includeResult = req.nextUrl.searchParams.get("includeResult") !== "false";
|
||||||
expectBinary: true,
|
const result = await contactApi.post<ArrayBuffer>(
|
||||||
});
|
`/list-hist/excel/download/event/${slug[1]}?includeResult=${includeResult}`,
|
||||||
|
body,
|
||||||
|
{ expectBinary: true },
|
||||||
|
);
|
||||||
return new NextResponse(result, { status: 200, headers: excelHeaders });
|
return new NextResponse(result, { status: 200, headers: excelHeaders });
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -4,13 +4,20 @@ import { useState } from 'react'
|
|||||||
import { Download } from 'lucide-react'
|
import { Download } from 'lucide-react'
|
||||||
import { KriDialog } from '@/components/common/KriDialog'
|
import { KriDialog } from '@/components/common/KriDialog'
|
||||||
import { Button } from '@/components/ui/button'
|
import { Button } from '@/components/ui/button'
|
||||||
|
import { Checkbox } from '@/components/ui/checkbox'
|
||||||
import { Label } from '@/components/ui/label'
|
import { Label } from '@/components/ui/label'
|
||||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
||||||
import { useDialog } from '@/hooks/useDialog'
|
import { useDialog } from '@/hooks/useDialog'
|
||||||
import type { DialogId } from '@/store/jotai/dialog'
|
import type { DialogId } from '@/store/jotai/dialog'
|
||||||
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption'
|
||||||
import KriDateRangePicker from '@/components/common/KriDateRangePicker'
|
import KriDateRangePicker from '@/components/common/KriDateRangePicker'
|
||||||
import type { ContactHistoryDownloadType, ListDownloadMode, ListDownloadPayload, ListFilterTarget } from '@/types/list'
|
import {
|
||||||
|
type ContactHistoryDownloadType,
|
||||||
|
ListEventHistoryOrder,
|
||||||
|
type ListDownloadMode,
|
||||||
|
type ListDownloadPayload,
|
||||||
|
type ListFilterTarget,
|
||||||
|
} from '@/types/list'
|
||||||
|
|
||||||
export type ListDownloadDialogProps = {
|
export type ListDownloadDialogProps = {
|
||||||
dialogId?: DialogId
|
dialogId?: DialogId
|
||||||
@@ -43,6 +50,8 @@ const ListDownloadDialog = ({
|
|||||||
const [contactHistoryDateFrom, setContactHistoryDateFrom] = useState('')
|
const [contactHistoryDateFrom, setContactHistoryDateFrom] = useState('')
|
||||||
const [contactHistoryDateTo, setContactHistoryDateTo] = useState('')
|
const [contactHistoryDateTo, setContactHistoryDateTo] = useState('')
|
||||||
const [contactHistoryType, setContactHistoryType] = useState<ContactHistoryDownloadType>('all')
|
const [contactHistoryType, setContactHistoryType] = useState<ContactHistoryDownloadType>('all')
|
||||||
|
const [historyOrder, setHistoryOrder] = useState<ListEventHistoryOrder>(ListEventHistoryOrder.DESC)
|
||||||
|
const [includeResult, setIncludeResult] = useState(true)
|
||||||
const [submitting, setSubmitting] = useState(false)
|
const [submitting, setSubmitting] = useState(false)
|
||||||
|
|
||||||
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
||||||
@@ -78,9 +87,11 @@ const ListDownloadDialog = ({
|
|||||||
mode,
|
mode,
|
||||||
target,
|
target,
|
||||||
onlyFiltered: target === 'filtered',
|
onlyFiltered: target === 'filtered',
|
||||||
|
includeResult,
|
||||||
contactHistoryDateFrom: mode === 'contact-history' ? contactHistoryDateFrom || undefined : undefined,
|
contactHistoryDateFrom: mode === 'contact-history' ? contactHistoryDateFrom || undefined : undefined,
|
||||||
contactHistoryDateTo: mode === 'contact-history' ? contactHistoryDateTo || undefined : undefined,
|
contactHistoryDateTo: mode === 'contact-history' ? contactHistoryDateTo || undefined : undefined,
|
||||||
contactHistoryType: mode === 'contact-history' ? contactHistoryType : undefined,
|
contactHistoryType: mode === 'contact-history' ? contactHistoryType : undefined,
|
||||||
|
historyOrder: mode === 'contact-history' ? historyOrder : undefined,
|
||||||
})
|
})
|
||||||
handleOpenChange(false)
|
handleOpenChange(false)
|
||||||
} finally {
|
} finally {
|
||||||
@@ -130,6 +141,16 @@ const ListDownloadDialog = ({
|
|||||||
filterSummary={filterSummary}
|
filterSummary={filterSummary}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
{mode === 'list' || mode === 'contact-history' ? (
|
||||||
|
<div className="flex items-center gap-2 rounded-md border p-4">
|
||||||
|
<Checkbox
|
||||||
|
id="download-include-result"
|
||||||
|
checked={includeResult}
|
||||||
|
onCheckedChange={(checked) => setIncludeResult(checked === true)}
|
||||||
|
/>
|
||||||
|
<Label className="text-base" htmlFor="download-include-result">결과값 포함</Label>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
{mode === 'contact-history' ? (
|
{mode === 'contact-history' ? (
|
||||||
<div className="rounded-md border p-4 space-y-4">
|
<div className="rounded-md border p-4 space-y-4">
|
||||||
<p className="text-lg font-semibold">이력 기준</p>
|
<p className="text-lg font-semibold">이력 기준</p>
|
||||||
@@ -149,6 +170,25 @@ const ListDownloadDialog = ({
|
|||||||
</RadioGroup>
|
</RadioGroup>
|
||||||
</div>
|
</div>
|
||||||
) : null}
|
) : null}
|
||||||
|
{mode === 'contact-history' && contactHistoryType === 'all' ? (
|
||||||
|
<div className="rounded-md border p-4 space-y-4">
|
||||||
|
<p className="text-lg font-semibold">이력 순서</p>
|
||||||
|
<RadioGroup
|
||||||
|
value={historyOrder}
|
||||||
|
onValueChange={(value) => setHistoryOrder(value as ListEventHistoryOrder)}
|
||||||
|
className="flex items-center gap-6 flex-wrap"
|
||||||
|
>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem value={ListEventHistoryOrder.DESC} id="download-history-order-desc" />
|
||||||
|
<Label className="text-base" htmlFor="download-history-order-desc">최근 이력이 왼쪽부터</Label>
|
||||||
|
</div>
|
||||||
|
<div className="flex items-center gap-2">
|
||||||
|
<RadioGroupItem value={ListEventHistoryOrder.ASC} id="download-history-order-asc" />
|
||||||
|
<Label className="text-base" htmlFor="download-history-order-asc">오래된 이력이 왼쪽부터</Label>
|
||||||
|
</div>
|
||||||
|
</RadioGroup>
|
||||||
|
</div>
|
||||||
|
) : null}
|
||||||
</KriDialog>
|
</KriDialog>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -275,8 +275,10 @@ export function useDeleteListEventMutation(prjctIdx: number, sid: string) {
|
|||||||
|
|
||||||
export function useDownloadListMutation(prjctIdx: number) {
|
export function useDownloadListMutation(prjctIdx: number) {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (listFilter: ListFilter) =>
|
mutationFn: ({ listFilter, includeResult }: { listFilter: ListFilter; includeResult: boolean }) =>
|
||||||
nextApi.post<ArrayBuffer>(`/list/excel-download/${prjctIdx}`, listFilter, { expectBinary: true }),
|
nextApi.post<ArrayBuffer>(`/list/excel-download/${prjctIdx}?includeResult=${includeResult}`, listFilter, {
|
||||||
|
expectBinary: true,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -289,8 +291,10 @@ export function useDownloadListUpdateHistoryMutation(prjctIdx: number) {
|
|||||||
|
|
||||||
export function useDownloadListEventHistoryMutation(prjctIdx: number) {
|
export function useDownloadListEventHistoryMutation(prjctIdx: number) {
|
||||||
return useMutation({
|
return useMutation({
|
||||||
mutationFn: (request: ListEventHistDownloadRequest) =>
|
mutationFn: ({ includeResult, ...request }: ListEventHistDownloadRequest & { includeResult: boolean }) =>
|
||||||
nextApi.post<ArrayBuffer>(`/list/event-history-download/${prjctIdx}`, request, { expectBinary: true }),
|
nextApi.post<ArrayBuffer>(`/list/event-history-download/${prjctIdx}?includeResult=${includeResult}`, request, {
|
||||||
|
expectBinary: true,
|
||||||
|
}),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -46,6 +46,11 @@ export enum ListEventHistoryBase {
|
|||||||
LATEST = 2,
|
LATEST = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum ListEventHistoryOrder {
|
||||||
|
ASC = 'ASC',
|
||||||
|
DESC = 'DESC',
|
||||||
|
}
|
||||||
|
|
||||||
export type FilterOperator = 'eq' | 'neq' | 'contains' | 'notContains' | 'empty' | 'notEmpty' | 'none';
|
export type FilterOperator = 'eq' | 'neq' | 'contains' | 'notContains' | 'empty' | 'notEmpty' | 'none';
|
||||||
|
|
||||||
export type FilterValueOption = {
|
export type FilterValueOption = {
|
||||||
@@ -78,9 +83,11 @@ export type ListDownloadPayload = {
|
|||||||
mode: ListDownloadMode;
|
mode: ListDownloadMode;
|
||||||
target: ListFilterTarget;
|
target: ListFilterTarget;
|
||||||
onlyFiltered: boolean;
|
onlyFiltered: boolean;
|
||||||
|
includeResult: boolean;
|
||||||
contactHistoryDateFrom?: string;
|
contactHistoryDateFrom?: string;
|
||||||
contactHistoryDateTo?: string;
|
contactHistoryDateTo?: string;
|
||||||
contactHistoryType?: ContactHistoryDownloadType;
|
contactHistoryType?: ContactHistoryDownloadType;
|
||||||
|
historyOrder?: ListEventHistoryOrder;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type ListResetScope = 'result-and-history' | 'list-only';
|
export type ListResetScope = 'result-and-history' | 'list-only';
|
||||||
@@ -355,6 +362,7 @@ export type ListEventHistDownloadRequest = {
|
|||||||
listFilter: ListFilter;
|
listFilter: ListFilter;
|
||||||
resultCodeTypes: number[];
|
resultCodeTypes: number[];
|
||||||
searchBase: ListEventHistoryBase;
|
searchBase: ListEventHistoryBase;
|
||||||
|
historyOrder: ListEventHistoryOrder;
|
||||||
dateRange?: {
|
dateRange?: {
|
||||||
startDate?: string;
|
startDate?: string;
|
||||||
endDate?: string;
|
endDate?: string;
|
||||||
|
|||||||
Reference in New Issue
Block a user