260427_01_ENH: 리스트 다이얼로그 및 리스트 작업 시작

This commit is contained in:
2026-04-27 09:55:51 +09:00
parent 1953b6528b
commit 6944064377
45 changed files with 2560 additions and 419 deletions

View File

@@ -1,25 +1,392 @@
"use client";
'use client'
import {useFontSizeValue} from "@/hooks/useFontSize";
import {useMounted} from "@/hooks/useMounted";
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
import BodyTitle from "@/components/layout/BodyTitle";
import {useSelectedProject} from "@/hooks/useSelectedProject";
import ProjectTitle from "@/components/layout/ProjectTitle";
import { useMemo, useState } from 'react'
import { PaginationState, SortingState } from '@tanstack/react-table'
import {
Download,
FileClock,
Funnel,
Mail,
MessageSquareMore,
PencilLine,
RotateCcw,
Upload,
} from 'lucide-react'
import { Input } from '@/components/ui/input'
import { Button } from '@/components/ui/button'
import { DataTable } from '@/components/data-table/DataTable'
import type { DataTableColumn } from '@/components/data-table/DataTable.type'
import { KriMultiSelect } from '@/components/common/KriAutoComplete'
import { LoadingOverlay } from '@/components/common/LoadingOverlay'
import { useMounted } from '@/hooks/useMounted'
import { useAuth } from '@/hooks/useAuth'
import { useDialog } from '@/hooks/useDialog'
import { useSelectedProject } from '@/hooks/useSelectedProject'
import { useListHeaderQuery, useListSearchQuery } from '@/query/list'
import { useResultCodesQuery } from '@/query/project'
import { getListColumns, ListTableRow } from '@/components/table-column/ListTableColumn'
import { ListSearchRequest } from '@/types/list'
import { ResultCode, ResultCodeType } from '@/types/project'
import { ListHeaderAssignConst } from '@/const/listConst'
import ListResetDialog, { ListResetScope, ListResetTarget } from '@/components/dialog/ListResetDialog'
import ListUploadDialog, { ListUploadHistory, ValidationOption } from '@/components/dialog/ListUploadDialog'
import ListHeaderManageDialog, { ListHeaderManageRow } from '@/components/dialog/ListHeaderManageDialog'
import ListBatchEditDialog, { BatchEditRow } from '@/components/dialog/ListBatchEditDialog'
import ListFilterDialog, { FilterRow } from '@/components/dialog/ListFilterDialog'
import ListDownloadDialog, { ListDownloadMode } from '@/components/dialog/ListDownloadDialog'
import MessageSendDialog, {
MessageSendMode,
MessageSendPayload,
MessageTemplateOption,
} from '@/components/dialog/MessageSendDialog'
import MessageHistoryDialog, { MessageHistoryRow } from '@/components/dialog/MessageHistoryDialog'
const uploadHistoryMock: ListUploadHistory[] = [
{ round: 1, fileName: 'a.xlsx', userId: 'admin', uploadCount: 3500, uploadAt: '2025-10-30T11:00:00Z' },
{ round: 2, fileName: '1.xlsx', userId: 'admin', uploadCount: 100, uploadAt: '2025-10-30T12:00:00Z' },
{ round: 3, fileName: '2.xlsx', userId: 'admin', uploadCount: 2000, uploadAt: '2025-10-30T13:00:00Z' },
]
const messageTemplateMock: MessageTemplateOption[] = [
{
id: 'sms-1',
name: '[SMS] Contact Notice',
title: 'Survey Request',
body: 'Please participate in the survey.',
},
{
id: 'email-1',
name: '[EMAIL] Contact Notice',
title: 'Survey Participation Guide',
body: 'Please click the link and complete the survey.',
},
]
const messageHistoryMock: MessageHistoryRow[] = [
{
id: 1,
type: 'sms',
title: 'Survey Request',
templateName: 'SMS Template A',
sendInfo: '010-xxxx-xxxx',
targetHeader: 'Phone Number',
targetCount: 405,
successCount: 405,
failCount: 0,
createdAt: '03.06 14:37',
sendAt: '03.06 14:30 (Reserve)',
status: 'Done',
templatePreview: 'Please participate in the survey.',
targetPreview: ['010-1234-5678', '010-1234-1111'],
successPreview: ['sid 1: success', 'sid 2: success'],
failPreview: [],
},
{
id: 2,
type: 'email',
title: 'Please answer this survey',
templateName: 'EMAIL Template A',
sendInfo: 'info@kric.com',
targetHeader: 'Email',
targetCount: 405,
successCount: 395,
failCount: 10,
createdAt: '03.06 14:37',
sendAt: '03.06 14:47 (Instant)',
status: 'Requested',
templatePreview: 'Please click the link and complete the survey.',
targetPreview: ['aa@kric.com', 'bb@kric.com'],
successPreview: ['sid 3: success', 'sid 4: success'],
failPreview: ['sid 5: bounce', 'sid 6: invalid'],
},
]
const ListManagePage = () => {
const fontSize = useFontSizeValue();
const mounted = useMounted();
const mounted = useMounted()
const { auth } = useAuth()
const { showDialog } = useDialog()
const { selectedProject } = useSelectedProject()
if (!mounted) return <LoadingOverlay force />;
const [searchText, setSearchText] = useState('')
const [searchContactResult, setSearchContactResult] = useState<string[]>([])
const [searchInterviewResult, setSearchInterviewResult] = useState<string[]>([])
const [searchSurveyResult, setSearchSurveyResult] = useState<string[]>([])
const [pagination, setPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: 10 })
const [sorting, setSorting] = useState<SortingState>([])
const [downloadMode, setDownloadMode] = useState<ListDownloadMode>('list')
const [messageSendMode, setMessageSendMode] = useState<MessageSendMode>('email')
const [filterRows, setFilterRows] = useState<FilterRow[]>([])
const [batchRows, setBatchRows] = useState<BatchEditRow[]>([])
const userRole = auth?.user?.userRole ?? 9000
const prjctIdx = selectedProject?.prjctIdx ?? 0
const enabled = mounted && prjctIdx > 0
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled)
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data])
const listSearchRequest = useMemo<ListSearchRequest>(() => {
const sort = sorting?.[0] ?? { id: 'sid', desc: true as const }
return {
listFilter: {
sidSet: [],
listUseSet: [],
assignUserMap: {
[ListHeaderAssignConst.OUTSOURCE]: [],
[ListHeaderAssignConst.CONTACT_INTERVIEWER]: [],
[ListHeaderAssignConst.FIELD_INTERVIEWER]: [],
},
memo: '',
otherItems: {},
},
pageRequest: {
pageIndex: pagination.pageIndex,
pageSize: pagination.pageSize,
sortBy: sort.id,
sortDir: sort.desc ? 'desc' : 'asc',
},
}
}, [pagination, sorting])
const listSearchQuery = useListSearchQuery(prjctIdx, listSearchRequest, enabled)
const columns = useMemo<DataTableColumn<ListTableRow, unknown>[]>(() => {
if (!listHeaderQuery.data) return []
return getListColumns(listHeaderQuery.data, resultCodeArray, userRole)
}, [listHeaderQuery.data, resultCodeArray, userRole])
const viewList = useMemo<ListTableRow[]>(
() => (listSearchQuery.data?.content ?? []).map((row) => ({ ...row, ...row.itemList })),
[listSearchQuery.data],
)
const totalCount = listSearchQuery.data?.totalElements ?? 0
const pageCount = listSearchQuery.data?.totalPages ?? 0
const headerOptions = useMemo(
() =>
(listHeaderQuery.data ?? []).map((header) => ({
id: header.listHderId,
label: header.listHderNm,
})),
[listHeaderQuery.data],
)
const headerManageRows = useMemo<ListHeaderManageRow[]>(
() =>
(listHeaderQuery.data ?? []).map((header) => ({
id: header.listHderId,
name: header.listHderNm,
visible: header.useColView,
locked: header.listHderGrad === 0,
})),
[listHeaderQuery.data],
)
const filterHeaderOptions = useMemo(
() => headerOptions.map((item) => ({ ...item, values: ['A', 'B', 'C'] })),
[headerOptions],
)
const messageTargetHeaders = useMemo(() => {
const matched = headerOptions.filter((header) => /email|phone|tel/i.test(header.label))
return matched.length > 0 ? matched : headerOptions.slice(0, 1)
}, [headerOptions])
const handleSearchClick = () => {
setPagination((prev) => ({ ...prev, pageIndex: 0 }))
}
const openDownloadDialog = (mode: ListDownloadMode) => {
setDownloadMode(mode)
showDialog('listDownloadDialog')
}
const openMessageDialog = (mode: MessageSendMode) => {
setMessageSendMode(mode)
showDialog('messageSendDialog')
}
const handleResetConfirm = async (payload: { target: ListResetTarget; scope: ListResetScope }) => {
void payload
alert('List reset action callback placeholder.')
}
const handleUploadConfirm = async (file: File, validation: ValidationOption) => {
void file
void validation
alert('List upload action callback placeholder.')
}
const handleDownloadTemplate = async () => {
alert('Template download callback placeholder.')
}
const handleHeaderManageConfirm = async (rows: ListHeaderManageRow[]) => {
void rows
alert('Header manage action callback placeholder.')
}
const handleFilterConfirm = async (rows: FilterRow[]) => {
setFilterRows(rows)
alert('Filter action callback placeholder.')
}
const handleBatchConfirm = async (rows: BatchEditRow[]) => {
setBatchRows(rows)
alert('Batch edit action callback placeholder.')
}
const handleDownloadConfirm = async (payload: { mode: ListDownloadMode; onlyFiltered: boolean }) => {
void payload
alert('Download action callback placeholder.')
}
const handleMessageSendConfirm = async (payload: MessageSendPayload) => {
void payload
alert('Message send action callback placeholder.')
}
if (!mounted) return <LoadingOverlay force />
return (
<div className="space-y-6 content-text-sm">
<div>
This is Manage List Page <span>{fontSize}</span>
<div className="flex gap-2 items-center">
<div className="flex flex-1 items-center gap-2 flex-wrap">
<Button variant="destructive" className="content-text-base gap-2" onClick={() => showDialog('listResetDialog')}>
<RotateCcw className="w-4 h-4" />
리스트 초기화
</Button>
<Button className="content-text-base" onClick={() => showDialog('listHeaderManageDialog')}>
헤더 관리
</Button>
<Button className="content-text-base gap-2" onClick={() => showDialog('listUploadDialog')}>
<Upload className="w-4 h-4" />
리스트 업로드
</Button>
<Button className="content-text-base bg-excel gap-2" onClick={() => openDownloadDialog('list')}>
<Download className="w-4 h-4" />
리스트
</Button>
<Button className="content-text-base bg-excel gap-2" onClick={() => openDownloadDialog('contact-history')}>
<Download className="w-4 h-4" />
컨택 이력
</Button>
<Button className="content-text-base bg-excel gap-2" onClick={() => openDownloadDialog('list-change-history')}>
<Download className="w-4 h-4" />
리스트 변경 이력
</Button>
<Button className="content-text-base gap-2" onClick={() => openDownloadDialog('upload-file')}>
<Download className="w-4 h-4" />
업로드 파일(.zip)
</Button>
</div>
<Button className="content-text-base bg-blue gap-2" onClick={() => openMessageDialog('email')}>
<Mail className="w-4 h-4" />
이메일 발송
</Button>
<Button className="content-text-base bg-blue gap-2" onClick={() => openMessageDialog('sms')}>
<MessageSquareMore className="w-4 h-4" />
문자 발송
</Button>
<Button className="content-text-base gap-2" onClick={() => showDialog('messageHistoryDialog')}>
<FileClock className="w-4 h-4" />
발송 이력
</Button>
</div>
</div>
);
};
export default ListManagePage;
<div className="flex gap-2 items-center">
<div className="flex flex-1 items-center gap-2 flex-wrap">
<Input
placeholder="SID ',' '~' 사용 가능"
className="w-100 h-9 bg-white"
value={searchText}
onChange={(e) => setSearchText(e.target.value)}
/>
<KriMultiSelect
items={resultCodeArray.filter((item) => item.resultCdTy === ResultCodeType.CONTACT)}
value={searchContactResult}
onChange={setSearchContactResult}
getValue={(item) => String(item.resultCd)}
getLabel={(item) => item.resultCdLbl}
placeholder="컨택 결과"
widthClassName="w-70"
heightClassName="h-9"
/>
<KriMultiSelect
items={resultCodeArray.filter((item) => item.resultCdTy === ResultCodeType.INTERVIEW)}
value={searchInterviewResult}
onChange={setSearchInterviewResult}
getValue={(item) => String(item.resultCd)}
getLabel={(item) => item.resultCdLbl}
placeholder="면접 결과"
widthClassName="w-70"
heightClassName="h-9"
/>
<KriMultiSelect
items={resultCodeArray.filter((item) => item.resultCdTy === ResultCodeType.SURVEY)}
value={searchSurveyResult}
onChange={setSearchSurveyResult}
getValue={(item) => String(item.resultCd)}
getLabel={(item) => item.resultCdLbl}
placeholder="설문 결과"
widthClassName="w-70"
heightClassName="h-9"
/>
<Button className="content-text-lg" onClick={handleSearchClick}>
검색
</Button>
<Button type="button" variant="outline" className="gap-2" onClick={() => showDialog('listFilterDialog')}>
<Funnel className="w-4 h-4" />
필터
</Button>
<Button type="button" variant="outline" className="gap-2" onClick={() => showDialog('listBatchEditDialog')}>
<PencilLine className="w-4 h-4" />
일괄 수정
</Button>
</div>
</div>
<div className="bg-white rounded-lg border border-gray-200 overflow-hidden">
<DataTable<ListTableRow>
columns={columns}
data={viewList}
isClient={false}
pageCount={pageCount}
totalCount={totalCount}
onPaginationChange={setPagination}
onSortingChange={setSorting}
selectMode="click-event"
pageSizeOptions={[10, 20, 30, 50]}
/>
</div>
<ListResetDialog onConfirm={handleResetConfirm} />
<ListUploadDialog onUpload={handleUploadConfirm} onDownloadTemplate={handleDownloadTemplate} uploadHistory={uploadHistoryMock} />
<ListHeaderManageDialog rows={headerManageRows} onConfirm={handleHeaderManageConfirm} />
<ListFilterDialog headerOptions={filterHeaderOptions} initialRows={filterRows} onConfirm={handleFilterConfirm} />
<ListBatchEditDialog
headerOptions={headerOptions}
appliedFilters={Object.fromEntries(filterRows.map((row) => [row.headerId, row.multiValues]))}
initialRows={batchRows}
onConfirm={handleBatchConfirm}
/>
<ListDownloadDialog mode={downloadMode} onDownload={handleDownloadConfirm} />
<MessageSendDialog
mode={messageSendMode}
templateOptions={messageTemplateMock}
targetHeaderOptions={messageTargetHeaders}
defaultSenderEmail="info@kric.com"
defaultSenderName="Korea Research"
defaultSenderNumber="02-0000-0000"
onConfirm={handleMessageSendConfirm}
/>
<MessageHistoryDialog rows={messageHistoryMock} />
</div>
)
}
export default ListManagePage

