From effe279be99150798fed51f207c8615aff078512 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Mon, 14 Sep 2026 10:05:08 +0900 Subject: [PATCH 1/2] =?UTF-8?q?260914=5F01=5FENH:=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B8=20=EC=9D=B4=EB=8F=99=20=EC=8B=9C=20=ED=95=84?= =?UTF-8?q?=ED=84=B0=20=EB=B0=8F=20=EA=B2=80=EC=83=89=20=EC=B4=88=EA=B8=B0?= =?UTF-8?q?=ED=99=94?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(pages)/(main)/list/manage/page.tsx | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/app/(pages)/(main)/list/manage/page.tsx b/src/app/(pages)/(main)/list/manage/page.tsx index e8fa206..5169fd1 100644 --- a/src/app/(pages)/(main)/list/manage/page.tsx +++ b/src/app/(pages)/(main)/list/manage/page.tsx @@ -1,6 +1,6 @@ 'use client' -import { useEffect, useMemo, useState } from 'react' +import { useEffect, useMemo, useRef, useState } from 'react' import type { PaginationState } from '@tanstack/react-table' import { useQueryClient } from '@tanstack/react-query' import { useRouter } from 'next/navigation' @@ -94,6 +94,7 @@ const ListManagePage = () => { const [pagination, setPagination] = useState({ pageIndex: 0, pageSize: 25 }) const [restoredVisit, setRestoredVisit] = useState(null) const [restoreResolved, setRestoreResolved] = useState(false) + const previousPrjctIdxRef = useRef(0) const { get: getLastListVisit, set: setLastListVisit, remove: removeLastListVisit } = useStorage( StorageKeys.LastListVisit, @@ -141,6 +142,21 @@ const ListManagePage = () => { // eslint-disable-next-line react-hooks/exhaustive-deps }, [mounted, isSelectedProjectHydrated, restoreResolved]) + useEffect(() => { + if (!mounted || !isSelectedProjectHydrated || prjctIdx <= 0) return + + const previousPrjctIdx = previousPrjctIdxRef.current + previousPrjctIdxRef.current = prjctIdx + if (previousPrjctIdx === 0 || previousPrjctIdx === prjctIdx) return + + setSelectedRows([]) + setCurrentListFilter(createEmptyListFilter()) + setFilterSummary([]) + setSearchUiState(createEmptySearchUiState()) + setPagination({ pageIndex: 0, pageSize: 25 }) + setRestoredVisit(null) + }, [isSelectedProjectHydrated, mounted, prjctIdx]) + // 브라우저 뒤로가기(popstate)는 Next.js가 이 페이지를 재마운트하지 않고 재사용할 수 있어 // refetchOnMount만으로는 최신 데이터를 보장 못한다. popstate는 브라우저 네이티브 이벤트라 // 재마운트 여부와 무관하게 항상 발생하므로, 여기서 명시적으로 무효화한다. @@ -290,6 +306,7 @@ const ListManagePage = () => { )} Date: Tue, 15 Sep 2026 12:30:52 +0900 Subject: [PATCH 2/2] =?UTF-8?q?260915=5F01=5FENH:=20=EB=8B=A4=EC=9A=B4?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20=EA=B2=B0=EA=B3=BC=EA=B0=92=20=ED=8F=AC?= =?UTF-8?q?=ED=95=A8=20=EB=B0=8F=20=EC=BB=A8=ED=83=9D=20=EC=9D=B4=EB=A0=A5?= =?UTF-8?q?=20=EC=A0=95=EB=A0=AC=20=EC=98=B5=EC=85=98=20=EC=B6=94=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/app/(pages)/(main)/list/manage/page.tsx | 5 ++- src/app/api/list/[[...slug]]/route.ts | 16 ++++++-- src/components/dialog/ListDownloadDialog.tsx | 42 +++++++++++++++++++- src/query/list.ts | 12 ++++-- src/types/list.ts | 8 ++++ 5 files changed, 73 insertions(+), 10 deletions(-) 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; -- 2.49.0.windows.1