260714_01_ENH: 테스트 서버에서 기동 후 중간 테스트를 위한 커밋
This commit is contained in:
@@ -1,8 +1,196 @@
|
||||
const ListAssignPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
'use client'
|
||||
|
||||
return (<div>This is List Assign Page</div>)
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useMounted } from '@kri/common/hooks'
|
||||
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { Tabs, TabsList, TabsTrigger } from '@/components/ui/tabs'
|
||||
import { KriMultiSelect } from '@/components/common/KriAutoComplete'
|
||||
import { AssignTargetList, useAssignTargetRows } from '@/components/assign/AssignTargetList'
|
||||
import { ListSearchTable } from '@/components/list/ListSearchTable'
|
||||
import { useResultCodesQuery } from '@/query/project'
|
||||
import { useListHeaderQuery } from '@/query/list'
|
||||
import { useResetListAssignMutation, useUpsertListAssignMutation } from '@/query/assign'
|
||||
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'
|
||||
|
||||
const ASSIGN_TAB_TYPES: ListHeaderAssignType[] = [
|
||||
ListHeaderAssignConst.OUTSOURCE,
|
||||
ListHeaderAssignConst.CONTACT_INTERVIEWER,
|
||||
ListHeaderAssignConst.FIELD_INTERVIEWER,
|
||||
]
|
||||
|
||||
const ASSIGNED_SENTINEL = '__ASSIGNED__'
|
||||
const UNASSIGNED_SENTINEL = '__UNASSIGNED__'
|
||||
const isAssignFilterSentinel = (value: string) => value === ASSIGNED_SENTINEL || value === UNASSIGNED_SENTINEL
|
||||
|
||||
const ListAssignPage = () => {
|
||||
const mounted = useMounted()
|
||||
const { auth } = useAuth()
|
||||
const { selectedProject } = useSelectedProject()
|
||||
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0
|
||||
const enabled = mounted && prjctIdx > 0
|
||||
const userRole = auth?.user?.userRole ?? 0
|
||||
|
||||
const [assignType, setAssignType] = useState<ListHeaderAssignType>(ListHeaderAssignConst.OUTSOURCE)
|
||||
const [selectedAssignId, setSelectedAssignId] = useState<string | undefined>(undefined)
|
||||
const [assignFilterIds, setAssignFilterIds] = useState<string[]>([])
|
||||
const [transferResve, setTransferResve] = useState(false)
|
||||
const [currentListFilter, setCurrentListFilter] = useState<ListFilter>(() => createEmptyListFilter())
|
||||
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled)
|
||||
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
|
||||
const upsertListAssignMutation = useUpsertListAssignMutation(prjctIdx)
|
||||
const resetListAssignMutation = useResetListAssignMutation(prjctIdx)
|
||||
const assignTargetRows = useAssignTargetRows({ prjctIdx, enabled, assignType })
|
||||
|
||||
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data])
|
||||
const listHeaders = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
||||
|
||||
const handleTabChange = (value: string) => {
|
||||
setAssignType(Number(value) as ListHeaderAssignType)
|
||||
setSelectedAssignId(undefined)
|
||||
}
|
||||
|
||||
// 좌측 테이블 선택값이 바뀌면 결과 필터 multiselect도 그 값으로 맞춘다.
|
||||
useEffect(() => {
|
||||
setAssignFilterIds(selectedAssignId ? [selectedAssignId] : [])
|
||||
}, [selectedAssignId])
|
||||
|
||||
// "배정됨"/"배정되지 않음"은 실제 대상 선택과 동시에 선택될 수 없다: 새로 클릭된 쪽만 남긴다.
|
||||
const handleAssignFilterChange = (next: string[]) => {
|
||||
const addedSentinel = next.find((value) => isAssignFilterSentinel(value) && !assignFilterIds.includes(value))
|
||||
if (addedSentinel) {
|
||||
setAssignFilterIds([addedSentinel])
|
||||
return
|
||||
}
|
||||
setAssignFilterIds(next.filter((value) => !isAssignFilterSentinel(value)))
|
||||
}
|
||||
|
||||
const assignFilterItems = useMemo(
|
||||
() => [
|
||||
{ id: ASSIGNED_SENTINEL, name: '배정됨' },
|
||||
{ id: UNASSIGNED_SENTINEL, name: '배정되지 않음' },
|
||||
...assignTargetRows,
|
||||
],
|
||||
[assignTargetRows],
|
||||
)
|
||||
|
||||
const externalAssignFilter = useMemo(() => {
|
||||
if (assignFilterIds[0] === ASSIGNED_SENTINEL) {
|
||||
return { type: assignType, values: [] as string[], condition: 'assigned' as const }
|
||||
}
|
||||
if (assignFilterIds[0] === UNASSIGNED_SENTINEL) {
|
||||
return { type: assignType, values: [] as string[], condition: 'unassigned' as const }
|
||||
}
|
||||
return { type: assignType, values: assignFilterIds }
|
||||
}, [assignType, assignFilterIds])
|
||||
|
||||
const handleAssign = async () => {
|
||||
if (!selectedAssignId) {
|
||||
alert('배정할 대상을 선택해주세요.')
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
await upsertListAssignMutation.mutateAsync({
|
||||
assignId: selectedAssignId,
|
||||
request: {
|
||||
assignType,
|
||||
transferResve: assignType === ListHeaderAssignConst.OUTSOURCE? false : transferResve,
|
||||
listFilter: currentListFilter,
|
||||
},
|
||||
})
|
||||
alert('배정되었습니다.')
|
||||
}
|
||||
|
||||
const handleResetAssign = async () => {
|
||||
if (!confirm('정말 배정을 초기화 하시겠습니까?')) return
|
||||
|
||||
await resetListAssignMutation.mutateAsync({
|
||||
assignType,
|
||||
listFilter: currentListFilter,
|
||||
})
|
||||
alert('배정이 초기화 되었습니다.')
|
||||
}
|
||||
|
||||
if (!mounted || !selectedProject) return <LoadingOverlayAdapter force />
|
||||
|
||||
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) => (
|
||||
<TabsTrigger key={type} value={String(type)}>
|
||||
{LIST_HEADER_TYPE_LABEL[type]}
|
||||
</TabsTrigger>
|
||||
))}
|
||||
</TabsList>
|
||||
</Tabs>
|
||||
|
||||
<AssignTargetList
|
||||
prjctIdx={prjctIdx}
|
||||
enabled={enabled}
|
||||
assignType={assignType}
|
||||
selectedId={selectedAssignId}
|
||||
onSelect={setSelectedAssignId}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="min-w-0 flex-1">
|
||||
<ListSearchTable
|
||||
prjctIdx={prjctIdx}
|
||||
enabled={enabled}
|
||||
userRole={userRole}
|
||||
userId={auth?.user?.userId ?? ''}
|
||||
userCmpn={auth?.user?.userCmpn ?? ''}
|
||||
resultCodes={resultCodeArray}
|
||||
listHeaders={listHeaders}
|
||||
selectMode="none"
|
||||
onCurrentFilterChange={setCurrentListFilter}
|
||||
excludeFilterHeaderTypes={[assignType]}
|
||||
externalAssignFilter={externalAssignFilter}
|
||||
filterActions={
|
||||
<KriMultiSelect
|
||||
items={assignFilterItems}
|
||||
value={assignFilterIds}
|
||||
onChange={handleAssignFilterChange}
|
||||
getValue={(item) => item.id}
|
||||
getLabel={(item) => item.name}
|
||||
placeholder={`${LIST_HEADER_TYPE_LABEL[assignType]} 필터`}
|
||||
widthClassName="w-56"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
}
|
||||
rightActions={
|
||||
<>
|
||||
{assignType !== ListHeaderAssignConst.OUTSOURCE && (
|
||||
<label className="flex items-center gap-2 text-base cursor-pointer">
|
||||
<Checkbox
|
||||
checked={transferResve}
|
||||
onCheckedChange={(checked) => setTransferResve(checked === true)}
|
||||
/>
|
||||
예약 이관
|
||||
</label>
|
||||
)}
|
||||
<Button type="button" onClick={handleAssign}>
|
||||
배정
|
||||
</Button>
|
||||
<Button type="button" variant="outline" onClick={handleResetAssign}>
|
||||
배정 초기화
|
||||
</Button>
|
||||
</>
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListAssignPage;
|
||||
export default ListAssignPage
|
||||
|
||||
@@ -13,18 +13,21 @@ import { UserInfo } from "@/types/user";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { KriSelect, KriSelectItem } from "@/components/common/KriSelect";
|
||||
import { useAuth } from "@/hooks/useAuth";
|
||||
import {CONTACT_USER_ROLE, DEFAULT_COMPANY_NAME, FW_USER_ROLE} from "@/const/userConst";
|
||||
import {CONTACT_INTERVIEWER_ROLE} from "@/const/userConst";
|
||||
|
||||
import {
|
||||
useFieldworkUsersQuery, useOutsourceUsersQuery,
|
||||
useFieldworkUsersQuery,
|
||||
useRoleListQuery,
|
||||
} from "@/query/user";
|
||||
import { useCmpnListQuery } from "@/query/cmpn";
|
||||
|
||||
import {
|
||||
useAssignedCmpnIdsQuery,
|
||||
useAssignedFieldworkIdsQuery,
|
||||
useSaveAssignedFieldworkMutation,
|
||||
useProjectTopQuery, useAssignedOutsourceIdsQuery,
|
||||
useProjectTopQuery,
|
||||
} from "@/query/project";
|
||||
import { isFieldWorkUser } from "@/utils/userRole";
|
||||
|
||||
const ProjectAssignPage = () => {
|
||||
const mounted = useMounted();
|
||||
@@ -34,9 +37,9 @@ const ProjectAssignPage = () => {
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
const enabled = mounted && prjctIdx > 0;
|
||||
|
||||
const companyQuery = useOutsourceUsersQuery(enabled);
|
||||
const companyQuery = useCmpnListQuery();
|
||||
const fwUsersQuery = useFieldworkUsersQuery(enabled);
|
||||
const assignedCompanyQuery = useAssignedOutsourceIdsQuery(prjctIdx, enabled);
|
||||
const assignedCmpnIdsQuery = useAssignedCmpnIdsQuery(prjctIdx, enabled);
|
||||
const assignedIdsQuery = useAssignedFieldworkIdsQuery(prjctIdx, enabled);
|
||||
const saveAssignMutation = useSaveAssignedFieldworkMutation(prjctIdx);
|
||||
|
||||
@@ -48,18 +51,14 @@ const ProjectAssignPage = () => {
|
||||
const projectArray = projectTopQuery.data ?? [];
|
||||
const companyArray = useMemo(() => {
|
||||
const companies = companyQuery.data ?? [];
|
||||
const assigned = assignedCompanyQuery.data ?? [];
|
||||
const assignedCompanies = companies
|
||||
.filter(c => !assigned.includes(c.userCmpn))
|
||||
.map(c => c.userCmpn);
|
||||
|
||||
return [DEFAULT_COMPANY_NAME, ...assignedCompanies];
|
||||
}, [companyQuery.data, assignedCompanyQuery.data]);
|
||||
const assignedCmpnIds = new Set(assignedCmpnIdsQuery.data ?? []);
|
||||
return companies.filter((company) => company.ownCmpn || assignedCmpnIds.has(company.cmpnId));
|
||||
}, [assignedCmpnIdsQuery.data, companyQuery.data]);
|
||||
|
||||
const roleArray: KriSelectItem[] = useMemo(() => {
|
||||
const roles = roleQuery.data ?? [];
|
||||
return roles
|
||||
.filter(r => r.roleCd >= FW_USER_ROLE)
|
||||
.filter(r => isFieldWorkUser(r.roleCd))
|
||||
.map(r => ({ value: String(r.roleCd), label: r.roleNm }));
|
||||
}, [roleQuery.data]);
|
||||
|
||||
@@ -219,14 +218,23 @@ const ProjectAssignPage = () => {
|
||||
|
||||
useEffect(() => {
|
||||
const cmpn = auth.user?.userCmpn ?? "";
|
||||
if (cmpn) setCompanyFilter(cmpn);
|
||||
}, [auth.user?.userCmpn]);
|
||||
const hasAuthCmpn = companyArray.some((company) => company.cmpnId === cmpn);
|
||||
|
||||
if (cmpn && hasAuthCmpn) {
|
||||
setCompanyFilter(cmpn);
|
||||
return;
|
||||
}
|
||||
|
||||
if (companyFilter && !companyArray.some((company) => company.cmpnId === companyFilter)) {
|
||||
setCompanyFilter("");
|
||||
}
|
||||
}, [auth.user?.userCmpn, companyArray, companyFilter]);
|
||||
|
||||
useEffect(() => {
|
||||
if (roleFilter) return;
|
||||
if (roleArray.length === 0) return;
|
||||
|
||||
const contactRole = roleArray.find(r => r.value === String(CONTACT_USER_ROLE));
|
||||
const contactRole = roleArray.find(r => r.value === String(CONTACT_INTERVIEWER_ROLE));
|
||||
setRoleFilter(contactRole ?? roleArray[0]);
|
||||
}, [roleArray, roleFilter]);
|
||||
|
||||
@@ -269,6 +277,8 @@ const ProjectAssignPage = () => {
|
||||
items={companyArray}
|
||||
value={companyFilter}
|
||||
onChange={handleCompanyChange}
|
||||
getValue={(item) => item.cmpnId}
|
||||
getLabel={(item) => item.cmpnAlias || item.cmpnId}
|
||||
placeholder="회사 선택"
|
||||
className="w-56 h-9"
|
||||
useAll={false}
|
||||
@@ -293,7 +303,7 @@ const ProjectAssignPage = () => {
|
||||
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] gap-6 mb-6">
|
||||
<div className="min-w-0">
|
||||
<div className="p-2 bg-black text-white rounded-lg text-lg mb-2 h-13 flex items-center">
|
||||
<div className="p-2 bg-primary text-white rounded-lg text-lg mb-2 h-13 flex items-center">
|
||||
<span className="truncate w-full">{assignInfoString}</span>
|
||||
</div>
|
||||
<div className="border border-gray-200 rounded-lg overflow-hidden bg-white shadow-sm">
|
||||
@@ -308,7 +318,7 @@ const ProjectAssignPage = () => {
|
||||
|
||||
<div className="h-[550px] overflow-y-auto">
|
||||
<table className="w-full">
|
||||
<thead className="bg-black text-white sticky top-0">
|
||||
<thead className="bg-primary text-white sticky top-0">
|
||||
<tr>
|
||||
<th className="p-2 text-left w-12">
|
||||
<Checkbox
|
||||
@@ -353,7 +363,7 @@ const ProjectAssignPage = () => {
|
||||
<Button
|
||||
onClick={handleAssign}
|
||||
disabled={selectedAbleUser.length === 0}
|
||||
className="bg-black hover:bg-gray-800 w-36 h-12 flex items-center justify-center text-base disabled:bg-gray-300"
|
||||
className="w-36 h-12 flex items-center justify-center text-base disabled:bg-gray-300"
|
||||
>
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
<span className="ml-2">배정 {selectedAbleUser.length}명</span>
|
||||
@@ -369,7 +379,7 @@ const ProjectAssignPage = () => {
|
||||
</div>
|
||||
|
||||
<div className="min-w-0">
|
||||
<div className="p-2 bg-black text-white rounded-lg text-lg mb-2 h-13">
|
||||
<div className="p-2 bg-primary text-white rounded-lg text-lg mb-2 h-13">
|
||||
<KriSingleSelect<ProjectInfo>
|
||||
items={projectArray}
|
||||
value={String(sourceProject?.prjctIdx ?? "")}
|
||||
@@ -401,7 +411,7 @@ const ProjectAssignPage = () => {
|
||||
|
||||
<div className="h-[550px] overflow-y-auto">
|
||||
<table className="w-full">
|
||||
<thead className="bg-black text-white sticky top-0">
|
||||
<thead className="bg-primary text-white sticky top-0">
|
||||
<tr>
|
||||
<th className="p-2 text-left w-12">
|
||||
<Checkbox
|
||||
@@ -446,7 +456,7 @@ const ProjectAssignPage = () => {
|
||||
<div className="flex justify-center">
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
className="bg-black hover:bg-gray-800 px-12 h-9 text-base font-medium"
|
||||
className=" px-12 h-9 text-base font-medium"
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import MainLayout from "@/components/layout/MainLayout";
|
||||
import AppMainLayout from "@/components/app-shell/AppMainLayout";
|
||||
import { cookies } from "next/headers";
|
||||
import { redirect } from "next/navigation";
|
||||
import {CookieKeys} from "@/store/cookie/cookie-keys";
|
||||
@@ -31,8 +31,8 @@ export default async function MainLayoutWrapper({
|
||||
}
|
||||
|
||||
return (
|
||||
<MainLayout initialFontSize={initialFontSize}>
|
||||
<AppMainLayout initialFontSize={initialFontSize}>
|
||||
{children}
|
||||
</MainLayout>
|
||||
</AppMainLayout>
|
||||
);
|
||||
}
|
||||
|
||||
@@ -1,8 +1,166 @@
|
||||
const ListContactPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
'use client'
|
||||
|
||||
return (<div>This is List Contact Page</div>)
|
||||
import { Suspense, useEffect, useMemo, useState } from "react";
|
||||
import { useRouter, useSearchParams } from "next/navigation";
|
||||
import { ArrowLeft, CalendarClock } 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 { 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";
|
||||
|
||||
const ListContactPageContent = () => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const sid = searchParams.get("sid") ?? "";
|
||||
|
||||
const mounted = useMounted();
|
||||
const { auth } = useAuth();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
const { isDialogOpen, showDialog } = useDialog();
|
||||
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
const prjctCd = selectedProject?.prjctCd ?? "";
|
||||
const itrntPrjctCd = selectedProject?.itrntPrjctCd ?? "";
|
||||
const userId = auth?.user?.userId ?? "";
|
||||
const userRole = auth?.user?.userRole ?? 0;
|
||||
const enabled = mounted && prjctIdx > 0 && !!sid;
|
||||
|
||||
const projectInfoQuery = useProjectInfoQuery(prjctIdx, mounted && prjctIdx > 0);
|
||||
const listHeaderQuery = useListHeaderQuery(prjctIdx, mounted && prjctIdx > 0);
|
||||
const listDetailQuery = useListDetailQuery(prjctIdx, sid, enabled);
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, mounted && prjctIdx > 0);
|
||||
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]);
|
||||
|
||||
const [isEditing, setIsEditing] = useState(false);
|
||||
const initialFormValues = useMemo(
|
||||
() => buildInitialValues(listHeaders, listDetailQuery.data),
|
||||
[listHeaders, listDetailQuery.data],
|
||||
);
|
||||
const [formValues, setFormValues] = useState<Record<number, string>>(initialFormValues);
|
||||
|
||||
useEffect(() => {
|
||||
setFormValues(initialFormValues);
|
||||
}, [initialFormValues]);
|
||||
|
||||
useEffect(() => {
|
||||
if (sid) return;
|
||||
alert("sid가 없으면 진행할 수 없습니다.");
|
||||
router.back();
|
||||
}, [sid, router]);
|
||||
|
||||
const handleNavigateToSid = (nextSid: string) => {
|
||||
router.push(`/list/contact?sid=${encodeURIComponent(nextSid)}`);
|
||||
};
|
||||
|
||||
const handleGoToListManage = () => {
|
||||
router.push("/list/manage");
|
||||
};
|
||||
|
||||
const handleFieldChange = (listHderId: number, value: string) => {
|
||||
setFormValues((prev) => ({ ...prev, [listHderId]: value }));
|
||||
};
|
||||
|
||||
const handleToggleEdit = async () => {
|
||||
if (!isEditing) {
|
||||
setIsEditing(true);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
await updateListMutation.mutateAsync({
|
||||
updateContents: Object.fromEntries(Object.entries(formValues)),
|
||||
listFilter: { ...createEmptyListFilter(), sidSet: [sid] },
|
||||
});
|
||||
alert("저장되었습니다.");
|
||||
setIsEditing(false);
|
||||
listDetailQuery.refetch();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
alert("저장 중 오류가 발생했습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
if (!sid) return null;
|
||||
if (!mounted || !selectedProject) return <LoadingOverlayAdapter force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<div className="flex items-center gap-3 w-1/2 pr-5">
|
||||
<Button type="button" variant="outline" size="icon" onClick={handleGoToListManage} aria-label="목록으로">
|
||||
<ArrowLeft className="h-4 w-4" />
|
||||
</Button>
|
||||
<h1 className="text-2xl font-bold tracking-tight">컨택 진행</h1>
|
||||
<span className="text-2xl font-bold tracking-tight">SID: {sid}</span>
|
||||
<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>
|
||||
<Button type="button" disabled={updateListMutation.isPending} onClick={handleToggleEdit}>
|
||||
{isEditing ? '저장' : '수정'}
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="grid grid-cols-1 gap-4 lg:grid-cols-2">
|
||||
<div className="h-[80vh] space-y-4 overflow-y-auto">
|
||||
<ListContactInfoPanel
|
||||
prjctIdx={prjctIdx}
|
||||
sid={sid}
|
||||
itrntPrjctCd={itrntPrjctCd}
|
||||
userRole={userRole}
|
||||
isEditing={isEditing}
|
||||
listHeaders={listHeaders}
|
||||
detail={listDetailQuery.data}
|
||||
surveyUrl={projectInfoQuery.data?.surveyUrl}
|
||||
formValues={formValues}
|
||||
onFieldChange={handleFieldChange}
|
||||
onSaved={() => listDetailQuery.refetch()}
|
||||
/>
|
||||
|
||||
{isManager(userRole) ? (
|
||||
<ListUpdateHistoryPanel prjctIdx={prjctIdx} sid={sid} listHeaders={listHeaders} />
|
||||
) : null}
|
||||
</div>
|
||||
|
||||
<ListContactEventPanel
|
||||
prjctIdx={prjctIdx}
|
||||
sid={sid}
|
||||
prjctCd={prjctCd}
|
||||
userId={userId}
|
||||
userRole={userRole}
|
||||
resultCodes={resultCodeArray}
|
||||
useContactSenario={projectInfoQuery.data?.useContactSenario ?? false}
|
||||
contactSenario={projectInfoQuery.data?.contactSenario}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<ReservationListDialog reservations={reserveByUserQuery.data ?? []} onSelectReservation={handleNavigateToSid} />
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ListContactPage;
|
||||
const ListContactPage = () => (
|
||||
<Suspense fallback={null}>
|
||||
<ListContactPageContent />
|
||||
</Suspense>
|
||||
);
|
||||
|
||||
export default ListContactPage;
|
||||
|
||||
@@ -1,27 +1,17 @@
|
||||
'use client'
|
||||
'use client'
|
||||
|
||||
import { useMemo, useState } from 'react'
|
||||
import { PaginationState, SortingState } from '@tanstack/react-table'
|
||||
import {
|
||||
Download,
|
||||
FileClock,
|
||||
Funnel,
|
||||
Mail,
|
||||
MessageSquareMore,
|
||||
PencilLine,
|
||||
RotateCcw,
|
||||
Upload,
|
||||
} from 'lucide-react'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { DataTable } from '@/components/data-table/DataTable'
|
||||
import type { DataTableColumn } from '@/components/data-table/DataTable.type'
|
||||
import { KriMultiSelect } from '@/components/common/KriAutoComplete'
|
||||
import { LoadingOverlay } from '@/components/common/LoadingOverlay'
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import type { PaginationState } from '@tanstack/react-table'
|
||||
import { useRouter } from 'next/navigation'
|
||||
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
import { useDialog } from '@/hooks/useDialog'
|
||||
import { useSelectedProject } from '@/hooks/useSelectedProject'
|
||||
import { useStorage } from '@/hooks/useStorage'
|
||||
import { StorageKeys } from '@/store/storage/storage-keys'
|
||||
import { ListManageActions } from '@/components/list/ListManageActions'
|
||||
import { ListSearchTable } from '@/components/list/ListSearchTable'
|
||||
import {
|
||||
useDownloadListEventHistoryMutation,
|
||||
useDownloadListExcelTemplateMutation,
|
||||
@@ -30,120 +20,37 @@ import {
|
||||
useDownloadListUpdateHistoryMutation,
|
||||
useDownloadUploadHistoryFileMutation,
|
||||
useListHeaderQuery,
|
||||
useListSearchQuery,
|
||||
useListUploadHistoryQuery,
|
||||
useResetListMutation,
|
||||
useUpdateListHeaderMutation,
|
||||
useUpdateListMutation,
|
||||
useUploadListExcelMutation,
|
||||
} from '@/query/list'
|
||||
import { useResultCodesQuery } from '@/query/project'
|
||||
import { getListColumns, ListTableRow } from '@/components/table-column/ListTableColumn'
|
||||
import type { ListTableRow } from '@/components/table-column/ListTableColumn'
|
||||
import {
|
||||
createEmptyListFilter,
|
||||
FilterRow,
|
||||
ListEventHistoryBase,
|
||||
ListDownloadMode,
|
||||
ListDownloadPayload,
|
||||
listHeader,
|
||||
ListFilterMatchType,
|
||||
ListFilterOperator,
|
||||
ListFilterTarget,
|
||||
ListOtherItemFilterCondition,
|
||||
type LastListVisit,
|
||||
type ListDownloadMode,
|
||||
type ListDownloadPayload,
|
||||
type ListFilter,
|
||||
type ListFilterTarget,
|
||||
type listHeader,
|
||||
ListResetMode,
|
||||
ListResetScope,
|
||||
ListSearchRequest,
|
||||
ListUploadRequest,
|
||||
type ListResetScope,
|
||||
type ListUploadRequest,
|
||||
} from '@/types/list'
|
||||
import { ResultCode, ResultCodeType } from '@/types/project'
|
||||
import { type ResultCode, ResultCodeType } from '@/types/project'
|
||||
import ListResetDialog from '@/components/dialog/ListResetDialog'
|
||||
import ListUploadDialog from '@/components/dialog/ListUploadDialog'
|
||||
import ListHeaderManageDialog from '@/components/dialog/ListHeaderManageDialog'
|
||||
import ListBatchEditDialog, { BatchEditRow } from '@/components/dialog/ListBatchEditDialog'
|
||||
import ListFilterDialog from '@/components/dialog/ListFilterDialog'
|
||||
import ListDownloadDialog from '@/components/dialog/ListDownloadDialog'
|
||||
import MessageSendDialog, {
|
||||
MessageSendMode,
|
||||
MessageSendPayload,
|
||||
MessageTemplateOption,
|
||||
} from '@/components/dialog/MessageSendDialog'
|
||||
import MessageHistoryDialog, { MessageHistoryRow } from '@/components/dialog/MessageHistoryDialog'
|
||||
import MessageSendDialog, { type MessageSendMode } from '@/components/dialog/MessageSendDialog'
|
||||
import MessageHistoryDialog from '@/components/dialog/MessageHistoryDialog'
|
||||
import { downloadBase64File, downloadFile, XLSX_MIME_TYPE } from '@kri/common/browser'
|
||||
|
||||
const messageTemplateMock: MessageTemplateOption[] = [
|
||||
{
|
||||
id: 'sms-1',
|
||||
name: '[SMS] Contact Notice',
|
||||
title: 'Survey Request',
|
||||
body: 'Please participate in the survey.',
|
||||
},
|
||||
{
|
||||
id: 'email-1',
|
||||
name: '[EMAIL] Contact Notice',
|
||||
title: 'Survey Participation Guide',
|
||||
body: 'Please click the link and complete the survey.',
|
||||
},
|
||||
]
|
||||
|
||||
const messageHistoryMock: MessageHistoryRow[] = [
|
||||
{
|
||||
id: 1,
|
||||
type: 'sms',
|
||||
title: 'Survey Request',
|
||||
templateName: 'SMS Template A',
|
||||
sendInfo: '010-xxxx-xxxx',
|
||||
targetHeader: 'Phone Number',
|
||||
targetCount: 405,
|
||||
successCount: 405,
|
||||
failCount: 0,
|
||||
createdAt: '03.06 14:37',
|
||||
sendAt: '03.06 14:30 (Reserve)',
|
||||
status: 'Done',
|
||||
templatePreview: 'Please participate in the survey.',
|
||||
targetPreview: ['010-1234-5678', '010-1234-1111'],
|
||||
successPreview: ['sid 1: success', 'sid 2: success'],
|
||||
failPreview: [],
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
type: 'email',
|
||||
title: 'Survey Answer Request',
|
||||
templateName: 'EMAIL Template A',
|
||||
sendInfo: 'info@kric.com',
|
||||
targetHeader: 'Email',
|
||||
targetCount: 405,
|
||||
successCount: 395,
|
||||
failCount: 10,
|
||||
createdAt: '03.06 14:37',
|
||||
sendAt: '03.06 14:47 (Instant)',
|
||||
status: 'Requested',
|
||||
templatePreview: 'Please click the link and complete the survey.',
|
||||
targetPreview: ['aa@kric.com', 'bb@kric.com'],
|
||||
successPreview: ['sid 3: success', 'sid 4: success'],
|
||||
failPreview: ['sid 5: bounce', 'sid 6: invalid'],
|
||||
},
|
||||
]
|
||||
|
||||
const toSidSet = (value: string) =>
|
||||
value
|
||||
.split(',')
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item.length > 0)
|
||||
|
||||
const toFilterCondition = (row: FilterRow, usesListValue: boolean): Omit<ListOtherItemFilterCondition, 'listHderId'> => {
|
||||
const values = usesListValue ? row.multiValues : [row.textValue.trim()]
|
||||
|
||||
if (row.operator === 'eq') {
|
||||
return { operator: ListFilterOperator.POSITIVE, matchType: ListFilterMatchType.EXACT, values }
|
||||
}
|
||||
if (row.operator === 'neq') {
|
||||
return { operator: ListFilterOperator.NEGATIVE, matchType: ListFilterMatchType.EXACT, values }
|
||||
}
|
||||
if (row.operator === 'contains') {
|
||||
return { operator: ListFilterOperator.POSITIVE, matchType: ListFilterMatchType.CONTAINS, values }
|
||||
}
|
||||
return { operator: ListFilterOperator.NEGATIVE, matchType: ListFilterMatchType.CONTAINS, values }
|
||||
}
|
||||
import {CONTACT_INTERVIEWER_ROLE} from "@/const/userConst";
|
||||
import { isManager } from "@/utils/userRole";
|
||||
import { applyListAccessFilter } from "@/utils/listAccess";
|
||||
|
||||
const toDateTimeRange = (from?: string, to?: string) => {
|
||||
if (!from || !to) return undefined
|
||||
@@ -158,28 +65,32 @@ const downloadArrayBuffer = (buffer: ArrayBuffer, filename: string, type = 'appl
|
||||
}
|
||||
|
||||
const ListManagePage = () => {
|
||||
const router = useRouter()
|
||||
const mounted = useMounted()
|
||||
const { auth } = useAuth()
|
||||
const { showDialog } = useDialog()
|
||||
const { selectedProject } = useSelectedProject()
|
||||
|
||||
const [searchText, setSearchText] = useState('')
|
||||
const [searchContactResult, setSearchContactResult] = useState<string[]>([])
|
||||
const [searchInterviewResult, setSearchInterviewResult] = useState<string[]>([])
|
||||
const [searchSurveyResult, setSearchSurveyResult] = useState<string[]>([])
|
||||
const [pagination, setPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: 10 })
|
||||
const [sorting, setSorting] = useState<SortingState>([])
|
||||
const { selectedProject, isSelectedProjectHydrated } = useSelectedProject()
|
||||
|
||||
const [downloadMode, setDownloadMode] = useState<ListDownloadMode>('list')
|
||||
const [messageSendMode, setMessageSendMode] = useState<MessageSendMode>('email')
|
||||
const [filterRows, setFilterRows] = useState<FilterRow[]>([])
|
||||
const [batchRows, setBatchRows] = useState<BatchEditRow[]>([])
|
||||
const [selectedRows, setSelectedRows] = useState<ListTableRow[]>([])
|
||||
const [currentListFilter, setCurrentListFilter] = useState<ListFilter>(() => createEmptyListFilter())
|
||||
const [listRefreshKey, setListRefreshKey] = useState(0)
|
||||
const [pagination, setPagination] = useState<PaginationState>({ pageIndex: 0, pageSize: 25 })
|
||||
const [restoredVisit, setRestoredVisit] = useState<LastListVisit | null>(null)
|
||||
const [restoreResolved, setRestoreResolved] = useState(false)
|
||||
|
||||
const userRole = auth?.user?.userRole ?? 9000
|
||||
const prjctName = selectedProject?.prjctName ?? '';
|
||||
const { get: getLastListVisit, set: setLastListVisit, remove: removeLastListVisit } = useStorage(
|
||||
StorageKeys.LastListVisit,
|
||||
)
|
||||
|
||||
const userRole = auth?.user?.userRole ?? CONTACT_INTERVIEWER_ROLE
|
||||
const userId = auth?.user?.userId ?? ''
|
||||
const userCmpn = auth?.user?.userCmpn ?? ''
|
||||
const prjctName = selectedProject?.prjctName ?? ''
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0
|
||||
const enabled = mounted && prjctIdx > 0
|
||||
const canManageList = isManager(userRole);
|
||||
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled)
|
||||
const listHeaderQuery = useListHeaderQuery(prjctIdx, enabled)
|
||||
@@ -188,7 +99,6 @@ const ListManagePage = () => {
|
||||
const uploadListExcelMutation = useUploadListExcelMutation(prjctIdx)
|
||||
const updateListHeaderMutation = useUpdateListHeaderMutation(prjctIdx)
|
||||
const resetListMutation = useResetListMutation(prjctIdx)
|
||||
const updateListMutation = useUpdateListMutation(prjctIdx)
|
||||
const downloadListMutation = useDownloadListMutation(prjctIdx)
|
||||
const downloadListUpdateHistoryMutation = useDownloadListUpdateHistoryMutation(prjctIdx)
|
||||
const downloadListEventHistoryMutation = useDownloadListEventHistoryMutation(prjctIdx)
|
||||
@@ -196,47 +106,23 @@ const ListManagePage = () => {
|
||||
const downloadUploadHistoryFileMutation = useDownloadUploadHistoryFileMutation(prjctIdx)
|
||||
|
||||
const resultCodeArray = useMemo<ResultCode[]>(() => resultCodesQuery.data ?? [], [resultCodesQuery.data])
|
||||
const headerManageRows = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
||||
|
||||
const listSearchRequest = useMemo<ListSearchRequest>(() => {
|
||||
const sort = sorting?.[0] ?? { id: 'sid', desc: false as const }
|
||||
const listFilter = createEmptyListFilter()
|
||||
listFilter.sidSet = toSidSet(searchText)
|
||||
listFilter.memoConditions = []
|
||||
listFilter.otherItemConditions = filterRows
|
||||
.map((row) => {
|
||||
const usesListValue = (listHeaderQuery.data ?? []).some(
|
||||
(header) => header.listHderId === row.headerId && (header.filterContents?.length ?? 0) > 0,
|
||||
)
|
||||
|
||||
return {
|
||||
listHderId: row.headerId,
|
||||
...toFilterCondition(row, usesListValue),
|
||||
}
|
||||
})
|
||||
.filter((item) => item.values.some((value) => value.trim().length > 0))
|
||||
|
||||
return {
|
||||
listFilter,
|
||||
pageRequest: {
|
||||
pageIndex: pagination.pageIndex,
|
||||
pageSize: pagination.pageSize,
|
||||
sortBy: sort.id,
|
||||
sortDir: sort.desc ? 'desc' : 'asc',
|
||||
},
|
||||
// 컨택 진행 화면에서 돌아왔을 때 1회만 복원하고, 재방문 시 다시 나타나지 않도록 즉시 지운다.
|
||||
// ListSearchTable이 첫 마운트될 때 초기 페이지네이션 값이 확정돼 있어야 하므로(useState는 이후 prop
|
||||
// 변경을 반영하지 않음), selectedProject 하이드레이션이 끝나기 전에는 ListSearchTable을 아예 그리지 않는다.
|
||||
useEffect(() => {
|
||||
if (!mounted || !isSelectedProjectHydrated || restoreResolved) return
|
||||
const stored = getLastListVisit()
|
||||
if (stored) {
|
||||
setRestoredVisit(stored)
|
||||
removeLastListVisit()
|
||||
}
|
||||
}, [filterRows, listHeaderQuery.data, pagination.pageIndex, pagination.pageSize, searchText, sorting])
|
||||
setRestoreResolved(true)
|
||||
// eslint-disable-next-line react-hooks/exhaustive-deps
|
||||
}, [mounted, isSelectedProjectHydrated, restoreResolved])
|
||||
|
||||
const listSearchQuery = useListSearchQuery(prjctIdx, listSearchRequest, enabled)
|
||||
|
||||
const columns = useMemo<DataTableColumn<ListTableRow, unknown>[]>(() => {
|
||||
if (!listHeaderQuery.data) return []
|
||||
return getListColumns(listHeaderQuery.data, resultCodeArray, userRole)
|
||||
}, [listHeaderQuery.data, resultCodeArray, userRole])
|
||||
|
||||
const viewList = useMemo<ListTableRow[]>(
|
||||
() => (listSearchQuery.data?.content ?? []).map((row) => ({ ...row, ...row.itemList })),
|
||||
[listSearchQuery.data],
|
||||
)
|
||||
const restoredForThisProject = restoredVisit?.prjctIdx === prjctIdx ? restoredVisit : undefined
|
||||
|
||||
const selectedSidSet = useMemo(
|
||||
() =>
|
||||
@@ -247,50 +133,30 @@ const ListManagePage = () => {
|
||||
[selectedRows],
|
||||
)
|
||||
|
||||
const buildTargetFilter = (target: ListFilterTarget) => {
|
||||
if (target === 'all') return createEmptyListFilter()
|
||||
if (target === 'selected') {
|
||||
return {
|
||||
...createEmptyListFilter(),
|
||||
sidSet: selectedSidSet,
|
||||
}
|
||||
}
|
||||
return listSearchRequest.listFilter
|
||||
const refreshList = () => {
|
||||
setListRefreshKey((prev) => prev + 1)
|
||||
}
|
||||
|
||||
const totalCount = listSearchQuery.data?.totalElements ?? 0
|
||||
const pageCount = listSearchQuery.data?.totalPages ?? 0
|
||||
const buildTargetFilter = (target: ListFilterTarget) => {
|
||||
if (target === 'all') {
|
||||
return applyListAccessFilter(createEmptyListFilter(), { userRole, userId, userCmpn })
|
||||
}
|
||||
if (target === 'selected') {
|
||||
return applyListAccessFilter(
|
||||
{
|
||||
...createEmptyListFilter(),
|
||||
sidSet: selectedSidSet,
|
||||
},
|
||||
{ userRole, userId, userCmpn },
|
||||
)
|
||||
}
|
||||
return applyListAccessFilter(currentListFilter, { userRole, userId, userCmpn })
|
||||
}
|
||||
|
||||
const headerOptions = useMemo(
|
||||
() =>
|
||||
(listHeaderQuery.data ?? []).map((header) => ({
|
||||
id: header.listHderId,
|
||||
label: header.listHderNm,
|
||||
})),
|
||||
[listHeaderQuery.data],
|
||||
)
|
||||
|
||||
const headerManageRows = useMemo<listHeader[]>(() => listHeaderQuery.data ?? [], [listHeaderQuery.data])
|
||||
|
||||
const filterHeaderOptions = useMemo(
|
||||
() =>
|
||||
(listHeaderQuery.data ?? [])
|
||||
.filter((header) => header.useFilter)
|
||||
.map((header) => ({
|
||||
id: header.listHderId,
|
||||
label: header.listHderNm,
|
||||
values: header.filterContents ?? [],
|
||||
})),
|
||||
[listHeaderQuery.data],
|
||||
)
|
||||
|
||||
const messageTargetHeaders = useMemo(() => {
|
||||
const matched = headerOptions.filter((header) => /email|phone|tel/i.test(header.label))
|
||||
return matched.length > 0 ? matched : headerOptions.slice(0, 1)
|
||||
}, [headerOptions])
|
||||
|
||||
const handleSearchClick = () => {
|
||||
setPagination((prev) => ({ ...prev, pageIndex: 0 }))
|
||||
const handleStartContact = (row: ListTableRow) => {
|
||||
const sid = String(row.sid ?? '')
|
||||
setLastListVisit({ prjctIdx, sid, pageIndex: pagination.pageIndex, pageSize: pagination.pageSize })
|
||||
router.push(`/list/contact?sid=${encodeURIComponent(sid)}`)
|
||||
}
|
||||
|
||||
const openDownloadDialog = (mode: ListDownloadMode) => {
|
||||
@@ -309,7 +175,7 @@ const ListManagePage = () => {
|
||||
resetMode: payload.scope === 'result-and-history' ? ListResetMode.HIST : ListResetMode.ALL,
|
||||
listFilter,
|
||||
})
|
||||
await listSearchQuery.refetch()
|
||||
refreshList()
|
||||
}
|
||||
|
||||
const handleUploadConfirm = async (file: File, request: ListUploadRequest) => {
|
||||
@@ -323,7 +189,7 @@ const ListManagePage = () => {
|
||||
alert(`${res.successCount}개의 리스트를 업로드했습니다.`);
|
||||
}
|
||||
|
||||
await listSearchQuery.refetch()
|
||||
refreshList()
|
||||
}
|
||||
|
||||
const handleDownloadTemplate = async () => {
|
||||
@@ -340,20 +206,6 @@ const ListManagePage = () => {
|
||||
await updateListHeaderMutation.mutateAsync(rows)
|
||||
}
|
||||
|
||||
const handleFilterConfirm = async (rows: FilterRow[]) => {
|
||||
setFilterRows(rows)
|
||||
}
|
||||
|
||||
const handleBatchConfirm = async (rows: BatchEditRow[]) => {
|
||||
setBatchRows(rows)
|
||||
const updateContents = Object.fromEntries(rows.map((row) => [String(row.headerId), row.value]))
|
||||
await updateListMutation.mutateAsync({
|
||||
updateContents,
|
||||
listFilter: buildTargetFilter('filtered'),
|
||||
})
|
||||
await listSearchQuery.refetch()
|
||||
}
|
||||
|
||||
const handleDownloadConfirm = async (payload: ListDownloadPayload) => {
|
||||
const listFilter = buildTargetFilter(payload.target)
|
||||
|
||||
@@ -384,160 +236,69 @@ const ListManagePage = () => {
|
||||
downloadArrayBuffer(buffer, `${prjctName} contact-history.xlsx`)
|
||||
}
|
||||
|
||||
const handleMessageSendConfirm = async (payload: MessageSendPayload) => {
|
||||
void payload
|
||||
alert('Message send action callback placeholder.')
|
||||
}
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />
|
||||
if (!mounted || !restoreResolved) return <LoadingOverlayAdapter force />
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<div className="flex gap-2 items-center">
|
||||
<div className="flex flex-1 items-center gap-2 flex-wrap">
|
||||
<Button variant="destructive" className="text-base gap-2" onClick={() => showDialog('listResetDialog')}>
|
||||
<RotateCcw className="w-4 h-4" />
|
||||
리스트 초기화
|
||||
</Button>
|
||||
<Button className="text-base" onClick={() => showDialog('listHeaderManageDialog')}>
|
||||
헤더 관리
|
||||
</Button>
|
||||
<Button className="text-base gap-2" onClick={() => showDialog('listUploadDialog')}>
|
||||
<Upload className="w-4 h-4" />
|
||||
리스트 업로드
|
||||
</Button>
|
||||
<Button className="text-base bg-excel gap-2" onClick={() => openDownloadDialog('list')}>
|
||||
<Download className="w-4 h-4" />
|
||||
리스트
|
||||
</Button>
|
||||
<Button className="text-base bg-excel gap-2" onClick={() => openDownloadDialog('contact-history')}>
|
||||
<Download className="w-4 h-4" />
|
||||
컨택 이력
|
||||
</Button>
|
||||
<Button className="text-base bg-excel gap-2" onClick={() => openDownloadDialog('list-change-history')}>
|
||||
<Download className="w-4 h-4" />
|
||||
리스트 변경 이력
|
||||
</Button>
|
||||
<Button className="text-base gap-2" onClick={() => openDownloadDialog('upload-file')}>
|
||||
<Download className="w-4 h-4" />
|
||||
업로드 파일(.zip)
|
||||
</Button>
|
||||
</div>
|
||||
<Button className="text-base bg-blue gap-2" onClick={() => openMessageDialog('email')}>
|
||||
<Mail className="w-4 h-4" />
|
||||
이메일 발송
|
||||
</Button>
|
||||
<Button className="text-base bg-blue gap-2" onClick={() => openMessageDialog('sms')}>
|
||||
<MessageSquareMore className="w-4 h-4" />
|
||||
문자 발송
|
||||
</Button>
|
||||
<Button className="text-base gap-2" onClick={() => showDialog('messageHistoryDialog')}>
|
||||
<FileClock className="w-4 h-4" />
|
||||
발송 이력
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Input
|
||||
placeholder="Search SID"
|
||||
className="w-100 h-9 bg-white"
|
||||
value={searchText}
|
||||
onChange={(e) => setSearchText(e.target.value)}
|
||||
/>
|
||||
<KriMultiSelect
|
||||
items={resultCodeArray.filter((item) => item.resultCdTy === ResultCodeType.CONTACT)}
|
||||
value={searchContactResult}
|
||||
onChange={setSearchContactResult}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="컨택 결과"
|
||||
widthClassName="w-70"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
<KriMultiSelect
|
||||
items={resultCodeArray.filter((item) => item.resultCdTy === ResultCodeType.INTERVIEW)}
|
||||
value={searchInterviewResult}
|
||||
onChange={setSearchInterviewResult}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="면접 결과"
|
||||
widthClassName="w-70"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
<KriMultiSelect
|
||||
items={resultCodeArray.filter((item) => item.resultCdTy === ResultCodeType.SURVEY)}
|
||||
value={searchSurveyResult}
|
||||
onChange={setSearchSurveyResult}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="설문 결과"
|
||||
widthClassName="w-70"
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
<Button className="text-lg" onClick={handleSearchClick}>
|
||||
검색
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="flex items-center gap-2 flex-wrap">
|
||||
<Button type="button" variant="outline" className="gap-2" onClick={() => showDialog('listFilterDialog')}>
|
||||
<Funnel className="w-4 h-4" />
|
||||
필터
|
||||
</Button>
|
||||
<Button type="button" variant="outline" className="gap-2" onClick={() => showDialog('listBatchEditDialog')}>
|
||||
<PencilLine className="w-4 h-4" />
|
||||
일괄 수정
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<DataTable<ListTableRow>
|
||||
columns={columns}
|
||||
data={viewList}
|
||||
getRowId={(row) => String(row.sid)}
|
||||
isClient={false}
|
||||
pageCount={pageCount}
|
||||
totalCount={totalCount}
|
||||
onPaginationChange={setPagination}
|
||||
onSortingChange={setSorting}
|
||||
selectMode="multi"
|
||||
onRowSelectionChange={setSelectedRows}
|
||||
pageSizeOptions={[10, 20, 30, 50]}
|
||||
{canManageList && (
|
||||
<ListManageActions
|
||||
onReset={() => showDialog('listResetDialog')}
|
||||
onHeaderManage={() => showDialog('listHeaderManageDialog')}
|
||||
onUpload={() => showDialog('listUploadDialog')}
|
||||
onDownload={openDownloadDialog}
|
||||
onMessageSend={openMessageDialog}
|
||||
onMessageHistory={() => showDialog('messageHistoryDialog')}
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
<ListResetDialog onConfirm={handleResetConfirm} />
|
||||
<ListUploadDialog
|
||||
onUpload={handleUploadConfirm}
|
||||
onDownloadTemplate={handleDownloadTemplate}
|
||||
uploadHistory={uploadHistoryQuery.data ?? []}
|
||||
onDownloadHistory={async (item) => {
|
||||
const buffer = await downloadUploadHistoryFileMutation.mutateAsync(item.listUploadLogId)
|
||||
downloadArrayBuffer(buffer, item.fileName)
|
||||
}}
|
||||
headerRows={headerManageRows}
|
||||
<ListSearchTable
|
||||
prjctIdx={prjctIdx}
|
||||
enabled={enabled}
|
||||
userRole={userRole}
|
||||
userId={userId}
|
||||
userCmpn={userCmpn}
|
||||
resultCodes={resultCodeArray}
|
||||
listHeaders={headerManageRows}
|
||||
enableBatchEdit={canManageList}
|
||||
refreshKey={listRefreshKey}
|
||||
onCurrentFilterChange={setCurrentListFilter}
|
||||
onSelectedRowsChange={setSelectedRows}
|
||||
onRowClick={!canManageList ? handleStartContact : undefined}
|
||||
onRowDoubleClick={canManageList ? handleStartContact : undefined}
|
||||
initialPagination={
|
||||
restoredForThisProject
|
||||
? { pageIndex: restoredForThisProject.pageIndex, pageSize: restoredForThisProject.pageSize }
|
||||
: undefined
|
||||
}
|
||||
onPaginationChange={setPagination}
|
||||
focusRowId={restoredForThisProject?.sid}
|
||||
/>
|
||||
<ListHeaderManageDialog rows={headerManageRows} onConfirm={handleHeaderManageConfirm} />
|
||||
<ListFilterDialog headerOptions={filterHeaderOptions} initialRows={filterRows} onConfirm={handleFilterConfirm} />
|
||||
<ListBatchEditDialog
|
||||
headerOptions={headerOptions}
|
||||
appliedFilters={Object.fromEntries(filterRows.map((row) => [row.headerId, row.multiValues]))}
|
||||
initialRows={batchRows}
|
||||
onConfirm={handleBatchConfirm}
|
||||
/>
|
||||
<ListDownloadDialog mode={downloadMode} onDownload={handleDownloadConfirm} />
|
||||
<MessageSendDialog
|
||||
mode={messageSendMode}
|
||||
templateOptions={messageTemplateMock}
|
||||
targetHeaderOptions={messageTargetHeaders}
|
||||
defaultSenderEmail="info@kric.com"
|
||||
defaultSenderName="코리아리서치"
|
||||
defaultSenderNumber="02-0000-0000"
|
||||
onConfirm={handleMessageSendConfirm}
|
||||
/>
|
||||
<MessageHistoryDialog rows={messageHistoryMock} />
|
||||
|
||||
{canManageList && (
|
||||
<>
|
||||
<ListResetDialog onConfirm={handleResetConfirm} />
|
||||
<ListUploadDialog
|
||||
onUpload={handleUploadConfirm}
|
||||
onDownloadTemplate={handleDownloadTemplate}
|
||||
uploadHistory={uploadHistoryQuery.data ?? []}
|
||||
onDownloadHistory={async (item) => {
|
||||
const buffer = await downloadUploadHistoryFileMutation.mutateAsync(item.listUploadLogId)
|
||||
downloadArrayBuffer(buffer, item.fileName)
|
||||
}}
|
||||
headerRows={headerManageRows}
|
||||
/>
|
||||
<ListHeaderManageDialog prjctIdx={prjctIdx} rows={headerManageRows} onConfirm={handleHeaderManageConfirm} />
|
||||
<ListDownloadDialog mode={downloadMode} onDownload={handleDownloadConfirm} />
|
||||
<MessageSendDialog
|
||||
mode={messageSendMode}
|
||||
listHeaders={headerManageRows}
|
||||
currentFilter={currentListFilter}
|
||||
selectedRows={selectedRows}
|
||||
onSent={refreshList}
|
||||
/>
|
||||
<MessageHistoryDialog />
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
99
src/app/(pages)/(main)/manage/cmpn/page.tsx
Normal file
99
src/app/(pages)/(main)/manage/cmpn/page.tsx
Normal file
@@ -0,0 +1,99 @@
|
||||
'use client'
|
||||
|
||||
import { useState } from "react";
|
||||
import { Button } from "@/components/ui/button";
|
||||
import AppPageTitle from "@/components/app-shell/AppPageTitle";
|
||||
import { DataTable } from "@/components/data-table/DataTable";
|
||||
import { getCmpnColumns } from "@/components/table-column/CmpnTableColumn";
|
||||
import CmpnUpsertDialog from "@/components/dialog/CmpnUpsertDialog";
|
||||
import { useDialog } from "@/hooks/useDialog";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import type { CmpnInfoSaveRequest } from "@/types/cmpn";
|
||||
import {
|
||||
useCheckCmpnIdDuplicateMutation,
|
||||
useCmpnDetailQuery,
|
||||
useCmpnListQuery,
|
||||
useUpsertCmpnMutation,
|
||||
} from "@/query/cmpn";
|
||||
|
||||
const CmpnManagePage = () => {
|
||||
const { showDialog } = useDialog();
|
||||
const mounted = useMounted();
|
||||
|
||||
const cmpnListQuery = useCmpnListQuery();
|
||||
const checkDupMutation = useCheckCmpnIdDuplicateMutation();
|
||||
const upsertMutation = useUpsertCmpnMutation();
|
||||
|
||||
const [editCmpnId, setEditCmpnId] = useState<string | null>(null);
|
||||
const [dialogMode, setDialogMode] = useState<'create' | 'edit'>('create');
|
||||
const cmpnDetailQuery = useCmpnDetailQuery(editCmpnId ?? "", !!editCmpnId);
|
||||
|
||||
const cmpnList = cmpnListQuery.data ?? [];
|
||||
|
||||
const handleCreateClick = () => {
|
||||
setDialogMode("create");
|
||||
setEditCmpnId(null);
|
||||
showDialog("cmpnUpsertDialog");
|
||||
};
|
||||
|
||||
const handleEdit = (cmpnId: string) => {
|
||||
setDialogMode("edit");
|
||||
setEditCmpnId(cmpnId);
|
||||
showDialog("cmpnUpsertDialog");
|
||||
};
|
||||
|
||||
const handleCheckDuplicate = (cmpnId: string) => {
|
||||
return checkDupMutation.mutateAsync(cmpnId);
|
||||
};
|
||||
|
||||
const handleSubmit = async (data: CmpnInfoSaveRequest): Promise<void> => {
|
||||
await upsertMutation.mutateAsync({ mode: dialogMode, data });
|
||||
|
||||
if (dialogMode === "create") {
|
||||
alert("등록되었습니다.");
|
||||
} else {
|
||||
alert("수정되었습니다.");
|
||||
}
|
||||
};
|
||||
|
||||
const columns = getCmpnColumns({
|
||||
onEdit: handleEdit,
|
||||
});
|
||||
|
||||
if (!mounted) return <LoadingOverlayAdapter force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<AppPageTitle titleText={"회사 관리"} />
|
||||
|
||||
<div className="flex justify-end">
|
||||
<Button onClick={handleCreateClick}>
|
||||
회사 등록
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
<div className="bg-white rounded-lg border border-gray-200 overflow-hidden">
|
||||
<DataTable
|
||||
columns={columns}
|
||||
data={cmpnList}
|
||||
isClient={true}
|
||||
selectMode="single"
|
||||
defaultPageSize={10}
|
||||
pageSizeOptions={[10, 20, 30, 50]}
|
||||
getRowId={(row) => row.cmpnId}
|
||||
maxBodyHeight="71vh"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<CmpnUpsertDialog
|
||||
mode={dialogMode}
|
||||
initialData={dialogMode === "edit" ? (cmpnDetailQuery.data ?? undefined) : undefined}
|
||||
onSubmit={handleSubmit}
|
||||
onCheckDuplicate={handleCheckDuplicate}
|
||||
/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
export default CmpnManagePage;
|
||||
@@ -3,7 +3,7 @@
|
||||
import { useMemo, useState } from "react";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import BodyTitle from "@/components/layout/BodyTitle";
|
||||
import AppPageTitle from "@/components/app-shell/AppPageTitle";
|
||||
import { DataTable } from "@/components/data-table/DataTable";
|
||||
import { getUserColumns } from "@/components/table-column/UserTableColumn";
|
||||
import UserUpsertDialog from "@/components/dialog/UserUpsertDialog";
|
||||
@@ -13,14 +13,13 @@ import {useDialog} from "@/hooks/useDialog";
|
||||
import { downloadBase64File, downloadFile, XLSX_MIME_TYPE } from "@kri/common/browser";
|
||||
import {KriMultiSelect} from "@/components/common/KriAutoComplete";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import type { MultiSelectOption } from "@/components/common/KriAutoComplete";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {DEFAULT_COMPANY_NAME, EXTERNAL_USER_ROLE} from "@/const/userConst";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import {DEFAULT_COMPANY_NAME} from "@/const/userConst";
|
||||
import {Upload} from "lucide-react";
|
||||
import {
|
||||
useRoleListQuery,
|
||||
useUserCompaniesQuery,
|
||||
useUsersQuery,
|
||||
useUserDetailQuery,
|
||||
useCheckUserIdDuplicateMutation,
|
||||
@@ -29,6 +28,8 @@ import {
|
||||
useUploadUsersExcelMutation,
|
||||
useDownloadUserExcelTemplateMutation,
|
||||
} from "@/query/user";
|
||||
import { useCmpnListQuery } from "@/query/cmpn";
|
||||
import { isInternalManager } from "@/utils/userRole";
|
||||
|
||||
const UserManagePage = () => {
|
||||
const { showDialog } = useDialog();
|
||||
@@ -36,7 +37,7 @@ const UserManagePage = () => {
|
||||
|
||||
const { auth } = useAuth();
|
||||
const roleQuery = useRoleListQuery();
|
||||
const cmpnQuery = useUserCompaniesQuery();
|
||||
const cmpnQuery = useCmpnListQuery();
|
||||
const usersQuery = useUsersQuery();
|
||||
|
||||
const checkDupMutation = useCheckUserIdDuplicateMutation();
|
||||
@@ -151,26 +152,26 @@ const UserManagePage = () => {
|
||||
onEdit: handleEdit,
|
||||
onDelete: handleDelete
|
||||
},
|
||||
userRoleArray
|
||||
userRoleArray,
|
||||
userCmpnArray
|
||||
);
|
||||
|
||||
const isInternal =
|
||||
mounted &&
|
||||
auth.user?.userRole != null &&
|
||||
auth.user.userRole < EXTERNAL_USER_ROLE
|
||||
isInternalManager(auth.user?.userRole)
|
||||
|
||||
const userCmpn = auth.user?.userCmpn ?? DEFAULT_COMPANY_NAME;
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />;
|
||||
if (!mounted) return <LoadingOverlayAdapter force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<BodyTitle titleText={"User management"}/>
|
||||
<AppPageTitle titleText={"사용자 관리"}/>
|
||||
|
||||
<div className="flex gap-2 items-center">
|
||||
<div className="flex flex-1 items-center gap-2">
|
||||
<Input
|
||||
placeholder="면접원 ID 또는 면접원 이름"
|
||||
placeholder="사용자 ID 또는 사용자 이름"
|
||||
className="w-70 h-9 bg-white"
|
||||
value={searchText}
|
||||
onChange={(e) => setSearchText(e.target.value)}
|
||||
@@ -181,6 +182,8 @@ const UserManagePage = () => {
|
||||
items={userCmpnArray}
|
||||
value={searchCmpn}
|
||||
onChange={setSearchCmpn}
|
||||
getValue={(item) => item.cmpnId}
|
||||
getLabel={(item) => item.cmpnAlias || item.cmpnId}
|
||||
placeholder="소속 회사"
|
||||
widthClassName="w-70"
|
||||
heightClassName="h-9"
|
||||
@@ -198,17 +201,16 @@ const UserManagePage = () => {
|
||||
/>
|
||||
</div>
|
||||
<Button
|
||||
className="text-lg"
|
||||
onClick={handleCreateClick}
|
||||
>
|
||||
면접원 등록
|
||||
사용자 등록
|
||||
</Button>
|
||||
<Button
|
||||
onClick={() => showDialog('userUploadDialog')}
|
||||
className="gap-2 bg-excel text-lg"
|
||||
className="gap-2 bg-excel"
|
||||
>
|
||||
<Upload className="w-4 h-4" />
|
||||
면접원 일괄 등록
|
||||
사용자 일괄 등록
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
@@ -221,6 +223,7 @@ const UserManagePage = () => {
|
||||
defaultPageSize={10}
|
||||
pageSizeOptions={[10, 20, 30, 50]}
|
||||
getRowId={(row) => row.userId} // row.id = userId
|
||||
maxBodyHeight="71vh"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import {MessageType, TemplateEmail} from "@/types/messageTemplate";
|
||||
import { MessageType, type TemplateEmail } from "@kri/common/noti-hub";
|
||||
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
||||
|
||||
const EmailTemplatePage = () => {
|
||||
@@ -21,4 +21,4 @@ const EmailTemplatePage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
export default EmailTemplatePage;
|
||||
export default EmailTemplatePage;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import {MessageType, TemplateSms} from "@/types/messageTemplate";
|
||||
import { MessageType, type TemplateSms } from "@kri/common/noti-hub";
|
||||
import MessageTemplate from "@/components/message-template/MessageTemplate";
|
||||
|
||||
const SmsTemplatePage = () => {
|
||||
@@ -23,4 +23,4 @@ const SmsTemplatePage = () => {
|
||||
)
|
||||
}
|
||||
|
||||
export default SmsTemplatePage;
|
||||
export default SmsTemplatePage;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
import {useMemo, useState} from "react";
|
||||
import BodyTitle from "@/components/layout/BodyTitle";
|
||||
import AppPageTitle from "@/components/app-shell/AppPageTitle";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {DataTable} from "@/components/data-table/DataTable";
|
||||
import {getProjectColumns} from "@/components/table-column/ProjectTableColumn";
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from "@/types/project";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import {KriMultiSelect} from "@/components/common/KriAutoComplete";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import type { MultiSelectOption } from "@/components/common/KriAutoComplete";
|
||||
import {PaginationState, SortingState} from "@tanstack/react-table";
|
||||
import ProjectCreateDialog from "@/components/dialog/ProjectCreateDialog";
|
||||
import {useDialog} from "@/hooks/useDialog";
|
||||
@@ -20,12 +20,12 @@ import {useAuth} from "@/hooks/useAuth";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
import {SelectedProject} from "@/store/jotai/project";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import {LoadingOverlay} from "@/components/common/LoadingOverlay";
|
||||
import {FW_USER_ROLE} from "@/const/userConst";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import {useItrntUserList} from "@/hooks/useItrntUserList";
|
||||
import {useRouter} from "next/navigation";
|
||||
import {useCreateProjectMutation, useProjectListQuery, useProjectOwnerListQuery} from "@/query/project";
|
||||
import {PROJECT_STATUS_LABEL} from "@/const/projectConst";
|
||||
import {isManager} from "@/utils/userRole";
|
||||
|
||||
const MainPage = () => {
|
||||
const router = useRouter();
|
||||
@@ -88,7 +88,7 @@ const MainPage = () => {
|
||||
|
||||
const columns = getProjectColumns(users);
|
||||
const userId = auth.user?.userId ?? "";
|
||||
const userRole = auth.user?.userRole ?? FW_USER_ROLE;
|
||||
const userRole = auth.user?.userRole;
|
||||
|
||||
const handleSearchClick = () => {
|
||||
const searchStatusCode:ProjectStatus[] = searchStatus
|
||||
@@ -141,11 +141,11 @@ const MainPage = () => {
|
||||
router.push(`/list/manage`);
|
||||
}
|
||||
|
||||
if (!mounted || isLoading) return <LoadingOverlay force />;
|
||||
if (!mounted || isLoading) return <LoadingOverlayAdapter force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<BodyTitle titleText={"프로젝트"}/>
|
||||
<AppPageTitle titleText={"프로젝트"}/>
|
||||
|
||||
<div className="flex gap-2 items-center">
|
||||
<div className="flex flex-1 items-center gap-2">
|
||||
@@ -161,7 +161,7 @@ const MainPage = () => {
|
||||
}}
|
||||
/>
|
||||
{
|
||||
userRole < FW_USER_ROLE &&
|
||||
isManager(userRole) &&
|
||||
<KriMultiSelect
|
||||
items={statusArray}
|
||||
value={searchStatus}
|
||||
@@ -192,14 +192,12 @@ const MainPage = () => {
|
||||
heightClassName="h-9"
|
||||
/>
|
||||
<Button
|
||||
className="text-lg"
|
||||
onClick={handleSearchClick}
|
||||
>
|
||||
검색
|
||||
</Button>
|
||||
</div>
|
||||
<Button
|
||||
className="text-lg"
|
||||
onClick={handleCreateClick}
|
||||
>
|
||||
프로젝트 등록
|
||||
@@ -213,12 +211,14 @@ const MainPage = () => {
|
||||
isClient={false}
|
||||
pageCount={pageCount}
|
||||
totalCount={totalCount}
|
||||
pagination={pagination}
|
||||
onPaginationChange={setPagination}
|
||||
onSortingChange={setSorting}
|
||||
selectMode='click-event'
|
||||
onRowClick={handleClick}
|
||||
pageSizeOptions={[10, 20, 30, 50]}
|
||||
getRowId={(row) => row.prjctCd} // row.id = userId
|
||||
maxBodyHeight="71vh"
|
||||
/>
|
||||
</div>
|
||||
|
||||
|
||||
@@ -1,8 +1,17 @@
|
||||
const ContactProgressPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
'use client'
|
||||
|
||||
return (<div>This is Contact Progress Page</div>)
|
||||
}
|
||||
import { ProgressPageContent } from "@/components/progress/ProgressPageContent";
|
||||
import { ProgressEventType } from "@/types/progress";
|
||||
import { ResultCodeType } from "@/types/project";
|
||||
|
||||
export default ContactProgressPage;
|
||||
const ContactProgressPage = () => (
|
||||
<ProgressPageContent
|
||||
eventTy={ProgressEventType.CONTACT}
|
||||
resultCdTy={ResultCodeType.CONTACT}
|
||||
pageTitle="컨택 현황"
|
||||
domainLabel="컨택"
|
||||
personLabel="컨택인력"
|
||||
/>
|
||||
);
|
||||
|
||||
export default ContactProgressPage;
|
||||
|
||||
@@ -1,8 +0,0 @@
|
||||
const FieldworkProgressPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
|
||||
return (<div>This is Fieldwork Progress Page</div>)
|
||||
}
|
||||
|
||||
export default FieldworkProgressPage;
|
||||
17
src/app/(pages)/(main)/progress/interview/page.tsx
Normal file
17
src/app/(pages)/(main)/progress/interview/page.tsx
Normal file
@@ -0,0 +1,17 @@
|
||||
'use client'
|
||||
|
||||
import { ProgressPageContent } from "@/components/progress/ProgressPageContent";
|
||||
import { ProgressEventType } from "@/types/progress";
|
||||
import { ResultCodeType } from "@/types/project";
|
||||
|
||||
const InterviewProgressPage = () => (
|
||||
<ProgressPageContent
|
||||
eventTy={ProgressEventType.INTERVIEW}
|
||||
resultCdTy={ResultCodeType.INTERVIEW}
|
||||
pageTitle="면접 현황"
|
||||
domainLabel="면접"
|
||||
personLabel="면접원"
|
||||
/>
|
||||
);
|
||||
|
||||
export default InterviewProgressPage;
|
||||
@@ -1,8 +1,151 @@
|
||||
'use client'
|
||||
|
||||
import { useMemo, useState } from "react";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import AppPageTitle from "@/components/app-shell/AppPageTitle";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import KriDateRangePicker from "@/components/common/KriDateRangePicker";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useSendResultSummaryQuery } from "@/query/message";
|
||||
import { clientEnv } from "@/lib/env.client";
|
||||
import { MessageType } from "@kri/common/noti-hub";
|
||||
import type { SendResultSummaryResponse } from "@kri/common/noti-hub";
|
||||
|
||||
const SEND_TYPE_ORDER = [MessageType.SMS, MessageType.LMS_MMS, MessageType.EMAIL] as const;
|
||||
|
||||
const SEND_TYPE_LABEL: Record<number, string> = {
|
||||
[MessageType.SMS]: "단문",
|
||||
[MessageType.LMS_MMS]: "장문",
|
||||
[MessageType.EMAIL]: "메일",
|
||||
};
|
||||
|
||||
type SummaryRow = {
|
||||
sendTy: number;
|
||||
price: number;
|
||||
totalCount: number;
|
||||
cost: number;
|
||||
successCount: number;
|
||||
failCount: number;
|
||||
standByCount: number;
|
||||
};
|
||||
|
||||
const sum = (list: SendResultSummaryResponse[], field: keyof SendResultSummaryResponse) =>
|
||||
list.reduce((acc, item) => acc + (item[field] as number | undefined ?? 0), 0);
|
||||
|
||||
const buildRows = (data: SendResultSummaryResponse[]): SummaryRow[] =>
|
||||
SEND_TYPE_ORDER.map((sendTy) => {
|
||||
const matched = data.filter((item) => item.sendTy === sendTy);
|
||||
return {
|
||||
sendTy,
|
||||
price: matched[0]?.price ?? 0,
|
||||
totalCount: sum(matched, "totalCount"),
|
||||
cost: sum(matched, "cost"),
|
||||
successCount: sum(matched, "successCount"),
|
||||
failCount: sum(matched, "failCount"),
|
||||
standByCount: sum(matched, "standByCount"),
|
||||
};
|
||||
});
|
||||
|
||||
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 url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
const mounted = useMounted();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
|
||||
return (<div>This is Message Progress Page</div>)
|
||||
}
|
||||
const [dateRange, setDateRange] = useState(() => {
|
||||
const now = new Date();
|
||||
return { from: getFirstDayOfMonth(now), to: getLastDayOfMonth(now) };
|
||||
});
|
||||
|
||||
export default MessageProgressPage;
|
||||
const prjctCd = selectedProject?.prjctCd ?? "";
|
||||
const itrntPrjctCd = selectedProject?.itrntPrjctCd ?? "";
|
||||
const enabled = mounted && !!prjctCd && !!dateRange.from && !!dateRange.to;
|
||||
|
||||
const summaryQuery = useSendResultSummaryQuery(
|
||||
{
|
||||
reqstSvc: clientEnv.REQUEST_SVC,
|
||||
itrntPrjctCd,
|
||||
prjctCd,
|
||||
sendStartDt: dateRange.from ? `${dateRange.from}T00:00:00` : undefined,
|
||||
sendEndDt: dateRange.to ? `${dateRange.to}T23:59:59` : undefined,
|
||||
},
|
||||
enabled,
|
||||
);
|
||||
|
||||
const rows = useMemo(() => buildRows(summaryQuery.data ?? []), [summaryQuery.data]);
|
||||
|
||||
const total = useMemo(
|
||||
() => ({
|
||||
totalCount: rows.reduce((acc, row) => acc + row.totalCount, 0),
|
||||
cost: rows.reduce((acc, row) => acc + row.cost, 0),
|
||||
successCount: rows.reduce((acc, row) => acc + row.successCount, 0),
|
||||
failCount: rows.reduce((acc, row) => acc + row.failCount, 0),
|
||||
standByCount: rows.reduce((acc, row) => acc + row.standByCount, 0),
|
||||
}),
|
||||
[rows],
|
||||
);
|
||||
|
||||
if (!mounted) return <LoadingOverlayAdapter force />;
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<AppPageTitle titleText="발송 현황" />
|
||||
|
||||
<KriDateRangePicker value={dateRange} onChange={setDateRange} className="w-80" />
|
||||
|
||||
<div className="rounded-md border overflow-hidden">
|
||||
<table className="w-full text-sm">
|
||||
<thead className="bg-blue-50">
|
||||
<tr>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">유형</th>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">단가</th>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">대상수</th>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">비용</th>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">성공</th>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">실패</th>
|
||||
<th className="h-10 px-3 text-center font-semibold border-b">발송중</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{rows.map((row) => (
|
||||
<tr key={row.sendTy} className="border-b last:border-b-0">
|
||||
<td className="h-10 px-3 text-center">{SEND_TYPE_LABEL[row.sendTy]}</td>
|
||||
<td className="h-10 px-3 text-center">{moneyUnit(row.price)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(row.totalCount)}</td>
|
||||
<td className="h-10 px-3 text-center">{moneyUnit(row.cost)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(row.successCount)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(row.failCount)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(row.standByCount)}</td>
|
||||
</tr>
|
||||
))}
|
||||
<tr className="bg-gray-50 font-semibold">
|
||||
<td className="h-10 px-3 text-center" colSpan={2}>합계</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(total.totalCount)}</td>
|
||||
<td className="h-10 px-3 text-center">{moneyUnit(total.cost)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(total.successCount)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(total.failCount)}</td>
|
||||
<td className="h-10 px-3 text-center">{caseUnit(total.standByCount)}</td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
<p className="text-xs text-muted-foreground">
|
||||
※ 보낸 내역을 토대로 계산된 값으로 실제 정산 금액과 차이가 발생할 수 있습니다.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default MessageProgressPage;
|
||||
|
||||
68
src/app/(pages)/(main)/progress/survey/page.tsx
Normal file
68
src/app/(pages)/(main)/progress/survey/page.tsx
Normal file
@@ -0,0 +1,68 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useRef } from "react";
|
||||
import { useMounted } from "@kri/common/hooks";
|
||||
import AppPageTitle from "@/components/app-shell/AppPageTitle";
|
||||
import { LoadingOverlayAdapter } from "@/components/app-shell/LoadingOverlayAdapter";
|
||||
import { useSelectedProject } from "@/hooks/useSelectedProject";
|
||||
import { useProjectInfoQuery, useSurveyRedirectUrlQuery } from "@/query/project";
|
||||
import { SurveyType } from "@/types/project";
|
||||
|
||||
const SurveyProgressPage = () => {
|
||||
const mounted = useMounted();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
const openedRef = useRef(false);
|
||||
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
const enabled = mounted && prjctIdx > 0;
|
||||
|
||||
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled);
|
||||
const projectInfo = projectInfoQuery.data;
|
||||
const surveyTy = projectInfo?.surveyTy ?? SurveyType.NONE;
|
||||
|
||||
const isKonKiwi = surveyTy === SurveyType.KON || surveyTy === SurveyType.KIWI;
|
||||
const isKiwi = surveyTy === SurveyType.KIWI ? 1 : 0;
|
||||
const pkey = projectInfo?.surveyPrjctCd ?? "";
|
||||
|
||||
const redirectUrlEnabled = enabled && !!projectInfo && isKonKiwi && !!pkey;
|
||||
const redirectUrlQuery = useSurveyRedirectUrlQuery(isKiwi, pkey, redirectUrlEnabled);
|
||||
|
||||
const targetUrl = isKonKiwi
|
||||
? (redirectUrlQuery.data ?? null)
|
||||
: surveyTy === SurveyType.EXTERNAL
|
||||
? (projectInfo?.surveyDashboardUrl || null)
|
||||
: null;
|
||||
|
||||
useEffect(() => {
|
||||
if (openedRef.current || !targetUrl) return;
|
||||
openedRef.current = true;
|
||||
window.open(targetUrl, "_blank");
|
||||
}, [targetUrl]);
|
||||
|
||||
const isLoading = !mounted || projectInfoQuery.isLoading || (redirectUrlEnabled && redirectUrlQuery.isLoading);
|
||||
|
||||
if (isLoading) return <LoadingOverlayAdapter force />;
|
||||
|
||||
if (targetUrl) {
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<AppPageTitle titleText="설문 현황" />
|
||||
<p>
|
||||
새 창에서 열립니다. 열리지 않았다면{" "}
|
||||
<a href={targetUrl} target="_blank" rel="noreferrer" className="text-blue-600 underline">
|
||||
여기
|
||||
</a>
|
||||
를 클릭해 주세요.
|
||||
</p>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<div className="space-y-6 text-sm">
|
||||
<AppPageTitle titleText="연결 가능한 현황이 없습니다." />
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
||||
export default SurveyProgressPage;
|
||||
@@ -1,7 +1,7 @@
|
||||
'use client'
|
||||
|
||||
import {useEffect, useState, useCallback, useRef, useMemo} from 'react'
|
||||
import BodyTitle from '@/components/layout/BodyTitle'
|
||||
import AppPageTitle from '@/components/app-shell/AppPageTitle'
|
||||
import {Button} from '@/components/ui/button'
|
||||
import {Input} from '@/components/ui/input'
|
||||
import {Label} from '@/components/ui/label'
|
||||
@@ -12,7 +12,7 @@ import {KriMultiSelect, KriSingleSelect} from '@/components/common/KriAutoComple
|
||||
import {useDialog} from '@/hooks/useDialog'
|
||||
import ResultCodeDialog from '@/components/dialog/ResultCodeDialog'
|
||||
import { useDebouncedValue, useMounted } from "@kri/common/hooks";
|
||||
import {LoadingOverlay} from '@/components/common/LoadingOverlay'
|
||||
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
|
||||
import {
|
||||
ProjectInfo, ProjectUpdateRequest, ResultCode,
|
||||
ProjectStatus, ResultCodeType, SurveyType
|
||||
@@ -23,7 +23,7 @@ import {
|
||||
SURVEY_TYPE_LABEL,
|
||||
SURVEY_TYPE_ORDER,
|
||||
} from "@/const/projectConst";
|
||||
import {MultiSelectOption} from "@/components/ui/multi-select";
|
||||
import type { MultiSelectOption } from "@/components/common/KriAutoComplete";
|
||||
import {FW_TEAM} from "@/const/userConst";
|
||||
import {useItrntUserList} from "@/hooks/useItrntUserList";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
@@ -33,12 +33,12 @@ import {useRouter} from "next/navigation";
|
||||
import {
|
||||
useProjectInfoQuery,
|
||||
useResultCodesQuery,
|
||||
useAssignedOutsourceIdsQuery,
|
||||
useAssignedCmpnIdsQuery,
|
||||
useUpdateProjectMutation,
|
||||
useDeleteProjectMutation,
|
||||
useUploadScenarioImageMutation, useKartProjectListQuery,
|
||||
} from "@/query/project";
|
||||
import {useOutsourceUsersQuery} from "@/query/user";
|
||||
import { useCmpnListQuery } from "@/query/cmpn";
|
||||
|
||||
const defaultProjectInfo: ProjectInfo = {
|
||||
prjctIdx: 0,
|
||||
@@ -51,6 +51,7 @@ const defaultProjectInfo: ProjectInfo = {
|
||||
surveyTy: SurveyType.NONE,
|
||||
surveyPrjctCd: '',
|
||||
surveyUrl: '',
|
||||
surveyDashboardUrl: '',
|
||||
ff: false,
|
||||
useContactSenario: false,
|
||||
contactSenario: '',
|
||||
@@ -61,7 +62,7 @@ const defaultProjectInfo: ProjectInfo = {
|
||||
type ExternalTab = 'redirect' | 'api'
|
||||
|
||||
const baseUrl = 'https://kcont.kric.com'
|
||||
const sidParam = 'sid=${$SID}'
|
||||
const sidParam = 'sid=[$SID]'
|
||||
|
||||
const externalUrls = {
|
||||
redirect: {
|
||||
@@ -94,6 +95,7 @@ const ProjectInfoPage = () => {
|
||||
|
||||
const [externalTab, setExternalTab] = useState<ExternalTab>('redirect')
|
||||
const sessionTempUrlsRef = useRef<Set<string>>(new Set());
|
||||
const initialProjectInfoRef = useRef<ProjectInfo | null>(null);
|
||||
|
||||
const userTeam = auth.user?.userTeam ?? "";
|
||||
const prjctIdx = selectedProject?.prjctIdx ?? 0;
|
||||
@@ -107,8 +109,8 @@ const ProjectInfoPage = () => {
|
||||
// 조회 쿼리들
|
||||
const projectInfoQuery = useProjectInfoQuery(prjctIdx, enabled);
|
||||
const resultCodesQuery = useResultCodesQuery(prjctIdx, enabled);
|
||||
const outsourceUsersQuery = useOutsourceUsersQuery(enabled);
|
||||
const assignedOutsourceQuery = useAssignedOutsourceIdsQuery(prjctIdx, enabled);
|
||||
const cmpnListQuery = useCmpnListQuery();
|
||||
const assignedCmpnQuery = useAssignedCmpnIdsQuery(prjctIdx, enabled);
|
||||
|
||||
const kartEnabled =
|
||||
mounted &&
|
||||
@@ -129,16 +131,16 @@ const ProjectInfoPage = () => {
|
||||
const uploadScenarioMutation = useUploadScenarioImageMutation(prjctIdx, projectInfo.prjctCd);
|
||||
|
||||
const [resultCodeArray, setResultCodeArray] = useState<ResultCode[]>([]);
|
||||
const [outsourceUserArray, setOutsourceUserArray] = useState<string[]>([]);
|
||||
const [assignCmpnIdArray, setAssignCmpnIdArray] = useState<string[]>([]);
|
||||
const [changeResultCodeType, setChangeResultCodeType] = useState<ResultCodeType[]>([]);
|
||||
|
||||
const outsourceOptionArray: MultiSelectOption[] = useMemo(() => {
|
||||
const arr = outsourceUsersQuery.data ?? [];
|
||||
return arr.map((u) => ({
|
||||
value: u.userId,
|
||||
label: `${u.userCmpn} / ${u.userName}(${u.userId})`,
|
||||
const cmpnOptionArray: MultiSelectOption[] = useMemo(() => {
|
||||
const arr = cmpnListQuery.data ?? [];
|
||||
return arr.filter((cmpn) => !cmpn.ownCmpn).map((cmpn) => ({
|
||||
value: cmpn.cmpnId,
|
||||
label: cmpn.cmpnAlias || cmpn.cmpnId,
|
||||
}));
|
||||
}, [outsourceUsersQuery.data]);
|
||||
}, [cmpnListQuery.data]);
|
||||
|
||||
|
||||
const surveyProjectArray = kartProjectListQuery.data ?? [];
|
||||
@@ -162,15 +164,15 @@ const ProjectInfoPage = () => {
|
||||
}
|
||||
|
||||
const handleImageUpload = useCallback(
|
||||
async (file: File): Promise<{ url: string }> => {
|
||||
async (file: File): Promise<string> => {
|
||||
if (!projectInfo.prjctCd) {
|
||||
alert("프로젝트 코드가 없습니다. 잠시 후 다시 시도해주세요.");
|
||||
return {url: ""};
|
||||
return "";
|
||||
}
|
||||
|
||||
const url = await uploadScenarioMutation.mutateAsync(file);
|
||||
sessionTempUrlsRef.current.add(url);
|
||||
return {url};
|
||||
return url;
|
||||
},
|
||||
[uploadScenarioMutation, projectInfo.prjctCd]
|
||||
);
|
||||
@@ -192,10 +194,11 @@ const ProjectInfoPage = () => {
|
||||
const requestUpdateProject: ProjectUpdateRequest = {
|
||||
projectInfo: projectInfo,
|
||||
resultCodeList: updateCodeArray,
|
||||
assignUserIdList: outsourceUserArray,
|
||||
assignCmpnIdList: assignCmpnIdArray,
|
||||
}
|
||||
|
||||
await updateMutation.mutateAsync(requestUpdateProject);
|
||||
initialProjectInfoRef.current = projectInfo;
|
||||
alert("저장되었습니다.");
|
||||
}
|
||||
|
||||
@@ -213,6 +216,7 @@ const ProjectInfoPage = () => {
|
||||
useEffect(() => {
|
||||
if (projectInfoQuery.data) {
|
||||
setProjectInfo(projectInfoQuery.data);
|
||||
initialProjectInfoRef.current = projectInfoQuery.data;
|
||||
}
|
||||
}, [projectInfoQuery.data]);
|
||||
|
||||
@@ -223,36 +227,61 @@ const ProjectInfoPage = () => {
|
||||
}, [resultCodesQuery.data]);
|
||||
|
||||
useEffect(() => {
|
||||
if (assignedOutsourceQuery.data) {
|
||||
setOutsourceUserArray(assignedOutsourceQuery.data);
|
||||
if (assignedCmpnQuery.data) {
|
||||
setAssignCmpnIdArray(assignedCmpnQuery.data);
|
||||
}
|
||||
}, [assignedOutsourceQuery.data]);
|
||||
}, [assignedCmpnQuery.data]);
|
||||
|
||||
useEffect(() => {
|
||||
if (projectInfo.surveyTy !== SurveyType.EXTERNAL) {
|
||||
setExternalTab('redirect')
|
||||
}
|
||||
}, [projectInfo.surveyTy]);
|
||||
|
||||
if (projectInfo.surveyPrjctCd && internalSurvey.has(projectInfo.surveyTy || SurveyType.NONE)){
|
||||
let surveyUrl = `/project/${projectInfo.surveyPrjctCd}/INDEX.asp?${sidParam}`;
|
||||
if(projectInfo.surveyTy === SurveyType.KON){
|
||||
// KON/KIWI 프로젝트 "선택"을 사용자가 직접 바꿨을 때만 surveyUrl을 자동 생성한다.
|
||||
// 저장된 프로젝트를 불러오는 경우(조회) 등에는 저장돼 있는 surveyUrl을 그대로 보여줘야 한다.
|
||||
const handleSurveyPrjctCdChange = (value: string) => {
|
||||
setProjectInfo((prev) => {
|
||||
const next = {...prev, surveyPrjctCd: value};
|
||||
|
||||
if (value && internalSurvey.has(prev.surveyTy || SurveyType.NONE)) {
|
||||
let surveyUrl = `/project/${value}/INDEX.asp?${sidParam}`;
|
||||
if (prev.surveyTy === SurveyType.KON) {
|
||||
surveyUrl = `https://kon.kric.com` + surveyUrl
|
||||
}
|
||||
else if(projectInfo.surveyTy === SurveyType.KIWI){
|
||||
} else if (prev.surveyTy === SurveyType.KIWI) {
|
||||
surveyUrl = `https://kon.kiwisurvey.kr` + surveyUrl
|
||||
}
|
||||
|
||||
handleChange('surveyUrl', surveyUrl)
|
||||
next.surveyUrl = surveyUrl;
|
||||
}
|
||||
}
|
||||
}, [projectInfo.surveyTy, projectInfo.surveyPrjctCd]);
|
||||
|
||||
if (!mounted) return <LoadingOverlay force />
|
||||
return next;
|
||||
})
|
||||
}
|
||||
|
||||
// 설문 연동(surveyTy)을 바꾸면 선택된 KON/KIWI 프로젝트, 설문 URL, 설문 대시보드 URL을 초기화한다.
|
||||
// 단, 최초 조회 시점의 surveyTy로 다시 돌아오면 그때 저장돼 있던 값을 복원한다.
|
||||
const handleSurveyTyChange = (value: string) => {
|
||||
const nextSurveyTy = Number(value) as SurveyType;
|
||||
const initial = initialProjectInfoRef.current;
|
||||
const backToInitial = !!initial && initial.surveyTy === nextSurveyTy;
|
||||
|
||||
setProjectInfo((prev) => ({
|
||||
...prev,
|
||||
surveyTy: nextSurveyTy,
|
||||
surveyPrjctCd: backToInitial ? (initial!.surveyPrjctCd ?? '') : '',
|
||||
surveyUrl: backToInitial ? (initial!.surveyUrl ?? '') : '',
|
||||
surveyDashboardUrl: backToInitial ? (initial!.surveyDashboardUrl ?? '') : '',
|
||||
}))
|
||||
}
|
||||
|
||||
if (!mounted) return <LoadingOverlayAdapter force />
|
||||
|
||||
return (
|
||||
<div className="min-h-full">
|
||||
<div className="space-y-6 pb-24 px-6">
|
||||
<div className="max-w-[900px]">
|
||||
<BodyTitle titleText="프로젝트 정보" />
|
||||
<AppPageTitle titleText="프로젝트 정보" />
|
||||
|
||||
{/* 1. 기본 정보 */}
|
||||
<div className="border rounded-lg p-6 space-y-5 bg-white mt-6">
|
||||
@@ -335,9 +364,9 @@ const ProjectInfoPage = () => {
|
||||
<div className="border rounded-lg p-6 space-y-4 bg-white mt-3">
|
||||
<h3 className="text-xl font-semibold">외주사</h3>
|
||||
<KriMultiSelect
|
||||
items={outsourceOptionArray}
|
||||
value={outsourceUserArray}
|
||||
onChange={(value) => setOutsourceUserArray(value)}
|
||||
items={cmpnOptionArray}
|
||||
value={assignCmpnIdArray}
|
||||
onChange={(value) => setAssignCmpnIdArray(value)}
|
||||
getValue={(item) => item.value}
|
||||
getLabel={(item) => item.label}
|
||||
maxCount={2}
|
||||
@@ -352,7 +381,7 @@ const ProjectInfoPage = () => {
|
||||
|
||||
<RadioGroup
|
||||
value={String(projectInfo.surveyTy ?? SurveyType.NONE)}
|
||||
onValueChange={(v) => handleChange('surveyTy', Number(v) as SurveyType)}
|
||||
onValueChange={handleSurveyTyChange}
|
||||
className="flex gap-4"
|
||||
>
|
||||
{SURVEY_TYPE_ORDER.map((t) => {
|
||||
@@ -374,7 +403,7 @@ const ProjectInfoPage = () => {
|
||||
<KriSingleSelect
|
||||
items={surveyProjectArray}
|
||||
value={projectInfo.surveyPrjctCd || ''}
|
||||
onChange={(value) => handleChange('surveyPrjctCd', value)}
|
||||
onChange={handleSurveyPrjctCdChange}
|
||||
getValue={(item) => item.pkey}
|
||||
getLabel={(item) => `[${item.pkey}] ${item.title}`}
|
||||
searchMode={"inputOnly"}
|
||||
@@ -397,6 +426,18 @@ const ProjectInfoPage = () => {
|
||||
</div>
|
||||
)}
|
||||
|
||||
{projectInfo.surveyTy === SurveyType.EXTERNAL && (
|
||||
<div className="space-y-2">
|
||||
<Label className="text-base">설문 대시보드 URL</Label>
|
||||
<Input
|
||||
value={projectInfo.surveyDashboardUrl || ''}
|
||||
onChange={(e) => handleChange('surveyDashboardUrl', e.target.value)}
|
||||
placeholder="https://"
|
||||
className="h-9"
|
||||
/>
|
||||
</div>
|
||||
)}
|
||||
|
||||
{projectInfo.surveyTy === SurveyType.EXTERNAL && (
|
||||
<div className="space-y-2">
|
||||
<Tabs value={externalTab} onValueChange={(v) => setExternalTab(v as ExternalTab)} className="w-full">
|
||||
@@ -490,7 +531,6 @@ const ProjectInfoPage = () => {
|
||||
{projectInfo.useContactSenario && (
|
||||
<div className="ml-6 border rounded p-4 bg-gray-50 text-sm text-gray-600">
|
||||
<KriEditor
|
||||
//editorMode={"both"}
|
||||
value={projectInfo.contactSenario ?? "<p></p>"}
|
||||
onChange={(html: string) => handleChange("contactSenario", html)}
|
||||
placeholder="컨택 시나리오를 작성해 주세요"
|
||||
|
||||
@@ -4,45 +4,31 @@ import Image from "next/image";
|
||||
import {Button} from "@/components/ui/button";
|
||||
import {Card, CardContent, CardHeader} from "@/components/ui/card";
|
||||
import {Input} from "@/components/ui/input";
|
||||
import React, { Suspense, useEffect, useRef, useState } from "react";
|
||||
import {useRouter, useSearchParams} from "next/navigation";
|
||||
import { useStorage } from "@/hooks/useStorage"
|
||||
import { StorageKeys } from "@/store/storage/storage-keys";
|
||||
import React, { useEffect, useRef, useState } from "react";
|
||||
import {useRouter} from "next/navigation";
|
||||
import {apiError} from "@kri/common/http";
|
||||
import {NONE_HTTP_ERROR} from "@kri/common/http";
|
||||
import {useLoginMutation} from "@/query/auth";
|
||||
import {useInternalInfoQuery} from "@/query/internal";
|
||||
|
||||
const LoginPageContent = () => {
|
||||
const LoginPage = () => {
|
||||
const router = useRouter();
|
||||
const searchParams = useSearchParams();
|
||||
const typeParam = searchParams.get("type") ?? "";
|
||||
|
||||
const loginMutation = useLoginMutation();
|
||||
const internalInfoQuery = useInternalInfoQuery();
|
||||
// TODO: 받은 데이터 확인
|
||||
console.log(internalInfoQuery.data);
|
||||
|
||||
const { get: getSeatNumberStorage } = useStorage(StorageKeys.SeatNumber);
|
||||
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
const [userId, setUserId] = useState<string>("");
|
||||
const [userPw, setUserPw] = useState<string>("");
|
||||
const [seatNum, setSeatNum] = useState<string>("");
|
||||
const [loginType, setLoginType] = useState<string>("");
|
||||
|
||||
const passwordInputRef = useRef<HTMLInputElement | null>(null);
|
||||
const seatNumberInputRef = useRef<HTMLInputElement | null>(null);
|
||||
|
||||
const tryLogin = async () => {
|
||||
if (!userId) return alert("Please enter ID.");
|
||||
if (!userPw) return alert("Please enter password.");
|
||||
if (loginType === "call" && !seatNum) return alert("Please enter seat number.");
|
||||
|
||||
setError(null);
|
||||
try {
|
||||
await loginMutation.mutateAsync({ userId, userPw, seatNum, loginType });
|
||||
await loginMutation.mutateAsync({ userId, userPw });
|
||||
} catch (e) {
|
||||
const err = apiError(e, {
|
||||
fallbackMessage: "Login failed.",
|
||||
@@ -59,18 +45,6 @@ const LoginPageContent = () => {
|
||||
}
|
||||
}, [loginMutation.isSuccess, router]);
|
||||
|
||||
// URL 쿼리 파라미터에서 type 수신
|
||||
useEffect(() => {
|
||||
setLoginType(typeParam);
|
||||
|
||||
if (typeParam === "call") {
|
||||
setSeatNum(getSeatNumberStorage() ?? "");
|
||||
} else {
|
||||
setSeatNum("");
|
||||
}
|
||||
|
||||
}, [typeParam]);
|
||||
|
||||
const handleIdKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
@@ -79,19 +53,6 @@ const LoginPageContent = () => {
|
||||
};
|
||||
|
||||
const handlePwKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
const seatNumberInput = seatNumberInputRef.current;
|
||||
if(loginType === "call" && seatNumberInput?.value === ""){
|
||||
seatNumberInput.focus();
|
||||
}
|
||||
else{
|
||||
tryLogin();
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
const handleSeatNumberKeyDown: React.KeyboardEventHandler<HTMLInputElement> = (e) => {
|
||||
if (e.key === "Enter") {
|
||||
e.preventDefault();
|
||||
tryLogin();
|
||||
@@ -118,13 +79,13 @@ const LoginPageContent = () => {
|
||||
<CardContent>
|
||||
<div className="space-y-4">
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">ID</label>
|
||||
<label className="text-base font-medium">ID</label>
|
||||
<Input
|
||||
id="id"
|
||||
name="id"
|
||||
type="text"
|
||||
required
|
||||
placeholder="Enter ID"
|
||||
placeholder="ID"
|
||||
value={userId}
|
||||
onChange={(e) => setUserId(e.currentTarget.value)}
|
||||
onKeyDown={handleIdKeyDown}
|
||||
@@ -132,14 +93,14 @@ const LoginPageContent = () => {
|
||||
</div>
|
||||
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">Password</label>
|
||||
<label className="text-base font-medium">Password</label>
|
||||
<Input
|
||||
id="password"
|
||||
name="password"
|
||||
type="password"
|
||||
autoComplete="current-password"
|
||||
required
|
||||
placeholder="Enter password"
|
||||
placeholder="password"
|
||||
value={userPw}
|
||||
onChange={(e) => setUserPw(e.currentTarget.value)}
|
||||
onKeyDown={handlePwKeyDown}
|
||||
@@ -147,24 +108,6 @@ const LoginPageContent = () => {
|
||||
/>
|
||||
</div>
|
||||
|
||||
{loginType === "call"?
|
||||
<div className="space-y-2">
|
||||
<label className="text-sm font-medium">자리번호 (면접원)</label>
|
||||
<Input
|
||||
id="seatNum"
|
||||
name="seatNum"
|
||||
type="text"
|
||||
placeholder="Enter seat number"
|
||||
value={seatNum}
|
||||
onChange={(e) => setSeatNum(e.currentTarget.value)}
|
||||
onKeyDown={handleSeatNumberKeyDown}
|
||||
ref={seatNumberInputRef}
|
||||
/>
|
||||
</div>
|
||||
:
|
||||
null
|
||||
}
|
||||
|
||||
{error && (
|
||||
<p className="text-sm text-red-500">
|
||||
{error}
|
||||
@@ -189,10 +132,4 @@ const LoginPageContent = () => {
|
||||
);
|
||||
}
|
||||
|
||||
const LoginPage = () => (
|
||||
<Suspense fallback={null}>
|
||||
<LoginPageContent />
|
||||
</Suspense>
|
||||
);
|
||||
|
||||
export default LoginPage;
|
||||
|
||||
@@ -9,9 +9,8 @@ const LogoutPage = () => {
|
||||
|
||||
useEffect(() => {
|
||||
(async () => {
|
||||
const { loginType } = await logoutMutation.mutateAsync();
|
||||
// 기존 로직 그대로: call 타입이면 쿼리 붙여서 이동
|
||||
router.replace(loginType === "call" ? "/login?type=call" : "/login");
|
||||
await logoutMutation.mutateAsync();
|
||||
router.replace("/login");
|
||||
})();
|
||||
}, []);
|
||||
|
||||
|
||||
@@ -18,15 +18,8 @@ const redirectPage = async ({
|
||||
}: redirectPageProps) => {
|
||||
const { slug } = await params;
|
||||
const sp = searchParams ? await searchParams : undefined;
|
||||
|
||||
//미들 웨어에서 처리
|
||||
console.log(sp);
|
||||
|
||||
const redirectSlug = toRedirectSlug(slug);
|
||||
|
||||
console.log(redirectSlug);
|
||||
|
||||
|
||||
if (!redirectSlug) notFound();
|
||||
|
||||
return (
|
||||
|
||||
@@ -9,8 +9,8 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "prjct-outsource" && slug.length === 2) {
|
||||
const result = await contactApi.get<string[]>(`/assign/prjct-outsource/${slug[1]}`);
|
||||
if (action === "prjct-cmpn" && slug.length === 2) {
|
||||
const result = await contactApi.get<string[]>(`/assign/prjct-cmpn/${slug[1]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
@@ -31,7 +31,7 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "prjct-fieldwork" && slug.length === 2) {
|
||||
if ((action === "prjct-fieldwork" || action === "prjct-cmpn") && slug.length === 2) {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
@@ -40,10 +40,41 @@ export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.put(`/assign/prjct-fieldwork/${slug[1]}`, body);
|
||||
await contactApi.put(`/assign/${action}/${slug[1]}`, body);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
if (action === "list" && slug.length === 3) {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const result = await contactApi.put<number>(`/assign/list/${slug[1]}/${slug[2]}`, body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const DELETE = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "list" && slug[1] === "reset" && slug.length === 3) {
|
||||
const body = await req.json().catch(() => null);
|
||||
const result = await contactApi.del<number>(`/assign/list/reset/${slug[2]}`, { json: body });
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
93
src/app/api/cmpn/[[...slug]]/route.ts
Normal file
93
src/app/api/cmpn/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,93 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { createContactApi } from "@/lib/http-server";
|
||||
import type { CmpnInfo } from "@/types/cmpn";
|
||||
import type { DataVerification } from "@kri/common";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
import { errorToResponse } from "@kri/common/http";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "check-cmpn-id") {
|
||||
const cmpnId = req.nextUrl.searchParams.get("cmpnId") ?? "";
|
||||
if (!cmpnId) {
|
||||
return NextResponse.json(
|
||||
{ message: "cmpnId 파라미터가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
const result = await contactApi.get<DataVerification>("/cmpn/check-cmpn-id", {
|
||||
query: { cmpnId },
|
||||
});
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (slug.length === 1) {
|
||||
const result = await contactApi.get<CmpnInfo>(`/cmpn/${encodeURIComponent(action)}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (!action) {
|
||||
const result = await contactApi.get<CmpnInfo[]>("/cmpn");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
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;
|
||||
const [action] = slug ?? [];
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (!action) {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.put("/cmpn", body);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const PATCH = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug ?? [];
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (!action) {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.patch("/cmpn", body);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -21,6 +21,22 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "survey-redirect-url" && slug.length === 3){
|
||||
const [, isKiwi, pkey] = slug;
|
||||
|
||||
const skey = await kartApi.get<string>(`/encrypt/pkey`, {
|
||||
headers: { pkey, iskiwi: isKiwi },
|
||||
});
|
||||
|
||||
const shortUrl = await kartApi.post<string>(
|
||||
`/uri/short`,
|
||||
{ realURI: "/Report/Current", mode: "U" },
|
||||
{ headers: { skey } },
|
||||
);
|
||||
|
||||
return NextResponse.json(shortUrl, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
25
src/app/api/list-call-hist/[[...slug]]/route.ts
Normal file
25
src/app/api/list-call-hist/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
|
||||
export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [prjctIdx, sid] = slug;
|
||||
if (!prjctIdx || !sid) {
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
}
|
||||
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({ message: "요청 바디가 없습니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const contactApi = await createContactApi();
|
||||
const result = await contactApi.put(`/list-call-hist/${prjctIdx}/${sid}`, body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
52
src/app/api/list-hist/[[...slug]]/route.ts
Normal file
52
src/app/api/list-hist/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,52 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {ListEventHistory, ListUpdateHistory} from "@/types/list";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "event" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListEventHistory[]>(`/list-hist/event/${slug[1]}/${slug[2]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "update" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListUpdateHistory[]>(`/list-hist/update/${slug[1]}/${slug[2]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
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;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "event") {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.put(`/list-hist/event`, body);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -27,6 +27,11 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "search-sid" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListSearchWithFullResult>(`/list/search-sid/${slug[1]}/${slug[2]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
@@ -76,6 +81,12 @@ export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
});
|
||||
}
|
||||
|
||||
if (action === "item-file-upload" && slug.length === 3) {
|
||||
const form = await req.formData();
|
||||
await contactApi.postForm(`/list/item-file/upload/${slug[1]}/${slug[2]}`, form);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
if (action === "excel-upload") {
|
||||
const form = await req.formData();
|
||||
const result = await contactApi.postForm(`/list/excel/upload/${slug[1]}`, form);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import {LoginRequest, LoginUser} from "@/types/auth";
|
||||
import type { LoginRequest, LoginUser } from "@kri/common";
|
||||
import {serverEnv} from "@/lib/env.server";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
|
||||
82
src/app/api/message-report/[[...slug]]/route.ts
Normal file
82
src/app/api/message-report/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,82 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createNotihubApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {FileResponse, PageRequest, PageResponse} from "@kri/common";
|
||||
import type {BulkSendInfo, SendResultSummaryRequest, SendResultSummaryResponse} from "@kri/common/noti-hub";
|
||||
import type {SendResultInfo} from "@/types/message";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [action, sendTy, reqstSvc, prjctCd] = slug;
|
||||
const notihubApi = await createNotihubApi();
|
||||
|
||||
if (action === "bulk-list" && sendTy && reqstSvc && prjctCd) {
|
||||
const result = await notihubApi.get<BulkSendInfo[]>(
|
||||
`/report/bulk-list/${sendTy}/${reqstSvc}/${prjctCd}`,
|
||||
);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
if (action === "send-result" && slug.length >= 4) {
|
||||
const [, sid, prjctCdParam, reqstSvcParam] = slug;
|
||||
const channelTy = req.nextUrl.searchParams.get("channelTy");
|
||||
const query = channelTy ? `?channelTy=${channelTy}` : "";
|
||||
const result = await notihubApi.get<SendResultInfo[]>(
|
||||
`/report/send-result/${sid}/${prjctCdParam}/${reqstSvcParam}${query}`,
|
||||
);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [action, bulkSendKey] = slug;
|
||||
const notihubApi = await createNotihubApi();
|
||||
|
||||
if (action === "bulk-detail" && bulkSendKey) {
|
||||
const body: PageRequest | null = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
|
||||
}
|
||||
|
||||
const result = await notihubApi.post<PageResponse<SendResultInfo>>(
|
||||
`/report/bulk-detail/${bulkSendKey}`,
|
||||
body,
|
||||
);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
if (action === "bulk-detail-excel" && bulkSendKey) {
|
||||
const result = await notihubApi.post<FileResponse>(
|
||||
`/report/bulk-detail/excel/${bulkSendKey}`,
|
||||
undefined,
|
||||
);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
if (action === "send-result-summary") {
|
||||
const body: SendResultSummaryRequest | null = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
|
||||
}
|
||||
|
||||
const result = await notihubApi.post<SendResultSummaryResponse[]>(
|
||||
`/report/send-result-summary`,
|
||||
body,
|
||||
);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
53
src/app/api/message-send/[[...slug]]/route.ts
Normal file
53
src/app/api/message-send/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,53 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createNotihubApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {BulkSendCreateRequest, BulkSendResponse, SendRequestBulk} from "@kri/common/noti-hub";
|
||||
|
||||
type MessageSendChannel = "sms" | "email";
|
||||
|
||||
const isSendChannel = (value: string): value is MessageSendChannel => value === "sms" || value === "email";
|
||||
|
||||
export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [action, channel] = slug;
|
||||
const notihubApi = await createNotihubApi();
|
||||
|
||||
if (action === "create-bulk" && channel && isSendChannel(channel)) {
|
||||
const body: BulkSendCreateRequest | null = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
|
||||
}
|
||||
|
||||
const result = await notihubApi.put<string>(`/send-${channel}/create/bulk`, body);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [action, channel] = slug;
|
||||
const notihubApi = await createNotihubApi();
|
||||
|
||||
if (action === "bulk" && channel && isSendChannel(channel)) {
|
||||
const body: SendRequestBulk | null = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
|
||||
}
|
||||
|
||||
const result = await notihubApi.post<BulkSendResponse>(`/send-${channel}/bulk`, body);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -2,7 +2,7 @@
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createNotihubApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import {Template, TemplateSummary} from "@/types/messageTemplate";
|
||||
import type { Template, TemplateSummary } from "@kri/common/noti-hub";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try{
|
||||
|
||||
38
src/app/api/message/[[...slug]]/route.ts
Normal file
38
src/app/api/message/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,38 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {MessageBulkSendResponse} from "@/types/message";
|
||||
|
||||
const isChannel = (value: string): value is "sms" | "email" => value === "sms" || value === "email";
|
||||
|
||||
export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [channel, action, prjctIdx] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (!isChannel(channel) || !prjctIdx) {
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
}
|
||||
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
|
||||
}
|
||||
|
||||
if (action === "single") {
|
||||
await contactApi.post(`/message/${channel}/single/${prjctIdx}`, body);
|
||||
return new NextResponse(null, {status: 204});
|
||||
}
|
||||
|
||||
if (action === "bulk") {
|
||||
const result = await contactApi.post<MessageBulkSendResponse>(`/message/${channel}/bulk/${prjctIdx}`, body);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
39
src/app/api/progress/[[...slug]]/route.ts
Normal file
39
src/app/api/progress/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,39 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {ProgressDateResponse, ProgressSearchRequest, ProgressUserResponse} from "@/types/progress";
|
||||
|
||||
const ACTION_PATH: Record<string, string> = {
|
||||
"user": "/progress/user",
|
||||
"last-date": "/progress/last-date",
|
||||
"date": "/progress/date",
|
||||
};
|
||||
|
||||
export const POST = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const {slug = []} = await context.params;
|
||||
const [action, prjctIdx, eventTy] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
const basePath = ACTION_PATH[action];
|
||||
if (!basePath || !prjctIdx || !eventTy) {
|
||||
return NextResponse.json({message: "Not found"}, {status: 404});
|
||||
}
|
||||
|
||||
const body: ProgressSearchRequest | null = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({message: "요청 바디가 없습니다."}, {status: 400});
|
||||
}
|
||||
|
||||
if (action === "user") {
|
||||
const result = await contactApi.post<ProgressUserResponse[]>(`${basePath}/${prjctIdx}/${eventTy}`, body);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
}
|
||||
|
||||
const result = await contactApi.post<ProgressDateResponse[]>(`${basePath}/${prjctIdx}/${eventTy}`, body);
|
||||
return NextResponse.json(result, {status: 200});
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
42
src/app/api/reserve/[[...slug]]/route.ts
Normal file
42
src/app/api/reserve/[[...slug]]/route.ts
Normal file
@@ -0,0 +1,42 @@
|
||||
import {NextRequest, NextResponse} from "next/server";
|
||||
import {RouteContext} from "@/types/common";
|
||||
import {createContactApi} from "@/lib/http-server";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
import type {ListReserve} from "@/types/list";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const { slug = [] } = await context.params;
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "sid" && slug.length === 3) {
|
||||
const result = await contactApi.get<ListReserve[]>(`/reserve/${slug[1]}/sid/${slug[2]}`);
|
||||
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 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
|
||||
export const PUT = async (req: NextRequest, context: RouteContext) => {
|
||||
try {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json({ message: "요청 바디가 없습니다." }, { status: 400 });
|
||||
}
|
||||
|
||||
const contactApi = await createContactApi();
|
||||
const result = await contactApi.put<ListReserve>(`/reserve`, body);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
}
|
||||
};
|
||||
@@ -1,7 +1,8 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { createContactApi } from "@/lib/http-server";
|
||||
import {ExcelUploadResult, UserInfo} from "@/types/user";
|
||||
import {DataVerification, RouteContext} from "@/types/common";
|
||||
import type { UserInfo } from "@/types/user";
|
||||
import type { DataVerification, ExcelUploadResult } from "@kri/common";
|
||||
import type { RouteContext } from "@/types/common";
|
||||
import {errorToResponse} from "@kri/common/http";
|
||||
|
||||
export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
@@ -25,16 +26,6 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "cmpn"){
|
||||
const result = await contactApi.get<string[]>("/user/cmpn");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "outsource"){
|
||||
const result = await contactApi.get<UserInfo[]>("/user/outsource");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "fieldwork"){
|
||||
const result = await contactApi.get<UserInfo[]>("/user/fieldwork");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
|
||||
@@ -9,19 +9,19 @@
|
||||
--font-sans: var(--font-geist-sans);
|
||||
--font-mono: var(--font-geist-mono);
|
||||
/* --content-font-size 배율 기반 font-size 스케일 (기본 text-* 유틸을 그대로 대체) */
|
||||
--font-size-xs: calc(var(--content-font-size) * 0.75);
|
||||
--font-size-sm: calc(var(--content-font-size) * 0.875);
|
||||
--font-size-base: var(--content-font-size);
|
||||
--font-size-lg: calc(var(--content-font-size) * 1.125);
|
||||
--font-size-xl: calc(var(--content-font-size) * 1.25);
|
||||
--font-size-2xl: calc(var(--content-font-size) * 1.5);
|
||||
--font-size-3xl: calc(var(--content-font-size) * 1.875);
|
||||
--font-size-4xl: calc(var(--content-font-size) * 2.25);
|
||||
--font-size-5xl: calc(var(--content-font-size) * 3);
|
||||
--font-size-6xl: calc(var(--content-font-size) * 3.75);
|
||||
--font-size-7xl: calc(var(--content-font-size) * 4.5);
|
||||
--font-size-8xl: calc(var(--content-font-size) * 6);
|
||||
--font-size-9xl: calc(var(--content-font-size) * 8);
|
||||
--text-xs: calc(var(--content-font-size) * 0.75);
|
||||
--text-sm: calc(var(--content-font-size) * 0.875);
|
||||
--text-base: var(--content-font-size);
|
||||
--text-lg: calc(var(--content-font-size) * 1.125);
|
||||
--text-xl: calc(var(--content-font-size) * 1.25);
|
||||
--text-2xl: calc(var(--content-font-size) * 1.5);
|
||||
--text-3xl: calc(var(--content-font-size) * 1.875);
|
||||
--text-4xl: calc(var(--content-font-size) * 2.25);
|
||||
--text-5xl: calc(var(--content-font-size) * 3);
|
||||
--text-6xl: calc(var(--content-font-size) * 3.75);
|
||||
--text-7xl: calc(var(--content-font-size) * 4.5);
|
||||
--text-8xl: calc(var(--content-font-size) * 6);
|
||||
--text-9xl: calc(var(--content-font-size) * 8);
|
||||
--color-sidebar-ring: var(--sidebar-ring);
|
||||
--color-sidebar-border: var(--sidebar-border);
|
||||
--color-sidebar-accent-foreground: var(--sidebar-accent-foreground);
|
||||
@@ -65,13 +65,13 @@
|
||||
--card-foreground: oklch(0.145 0 0);
|
||||
--popover: oklch(1 0 0);
|
||||
--popover-foreground: oklch(0.145 0 0);
|
||||
--primary: oklch(0.205 0 0);
|
||||
--primary: oklch(0.33 0.07 255);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.97 0 0);
|
||||
--secondary-foreground: oklch(0.205 0 0);
|
||||
--muted: oklch(0.97 0 0);
|
||||
--muted-foreground: oklch(0.556 0 0);
|
||||
--accent: oklch(0.97 0 0);
|
||||
--accent: oklch(0.87 0.18 95);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.577 0.245 27.325);
|
||||
--border: oklch(0.922 0 0);
|
||||
@@ -100,14 +100,14 @@
|
||||
--card-foreground: oklch(0.985 0 0);
|
||||
--popover: oklch(0.205 0 0);
|
||||
--popover-foreground: oklch(0.985 0 0);
|
||||
--primary: oklch(0.922 0 0);
|
||||
--primary-foreground: oklch(0.205 0 0);
|
||||
--primary: oklch(0.55 0.09 255);
|
||||
--primary-foreground: oklch(0.985 0 0);
|
||||
--secondary: oklch(0.269 0 0);
|
||||
--secondary-foreground: oklch(0.985 0 0);
|
||||
--muted: oklch(0.269 0 0);
|
||||
--muted-foreground: oklch(0.708 0 0);
|
||||
--accent: oklch(0.269 0 0);
|
||||
--accent-foreground: oklch(0.985 0 0);
|
||||
--accent: oklch(0.8 0.17 95);
|
||||
--accent-foreground: oklch(0.205 0 0);
|
||||
--destructive: oklch(0.704 0.191 22.216);
|
||||
--border: oklch(1 0 0 / 10%);
|
||||
--input: oklch(1 0 0 / 15%);
|
||||
@@ -128,10 +128,10 @@
|
||||
}
|
||||
|
||||
.bg-excel {
|
||||
background-color: var(--color-green-600);
|
||||
background-color: #217346;
|
||||
}
|
||||
.bg-excel:hover {
|
||||
background-color: var(--color-green-700);
|
||||
background-color: #185c37;
|
||||
}
|
||||
|
||||
.bg-blue {
|
||||
|
||||
Reference in New Issue
Block a user