260812_01_ENH: 배정·진행 현황 개선 및 예약/이벤트 이력 기능 추가
- 프로젝트별 외주사·필드워커 배정 현황 및 미배정 건수 UI 추가 - 현장 면접 진행 여부와 사용자 권한에 따른 배정 탭·필터·컬럼 노출 제어 - 컨택 마지막 이벤트 일자 필터·정렬 및 결과/일자 컬럼 분리 - 컨택·면접·발송 현황의 날짜 범위 선택 optional 처리 - 진행 현황의 미배정 표시 및 일자별 미사용 결과 제외 - 전역 예약 기간 조회·이동 및 5분 단위 예약 알림 추가 - 내부 관리자용 이벤트 이력 단건 삭제 기능 추가 - 리스트 필터 UI 및 일반 헤더 정렬 기준 개선 - 프로젝트 저장 시 선택 프로젝트 정보 동기화
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useMounted } from '@kri/common/hooks'
|
||||
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
@@ -17,6 +17,7 @@ import { useResetListAssignMutation, useUpsertListAssignMutation } from '@/query
|
||||
import { ListHeaderAssignConst, LIST_HEADER_TYPE_LABEL } from '@/const/listConst'
|
||||
import { createEmptyListFilter, type ListFilter, type ListHeaderAssignType, type listHeader } from '@/types/list'
|
||||
import type { ResultCode } from '@/types/project'
|
||||
import { isExternalManager } from '@/utils/userRole'
|
||||
|
||||
const ASSIGN_TAB_TYPES: ListHeaderAssignType[] = [
|
||||
ListHeaderAssignConst.CONTACT_INTERVIEWER,
|
||||
@@ -36,8 +37,15 @@ const ListAssignPage = () => {
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0
|
||||
const enabled = mounted && prjctIdx > 0
|
||||
const userRole = auth?.user?.userRole ?? 0
|
||||
const isExternalUser = isExternalManager(userRole)
|
||||
|
||||
const [assignType, setAssignType] = useState<ListHeaderAssignType>(ListHeaderAssignConst.CONTACT_INTERVIEWER)
|
||||
const effectiveAssignType =
|
||||
selectedProject?.ff === false && assignType === ListHeaderAssignConst.FIELD_INTERVIEWER
|
||||
? ListHeaderAssignConst.CONTACT_INTERVIEWER
|
||||
: isExternalUser && assignType === ListHeaderAssignConst.OUTSOURCE
|
||||
? ListHeaderAssignConst.CONTACT_INTERVIEWER
|
||||
: assignType
|
||||
const [selectedAssignId, setSelectedAssignId] = useState<string | undefined>(undefined)
|
||||
const [assignFilterIds, setAssignFilterIds] = useState<string[]>([])
|
||||
const [transferResve, setTransferResve] = useState(false)
|
||||
@@ -49,11 +57,34 @@ const ListAssignPage = () => {
|
||||
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
|
||||
const upsertListAssignMutation = useUpsertListAssignMutation(prjctIdx)
|
||||
const resetListAssignMutation = useResetListAssignMutation(prjctIdx)
|
||||
const assignTargetRows = useAssignTargetRows({ prjctIdx, enabled, assignType })
|
||||
const assignTargetRows = useAssignTargetRows({ prjctIdx, enabled, assignType: effectiveAssignType })
|
||||
|
||||
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data])
|
||||
const surveyArray = useMemo(() => projectInfoQuery.data?.surveys ?? [], [projectInfoQuery.data])
|
||||
const listHeaders = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
||||
const assignTabTypes = useMemo(
|
||||
() =>
|
||||
ASSIGN_TAB_TYPES.filter((type) => {
|
||||
if (type === ListHeaderAssignConst.FIELD_INTERVIEWER && selectedProject?.ff === false) return false
|
||||
if (type === ListHeaderAssignConst.OUTSOURCE && isExternalUser) return false
|
||||
return true
|
||||
}),
|
||||
[selectedProject?.ff, isExternalUser],
|
||||
)
|
||||
|
||||
useEffect(() => {
|
||||
if (selectedProject?.ff === false && assignType === ListHeaderAssignConst.FIELD_INTERVIEWER) {
|
||||
setAssignType(ListHeaderAssignConst.CONTACT_INTERVIEWER)
|
||||
setSelectedAssignId(undefined)
|
||||
setAssignFilterIds([])
|
||||
return
|
||||
}
|
||||
if (isExternalUser && assignType === ListHeaderAssignConst.OUTSOURCE) {
|
||||
setAssignType(ListHeaderAssignConst.CONTACT_INTERVIEWER)
|
||||
setSelectedAssignId(undefined)
|
||||
setAssignFilterIds([])
|
||||
}
|
||||
}, [assignType, selectedProject?.ff, isExternalUser])
|
||||
|
||||
const handleTabChange = (value: string) => {
|
||||
setAssignType(Number(value) as ListHeaderAssignType)
|
||||
@@ -81,13 +112,13 @@ const ListAssignPage = () => {
|
||||
|
||||
const externalAssignFilter = useMemo(() => {
|
||||
if (assignFilterIds[0] === ASSIGNED_SENTINEL) {
|
||||
return { type: assignType, values: [] as string[], condition: 'assigned' as const }
|
||||
return { type: effectiveAssignType, values: [] as string[], condition: 'assigned' as const }
|
||||
}
|
||||
if (assignFilterIds[0] === UNASSIGNED_SENTINEL) {
|
||||
return { type: assignType, values: [] as string[], condition: 'unassigned' as const }
|
||||
return { type: effectiveAssignType, values: [] as string[], condition: 'unassigned' as const }
|
||||
}
|
||||
return { type: assignType, values: assignFilterIds }
|
||||
}, [assignType, assignFilterIds])
|
||||
return { type: effectiveAssignType, values: assignFilterIds }
|
||||
}, [effectiveAssignType, assignFilterIds])
|
||||
|
||||
const hasNoAppliedFilter = () => filterSummary.length === 0 && assignFilterIds.length === 0
|
||||
|
||||
@@ -103,8 +134,8 @@ const ListAssignPage = () => {
|
||||
await upsertListAssignMutation.mutateAsync({
|
||||
assignId: selectedAssignId,
|
||||
request: {
|
||||
assignType,
|
||||
transferResve: assignType === ListHeaderAssignConst.OUTSOURCE? false : transferResve,
|
||||
assignType: effectiveAssignType,
|
||||
transferResve: effectiveAssignType === ListHeaderAssignConst.OUTSOURCE? false : transferResve,
|
||||
listFilter: currentListFilter,
|
||||
},
|
||||
})
|
||||
@@ -118,7 +149,7 @@ const ListAssignPage = () => {
|
||||
if (!confirm('정말 배정을 초기화 하시겠습니까?')) return
|
||||
|
||||
await resetListAssignMutation.mutateAsync({
|
||||
assignType,
|
||||
assignType: effectiveAssignType,
|
||||
listFilter: currentListFilter,
|
||||
})
|
||||
alert('배정이 초기화 되었습니다.')
|
||||
@@ -129,9 +160,9 @@ const ListAssignPage = () => {
|
||||
return (
|
||||
<div className="flex gap-4 text-sm">
|
||||
<div className="w-72 shrink-0 space-y-2">
|
||||
<Tabs value={String(assignType)} onValueChange={handleTabChange}>
|
||||
<TabsList className="grid w-full grid-cols-3">
|
||||
{ASSIGN_TAB_TYPES.map((type) => (
|
||||
<Tabs value={String(effectiveAssignType)} onValueChange={handleTabChange}>
|
||||
<TabsList className={`grid w-full ${assignTabTypes.length === 2 ? 'grid-cols-2' : assignTabTypes.length === 1 ? 'grid-cols-1' : 'grid-cols-3'}`}>
|
||||
{assignTabTypes.map((type) => (
|
||||
<TabsTrigger key={type} value={String(type)}>
|
||||
{LIST_HEADER_TYPE_LABEL[type]}
|
||||
</TabsTrigger>
|
||||
@@ -142,7 +173,8 @@ const ListAssignPage = () => {
|
||||
<AssignTargetList
|
||||
prjctIdx={prjctIdx}
|
||||
enabled={enabled}
|
||||
assignType={assignType}
|
||||
assignType={effectiveAssignType}
|
||||
userRole={userRole}
|
||||
selectedId={selectedAssignId}
|
||||
onSelect={setSelectedAssignId}
|
||||
/>
|
||||
@@ -158,10 +190,11 @@ const ListAssignPage = () => {
|
||||
resultCodes={resultCodeArray}
|
||||
surveys={surveyArray}
|
||||
listHeaders={listHeaders}
|
||||
fieldInterviewEnabled={selectedProject.ff !== false}
|
||||
selectMode="none"
|
||||
onCurrentFilterChange={setCurrentListFilter}
|
||||
onFilterSummaryChange={setFilterSummary}
|
||||
excludeFilterHeaderTypes={[assignType]}
|
||||
excludeFilterHeaderTypes={[effectiveAssignType]}
|
||||
externalAssignFilter={externalAssignFilter}
|
||||
filterActions={
|
||||
<KriMultiSelect
|
||||
@@ -170,14 +203,14 @@ const ListAssignPage = () => {
|
||||
onChange={handleAssignFilterChange}
|
||||
getValue={(item) => item.id}
|
||||
getLabel={(item) => item.name}
|
||||
placeholder={`${LIST_HEADER_TYPE_LABEL[assignType]} 필터`}
|
||||
placeholder={`${LIST_HEADER_TYPE_LABEL[effectiveAssignType]} 필터`}
|
||||
widthClassName="w-56"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
}
|
||||
rightActions={
|
||||
<>
|
||||
{assignType === ListHeaderAssignConst.CONTACT_INTERVIEWER && (
|
||||
{effectiveAssignType === ListHeaderAssignConst.CONTACT_INTERVIEWER && (
|
||||
<label className="flex items-center gap-2 text-base cursor-pointer">
|
||||
<Checkbox
|
||||
checked={transferResve}
|
||||
|
||||
@@ -13,7 +13,7 @@ import { UserInfo } from "@/types/user";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { KriSelect, KriSelectItem } from "@/components/common/KriSelect";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import {CONTACT_INTERVIEWER_ROLE} from "@/const/userConst";
|
||||
import { CONTACT_INTERVIEWER_ROLE, FIELD_INTERVIEWER_ROLE } from "@/const/userConst";
|
||||
|
||||
import {
|
||||
useFieldworkUsersQuery,
|
||||
@@ -61,8 +61,9 @@ const ProjectAssignPage = () => {
|
||||
const roles = roleQuery.data ?? [];
|
||||
return roles
|
||||
.filter(r => isFieldWorkUser(r.roleCd))
|
||||
.filter(r => selectedProject?.ff !== false || r.roleCd !== FIELD_INTERVIEWER_ROLE)
|
||||
.map(r => ({ value: String(r.roleCd), label: r.roleNm }));
|
||||
}, [roleQuery.data]);
|
||||
}, [roleQuery.data, selectedProject?.ff]);
|
||||
|
||||
const [companyFilter, setCompanyFilter] = useState<string>('');
|
||||
const [roleFilter, setRoleFilter] = useState<KriSelectItem | undefined>(undefined);
|
||||
@@ -233,8 +234,8 @@ const ProjectAssignPage = () => {
|
||||
}, [auth.user?.userCmpn, companyArray, companyFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
if (roleFilter) return;
|
||||
if (roleArray.length === 0) return;
|
||||
if (roleFilter && roleArray.some(role => role.value === roleFilter.value)) return;
|
||||
|
||||
const contactRole = roleArray.find(r => r.value === String(CONTACT_INTERVIEWER_ROLE));
|
||||
setRoleFilter(contactRole ?? roleArray[0]);
|
||||
|
||||
@@ -2,19 +2,17 @@
|
||||
|
||||
import { Suspense, useEffect, useMemo, useState } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { ArrowLeft, CalendarClock, RefreshCw } from "lucide-react";
|
||||
import { ArrowLeft, RefreshCw } from "lucide-react";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useDialog } from "@/hooks/useDialog";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useListDetailQuery, useListHeaderQuery, useListReserveByUserQuery, useUpdateListMutation } from "@/query/list";
|
||||
import { useListDetailQuery, useListHeaderQuery, useUpdateListMutation } from "@/query/list";
|
||||
import { useProjectInfoQuery, useResultCodesQuery } from "@/query/project";
|
||||
import ListContactInfoPanel, { buildInitialValues } from "@/components/list-contact/ListContactInfoPanel";
|
||||
import ListContactEventPanel from "@/components/list-contact/ListContactEventPanel";
|
||||
import ListUpdateHistoryPanel from "@/components/list-contact/ListUpdateHistoryPanel";
|
||||
import ReservationListDialog from "@/components/dialog/ReservationListDialog";
|
||||
import { createEmptyListFilter, type listHeader } from "@/types/list";
|
||||
import type { ResultCode } from "@/types/project";
|
||||
import { isManager } from "@/utils/userRole";
|
||||
@@ -31,7 +29,6 @@ const ListContactPageContent = () => {
|
||||
const mounted = useMounted();
|
||||
const { auth } = useAuth();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
const { isDialogOpen, showDialog } = useDialog();
|
||||
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
const prjctCd = selectedProject?.prjctCd ?? "";
|
||||
@@ -116,9 +113,6 @@ const ListContactPageContent = () => {
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, queriesEnabled);
|
||||
const updateListMutation = useUpdateListMutation(prjctIdx);
|
||||
|
||||
const reservationDialogOpen = isDialogOpen('reservationListDialog');
|
||||
const reserveByUserQuery = useListReserveByUserQuery(prjctIdx, userId, reservationDialogOpen);
|
||||
|
||||
const listHeaders = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data]);
|
||||
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data]);
|
||||
|
||||
@@ -139,14 +133,6 @@ const ListContactPageContent = () => {
|
||||
router.push("/list/manage");
|
||||
}, [sid, router]);
|
||||
|
||||
const handleNavigateToSid = (nextSid: string) => {
|
||||
if(shouldBlockNavigation){
|
||||
alert("통화 중에는 이동할 수 없습니다.");
|
||||
return;
|
||||
}
|
||||
router.push(`/list/contact?sid=${encodeURIComponent(nextSid)}`);
|
||||
};
|
||||
|
||||
const handleGoToListManage = () => {
|
||||
if(shouldBlockNavigation){
|
||||
alert("통화 중에는 이동할 수 없습니다.");
|
||||
@@ -206,10 +192,6 @@ const ListContactPageContent = () => {
|
||||
<RefreshCw className={`h-4 w-4 ${listDetailQuery.isFetching ? "animate-spin" : ""}`} />
|
||||
</Button>
|
||||
<div className="ml-auto flex items-center gap-2">
|
||||
<Button type="button" variant="outline" className="gap-2" onClick={() => showDialog('reservationListDialog')}>
|
||||
<CalendarClock className="h-4 w-4" />
|
||||
예약리스트 조회
|
||||
</Button>
|
||||
{isEditing ? (
|
||||
<Button type="button" variant="outline" disabled={updateListMutation.isPending} onClick={handleCancelEdit}>
|
||||
취소
|
||||
@@ -258,8 +240,6 @@ const ListContactPageContent = () => {
|
||||
detail={listDetailQuery.data}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ReservationListDialog reservations={reserveByUserQuery.data ?? []} onSelectReservation={handleNavigateToSid} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
@@ -68,6 +68,7 @@ const downloadArrayBuffer = (buffer: ArrayBuffer, filename: string, type = 'appl
|
||||
const createEmptySearchUiState = (): ListSearchUiState => ({
|
||||
searchText: '',
|
||||
searchContactResult: [],
|
||||
searchContactDateRange: { from: '', to: '' },
|
||||
searchInterviewResult: [],
|
||||
surveyResultSelections: {},
|
||||
filterRows: [],
|
||||
@@ -284,6 +285,7 @@ const ListManagePage = () => {
|
||||
resultCodes={resultCodeArray}
|
||||
surveys={surveyArray}
|
||||
listHeaders={headerManageRows}
|
||||
fieldInterviewEnabled={selectedProject?.ff !== false}
|
||||
enableBatchEdit={canManageList}
|
||||
selectMode={canManageList ? 'multi' : 'click-event'}
|
||||
refreshKey={listRefreshKey}
|
||||
|
||||
@@ -49,28 +49,15 @@ const buildRows = (data: SendResultSummaryResponse[]): SummaryRow[] =>
|
||||
const moneyUnit = (value: number) => `${value.toLocaleString()}원`;
|
||||
const caseUnit = (value: number) => `${value.toLocaleString()}건`;
|
||||
|
||||
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);
|
||||
};
|
||||
|
||||
const MessageProgressPage = () => {
|
||||
const mounted = useMounted();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
|
||||
const [dateRange, setDateRange] = useState(() => {
|
||||
const now = new Date();
|
||||
return { from: getFirstDayOfMonth(now), to: getLastDayOfMonth(now) };
|
||||
});
|
||||
const [dateRange, setDateRange] = useState({ from: "", to: "" });
|
||||
|
||||
const prjctCd = selectedProject?.prjctCd ?? "";
|
||||
const itrntPrjctCd = selectedProject?.itrntPrjctCd ?? "";
|
||||
const enabled = mounted && !!prjctCd && !!dateRange.from && !!dateRange.to;
|
||||
const enabled = mounted && !!prjctCd;
|
||||
|
||||
const summaryQuery = useSendResultSummaryQuery(
|
||||
{
|
||||
|
||||
@@ -333,7 +333,7 @@ const SurveyCard = ({ survey, index, itrntPrjctCd, userTeam, invalidField, onReg
|
||||
const ProjectInfoPage = () => {
|
||||
const router = useRouter();
|
||||
const mounted = useMounted();
|
||||
const {selectedProject} = useSelectedProject();
|
||||
const {selectedProject, setSelectedProject} = useSelectedProject();
|
||||
const {isDialogOpen, showDialog, hideDialog} = useDialog();
|
||||
const {users} = useItrntUserList();
|
||||
const {auth} = useAuth();
|
||||
@@ -544,6 +544,16 @@ const ProjectInfoPage = () => {
|
||||
}
|
||||
|
||||
await updateMutation.mutateAsync(requestUpdateProject);
|
||||
const savedProjectInfo = requestUpdateProject.projectInfo;
|
||||
setSelectedProject({
|
||||
prjctIdx: savedProjectInfo.prjctIdx,
|
||||
prjctCd: savedProjectInfo.prjctCd,
|
||||
prjctName: savedProjectInfo.prjctName,
|
||||
itrntPrjctCd: savedProjectInfo.itrntPrjctCd,
|
||||
ownerDept: savedProjectInfo.ownerDept,
|
||||
ownerFw: savedProjectInfo.ownerFw,
|
||||
ff: savedProjectInfo.ff,
|
||||
});
|
||||
initialProjectInfoRef.current = projectInfo;
|
||||
alert("저장되었습니다.");
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {ProjectCompanyAssignSummary, ProjectFieldworkAssignSummary} from "@/types/list";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
@@ -19,6 +20,25 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "prjct-cmpn-summary" && slug.length === 2) {
|
||||
const result = await contactApi.get<ProjectCompanyAssignSummary>(`/assign/prjct-cmpn-summary/${slug[1]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "prjct-fieldwork-summary" && slug.length === 2) {
|
||||
const assignType = req.nextUrl.searchParams.get("assignType");
|
||||
const cmpnIds = req.nextUrl.searchParams.get("cmpnIds");
|
||||
if (!assignType) {
|
||||
return NextResponse.json({ message: "assignType이 필요합니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const query = `?assignType=${assignType}${cmpnIds ? `&cmpnIds=${encodeURIComponent(cmpnIds)}` : ""}`;
|
||||
const result = await contactApi.get<ProjectFieldworkAssignSummary>(
|
||||
`/assign/prjct-fieldwork-summary/${slug[1]}${query}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -30,6 +30,23 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
}
|
||||
};
|
||||
|
||||
export const DELETE = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "event" && slug.length === 2) {
|
||||
await contactApi.del(`/list-hist/event/${slug[1]}`);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
|
||||
@@ -17,11 +17,31 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "user" && slug.length === 3 && slug[2] === "search") {
|
||||
const fromDt = req.nextUrl.searchParams.get("fromDt");
|
||||
const toDt = req.nextUrl.searchParams.get("toDt");
|
||||
if (!fromDt || !toDt) {
|
||||
return NextResponse.json({ message: "fromDt, toDt가 필요합니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const result = await contactApi.get<ListReserve[]>(
|
||||
`/reserve/user/${encodeURIComponent(slug[1])}/search?fromDt=${fromDt}&toDt=${toDt}`,
|
||||
);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "user" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListReserve[]>(`/reserve/${slug[1]}/user/${slug[2]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "user" && slug.length === 2) {
|
||||
const requestPast = req.nextUrl.searchParams.get("requestPast");
|
||||
const query = requestPast !== null ? `?requestPast=${requestPast}` : "";
|
||||
const result = await contactApi.get<ListReserve[]>(`/reserve/user/${encodeURIComponent(slug[1])}${query}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -251,3 +251,4 @@
|
||||
.ProseMirror [data-resize-container][data-resize-state="resizing"] {
|
||||
outline: 1px dashed #0ea5e9;
|
||||
}
|
||||
|
||||
|
||||
@@ -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 [
|
||||
{
|
||||
|
||||
85
src/hooks/useReserveNotification.tsx
Normal file
85
src/hooks/useReserveNotification.tsx
Normal file
@@ -0,0 +1,85 @@
|
||||
"use client";
|
||||
|
||||
import { useEffect } from "react";
|
||||
import { X } from "lucide-react";
|
||||
import { toast } from "sonner";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import { useDialog } from "@/hooks/useDialog";
|
||||
import { fetchReserveNotifications } from "@/query/reserve";
|
||||
|
||||
const FIVE_MINUTES_MS = 5 * 60_000;
|
||||
const RESERVE_NOTIFICATION_TOAST_ID = "reserve-notification";
|
||||
|
||||
// 예약은 5분 단위로만 등록되므로, 5분 정각(0,5,10,...)에 맞춰 조회해야 창을 놓치지 않는다.
|
||||
const msUntilNextFiveMinuteMark = (now: Date) => {
|
||||
const next = new Date(now);
|
||||
const minutesToNext = 5 - (now.getMinutes() % 5);
|
||||
next.setMinutes(now.getMinutes() + minutesToNext, 0, 0);
|
||||
return next.getTime() - now.getTime();
|
||||
};
|
||||
|
||||
export function useReserveNotification() {
|
||||
const { auth } = useAuth();
|
||||
const { showDialog } = useDialog();
|
||||
const userId = auth.user?.userId ?? "";
|
||||
|
||||
useEffect(() => {
|
||||
if (!userId) return;
|
||||
|
||||
let intervalId: ReturnType<typeof setInterval> | undefined;
|
||||
let cancelled = false;
|
||||
|
||||
const showNotification = () => {
|
||||
toast.custom(
|
||||
(id) => (
|
||||
<div
|
||||
className="flex w-[360px] cursor-pointer items-start justify-between gap-3 rounded-lg border border-amber-500 bg-amber-100 p-4 text-amber-900 shadow-md"
|
||||
onClick={() => {
|
||||
toast.dismiss(id);
|
||||
showDialog("reserveSearchDialog");
|
||||
}}
|
||||
>
|
||||
<span className="text-base font-bold">5분 이내에 예약된 내용이 있습니다.</span>
|
||||
<button
|
||||
type="button"
|
||||
aria-label="닫기"
|
||||
className="shrink-0 cursor-pointer rounded-full p-1 text-amber-900/70 hover:bg-amber-200 hover:text-amber-900"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation();
|
||||
toast.dismiss(id);
|
||||
}}
|
||||
>
|
||||
<X className="size-4" />
|
||||
</button>
|
||||
</div>
|
||||
),
|
||||
{ id: RESERVE_NOTIFICATION_TOAST_ID, duration: Infinity },
|
||||
);
|
||||
};
|
||||
|
||||
const poll = async (requestPast: boolean) => {
|
||||
try {
|
||||
const reservations = await fetchReserveNotifications(userId, requestPast);
|
||||
if (cancelled || reservations.length === 0) return;
|
||||
|
||||
showNotification();
|
||||
} catch (error) {
|
||||
console.error("[reserve-notification] 예약 알림 조회 실패", error);
|
||||
}
|
||||
};
|
||||
|
||||
void poll(true);
|
||||
|
||||
const alignTimeoutId = setTimeout(() => {
|
||||
if (cancelled) return;
|
||||
void poll(false);
|
||||
intervalId = setInterval(() => void poll(false), FIVE_MINUTES_MS);
|
||||
}, msUntilNextFiveMinuteMark(new Date()));
|
||||
|
||||
return () => {
|
||||
cancelled = true;
|
||||
clearTimeout(alignTimeoutId);
|
||||
if (intervalId) clearInterval(intervalId);
|
||||
};
|
||||
}, [userId, showDialog]);
|
||||
}
|
||||
@@ -2,15 +2,27 @@
|
||||
|
||||
import { useMutation, useQueryClient } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { qk } from "@/query/key/keys";
|
||||
import type { ListAssignRequest, ListAssignResetRequest } from "@/types/list";
|
||||
|
||||
const invalidateAssignSummaries = (qc: ReturnType<typeof useQueryClient>, prjctIdx: number) =>
|
||||
Promise.all([
|
||||
qc.invalidateQueries({ queryKey: qk.projectAssignCmpnSummary(prjctIdx) }),
|
||||
qc.invalidateQueries({ queryKey: ["assign", "prjct-fieldwork-summary", prjctIdx] }),
|
||||
]);
|
||||
|
||||
export function useUpsertListAssignMutation(prjctIdx: number) {
|
||||
const qc = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: ({ assignId, request }: { assignId: string; request: ListAssignRequest }) =>
|
||||
nextApi.put<number>(`/assign/list/${prjctIdx}/${encodeURIComponent(assignId)}`, request),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
qc.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
invalidateAssignSummaries(qc, prjctIdx),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -20,6 +32,11 @@ export function useResetListAssignMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (request: ListAssignResetRequest) =>
|
||||
nextApi.del<number>(`/assign/list/reset/${prjctIdx}`, { json: request }),
|
||||
onSuccess: () => qc.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
qc.invalidateQueries({ queryKey: ["list", "search-filter"] }),
|
||||
invalidateAssignSummaries(qc, prjctIdx),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
@@ -30,6 +30,9 @@ export const qk = {
|
||||
/********** 배정 관련 **********/
|
||||
projectAssignFieldwork: (prjctIdx: number) => ["assign", "prjct-fieldwork", prjctIdx] as const,
|
||||
projectAssignCmpn: (prjctIdx: number) => ["assign", "prjct-cmpn", prjctIdx] as const,
|
||||
projectAssignCmpnSummary: (prjctIdx: number) => ["assign", "prjct-cmpn-summary", prjctIdx] as const,
|
||||
projectAssignFieldworkSummary: (prjctIdx: number, assignType: number, cmpnIds: string[]) =>
|
||||
["assign", "prjct-fieldwork-summary", prjctIdx, assignType, [...cmpnIds].sort()] as const,
|
||||
/********** 배정 관련 **********/
|
||||
|
||||
/********** KON, KIWI 프로젝트 관련 KART에서 받아옴 **********/
|
||||
@@ -58,9 +61,13 @@ export const qk = {
|
||||
listEventHistory: (prjctIdx: number, sid: string) => ["list", "event-history", prjctIdx, sid] as const,
|
||||
listUpdateHistory: (prjctIdx: number, sid: string) => ["list", "update-history", prjctIdx, sid] as const,
|
||||
listReserveBySid: (prjctIdx: number, sid: string) => ["list", "reserve", "sid", prjctIdx, sid] as const,
|
||||
listReserveByUser: (prjctIdx: number, userId: string) => ["list", "reserve", "user", prjctIdx, userId] as const,
|
||||
/********** 리스트 관련 **********/
|
||||
|
||||
/********** 예약 알림 관련 **********/
|
||||
reserveSearch: (userId: string, fromDt: string, toDt: string) =>
|
||||
["reserve", "search", userId, fromDt, toDt] as const,
|
||||
/********** 예약 알림 관련 **********/
|
||||
|
||||
/********** 템플릿 및 발송 관련 **********/
|
||||
mainTemplate: (prjctIdx: number, chnnlTy: ChannelType) =>
|
||||
["project", "main-template", prjctIdx, chnnlTy] as const,
|
||||
|
||||
@@ -52,6 +52,9 @@ const serializeListSearchRequest = (request: ListSearchRequest) => ({
|
||||
[ResultCodeType.INTERVIEW]: [],
|
||||
},
|
||||
surveyResultConditions: request.listFilter.surveyResultConditions ?? [],
|
||||
...(request.listFilter.lastEventDateRange?.length
|
||||
? { lastEventDateRange: request.listFilter.lastEventDateRange }
|
||||
: {}),
|
||||
memoConditions: request.listFilter.memoConditions ?? [],
|
||||
otherItemConditions: request.listFilter.otherItemConditions ?? [],
|
||||
},
|
||||
@@ -122,26 +125,15 @@ export function useListReserveBySidQuery(prjctIdx: number, sid: string, enabled:
|
||||
});
|
||||
}
|
||||
|
||||
export function useListReserveByUserQuery(prjctIdx: number, userId: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.listReserveByUser(prjctIdx, userId),
|
||||
queryFn: () => nextApi.get<ListReserve[]>(`/reserve/user/${prjctIdx}/${userId}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
export function useReserveMutation(prjctIdx: number, sid: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (request: ListReserveRequest) => nextApi.put<ListReserve>(`/reserve`, request),
|
||||
onSuccess: async (_result, request) => {
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: qk.listReserveBySid(prjctIdx, sid) }),
|
||||
queryClient.invalidateQueries({ queryKey: qk.listReserveByUser(prjctIdx, request.userId) }),
|
||||
queryClient.invalidateQueries({ queryKey: ["reserve", "search"] }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
@@ -260,6 +252,20 @@ export function useAddListEventMutation(prjctIdx: number, sid: string) {
|
||||
});
|
||||
}
|
||||
|
||||
export function useDeleteListEventMutation(prjctIdx: number, sid: string) {
|
||||
const queryClient = useQueryClient();
|
||||
|
||||
return useMutation({
|
||||
mutationFn: (listEventHistIdx: number) => nextApi.del<void>(`/list-hist/event/${listEventHistIdx}`),
|
||||
onSuccess: async () => {
|
||||
await Promise.all([
|
||||
queryClient.invalidateQueries({ queryKey: qk.listDetail(prjctIdx, sid) }),
|
||||
queryClient.invalidateQueries({ queryKey: qk.listEventHistory(prjctIdx, sid) }),
|
||||
]);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
export function useDownloadListMutation(prjctIdx: number) {
|
||||
return useMutation({
|
||||
mutationFn: (listFilter: ListFilter) =>
|
||||
|
||||
@@ -11,6 +11,7 @@ import type {
|
||||
ProjectListRequest,
|
||||
ProjectOwnerResponse, ProjectUpdateRequest, ResultCode
|
||||
} from "@/types/project";
|
||||
import type { ListHeaderAssignType, ProjectCompanyAssignSummary, ProjectFieldworkAssignSummary } from "@/types/list";
|
||||
import type { PageRequest, PageResponse } from "@kri/common";
|
||||
|
||||
export function useProjectOwnerListQuery(enabled: boolean = true) {
|
||||
@@ -166,6 +167,41 @@ export function useAssignedFieldworkIdsQuery(prjctIdx: number, enabled: boolean)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트의 외주사별 배정 현황(총 개수/미배정 개수/외주사별 배정 개수)
|
||||
*/
|
||||
export function useAssignedCmpnSummaryQuery(prjctIdx: number, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.projectAssignCmpnSummary(prjctIdx),
|
||||
queryFn: () => nextApi.get<ProjectCompanyAssignSummary>(`/assign/prjct-cmpn-summary/${prjctIdx}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 프로젝트의 컨택원/면접원별 배정 현황(총 개수/미배정 개수/사람별 배정 개수)
|
||||
* cmpnIds를 지정하면 해당 외주사 소속 인원 범위로 카운트가 재계산된다(외주사 계정은 서버에서 본인 회사로 강제됨).
|
||||
*/
|
||||
export function useAssignedFieldworkSummaryQuery(
|
||||
prjctIdx: number,
|
||||
assignType: ListHeaderAssignType,
|
||||
cmpnIds: string[],
|
||||
enabled: boolean,
|
||||
) {
|
||||
return useQuery({
|
||||
queryKey: qk.projectAssignFieldworkSummary(prjctIdx, assignType, cmpnIds),
|
||||
queryFn: () => {
|
||||
const query = `?assignType=${assignType}${cmpnIds.length > 0 ? `&cmpnIds=${cmpnIds.join(",")}` : ""}`;
|
||||
return nextApi.get<ProjectFieldworkAssignSummary>(`/assign/prjct-fieldwork-summary/${prjctIdx}${query}`);
|
||||
},
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
});
|
||||
}
|
||||
|
||||
export function useCreateProjectMutation() {
|
||||
const qc = useQueryClient();
|
||||
|
||||
|
||||
30
src/query/reserve.ts
Normal file
30
src/query/reserve.ts
Normal file
@@ -0,0 +1,30 @@
|
||||
"use client";
|
||||
|
||||
import { useQuery } from "@tanstack/react-query";
|
||||
import { nextApi } from "@/lib/http-client";
|
||||
import { qk } from "@/query/key/keys";
|
||||
import type { ListReserve } from "@/types/list";
|
||||
|
||||
/**
|
||||
* 헤더의 예약 조회 다이얼로그용: 전체 프로젝트 대상, 날짜 range로 조회.
|
||||
*/
|
||||
export function useReserveSearchQuery(userId: string, fromDt: string, toDt: string, enabled: boolean) {
|
||||
return useQuery({
|
||||
queryKey: qk.reserveSearch(userId, fromDt, toDt),
|
||||
queryFn: () =>
|
||||
nextApi.get<ListReserve[]>(`/reserve/user/${encodeURIComponent(userId)}/search?fromDt=${fromDt}&toDt=${toDt}`),
|
||||
enabled,
|
||||
staleTime: 0,
|
||||
refetchOnMount: "always",
|
||||
meta: { ignoreGlobalLoading: true },
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 5분 정각 폴링용: react-query 캐시 없이 그때그때 호출한다(useReserveNotification 훅 전용).
|
||||
*/
|
||||
export function fetchReserveNotifications(userId: string, requestPast: boolean) {
|
||||
return nextApi.get<ListReserve[]>(
|
||||
`/reserve/user/${encodeURIComponent(userId)}?requestPast=${requestPast}`,
|
||||
);
|
||||
}
|
||||
@@ -15,5 +15,5 @@ export type DialogId =
|
||||
| "messageSendDialog"
|
||||
| "messageHistoryDialog"
|
||||
| "surveyQrDialog"
|
||||
| "reservationListDialog"
|
||||
| "reserveSearchDialog"
|
||||
| "singleMessageSendDialog";
|
||||
|
||||
@@ -46,7 +46,7 @@ export enum ListEventHistoryBase {
|
||||
LATEST = 2,
|
||||
}
|
||||
|
||||
export type FilterOperator = 'eq' | 'neq' | 'contains' | 'notContains' | 'empty' | 'notEmpty';
|
||||
export type FilterOperator = 'eq' | 'neq' | 'contains' | 'notContains' | 'empty' | 'notEmpty' | 'none';
|
||||
|
||||
export type FilterValueOption = {
|
||||
value: string;
|
||||
@@ -57,6 +57,7 @@ export type FilterHeaderOption = {
|
||||
id: number;
|
||||
label: string;
|
||||
allowedOperators: FilterOperator[];
|
||||
defaultOperator: FilterOperator;
|
||||
valueOptions?: FilterValueOption[];
|
||||
disabled?: boolean;
|
||||
};
|
||||
@@ -120,6 +121,13 @@ export type SurveyResultCondition = {
|
||||
resultCodes: number[];
|
||||
};
|
||||
|
||||
export interface LastEventDateRange {
|
||||
resultCodeType: 21 | 22 | 91;
|
||||
prjctSurveyIdx?: number | null;
|
||||
startDate?: string | null;
|
||||
endDate?: string | null;
|
||||
}
|
||||
|
||||
export type ListFilter = {
|
||||
sidSet: string[];
|
||||
listUseSet: ListIsUse[];
|
||||
@@ -128,6 +136,7 @@ export type ListFilter = {
|
||||
assignConditions: ListAssignFilterCondition[];
|
||||
resultCodeMap: Record<Exclude<ResultCodeType, ResultCodeType.SURVEY>, number[]>;
|
||||
surveyResultConditions: SurveyResultCondition[];
|
||||
lastEventDateRange?: LastEventDateRange[];
|
||||
memoConditions: ListFilterCondition[];
|
||||
otherItemConditions: ListOtherItemFilterCondition[];
|
||||
};
|
||||
@@ -160,6 +169,7 @@ export type SurveyResultSelections = Record<number, string[]>;
|
||||
export type ListSearchUiState = {
|
||||
searchText: string;
|
||||
searchContactResult: string[];
|
||||
searchContactDateRange: { from: string; to: string };
|
||||
searchInterviewResult: string[];
|
||||
surveyResultSelections: SurveyResultSelections;
|
||||
filterRows: FilterRow[];
|
||||
@@ -252,6 +262,7 @@ export type ListUpdateHistory = {
|
||||
export type ListReserve = {
|
||||
listResveIdx: number;
|
||||
prjctIdx: number;
|
||||
prjctName: string;
|
||||
sid: string;
|
||||
memo?: string;
|
||||
cnfirm: boolean;
|
||||
@@ -310,6 +321,31 @@ export type ListAssignResetRequest = {
|
||||
listFilter: ListFilter;
|
||||
};
|
||||
|
||||
export type CompanyAssignSummaryItem = {
|
||||
cmpnId: string;
|
||||
cmpnAlias: string;
|
||||
assignedCount: number;
|
||||
};
|
||||
|
||||
export type ProjectCompanyAssignSummary = {
|
||||
totalCount: number;
|
||||
unassignedCount: number;
|
||||
assignees: CompanyAssignSummaryItem[];
|
||||
};
|
||||
|
||||
export type FieldworkAssignSummaryItem = {
|
||||
userId: string;
|
||||
userName: string;
|
||||
userCmpn: string;
|
||||
assignedCount: number;
|
||||
};
|
||||
|
||||
export type ProjectFieldworkAssignSummary = {
|
||||
totalCount: number;
|
||||
unassignedCount: number;
|
||||
assignees: FieldworkAssignSummaryItem[];
|
||||
};
|
||||
|
||||
export type ListResetRequest = {
|
||||
resetMode: ListResetMode;
|
||||
listFilter: ListFilter;
|
||||
|
||||
Reference in New Issue
Block a user