diff --git a/src/app/(pages)/(main)/list/manage/page.tsx b/src/app/(pages)/(main)/list/manage/page.tsx index 5169fd1..b68b529 100644 --- a/src/app/(pages)/(main)/list/manage/page.tsx +++ b/src/app/(pages)/(main)/list/manage/page.tsx @@ -31,6 +31,7 @@ import type { ListTableRow } from '@/components/table-column/ListTableColumn' import { createEmptyListFilter, ListEventHistoryBase, + ListEventHistoryOrder, type LastListVisit, type ListDownloadMode, type ListDownloadPayload, @@ -263,7 +264,7 @@ const ListManagePage = () => { const listFilter = buildTargetFilter(payload.target) if (payload.mode === 'list') { - const buffer = await downloadListMutation.mutateAsync(listFilter) + const buffer = await downloadListMutation.mutateAsync({ listFilter, includeResult: payload.includeResult }) downloadArrayBuffer(buffer, `${prjctName} list.xlsx`) return } @@ -281,9 +282,11 @@ const ListManagePage = () => { } const buffer = await downloadListEventHistoryMutation.mutateAsync({ + includeResult: payload.includeResult, listFilter, resultCodeTypes: [ResultCodeType.CONTACT, ResultCodeType.INTERVIEW, ResultCodeType.SURVEY], searchBase: payload.contactHistoryType === 'latest' ? ListEventHistoryBase.LATEST : ListEventHistoryBase.ALL, + historyOrder: payload.historyOrder ?? ListEventHistoryOrder.DESC, dateRange: toDateTimeRange(payload.contactHistoryDateFrom, payload.contactHistoryDateTo), }) downloadArrayBuffer(buffer, `${prjctName} contact-history.xlsx`) diff --git a/src/app/api/list/[[...slug]]/route.ts b/src/app/api/list/[[...slug]]/route.ts index 48f9009..7d34742 100644 --- a/src/app/api/list/[[...slug]]/route.ts +++ b/src/app/api/list/[[...slug]]/route.ts @@ -108,7 +108,12 @@ export const POST = async (req: NextRequest, context: RouteContext) => { if (action === "excel-download") { const body = await req.json().catch(() => null); - const result = await contactApi.post(`/list/excel/download/${slug[1]}`, body, { expectBinary: true }); + const includeResult = req.nextUrl.searchParams.get("includeResult") !== "false"; + const result = await contactApi.post( + `/list/excel/download/${slug[1]}?includeResult=${includeResult}`, + body, + { expectBinary: true }, + ); 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") { const body = await req.json().catch(() => null); - const result = await contactApi.post(`/list-hist/excel/download/event/${slug[1]}`, body, { - expectBinary: true, - }); + const includeResult = req.nextUrl.searchParams.get("includeResult") !== "false"; + const result = await contactApi.post( + `/list-hist/excel/download/event/${slug[1]}?includeResult=${includeResult}`, + body, + { expectBinary: true }, + ); return new NextResponse(result, { status: 200, headers: excelHeaders }); } diff --git a/src/components/dialog/ListDownloadDialog.tsx b/src/components/dialog/ListDownloadDialog.tsx index abd4835..1d380b5 100644 --- a/src/components/dialog/ListDownloadDialog.tsx +++ b/src/components/dialog/ListDownloadDialog.tsx @@ -4,13 +4,20 @@ import { useState } from 'react' import { Download } from 'lucide-react' import { KriDialog } from '@/components/common/KriDialog' import { Button } from '@/components/ui/button' +import { Checkbox } from '@/components/ui/checkbox' 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' import ApplyFilterOption, { validateApplyFilterTarget } from './ListDialogOption/ApplyFilterOption' 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 = { dialogId?: DialogId @@ -43,6 +50,8 @@ const ListDownloadDialog = ({ const [contactHistoryDateFrom, setContactHistoryDateFrom] = useState('') const [contactHistoryDateTo, setContactHistoryDateTo] = useState('') const [contactHistoryType, setContactHistoryType] = useState('all') + const [historyOrder, setHistoryOrder] = useState(ListEventHistoryOrder.DESC) + const [includeResult, setIncludeResult] = useState(true) const [submitting, setSubmitting] = useState(false) const resolvedOpen = open ?? isDialogOpen(dialogId) @@ -78,9 +87,11 @@ const ListDownloadDialog = ({ mode, target, onlyFiltered: target === 'filtered', + includeResult, contactHistoryDateFrom: mode === 'contact-history' ? contactHistoryDateFrom || undefined : undefined, contactHistoryDateTo: mode === 'contact-history' ? contactHistoryDateTo || undefined : undefined, contactHistoryType: mode === 'contact-history' ? contactHistoryType : undefined, + historyOrder: mode === 'contact-history' ? historyOrder : undefined, }) handleOpenChange(false) } finally { @@ -130,6 +141,16 @@ const ListDownloadDialog = ({ filterSummary={filterSummary} /> + {mode === 'list' || mode === 'contact-history' ? ( +
+ setIncludeResult(checked === true)} + /> + +
+ ) : null} {mode === 'contact-history' ? (

이력 기준

@@ -149,6 +170,25 @@ const ListDownloadDialog = ({
) : null} + {mode === 'contact-history' && contactHistoryType === 'all' ? ( +
+

이력 순서

+ setHistoryOrder(value as ListEventHistoryOrder)} + className="flex items-center gap-6 flex-wrap" + > +
+ + +
+
+ + +
+
+
+ ) : null} ) } diff --git a/src/query/list.ts b/src/query/list.ts index fc4dec1..4f08f07 100644 --- a/src/query/list.ts +++ b/src/query/list.ts @@ -275,8 +275,10 @@ export function useDeleteListEventMutation(prjctIdx: number, sid: string) { export function useDownloadListMutation(prjctIdx: number) { return useMutation({ - mutationFn: (listFilter: ListFilter) => - nextApi.post(`/list/excel-download/${prjctIdx}`, listFilter, { expectBinary: true }), + mutationFn: ({ listFilter, includeResult }: { listFilter: ListFilter; includeResult: boolean }) => + nextApi.post(`/list/excel-download/${prjctIdx}?includeResult=${includeResult}`, listFilter, { + expectBinary: true, + }), }); } @@ -289,8 +291,10 @@ export function useDownloadListUpdateHistoryMutation(prjctIdx: number) { export function useDownloadListEventHistoryMutation(prjctIdx: number) { return useMutation({ - mutationFn: (request: ListEventHistDownloadRequest) => - nextApi.post(`/list/event-history-download/${prjctIdx}`, request, { expectBinary: true }), + mutationFn: ({ includeResult, ...request }: ListEventHistDownloadRequest & { includeResult: boolean }) => + nextApi.post(`/list/event-history-download/${prjctIdx}?includeResult=${includeResult}`, request, { + expectBinary: true, + }), }); } diff --git a/src/types/list.ts b/src/types/list.ts index 11ba3ea..7b63e0b 100644 --- a/src/types/list.ts +++ b/src/types/list.ts @@ -46,6 +46,11 @@ export enum ListEventHistoryBase { LATEST = 2, } +export enum ListEventHistoryOrder { + ASC = 'ASC', + DESC = 'DESC', +} + export type FilterOperator = 'eq' | 'neq' | 'contains' | 'notContains' | 'empty' | 'notEmpty' | 'none'; export type FilterValueOption = { @@ -78,9 +83,11 @@ export type ListDownloadPayload = { mode: ListDownloadMode; target: ListFilterTarget; onlyFiltered: boolean; + includeResult: boolean; contactHistoryDateFrom?: string; contactHistoryDateTo?: string; contactHistoryType?: ContactHistoryDownloadType; + historyOrder?: ListEventHistoryOrder; }; export type ListResetScope = 'result-and-history' | 'list-only'; @@ -355,6 +362,7 @@ export type ListEventHistDownloadRequest = { listFilter: ListFilter; resultCodeTypes: number[]; searchBase: ListEventHistoryBase; + historyOrder: ListEventHistoryOrder; dateRange?: { startDate?: string; endDate?: string;