260812_01_ENH: 배정·진행 현황 개선 및 예약/이벤트 이력 기능 추가
- 프로젝트별 외주사·필드워커 배정 현황 및 미배정 건수 UI 추가 - 현장 면접 진행 여부와 사용자 권한에 따른 배정 탭·필터·컬럼 노출 제어 - 컨택 마지막 이벤트 일자 필터·정렬 및 결과/일자 컬럼 분리 - 컨택·면접·발송 현황의 날짜 범위 선택 optional 처리 - 진행 현황의 미배정 표시 및 일자별 미사용 결과 제외 - 전역 예약 기간 조회·이동 및 5분 단위 예약 알림 추가 - 내부 관리자용 이벤트 이력 단건 삭제 기능 추가 - 리스트 필터 UI 및 일반 헤더 정렬 기준 개선 - 프로젝트 저장 시 선택 프로젝트 정보 동기화
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
"use client";
|
||||
|
||||
import Image from "next/image";
|
||||
import { LogOut, ZoomIn, ZoomOut } from "lucide-react";
|
||||
import { CalendarClock, LogOut, ZoomIn, ZoomOut } from "lucide-react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { KriHeader } from "@/components/layout/KriHeader";
|
||||
import type { TopMenuItem } from "@/config/menu.types";
|
||||
@@ -21,6 +21,7 @@ interface AppHeaderProps {
|
||||
onNavigate: (path: string) => void;
|
||||
decreaseFontSize: () => void;
|
||||
increaseFontSize: () => void;
|
||||
onOpenReserveSearch: () => void;
|
||||
}
|
||||
|
||||
export function AppHeader({
|
||||
@@ -37,6 +38,7 @@ export function AppHeader({
|
||||
onNavigate,
|
||||
decreaseFontSize,
|
||||
increaseFontSize,
|
||||
onOpenReserveSearch,
|
||||
}: AppHeaderProps) {
|
||||
return (
|
||||
<KriHeader
|
||||
@@ -77,6 +79,9 @@ export function AppHeader({
|
||||
<ZoomIn className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
<Button variant="ghost" size="icon-lg" onClick={onOpenReserveSearch} title="예약 내역 조회">
|
||||
<CalendarClock className="size-6" />
|
||||
</Button>
|
||||
<span className="hidden text-sm text-gray-600 sm:inline">{userInfo?.userName || ""}</span>
|
||||
<Button variant="ghost" size="sm" className="gap-2" onClick={() => onNavigate("/logout")}>
|
||||
<LogOut className="h-4 w-4" />
|
||||
|
||||
@@ -7,9 +7,11 @@ import { getCurrentPositionMeta } from "@kri/common/browser";
|
||||
import { KriMainLayout } from "@/components/layout/KriMainLayout";
|
||||
import { AppHeader } from "@/components/app-shell/AppHeader";
|
||||
import { AppSidebar } from "@/components/app-shell/AppSidebar";
|
||||
import ReserveSearchDialog from "@/components/dialog/ReserveSearchDialog";
|
||||
import { useFontSize } from "@/hooks/useFontSize";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useDialog } from "@/hooks/useDialog";
|
||||
import { manageSideMenus, projectSideMenus, topMenus } from "@/config/menu.data";
|
||||
import type { SideMenuItem, SideSubMenuItem, TopMenuItem } from "@/config/menu.types";
|
||||
import { cn } from "@/lib/utils";
|
||||
@@ -103,6 +105,7 @@ export default function AppMainLayout({ children, initialFontSize }: AppMainLayo
|
||||
|
||||
const { auth } = useAuth();
|
||||
const { selectedProject, isSelectedProjectHydrated } = useSelectedProject();
|
||||
const { showDialog } = useDialog();
|
||||
const [menuOpen, setMenuOpen] = useState(true);
|
||||
const [fontSize, setFontSize] = useFontSize(initialFontSize, { hydrateFromCookie: false });
|
||||
const userRole = auth.user?.userRole;
|
||||
@@ -207,6 +210,7 @@ export default function AppMainLayout({ children, initialFontSize }: AppMainLayo
|
||||
onNavigate={movePage}
|
||||
decreaseFontSize={decreaseFontSize}
|
||||
increaseFontSize={increaseFontSize}
|
||||
onOpenReserveSearch={() => showDialog("reserveSearchDialog")}
|
||||
/>
|
||||
}
|
||||
sidebar={
|
||||
@@ -224,6 +228,7 @@ export default function AppMainLayout({ children, initialFontSize }: AppMainLayo
|
||||
}
|
||||
>
|
||||
{children}
|
||||
<ReserveSearchDialog />
|
||||
</KriMainLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,17 +1,25 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useCmpnListQuery } from '@/query/cmpn'
|
||||
import { useFieldworkUsersQuery } from '@/query/user'
|
||||
import { useAssignedCmpnIdsQuery, useAssignedFieldworkIdsQuery } from '@/query/project'
|
||||
import {
|
||||
useAssignedCmpnIdsQuery,
|
||||
useAssignedCmpnSummaryQuery,
|
||||
useAssignedFieldworkIdsQuery,
|
||||
useAssignedFieldworkSummaryQuery,
|
||||
} from '@/query/project'
|
||||
import { KriMultiSelect } from '@/components/common/KriAutoComplete'
|
||||
import { ListHeaderAssignConst } from '@/const/listConst'
|
||||
import { CONTACT_INTERVIEWER_ROLE, FIELD_INTERVIEWER_ROLE } from '@/const/userConst'
|
||||
import { isInternalManager } from '@/utils/userRole'
|
||||
import type { ListHeaderAssignType } from '@/types/list'
|
||||
|
||||
export type AssignTargetListProps = {
|
||||
prjctIdx: number
|
||||
enabled: boolean
|
||||
assignType: ListHeaderAssignType
|
||||
userRole: number
|
||||
selectedId?: string
|
||||
onSelect: (id: string) => void
|
||||
}
|
||||
@@ -61,42 +69,127 @@ export function useAssignTargetRows({ prjctIdx, enabled, assignType }: UseAssign
|
||||
])
|
||||
}
|
||||
|
||||
type AssignSummaryRow = {
|
||||
id: string
|
||||
name: string
|
||||
assignedCount: number
|
||||
cmpn?: string
|
||||
}
|
||||
|
||||
export function AssignTargetList({
|
||||
prjctIdx,
|
||||
enabled,
|
||||
assignType,
|
||||
userRole,
|
||||
selectedId,
|
||||
onSelect
|
||||
}: AssignTargetListProps) {
|
||||
const rows = useAssignTargetRows({ prjctIdx, enabled, assignType })
|
||||
const isOutsource = assignType === ListHeaderAssignConst.OUTSOURCE
|
||||
const canFilterByCmpn = !isOutsource && isInternalManager(userRole)
|
||||
const showCmpnColumn = canFilterByCmpn
|
||||
const [cmpnIds, setCmpnIds] = useState<string[]>([])
|
||||
|
||||
const cmpnListQuery = useCmpnListQuery()
|
||||
const cmpnSummaryQuery = useAssignedCmpnSummaryQuery(prjctIdx, enabled && isOutsource)
|
||||
const fieldworkSummaryQuery = useAssignedFieldworkSummaryQuery(
|
||||
prjctIdx,
|
||||
assignType,
|
||||
cmpnIds,
|
||||
enabled && !isOutsource,
|
||||
)
|
||||
|
||||
const summary = isOutsource ? cmpnSummaryQuery.data : fieldworkSummaryQuery.data
|
||||
const isLoading = isOutsource ? cmpnSummaryQuery.isLoading : fieldworkSummaryQuery.isLoading
|
||||
|
||||
const cmpnAliasById = useMemo(
|
||||
() => new Map((cmpnListQuery.data ?? []).map((cmpn) => [cmpn.cmpnId, cmpn.cmpnAlias || cmpn.cmpnId])),
|
||||
[cmpnListQuery.data],
|
||||
)
|
||||
|
||||
const rows = useMemo<AssignSummaryRow[]>(() => {
|
||||
if (isOutsource) {
|
||||
return (cmpnSummaryQuery.data?.assignees ?? []).map((item) => ({
|
||||
id: item.cmpnId,
|
||||
name: item.cmpnAlias || item.cmpnId,
|
||||
assignedCount: item.assignedCount,
|
||||
}))
|
||||
}
|
||||
return (fieldworkSummaryQuery.data?.assignees ?? []).map((item) => ({
|
||||
id: item.userId,
|
||||
name: item.userName,
|
||||
assignedCount: item.assignedCount,
|
||||
cmpn: cmpnAliasById.get(item.userCmpn) ?? item.userCmpn,
|
||||
}))
|
||||
}, [isOutsource, cmpnSummaryQuery.data, fieldworkSummaryQuery.data, cmpnAliasById])
|
||||
|
||||
return (
|
||||
<div className="border border-gray-200 rounded-lg overflow-hidden bg-white shadow-sm">
|
||||
<div className="h-[78vh] overflow-y-auto">
|
||||
<div className="flex h-[78vh] flex-col border border-gray-200 rounded-lg overflow-hidden bg-white shadow-sm">
|
||||
{canFilterByCmpn ? (
|
||||
<div className="shrink-0 border-b border-gray-200 p-2">
|
||||
<KriMultiSelect
|
||||
items={cmpnListQuery.data ?? []}
|
||||
value={cmpnIds}
|
||||
onChange={setCmpnIds}
|
||||
getValue={(item) => item.cmpnId}
|
||||
getLabel={(item) => item.cmpnAlias || item.cmpnId}
|
||||
placeholder="외주사 선택(전체)"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
{summary ? (
|
||||
<div className="shrink-0 border-b border-gray-200 bg-gray-50 px-3 py-1 text-lg font-semibold text-gray-700">
|
||||
전체 {summary.totalCount}건 · 미배정 {summary.unassignedCount}건
|
||||
</div>
|
||||
) : null}
|
||||
|
||||
<div className="flex-1 overflow-y-auto">
|
||||
<table className="w-full table-fixed">
|
||||
<colgroup>
|
||||
<col className="w-28" />
|
||||
<col className="w-20" />
|
||||
<col />
|
||||
{showCmpnColumn ? <col className="w-20" /> : null}
|
||||
<col className="w-14" />
|
||||
</colgroup>
|
||||
<thead className="bg-primary text-white sticky top-0">
|
||||
<tr>
|
||||
<th className="p-2 text-left text-base font-medium">ID</th>
|
||||
<th className="p-2 text-left text-base font-medium">이름</th>
|
||||
{showCmpnColumn ? <th className="p-2 text-left text-base font-medium">회사</th> : null}
|
||||
<th className="p-2 text-right text-base font-medium">배정</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr
|
||||
key={row.id}
|
||||
className={`border-b border-gray-100 cursor-pointer hover:bg-gray-50 ${
|
||||
selectedId === row.id ? 'bg-accent' : ''
|
||||
}`}
|
||||
onClick={() => onSelect(row.id)}
|
||||
>
|
||||
<td className="p-2 text-base truncate">{row.id}</td>
|
||||
<td className="p-2 text-base truncate">{row.name}</td>
|
||||
{isLoading ? (
|
||||
<tr>
|
||||
<td colSpan={showCmpnColumn ? 4 : 3} className="p-4 text-center text-sm text-muted-foreground">
|
||||
불러오는 중...
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
) : rows.length === 0 ? (
|
||||
<tr>
|
||||
<td colSpan={showCmpnColumn ? 4 : 3} className="p-4 text-center text-sm text-muted-foreground">
|
||||
대상이 없습니다.
|
||||
</td>
|
||||
</tr>
|
||||
) : (
|
||||
rows.map((row) => (
|
||||
<tr
|
||||
key={row.id}
|
||||
className={`border-b border-gray-100 cursor-pointer hover:bg-gray-50 ${
|
||||
selectedId === row.id ? 'bg-accent' : ''
|
||||
}`}
|
||||
onClick={() => onSelect(row.id)}
|
||||
>
|
||||
<td className="p-2 text-base truncate">{row.id}</td>
|
||||
<td className="p-2 text-base truncate">{row.name}</td>
|
||||
{showCmpnColumn ? <td className="p-2 text-base truncate">{row.cmpn}</td> : null}
|
||||
<td className="p-2 text-base text-right">{row.assignedCount}</td>
|
||||
</tr>
|
||||
))
|
||||
)}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@@ -116,7 +116,7 @@ export function KriDateTimePicker({
|
||||
mode="single"
|
||||
selected={date}
|
||||
onSelect={handleDateSelect}
|
||||
initialFocus
|
||||
autoFocus
|
||||
/>
|
||||
<KriTimePicker
|
||||
value={time || '00:00'}
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { Plus, X } from 'lucide-react'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
@@ -33,12 +32,13 @@ export const operatorLabel: Record<FilterOperator, string> = {
|
||||
notContains: '포함하지 않음',
|
||||
empty: '값 없음',
|
||||
notEmpty: '값 있음',
|
||||
none: '필터 없음',
|
||||
}
|
||||
|
||||
const createFilterRow = (headerId: number, headerOptions: FilterHeaderOption[]): FilterRow => ({
|
||||
id: crypto.randomUUID(),
|
||||
headerId,
|
||||
operator: headerOptions.find((option) => option.id === headerId)?.allowedOperators[0] ?? 'eq',
|
||||
operator: headerOptions.find((option) => option.id === headerId)?.defaultOperator ?? 'eq',
|
||||
textValue: '',
|
||||
multiValues: [],
|
||||
})
|
||||
@@ -56,18 +56,17 @@ const ListFilterDialog = ({
|
||||
const [submitting, setSubmitting] = useState(false)
|
||||
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
||||
const defaultHeaderId = headerOptions.find((option) => !option.disabled)?.id ?? 0
|
||||
|
||||
useEffect(() => {
|
||||
if (!resolvedOpen) return
|
||||
if (initialRows.length > 0) {
|
||||
setRows(initialRows.map((row) => ({ ...row })))
|
||||
return
|
||||
}
|
||||
if (defaultHeaderId > 0) {
|
||||
setRows([createFilterRow(defaultHeaderId, headerOptions)])
|
||||
}
|
||||
}, [resolvedOpen, initialRows, defaultHeaderId, headerOptions])
|
||||
const initialByHeaderId = new Map(initialRows.map((row) => [row.headerId, row]))
|
||||
setRows(
|
||||
headerOptions.map((option) => {
|
||||
const existing = initialByHeaderId.get(option.id)
|
||||
return existing ? { ...existing } : createFilterRow(option.id, headerOptions)
|
||||
}),
|
||||
)
|
||||
}, [resolvedOpen, initialRows, headerOptions])
|
||||
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
onOpenChange?.(nextOpen)
|
||||
@@ -78,17 +77,8 @@ const ListFilterDialog = ({
|
||||
hideDialog(dialogId)
|
||||
}
|
||||
|
||||
const handleAddRow = () => {
|
||||
if (defaultHeaderId <= 0) return
|
||||
setRows((prev) => [...prev, createFilterRow(defaultHeaderId, headerOptions)])
|
||||
}
|
||||
|
||||
const handleRemoveRow = (id: string) => {
|
||||
setRows((prev) => prev.filter((row) => row.id !== id))
|
||||
}
|
||||
|
||||
const handleChangeRow = (id: string, updater: (row: FilterRow) => FilterRow) => {
|
||||
setRows((prev) => prev.map((row) => (row.id === id ? updater(row) : row)))
|
||||
const handleChangeRow = (headerId: number, updater: (row: FilterRow) => FilterRow) => {
|
||||
setRows((prev) => prev.map((row) => (row.headerId === headerId ? updater(row) : row)))
|
||||
}
|
||||
|
||||
const getHeaderOption = (headerId: number) => headerOptions.find((item) => item.id === headerId)
|
||||
@@ -108,6 +98,7 @@ const ListFilterDialog = ({
|
||||
rows
|
||||
.map((row) => {
|
||||
if (isDisabledHeader(row.headerId)) return null
|
||||
if (row.operator === 'none') return null
|
||||
if (row.operator === 'empty' || row.operator === 'notEmpty') return row
|
||||
if (isListValueHeader(row.headerId)) return row.multiValues.length > 0 ? row : null
|
||||
return row.textValue.trim().length > 0 ? row : null
|
||||
@@ -117,13 +108,6 @@ const ListFilterDialog = ({
|
||||
)
|
||||
|
||||
const handleConfirm = async () => {
|
||||
// rows가 아예 없으면 "필터를 전부 지우겠다"는 의도이므로 그대로 통과시킨다.
|
||||
// rows는 있는데 값을 안 채워 serializedRows가 비면, 실수로 방치된 조건일 가능성이 높아 알려준다.
|
||||
if (rows.length > 0 && serializedRows.length === 0) {
|
||||
alert('필터 조건을 입력해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
await onConfirm(serializedRows)
|
||||
@@ -151,61 +135,33 @@ const ListFilterDialog = ({
|
||||
}
|
||||
>
|
||||
<div className="overflow-hidden rounded-md border">
|
||||
<div className="grid h-11 grid-cols-[1fr_140px_1.4fr_64px] items-center border-b bg-muted px-4 text-sm font-semibold">
|
||||
<div className="grid h-11 grid-cols-[1fr_140px_1.4fr] items-center border-b bg-muted px-4 text-sm font-semibold">
|
||||
<span>헤더</span>
|
||||
<span>비교 연산자</span>
|
||||
<span>값</span>
|
||||
<span />
|
||||
</div>
|
||||
|
||||
<div className="max-h-80 overflow-auto">
|
||||
<div className="max-h-170 overflow-auto">
|
||||
{rows.map((row) => {
|
||||
const valueOptions = getValueOptions(row.headerId)
|
||||
const listMode = isListValueHeader(row.headerId)
|
||||
const disabled = isDisabledHeader(row.headerId)
|
||||
const rowAllowedOperators = getAllowedOperators(row.headerId)
|
||||
const isEmptyOperator = row.operator === 'empty' || row.operator === 'notEmpty'
|
||||
const isValuelessOperator = row.operator === 'empty' || row.operator === 'notEmpty' || row.operator === 'none'
|
||||
const headerLabel = getHeaderOption(row.headerId)?.label ?? String(row.headerId)
|
||||
|
||||
return (
|
||||
<div
|
||||
key={row.id}
|
||||
className="grid min-h-12 grid-cols-[1fr_140px_1.4fr_64px] items-center gap-2 border-b px-4 py-2 last:border-b-0"
|
||||
key={row.headerId}
|
||||
className="grid min-h-12 grid-cols-[1fr_140px_1.4fr] items-center gap-2 border-b px-4 py-2 last:border-b-0"
|
||||
>
|
||||
<Select
|
||||
value={String(row.headerId)}
|
||||
disabled={disabled}
|
||||
onValueChange={(value) => {
|
||||
const nextHeaderId = Number(value)
|
||||
const nextAllowedOperators = getAllowedOperators(nextHeaderId)
|
||||
|
||||
handleChangeRow(row.id, (current) => ({
|
||||
...current,
|
||||
headerId: nextHeaderId,
|
||||
operator: nextAllowedOperators.includes(current.operator)
|
||||
? current.operator
|
||||
: nextAllowedOperators[0] ?? 'eq',
|
||||
textValue: '',
|
||||
multiValues: [],
|
||||
}))
|
||||
}}
|
||||
>
|
||||
<SelectTrigger className="w-full">
|
||||
<SelectValue placeholder="헤더 선택" />
|
||||
</SelectTrigger>
|
||||
<SelectContent>
|
||||
{headerOptions.map((option) => (
|
||||
<SelectItem key={option.id} value={String(option.id)} disabled={option.disabled}>
|
||||
{option.label}
|
||||
</SelectItem>
|
||||
))}
|
||||
</SelectContent>
|
||||
</Select>
|
||||
<span className={disabled ? 'text-sm text-muted-foreground' : 'text-sm'}>{headerLabel}</span>
|
||||
|
||||
<Select
|
||||
value={row.operator}
|
||||
disabled={disabled}
|
||||
onValueChange={(value) =>
|
||||
handleChangeRow(row.id, (current) => ({
|
||||
handleChangeRow(row.headerId, (current) => ({
|
||||
...current,
|
||||
operator: value as FilterOperator,
|
||||
}))
|
||||
@@ -223,7 +179,7 @@ const ListFilterDialog = ({
|
||||
</SelectContent>
|
||||
</Select>
|
||||
|
||||
{isEmptyOperator ? (
|
||||
{isValuelessOperator ? (
|
||||
<Input placeholder="값을 입력할 필요 없음" value="" disabled />
|
||||
) : listMode ? (
|
||||
<KriMultiSelect
|
||||
@@ -231,7 +187,7 @@ const ListFilterDialog = ({
|
||||
value={row.multiValues}
|
||||
disabled={disabled}
|
||||
onChange={(values) =>
|
||||
handleChangeRow(row.id, (current) => ({
|
||||
handleChangeRow(row.headerId, (current) => ({
|
||||
...current,
|
||||
multiValues: values,
|
||||
}))
|
||||
@@ -252,36 +208,18 @@ const ListFilterDialog = ({
|
||||
value={row.textValue}
|
||||
disabled={disabled}
|
||||
onChange={(event) =>
|
||||
handleChangeRow(row.id, (current) => ({
|
||||
handleChangeRow(row.headerId, (current) => ({
|
||||
...current,
|
||||
textValue: event.target.value,
|
||||
}))
|
||||
}
|
||||
/>
|
||||
)}
|
||||
|
||||
<div className="flex justify-center">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
disabled={disabled}
|
||||
onClick={() => handleRemoveRow(row.id)}
|
||||
aria-label="조건 제거"
|
||||
>
|
||||
<X className="h-4 w-4" />
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
})}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<Button type="button" variant="outline" onClick={handleAddRow} className="gap-2" disabled={defaultHeaderId <= 0}>
|
||||
<Plus className="h-4 w-4" />
|
||||
조건 추가
|
||||
</Button>
|
||||
</KriDialog>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ type ListHeaderRowProps = {
|
||||
onDelete: (id: number) => void
|
||||
}
|
||||
|
||||
const COMMON_GRADE_ORDER_START = 101
|
||||
|
||||
const isCommonGrade = (grade: ListHeaderGrade) => grade === ListHeaderGrade.COMMON
|
||||
const isImmutableGrade = (grade: ListHeaderGrade) => grade === ListHeaderGrade.IMMUTABLE
|
||||
|
||||
@@ -328,11 +330,12 @@ const ListHeaderManageDialog = ({
|
||||
|
||||
setSubmitting(true)
|
||||
try {
|
||||
const orderedRows = localRows.map((row, index) => ({
|
||||
...row,
|
||||
prjctIdx: row.prjctIdx ?? prjctIdx,
|
||||
listHderOrder: index + 1,
|
||||
}))
|
||||
let defaultOrder = 0
|
||||
let commonOrder = COMMON_GRADE_ORDER_START - 1
|
||||
const orderedRows = localRows.map((row) => {
|
||||
const listHderOrder = isCommonGrade(row.listHderGrad) ? (commonOrder += 1) : (defaultOrder += 1)
|
||||
return { ...row, prjctIdx: row.prjctIdx ?? prjctIdx, listHderOrder }
|
||||
})
|
||||
await onConfirm(orderedRows)
|
||||
handleOpenChange(false)
|
||||
} finally {
|
||||
|
||||
@@ -1,91 +0,0 @@
|
||||
'use client'
|
||||
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import type { ListReserve } from '@/types/list'
|
||||
import { formatKst } from '@kri/common'
|
||||
|
||||
export type ReservationListDialogProps = {
|
||||
dialogId?: DialogId
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
reservations: ListReserve[]
|
||||
onSelectReservation: (sid: string) => void
|
||||
}
|
||||
|
||||
// 오늘과 가장 가까운(과거/미래 무관) 예약의 sid를 찾는다.
|
||||
export const findClosestReservationSid = (reservations: ListReserve[], now: Date = new Date()): string | null => {
|
||||
if (reservations.length === 0) return null
|
||||
|
||||
return reservations.reduce((closest, current) => {
|
||||
const closestDiff = Math.abs(new Date(closest.resveDt).getTime() - now.getTime())
|
||||
const currentDiff = Math.abs(new Date(current.resveDt).getTime() - now.getTime())
|
||||
return currentDiff < closestDiff ? current : closest
|
||||
}, reservations[0]).sid
|
||||
}
|
||||
|
||||
const ReservationListDialog = ({
|
||||
dialogId = 'reservationListDialog',
|
||||
open,
|
||||
onOpenChange,
|
||||
reservations,
|
||||
onSelectReservation,
|
||||
}: ReservationListDialogProps) => {
|
||||
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
||||
const closestSid = findClosestReservationSid(reservations)
|
||||
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
onOpenChange?.(nextOpen)
|
||||
if (nextOpen) {
|
||||
showDialog(dialogId)
|
||||
return
|
||||
}
|
||||
hideDialog(dialogId)
|
||||
}
|
||||
|
||||
const handleSelect = (sid: string) => {
|
||||
onSelectReservation(sid)
|
||||
handleOpenChange(false)
|
||||
}
|
||||
|
||||
return (
|
||||
<KriDialog
|
||||
open={resolvedOpen}
|
||||
onOpenChange={handleOpenChange}
|
||||
title={<span className="text-xl">예약리스트 조회</span>}
|
||||
contentClassName="sm:max-w-[480px]"
|
||||
showDefaultFooter
|
||||
>
|
||||
<div className="max-h-80 overflow-auto rounded-md border">
|
||||
{reservations.length === 0 ? (
|
||||
<div className="p-6 text-center text-sm text-muted-foreground">예약된 리스트가 없습니다.</div>
|
||||
) : (
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">SID</th>
|
||||
<th className="p-2 text-left">예약 일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{reservations.map((item) => (
|
||||
<tr
|
||||
key={item.listResveIdx}
|
||||
className={`cursor-pointer border-t hover:bg-muted/50 ${item.sid === closestSid ? 'bg-accent' : ''}`}
|
||||
onClick={() => handleSelect(item.sid)}
|
||||
>
|
||||
<td className="p-2">{item.sid}</td>
|
||||
<td className="p-2">{formatKst(item.resveDt, 'dateHourMin')}</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</KriDialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default ReservationListDialog
|
||||
150
src/components/dialog/ReserveSearchDialog.tsx
Normal file
150
src/components/dialog/ReserveSearchDialog.tsx
Normal file
@@ -0,0 +1,150 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { useQueryClient } from '@tanstack/react-query'
|
||||
import { formatKst } from '@kri/common'
|
||||
import { KriDialog } from '@/components/common/KriDialog'
|
||||
import { KriDateRangePicker, type KriDateRange } from '@/components/common/KriDateRangePicker'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
||||
import { useCtiCallPhase } from '@/hooks/useCtiCallPhase'
|
||||
import { CTI_CALL_PHASE } from '@/const/ctiConst'
|
||||
import { useReserveSearchQuery } from '@/query/reserve'
|
||||
import { nextApi } from '@/lib/http-client'
|
||||
import { qk } from '@/query/key/keys'
|
||||
import type { DialogId } from '@/store/jotai/dialog'
|
||||
import type { SelectedProject } from '@/store/jotai/project'
|
||||
import type { ProjectInfo } from '@/types/project'
|
||||
|
||||
export type ReserveSearchDialogProps = {
|
||||
dialogId?: DialogId
|
||||
open?: boolean
|
||||
onOpenChange?: (open: boolean) => void
|
||||
}
|
||||
|
||||
const toDateInput = (date: Date) => {
|
||||
const year = date.getFullYear()
|
||||
const month = String(date.getMonth() + 1).padStart(2, '0')
|
||||
const day = String(date.getDate()).padStart(2, '0')
|
||||
return `${year}-${month}-${day}`
|
||||
}
|
||||
|
||||
const todayRange = (): KriDateRange => {
|
||||
const today = toDateInput(new Date())
|
||||
return { from: today, to: today }
|
||||
}
|
||||
|
||||
const ReserveSearchDialog = ({
|
||||
dialogId = 'reserveSearchDialog',
|
||||
open,
|
||||
onOpenChange,
|
||||
}: ReserveSearchDialogProps) => {
|
||||
const router = useRouter()
|
||||
const queryClient = useQueryClient()
|
||||
const { isDialogOpen, showDialog, hideDialog } = useDialog()
|
||||
const { auth } = useAuth()
|
||||
const { setSelectedProject } = useSelectedProject()
|
||||
const ctiCallPhase = useCtiCallPhase()
|
||||
const shouldBlockNavigation = CTI_CALL_PHASE.includes(ctiCallPhase)
|
||||
|
||||
const [range, setRange] = useState<KriDateRange>(todayRange)
|
||||
const [navigatingSid, setNavigatingSid] = useState<string | null>(null)
|
||||
|
||||
const resolvedOpen = open ?? isDialogOpen(dialogId)
|
||||
const userId = auth.user?.userId ?? ''
|
||||
const enabled = resolvedOpen && !!userId && !!range.from && !!range.to
|
||||
|
||||
const reserveSearchQuery = useReserveSearchQuery(userId, range.from, range.to, enabled)
|
||||
const reservations = reserveSearchQuery.data ?? []
|
||||
|
||||
const handleOpenChange = (nextOpen: boolean) => {
|
||||
onOpenChange?.(nextOpen)
|
||||
if (nextOpen) {
|
||||
showDialog(dialogId)
|
||||
return
|
||||
}
|
||||
hideDialog(dialogId)
|
||||
}
|
||||
|
||||
const handleRowClick = async (prjctIdx: number, sid: string) => {
|
||||
if (shouldBlockNavigation) {
|
||||
alert('통화 중에는 이동할 수 없습니다.')
|
||||
return
|
||||
}
|
||||
|
||||
setNavigatingSid(sid)
|
||||
try {
|
||||
const projectInfo = await queryClient.fetchQuery({
|
||||
queryKey: qk.projectInfo(prjctIdx),
|
||||
queryFn: () => nextApi.get<ProjectInfo>(`/project/info/${prjctIdx}`),
|
||||
})
|
||||
|
||||
setSelectedProject({
|
||||
prjctIdx: projectInfo.prjctIdx,
|
||||
prjctCd: projectInfo.prjctCd,
|
||||
prjctName: projectInfo.prjctName,
|
||||
itrntPrjctCd: projectInfo.itrntPrjctCd,
|
||||
ownerDept: projectInfo.ownerDept,
|
||||
ownerFw: projectInfo.ownerFw,
|
||||
ff: projectInfo.ff,
|
||||
} as SelectedProject)
|
||||
|
||||
handleOpenChange(false)
|
||||
router.push(`/list/contact?sid=${encodeURIComponent(sid)}`)
|
||||
} finally {
|
||||
setNavigatingSid(null)
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
<KriDialog
|
||||
open={resolvedOpen}
|
||||
onOpenChange={handleOpenChange}
|
||||
title={<span className="text-xl">예약 내역 조회</span>}
|
||||
contentClassName="sm:max-w-[860px]"
|
||||
showDefaultFooter
|
||||
>
|
||||
<div className="space-y-3">
|
||||
<KriDateRangePicker value={range} onChange={setRange} className="w-full" />
|
||||
|
||||
<div className="max-h-80 overflow-auto rounded-md border">
|
||||
{reserveSearchQuery.isLoading ? (
|
||||
<div className="p-6 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
) : reservations.length === 0 ? (
|
||||
<div className="p-6 text-center text-sm text-muted-foreground">예약된 내역이 없습니다.</div>
|
||||
) : (
|
||||
<table className="w-full text-sm">
|
||||
<thead className="sticky top-0 bg-muted">
|
||||
<tr>
|
||||
<th className="p-2 text-left">프로젝트</th>
|
||||
<th className="p-2 text-left">SID</th>
|
||||
<th className="p-2 text-left">예약 일시</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{reservations.map((item) => (
|
||||
<tr
|
||||
key={item.listResveIdx}
|
||||
className="cursor-pointer border-t hover:bg-muted/50"
|
||||
onClick={() => handleRowClick(item.prjctIdx, item.sid)}
|
||||
>
|
||||
<td className="p-2">{item.prjctName}</td>
|
||||
<td className="p-2">{item.sid}</td>
|
||||
<td className="p-2">
|
||||
{formatKst(item.resveDt, 'dateHourMin')}
|
||||
{navigatingSid === item.sid ? ' (이동 중...)' : ''}
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
</KriDialog>
|
||||
)
|
||||
}
|
||||
|
||||
export default ReserveSearchDialog
|
||||
@@ -1,12 +1,12 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from 'react'
|
||||
import { RefreshCw } from 'lucide-react'
|
||||
import { RefreshCw, Trash2 } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { RadioGroup, RadioGroupItem } from '@/components/ui/radio-group'
|
||||
import { KriDateTimePicker } from '@/components/common/KriDateTimePicker'
|
||||
import CollapsibleHistorySection from '@/components/list-contact/CollapsibleHistorySection'
|
||||
import { useAddListEventMutation, useListEventHistoryQuery, useReserveMutation } from '@/query/list'
|
||||
import { useAddListEventMutation, useDeleteListEventMutation, useListEventHistoryQuery, useReserveMutation } from '@/query/list'
|
||||
import { useSendResultBySidQuery } from '@/query/message'
|
||||
import { useInternalInfoQuery } from '@/query/internal'
|
||||
import { clientEnv } from '@/lib/env.client'
|
||||
@@ -24,6 +24,7 @@ import type { listHeader, ListSearchWithFullResult } from '@/types/list'
|
||||
import { buildListContactVariableValues } from '@/components/list-contact/listContactVariables'
|
||||
import { escapeHtml, substituteVariables } from '@/lib/variableSubstitution'
|
||||
import { sanitizeHtml } from '@/components/kri-editor/utils/sanitizeHtml'
|
||||
import { isInternalManager } from '@/utils/userRole'
|
||||
|
||||
const RefreshIconButton = ({ onRefresh, isFetching }: { onRefresh: () => void; isFetching: boolean }) => (
|
||||
<Button
|
||||
@@ -51,6 +52,7 @@ type ContactEventSectionProps = {
|
||||
showInput?: boolean
|
||||
submitting: boolean
|
||||
onSubmit: (resultCd: number, memo: string, resveDt: string, listCallHistIdx: number | null) => Promise<void>
|
||||
canDelete: boolean
|
||||
}
|
||||
|
||||
const EventHistoryList = ({
|
||||
@@ -58,11 +60,17 @@ const EventHistoryList = ({
|
||||
history,
|
||||
resultCodeType,
|
||||
resultCodes,
|
||||
canDelete = false,
|
||||
onDelete,
|
||||
isDeleting = false,
|
||||
}: {
|
||||
isLoading: boolean
|
||||
history: ReturnType<typeof useListEventHistoryQuery>['data']
|
||||
resultCodeType: ResultCodeType
|
||||
resultCodes: ResultCode[]
|
||||
canDelete?: boolean
|
||||
onDelete?: (listEventHistIdx: number) => void
|
||||
isDeleting?: boolean
|
||||
}) => {
|
||||
const filteredHistory = (history ?? [])
|
||||
.filter((item) => item.eventTy === resultCodeType)
|
||||
@@ -72,6 +80,11 @@ const EventHistoryList = ({
|
||||
resultCodes.find((code) => code.resultCdTy === resultCodeType && code.resultCd === resultCd)?.resultCdLbl ??
|
||||
String(resultCd)
|
||||
|
||||
const handleDelete = (listEventHistIdx: number) => {
|
||||
if (!confirm('이력을 삭제하시겠습니까?')) return
|
||||
onDelete?.(listEventHistIdx)
|
||||
}
|
||||
|
||||
if (isLoading) {
|
||||
return <div className="rounded-md border p-4 text-center text-sm text-muted-foreground">불러오는 중...</div>
|
||||
}
|
||||
@@ -89,6 +102,7 @@ const EventHistoryList = ({
|
||||
<th className="p-2 text-left">메모</th>
|
||||
<th className="p-2 text-left">등록자</th>
|
||||
<th className="p-2 text-left">일시</th>
|
||||
{canDelete ? <th className="p-2 text-left">삭제</th> : null}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -100,6 +114,20 @@ const EventHistoryList = ({
|
||||
<td className="p-2">{item.memo || '-'}</td>
|
||||
<td className="p-2">{item.regUser}</td>
|
||||
<td className="p-2">{formatKst(item.regDt, 'dateHourMin')}</td>
|
||||
{canDelete ? (
|
||||
<td className="p-2">
|
||||
<Button
|
||||
type="button"
|
||||
variant="ghost"
|
||||
size="icon-sm"
|
||||
aria-label="이력 삭제"
|
||||
disabled={isDeleting}
|
||||
onClick={() => handleDelete(item.listEventHistIdx)}
|
||||
>
|
||||
<Trash2 className="h-4 w-4" />
|
||||
</Button>
|
||||
</td>
|
||||
) : null}
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
@@ -118,6 +146,7 @@ const ContactEventSection = ({
|
||||
showInput = true,
|
||||
submitting,
|
||||
onSubmit,
|
||||
canDelete,
|
||||
}: ContactEventSectionProps) => {
|
||||
const [resultCd, setResultCd] = useState('')
|
||||
const [memo, setMemo] = useState('')
|
||||
@@ -130,6 +159,7 @@ const ContactEventSection = ({
|
||||
const historyQuery = useListEventHistoryQuery(prjctIdx, sid, true)
|
||||
const ctiLastCallHistId = useCtiLastCallHistId(prjctIdx, sid)
|
||||
const listCallHistIdx = isContactType ? ctiLastCallHistId : null
|
||||
const deleteEventMutation = useDeleteListEventMutation(prjctIdx, sid)
|
||||
|
||||
const handleResultCdChange = (next: string) => {
|
||||
setResultCd(next)
|
||||
@@ -179,7 +209,7 @@ const ContactEventSection = ({
|
||||
/>
|
||||
|
||||
{showReservation && isReservationSelected ? (
|
||||
<KriDateTimePicker value={resveDt} onChange={setResveDt} placeholder="예약 날짜/시간" />
|
||||
<KriDateTimePicker value={resveDt} onChange={setResveDt} startHour={9} endHour={20} placeholder="예약 날짜/시간" />
|
||||
) : null}
|
||||
|
||||
<Button type="button" className="w-full" disabled={submitting} onClick={handleAdd}>
|
||||
@@ -194,7 +224,15 @@ const ContactEventSection = ({
|
||||
showDivider={showInput}
|
||||
headerExtra={<RefreshIconButton onRefresh={() => historyQuery.refetch()} isFetching={historyQuery.isFetching} />}
|
||||
>
|
||||
<EventHistoryList isLoading={historyQuery.isLoading} history={historyQuery.data} resultCodeType={resultCodeType} resultCodes={resultCodes} />
|
||||
<EventHistoryList
|
||||
isLoading={historyQuery.isLoading}
|
||||
history={historyQuery.data}
|
||||
resultCodeType={resultCodeType}
|
||||
resultCodes={resultCodes}
|
||||
canDelete={canDelete}
|
||||
isDeleting={deleteEventMutation.isPending}
|
||||
onDelete={(listEventHistIdx) => deleteEventMutation.mutate(listEventHistIdx)}
|
||||
/>
|
||||
</CollapsibleHistorySection>
|
||||
</div>
|
||||
)
|
||||
@@ -311,6 +349,7 @@ const ListContactEventPanel = ({
|
||||
const internalInfoQuery = useInternalInfoQuery()
|
||||
const showContactInput = userRole !== FIELD_INTERVIEWER_ROLE
|
||||
const showInterviewInput = userRole !== CONTACT_INTERVIEWER_ROLE
|
||||
const canDeleteEvent = isInternalManager(userRole)
|
||||
const contactSenarioValues = Object.fromEntries(
|
||||
Object.entries(buildListContactVariableValues(listHeaders, detail, sid)).map(([key, value]) => [
|
||||
key,
|
||||
@@ -358,6 +397,7 @@ const ListContactEventPanel = ({
|
||||
showInput={showContactInput}
|
||||
submitting={addListEventMutation.isPending || reserveMutation.isPending}
|
||||
onSubmit={handleAddEvent(ResultCodeType.CONTACT)}
|
||||
canDelete={canDeleteEvent}
|
||||
/>
|
||||
|
||||
<SendResultHistory sid={sid} prjctCd={prjctCd} />
|
||||
@@ -372,6 +412,7 @@ const ListContactEventPanel = ({
|
||||
showInput={showInterviewInput}
|
||||
submitting={addListEventMutation.isPending}
|
||||
onSubmit={handleAddEvent(ResultCodeType.INTERVIEW)}
|
||||
canDelete={canDeleteEvent}
|
||||
/>
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import { Input } from '@/components/ui/input'
|
||||
import { DataTable } from '@/components/data-table/DataTable'
|
||||
import type { DataTableColumn, SelectMode } from '@/components/data-table/DataTable.type'
|
||||
import { KriMultiSelect } from '@/components/common/KriAutoComplete'
|
||||
import KriDateRangePicker, { type KriDateRange } from '@/components/common/KriDateRangePicker'
|
||||
import ListBatchEditDialog, { type BatchEditPayload, type BatchEditResultCodes, type BatchEditRow, type BatchEditSurveyResultCodes } from '@/components/dialog/ListBatchEditDialog'
|
||||
import ListFilterDialog, { operatorLabel } from '@/components/dialog/ListFilterDialog'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
@@ -50,6 +51,7 @@ export type ListSearchTableProps = {
|
||||
resultCodes: ResultCode[]
|
||||
surveys: ProjectSurvey[]
|
||||
listHeaders: listHeader[]
|
||||
fieldInterviewEnabled?: boolean
|
||||
enableBatchEdit?: boolean
|
||||
refreshKey?: number
|
||||
selectMode?: SelectMode
|
||||
@@ -133,7 +135,7 @@ const toFilterCondition = (row: FilterRow, usesListValue: boolean): Omit<ListOth
|
||||
const TEXT_LIKE_OPERATORS: FilterOperator[] = ['eq', 'neq', 'contains', 'notContains', 'empty', 'notEmpty']
|
||||
const ASSIGN_LIKE_OPERATORS: FilterOperator[] = ['eq', 'neq', 'empty', 'notEmpty']
|
||||
const IS_USE_OPERATORS: FilterOperator[] = ['eq', 'neq']
|
||||
const FILE_OPERATORS: FilterOperator[] = ['empty', 'notEmpty']
|
||||
const FILE_OPERATORS: FilterOperator[] = ['none', 'empty', 'notEmpty']
|
||||
|
||||
const getAllowedOperators = (listHderTy: number): FilterOperator[] => {
|
||||
if (listHderTy === ListHeaderConst.IS_USE) return IS_USE_OPERATORS
|
||||
@@ -142,6 +144,13 @@ const getAllowedOperators = (listHderTy: number): FilterOperator[] => {
|
||||
return TEXT_LIKE_OPERATORS
|
||||
}
|
||||
|
||||
const getDefaultOperator = (listHderTy: number): FilterOperator => {
|
||||
if (listHderTy === ListHeaderConst.FILE) return 'none'
|
||||
if (listHderTy === ListHeaderConst.IS_USE) return 'eq'
|
||||
if (isAssignHeaderType(listHderTy) || listHderTy === ListHeaderConst.CONTENT_ITEM) return 'eq'
|
||||
return 'contains'
|
||||
}
|
||||
|
||||
const IS_USE_VALUE_OPTIONS: FilterValueOption[] = Object.entries(LIST_IS_USE_LABEL).map(([value, label]) => ({
|
||||
value,
|
||||
label,
|
||||
@@ -156,6 +165,7 @@ export function ListSearchTable({
|
||||
resultCodes,
|
||||
surveys,
|
||||
listHeaders,
|
||||
fieldInterviewEnabled = true,
|
||||
enableBatchEdit = false,
|
||||
refreshKey = 0,
|
||||
selectMode = 'multi',
|
||||
@@ -178,6 +188,9 @@ export function ListSearchTable({
|
||||
const { showDialog } = useDialog()
|
||||
const [searchText, setSearchText] = useState(initialSearchState?.searchText ?? '')
|
||||
const [searchContactResult, setSearchContactResult] = useState<string[]>(initialSearchState?.searchContactResult ?? [])
|
||||
const [searchContactDateRange, setSearchContactDateRange] = useState<KriDateRange>(
|
||||
initialSearchState?.searchContactDateRange ?? { from: '', to: '' },
|
||||
)
|
||||
const [searchInterviewResult, setSearchInterviewResult] = useState<string[]>(initialSearchState?.searchInterviewResult ?? [])
|
||||
const [surveyResultSelections, setSurveyResultSelections] = useState<SurveyResultSelections>(initialSearchState?.surveyResultSelections ?? {})
|
||||
const [pagination, setPagination] = useState<PaginationState>(initialPagination ?? { pageIndex: 0, pageSize: 25 })
|
||||
@@ -200,7 +213,11 @@ export function ListSearchTable({
|
||||
enabled,
|
||||
assignType: ListHeaderAssignConst.CONTACT_INTERVIEWER,
|
||||
})
|
||||
const fieldTargetRows = useAssignTargetRows({ prjctIdx, enabled, assignType: ListHeaderAssignConst.FIELD_INTERVIEWER })
|
||||
const fieldTargetRows = useAssignTargetRows({
|
||||
prjctIdx,
|
||||
enabled: enabled && fieldInterviewEnabled,
|
||||
assignType: ListHeaderAssignConst.FIELD_INTERVIEWER,
|
||||
})
|
||||
|
||||
const getValueOptionsForHeader = useCallback(
|
||||
(header: listHeader): FilterValueOption[] | undefined => {
|
||||
@@ -222,20 +239,28 @@ export function ListSearchTable({
|
||||
[contactTargetRows, fieldTargetRows, outsourceTargetRows],
|
||||
)
|
||||
|
||||
const availableListHeaders = useMemo(
|
||||
() =>
|
||||
fieldInterviewEnabled
|
||||
? listHeaders
|
||||
: listHeaders.filter((header) => header.listHderTy !== ListHeaderConst.FIELD_INTERVIEWER),
|
||||
[fieldInterviewEnabled, listHeaders],
|
||||
)
|
||||
|
||||
const accessibleListHeaders = useMemo(
|
||||
() => listHeaders.filter((header) => isListHeaderVisibleByAccess(header, userRole)),
|
||||
[listHeaders, userRole],
|
||||
() => availableListHeaders.filter((header) => isListHeaderVisibleByAccess(header, userRole)),
|
||||
[availableListHeaders, userRole],
|
||||
)
|
||||
|
||||
const accessibleFilterHeaders = useMemo(
|
||||
() =>
|
||||
listHeaders.filter(
|
||||
availableListHeaders.filter(
|
||||
(header) =>
|
||||
header.listHderTy !== ListHeaderConst.SID &&
|
||||
isListFilterVisibleByAccess(header, userRole) &&
|
||||
!excludeFilterHeaderTypes?.includes(header.listHderTy),
|
||||
),
|
||||
[listHeaders, userRole, excludeFilterHeaderTypes],
|
||||
[availableListHeaders, userRole, excludeFilterHeaderTypes],
|
||||
)
|
||||
|
||||
const accessibleFilterHeaderById = useMemo(
|
||||
@@ -252,7 +277,7 @@ export function ListSearchTable({
|
||||
listFilter.memoConditions = []
|
||||
listFilter.resultCodeMap = {
|
||||
[ResultCodeType.CONTACT]: searchContactResult.map(Number),
|
||||
[ResultCodeType.INTERVIEW]: searchInterviewResult.map(Number),
|
||||
[ResultCodeType.INTERVIEW]: fieldInterviewEnabled ? searchInterviewResult.map(Number) : [],
|
||||
}
|
||||
listFilter.surveyResultConditions = Object.entries(surveyResultSelections)
|
||||
.filter(([, codes]) => codes.length > 0)
|
||||
@@ -261,9 +286,20 @@ export function ListSearchTable({
|
||||
resultCodes: codes.map(Number),
|
||||
}))
|
||||
|
||||
if (searchContactDateRange.from || searchContactDateRange.to) {
|
||||
listFilter.lastEventDateRange = [
|
||||
{
|
||||
resultCodeType: ResultCodeType.CONTACT,
|
||||
startDate: searchContactDateRange.from ? `${searchContactDateRange.from}T00:00:00` : undefined,
|
||||
endDate: searchContactDateRange.to ? `${searchContactDateRange.to}T23:59:59` : undefined,
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
filterRows.forEach((row) => {
|
||||
const header = accessibleFilterHeaderById.get(row.headerId)
|
||||
if (!header || lockedListFilterHeaderTypes.has(header.listHderTy)) return
|
||||
if (row.operator === 'none') return
|
||||
|
||||
const isEmptyOperator = row.operator === 'empty' || row.operator === 'notEmpty'
|
||||
const usesListValue = getValueOptionsForHeader(header) !== undefined
|
||||
@@ -324,12 +360,14 @@ export function ListSearchTable({
|
||||
}, [
|
||||
accessibleFilterHeaderById,
|
||||
externalAssignFilter,
|
||||
fieldInterviewEnabled,
|
||||
filterRows,
|
||||
getValueOptionsForHeader,
|
||||
lockedListFilterHeaderTypes,
|
||||
pagination.pageIndex,
|
||||
pagination.pageSize,
|
||||
searchContactResult,
|
||||
searchContactDateRange,
|
||||
searchInterviewResult,
|
||||
surveyResultSelections,
|
||||
searchText,
|
||||
@@ -363,13 +401,19 @@ export function ListSearchTable({
|
||||
|
||||
const resultSummaryGroups: { label: string; type: ResultCodeType; values: string[] }[] = [
|
||||
{ label: '컨택 결과', type: ResultCodeType.CONTACT, values: searchContactResult },
|
||||
{ label: '면접 결과', type: ResultCodeType.INTERVIEW, values: searchInterviewResult },
|
||||
...(fieldInterviewEnabled
|
||||
? [{ label: '면접 결과', type: ResultCodeType.INTERVIEW, values: searchInterviewResult }]
|
||||
: []),
|
||||
]
|
||||
resultSummaryGroups.forEach(({ label, type, values }) => {
|
||||
if (values.length === 0) return
|
||||
lines.push(`${label}: ${values.map((value) => resultCodeLabel(type, value)).join(', ')}`)
|
||||
})
|
||||
|
||||
if (searchContactDateRange.from || searchContactDateRange.to) {
|
||||
lines.push(`컨택 일자: ${searchContactDateRange.from || ''} ~ ${searchContactDateRange.to || ''}`)
|
||||
}
|
||||
|
||||
surveys.forEach((survey) => {
|
||||
if (survey.prjctSurveyIdx == null) return
|
||||
const codes = surveyResultSelections[survey.prjctSurveyIdx] ?? []
|
||||
@@ -404,9 +448,11 @@ export function ListSearchTable({
|
||||
}, [
|
||||
accessibleFilterHeaderById,
|
||||
filterRows,
|
||||
fieldInterviewEnabled,
|
||||
getValueOptionsForHeader,
|
||||
lockedListFilterHeaderTypes,
|
||||
resultCodeLabel,
|
||||
searchContactDateRange,
|
||||
searchContactResult,
|
||||
searchInterviewResult,
|
||||
surveys,
|
||||
@@ -446,9 +492,12 @@ export function ListSearchTable({
|
||||
)
|
||||
|
||||
const columns = useMemo<DataTableColumn<ListTableRow, unknown>[]>(() => {
|
||||
if (!listHeaders.length) return []
|
||||
return getListColumns(listHeaders, resultCodes, userRole, surveys)
|
||||
}, [listHeaders, resultCodes, userRole, surveys])
|
||||
if (!availableListHeaders.length) return []
|
||||
const listColumns = getListColumns(availableListHeaders, resultCodes, userRole, surveys)
|
||||
return fieldInterviewEnabled
|
||||
? listColumns
|
||||
: listColumns.filter((column) => column.id !== 'result-interview')
|
||||
}, [availableListHeaders, fieldInterviewEnabled, resultCodes, surveys, userRole])
|
||||
|
||||
const viewList = useMemo<ListTableRow[]>(
|
||||
() => (listSearchQuery.data?.content ?? []).map((row) => ({ ...row, ...row.itemList })),
|
||||
@@ -477,6 +526,7 @@ export function ListSearchTable({
|
||||
id: header.listHderId,
|
||||
label: header.listHderNm,
|
||||
allowedOperators: getAllowedOperators(header.listHderTy),
|
||||
defaultOperator: getDefaultOperator(header.listHderTy),
|
||||
valueOptions: getValueOptionsForHeader(header),
|
||||
disabled: lockedListFilterHeaderTypes.has(header.listHderTy),
|
||||
})),
|
||||
@@ -535,6 +585,7 @@ export function ListSearchTable({
|
||||
onSearchStateChange?.({
|
||||
searchText,
|
||||
searchContactResult,
|
||||
searchContactDateRange,
|
||||
searchInterviewResult,
|
||||
surveyResultSelections,
|
||||
filterRows,
|
||||
@@ -543,6 +594,7 @@ export function ListSearchTable({
|
||||
}, [
|
||||
searchText,
|
||||
searchContactResult,
|
||||
searchContactDateRange,
|
||||
searchInterviewResult,
|
||||
surveyResultSelections,
|
||||
filterRows,
|
||||
@@ -572,7 +624,7 @@ export function ListSearchTable({
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Input
|
||||
placeholder="SID 검색"
|
||||
className="h-9 bg-white flex-1 min-w-0 max-w-xs"
|
||||
@@ -592,18 +644,29 @@ export function ListSearchTable({
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
</div>
|
||||
<div className="flex-1 min-w-0 max-w-xs">
|
||||
<KriMultiSelect
|
||||
items={resultCodes.filter((item) => item.resultCdTy === ResultCodeType.INTERVIEW)}
|
||||
value={searchInterviewResult}
|
||||
onChange={setSearchInterviewResult}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="면접 결과"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
</div>
|
||||
<KriDateRangePicker
|
||||
value={searchContactDateRange}
|
||||
onChange={(range) => {
|
||||
setSearchContactDateRange(range)
|
||||
setPagination((prev) => ({ ...prev, pageIndex: 0 }))
|
||||
}}
|
||||
placeholder="컨택 일자"
|
||||
className="flex-1 min-w-[240px] max-w-xs"
|
||||
/>
|
||||
{fieldInterviewEnabled ? (
|
||||
<div className="flex-1 min-w-0 max-w-xs">
|
||||
<KriMultiSelect
|
||||
items={resultCodes.filter((item) => item.resultCdTy === ResultCodeType.INTERVIEW)}
|
||||
value={searchInterviewResult}
|
||||
onChange={setSearchInterviewResult}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="면접 결과"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
</div>
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
{surveys.length > 0 ? (
|
||||
|
||||
@@ -14,22 +14,13 @@ import { useCmpnListQuery } from "@/query/cmpn";
|
||||
import { useResultCodesQuery } from "@/query/project";
|
||||
import { useDateProgressQuery, useLastDateProgressQuery, useUserProgressQuery } from "@/query/progress";
|
||||
import type { ProgressEventTypeValue } from "@/types/progress";
|
||||
import type { ResultCodeType } from "@/types/project";
|
||||
import { ResultCodeType } from "@/types/project";
|
||||
import { RESULT_CODE_UNUSED } from "@/const/projectConst";
|
||||
import { UserProgressTable } from "./UserProgressTable";
|
||||
import { DateProgressSection } from "./DateProgressSection";
|
||||
import { buildResultCodeColumns } from "./resultCodeColumns";
|
||||
import { isExternalManager, isFieldWorkUser, isInternalManager } from "@/utils/userRole";
|
||||
|
||||
const getFirstDayOfMonth = (date: Date) => {
|
||||
const d = new Date(date.getFullYear(), date.getMonth(), 1);
|
||||
return d.toISOString().slice(0, 10);
|
||||
};
|
||||
|
||||
const getLastDayOfMonth = (date: Date) => {
|
||||
const d = new Date(date.getFullYear(), date.getMonth() + 1, 0);
|
||||
return d.toISOString().slice(0, 10);
|
||||
};
|
||||
|
||||
export type ProgressPageContentProps = {
|
||||
eventTy: ProgressEventTypeValue;
|
||||
resultCdTy: ResultCodeType;
|
||||
@@ -44,10 +35,7 @@ export function ProgressPageContent({ eventTy, resultCdTy, pageTitle, domainLabe
|
||||
const { selectedProject } = useSelectedProject();
|
||||
const { users, isLoading: usersLoading } = useItrntUserList();
|
||||
|
||||
const [dateRange, setDateRange] = useState(() => {
|
||||
const now = new Date();
|
||||
return { from: getFirstDayOfMonth(now), to: getLastDayOfMonth(now) };
|
||||
});
|
||||
const [dateRange, setDateRange] = useState({ from: "", to: "" });
|
||||
const [selectedUserId, setSelectedUserId] = useState<string | null>(null);
|
||||
const [selectedCmpnId, setSelectedCmpnId] = useState("ALL");
|
||||
|
||||
@@ -57,13 +45,20 @@ export function ProgressPageContent({ eventTy, resultCdTy, pageTitle, domainLabe
|
||||
const showCmpnSelect = isInternalManager(userRole);
|
||||
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
const enabled = mounted && !usersLoading && prjctIdx > 0 && !!dateRange.from && !!dateRange.to;
|
||||
const enabled = mounted && !usersLoading && prjctIdx > 0;
|
||||
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled);
|
||||
const resultCodeColumns = useMemo(
|
||||
() => buildResultCodeColumns(resultCodesQuery.data ?? [], resultCdTy),
|
||||
[resultCodesQuery.data, resultCdTy],
|
||||
);
|
||||
const dateResultCodeColumns = useMemo(
|
||||
() =>
|
||||
resultCdTy === ResultCodeType.CONTACT
|
||||
? resultCodeColumns.filter(({ resultCd }) => resultCd !== RESULT_CODE_UNUSED)
|
||||
: resultCodeColumns,
|
||||
[resultCdTy, resultCodeColumns],
|
||||
);
|
||||
|
||||
const userNameMap = useMemo(() => {
|
||||
const map: Record<string, string> = {};
|
||||
@@ -157,14 +152,14 @@ export function ProgressPageContent({ eventTy, resultCdTy, pageTitle, domainLabe
|
||||
title={`일자별 ${domainLabel} 현황(전체)`}
|
||||
subtitle={`일자별 입력된 ${domainLabel} 진행 현황을 전체 결과를 기준으로 집계하는 현황입니다.`}
|
||||
rows={dateProgressQuery.data ?? []}
|
||||
resultCodeColumns={resultCodeColumns}
|
||||
resultCodeColumns={dateResultCodeColumns}
|
||||
/>
|
||||
|
||||
<DateProgressSection
|
||||
title={`일자별 ${domainLabel} 현황(마지막 기준)`}
|
||||
subtitle={`일자별 입력된 ${domainLabel} 진행 현황을 최고 결과를 기준으로 집계하는 현황입니다.`}
|
||||
rows={lastDateProgressQuery.data ?? []}
|
||||
resultCodeColumns={resultCodeColumns}
|
||||
resultCodeColumns={dateResultCodeColumns}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
|
||||
@@ -16,6 +16,11 @@ export type UserProgressTableProps = {
|
||||
|
||||
const pct = (count: number, total: number) => (total > 0 ? `(${((count / total) * 100).toFixed(1)})` : '(0.0)')
|
||||
|
||||
const getUserLabel = (userId: string | undefined, userNameMap: Record<string, string>) => {
|
||||
if (userId === 'UNASSIGNED') return '미배정'
|
||||
return userNameMap[userId ?? ''] ?? userId ?? ''
|
||||
}
|
||||
|
||||
export function UserProgressTable({
|
||||
rows,
|
||||
resultCodeColumns,
|
||||
@@ -38,10 +43,10 @@ export function UserProgressTable({
|
||||
{
|
||||
id: 'userId',
|
||||
header: '담당자',
|
||||
accessorFn: (row) => userNameMap[row.userId ?? ''] ?? row.userId ?? '',
|
||||
accessorFn: (row) => getUserLabel(row.userId, userNameMap),
|
||||
cell: ({ row }) => (
|
||||
<div className="text-center">
|
||||
{row.getIsPinned() ? 'Total' : (userNameMap[row.original.userId ?? ''] ?? row.original.userId ?? '')}
|
||||
{row.getIsPinned() ? 'Total' : getUserLabel(row.original.userId, userNameMap)}
|
||||
</div>
|
||||
),
|
||||
},
|
||||
|
||||
@@ -5,6 +5,7 @@ import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdap
|
||||
import { QueryProvider } from "@kri/common/query";
|
||||
import { QueryLoadingSync } from "./QueryLoadingSync";
|
||||
import { CtiConnectionSync } from "./CtiConnectionSync";
|
||||
import { ReserveNotificationSync } from "./ReserveNotificationSync";
|
||||
|
||||
export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
@@ -23,6 +24,7 @@ export function AppProvider({ children }: { children: React.ReactNode }) {
|
||||
>
|
||||
<QueryLoadingSync />
|
||||
<CtiConnectionSync />
|
||||
<ReserveNotificationSync />
|
||||
<LoadingOverlayAdapter />
|
||||
{children}
|
||||
</QueryProvider>
|
||||
|
||||
8
src/components/providers/ReserveNotificationSync.tsx
Normal file
8
src/components/providers/ReserveNotificationSync.tsx
Normal file
@@ -0,0 +1,8 @@
|
||||
"use client";
|
||||
|
||||
import { useReserveNotification } from "@/hooks/useReserveNotification";
|
||||
|
||||
export function ReserveNotificationSync() {
|
||||
useReserveNotification();
|
||||
return null;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ const getResultColumns = (resultCodeArray: ResultCode[], surveys: ProjectSurvey[
|
||||
|
||||
const formatResult = (
|
||||
result?: ListResultBase,
|
||||
options?: { resultType?: ResultCodeType; showCount?: boolean },
|
||||
options?: { resultType?: ResultCodeType; showCount?: boolean; showDate?: boolean },
|
||||
) => {
|
||||
const lastResultCd = result?.lastResultCd;
|
||||
if (lastResultCd === undefined) return "";
|
||||
@@ -33,6 +33,7 @@ const getResultColumns = (resultCodeArray: ResultCode[], surveys: ProjectSurvey[
|
||||
options?.resultType !== undefined ? labelByTypeCode.get(`${options.resultType}:${lastResultCd}`) ?? "" : "";
|
||||
const label = result?.lastResultViewLabel || fallbackLabel;
|
||||
const showCount = options?.showCount ?? true;
|
||||
const showDate = options?.showDate ?? true;
|
||||
const count = result?.attemptCount ?? 0;
|
||||
const resultText = showCount ? `${lastResultCd}. ${label} (${count}회)` : `${lastResultCd}. ${label}`;
|
||||
const dt = result?.lastResultDt ? formatKst(result.lastResultDt, "dateHourMin") : "";
|
||||
@@ -40,7 +41,7 @@ const getResultColumns = (resultCodeArray: ResultCode[], surveys: ProjectSurvey[
|
||||
return (
|
||||
<div className="leading-tight">
|
||||
<div>{resultText}</div>
|
||||
{dt && <div>({dt})</div>}
|
||||
{showDate && dt && <div>({dt})</div>}
|
||||
</div>
|
||||
);
|
||||
};
|
||||
@@ -65,7 +66,20 @@ const getResultColumns = (resultCodeArray: ResultCode[], surveys: ProjectSurvey[
|
||||
header: "컨택 결과",
|
||||
accessorFn: (row) => (row.contactResult as ListContactResult | undefined)?.lastResultCd ?? null,
|
||||
cell: ({ row }) =>
|
||||
formatResult(row.original.contactResult as ListContactResult | undefined, { resultType: ResultCodeType.CONTACT }),
|
||||
formatResult(row.original.contactResult as ListContactResult | undefined, {
|
||||
resultType: ResultCodeType.CONTACT,
|
||||
showDate: false,
|
||||
}),
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
id: "result-date-contact",
|
||||
header: "컨택 일자",
|
||||
accessorFn: (row) => (row.contactResult as ListContactResult | undefined)?.lastResultDt ?? null,
|
||||
cell: ({ row }) => {
|
||||
const lastResultDt = (row.original.contactResult as ListContactResult | undefined)?.lastResultDt;
|
||||
return lastResultDt ? formatKst(lastResultDt, "dateHourMin") : "";
|
||||
},
|
||||
enableSorting: true,
|
||||
},
|
||||
{
|
||||
@@ -108,9 +122,10 @@ const getResultColumns = (resultCodeArray: ResultCode[], surveys: ProjectSurvey[
|
||||
|
||||
const resultColumnOrder = new Map([
|
||||
["result-contact", 0],
|
||||
["result-interview", 1],
|
||||
["mailSendResult", 3],
|
||||
["smsSendResult", 4],
|
||||
["result-date-contact", 1],
|
||||
["result-interview", 2],
|
||||
["mailSendResult", 4],
|
||||
["smsSendResult", 5],
|
||||
]);
|
||||
|
||||
return columns.sort((a, b) => (resultColumnOrder.get(a.id ?? "") ?? 2) - (resultColumnOrder.get(b.id ?? "") ?? 2));
|
||||
|
||||
@@ -18,7 +18,8 @@ export const getProjectColumns = (
|
||||
e.stopPropagation();
|
||||
onNavigateToInfo(projectInfo);
|
||||
};
|
||||
const infoCellClass = "flex h-full w-full items-center cursor-pointer";
|
||||
// DataTable의 body row td 패딩(px-2 py-1)만큼 음수 마진/확장으로 채워서, 클릭 영역을 셀 패딩까지 포함한 전체로 넓힌다.
|
||||
const infoCellClass = "flex h-[calc(100%+0.5rem)] w-[calc(100%+1rem)] -mx-2 -my-1 items-center px-2 cursor-pointer";
|
||||
|
||||
return [
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user