View File

@@ -7,7 +7,7 @@ import BodyTitle from "@/components/layout/BodyTitle";
import { DataTable } from "@/components/data-table/DataTable";
import { getUserColumns } from "@/components/table-column/UserTableColumn";
import UserUpsertDialog from "@/components/dialog/UserUpsertDialog";
import {UserInfo, UserInfoSaveRequest} from "@/types/user";
import {UserInfoSaveRequest} from "@/types/user";
import UserUploadDialog from "@/components/dialog/UserUploadDialog";
import {useDialog} from "@/hooks/useDialog";
import {downloadBase64File, downloadFile} from "@/lib/utils";
@@ -17,6 +17,7 @@ import {MultiSelectOption} from "@/components/ui/multi-select";
import {useMounted} from "@/hooks/useMounted";
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
import {DEFAULT_COMPANY_NAME, EXTERNAL_USER_ROLE} from "@/const/userConst";
import {Upload} from "lucide-react";
import {
useRoleListQuery,
useUserCompaniesQuery,
@@ -203,8 +204,9 @@ const UserManagePage = () => {
</Button>
<Button
onClick={() => showDialog('userUploadDialog')}
className="gap-2 bg-green-600 hover:bg-green-700 content-text-lg"
className="gap-2 bg-excel content-text-lg"
>
<Upload className="w-4 h-4" />
면접원 일괄 등록
</Button>
</div>
@@ -240,4 +242,4 @@ const UserManagePage = () => {
);
}
export default UserManagePage;
export default UserManagePage;

View File

@@ -1,6 +1,5 @@
import {MessageType, TemplateEmail} from "@/types/messageTemplate";
import MessageTemplate from "@/components/message-template/MessageTemplate";
import BodyTitle from "@/components/layout/BodyTitle";
const EmailTemplatePage = () => {

View File

@@ -2,7 +2,6 @@
import {MessageType, TemplateSms} from "@/types/messageTemplate";
import MessageTemplate from "@/components/message-template/MessageTemplate";
import BodyTitle from "@/components/layout/BodyTitle";
const SmsTemplatePage = () => {

View File

@@ -119,6 +119,8 @@ const MainPage = () => {
itrntPrjctCd: projectInfo.itrntPrjctCd,
ownerDept: projectInfo.ownerDept,
ownerFw: projectInfo.ownerFw,
surveyTy: projectInfo.surveyTy,
ff: projectInfo.ff
} as SelectedProject);
router.push("/project/info");
@@ -132,6 +134,8 @@ const MainPage = () => {
itrntPrjctCd: projectInfo.itrntPrjctCd,
ownerDept: projectInfo.ownerDept,
ownerFw: projectInfo.ownerFw,
surveyTy: projectInfo.surveyTy,
ff: projectInfo.ff
} as SelectedProject);
router.push(`/list/manage`);

View File

@@ -6,7 +6,6 @@ import {Card, CardContent, CardHeader} from "@/components/ui/card";
import {Input} from "@/components/ui/input";
import React, {useEffect, useRef, useState} from "react";
import {useRouter, useSearchParams} from "next/navigation";
import { useAuth } from "@/hooks/useAuth";
import { useStorage } from "@/hooks/useStorage"
import { StorageKeys } from "@/store/storage/storage-keys";
import {apiError} from "@/lib/http-util";
@@ -18,10 +17,9 @@ const LoginPage = () => {
const searchParams = useSearchParams();
const typeParam = searchParams.get("type") ?? "";
const { auth } = useAuth();
const loginMutation = useLoginMutation();
const { get: getSeatNumberStorage, set: setSeatNumberStorage } = useStorage(StorageKeys.SeatNumber);
const { get: getSeatNumberStorage } = useStorage(StorageKeys.SeatNumber);
const [error, setError] = useState<string | null>(null);
@@ -50,10 +48,10 @@ const LoginPage = () => {
}
useEffect(() => {
if(auth.user){
if (loginMutation.isSuccess) {
router.replace("/");
}
}, [auth.user]);
}, [loginMutation.isSuccess, router]);
// URL 쿼리 파라미터에서 type 수신
useEffect(() => {
@@ -185,4 +183,4 @@ const LoginPage = () => {
);
}
export default LoginPage;
export default LoginPage;

View File

@@ -12,7 +12,6 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
const {slug = []} = await context.params;
const [action] = slug;
console.log(slug)
const sid = (searchParams.get("sid") ?? "").trim();
const allowAction = ["start", "complete", "screen", "quota"]
if(slug.length === 1 && allowAction.includes(action.toLowerCase()) && sid.length > 0){

View File

@@ -0,0 +1,52 @@
import {NextRequest, NextResponse} from "next/server";
import {PageResponse, RouteContext} from "@/types/common";
import {createContactApi} from "@/lib/server-api";
import {errorToResponse} from "@/lib/http-util";
import {listHeader, ListSearchRequest, ListSearchWithFullResult} from "@/types/list";
export const GET = async (req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
if(action === "header") {
const result = await contactApi.get<listHeader[]>(
`/list-header/${slug[1]}`,
);
return NextResponse.json(result, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
}
};
export const POST = async (req: NextRequest, context: RouteContext) => {
try {
const {slug = []} = await context.params;
const [action] = slug;
const contactApi = await createContactApi();
if(action === "search-filter"){
const body: ListSearchRequest | null = await req.json().catch(() => null);
if (!body) {
return NextResponse.json(
{ message: "요청 바디가 없습니다." },
{ status: 400 }
);
}
const result = await contactApi.post<PageResponse<ListSearchWithFullResult>>(
`/list/search-filter/${slug[1]}`,
body,
);
return NextResponse.json(result, { status: 200 });
}
return NextResponse.json({ message: "Not found" }, { status: 404 });
} catch (error: unknown) {
return errorToResponse(error);
}
};

View File

@@ -2,7 +2,7 @@ import {NextRequest, NextResponse} from "next/server";
import {createContactApi, createIntranetApi} from "@/lib/server-api";
import {errorToResponse} from "@/lib/http-util";
import {PageResponse, RouteContext} from "@/types/common";
import {IntranetProjectSearchResponse, ProjectInfo, ProjectOwnerResponse, ResultCode} from "@/types/project";
import {ProjectInfo, ProjectListRequest, ProjectOwnerResponse} from "@/types/project";
export const GET = async (req: NextRequest, context: RouteContext) => {
try {
@@ -51,7 +51,7 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
const contactApi = await createContactApi();
if(action === "list"){
const body = await req.json().catch(() => null);
const body: ProjectListRequest | null = await req.json().catch(() => null);
if (!body) {
return NextResponse.json(
{ message: "요청 바디가 없습니다." },

View File

@@ -1,6 +1,6 @@
import { NextRequest, NextResponse } from "next/server";
import { createContactApi } from "@/lib/server-api";
import {UserInfo, UserUploadResponse} from "@/types/user";
import {ExcelUploadResult, UserInfo} from "@/types/user";
import {DataVerification, RouteContext} from "@/types/common";
import {errorToResponse} from "@/lib/http-util";
@@ -63,7 +63,7 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
const [action] = slug ?? [];
const contactApi = await createContactApi();
if (action === "excel") {
if (action === "excel-upload") {
const formData = await req.formData();
const file = formData.get("file") as File | null;
@@ -77,8 +77,8 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
const backendForm = new FormData();
backendForm.append("file", file, file.name);
const result = await contactApi.postForm<UserUploadResponse>(
"/user/excel",
const result = await contactApi.postForm<ExcelUploadResult>(
"/user/excel/upload",
backendForm
);

View File

@@ -113,6 +113,20 @@
--sidebar-ring: oklch(0.556 0 0);
}
.bg-excel {
background-color: var(--color-green-600);
}
.bg-excel:hover {
background-color: var(--color-green-700);
}
.bg-blue {
background-color: var(--color-blue-600);
}
.bg-blue:hover {
background-color: var(--color-blue-700);
}
/* 배율별 유틸 클래스 */
.content-text-xs {
font-size: calc(var(--content-font-size) * 0.75);
@@ -252,4 +266,4 @@
/* 리사이즈 중인 상태를 잡고 싶으면 */
.ProseMirror [data-resize-container][data-resize-state="resizing"] {
outline: 1px dashed #0ea5e9;
}
}