251216_01_ENH : 프로젝트에 FW User 배정 구현 및 테스트 완료
This commit is contained in:
@@ -1,8 +0,0 @@
|
||||
const ProjectAssignPage = () => {
|
||||
//const url = buildUrlWithParams("/login", searchParams, { ref: "root" });
|
||||
//redirect(url);
|
||||
|
||||
return (<div>This is Project Assign Page</div>)
|
||||
}
|
||||
|
||||
export default ProjectAssignPage;
|
||||
@@ -57,11 +57,6 @@ const UserManagePage = () => {
|
||||
|
||||
const userData = await nextApi.get<UserInfo[]>("/user");
|
||||
setUserList(userData);
|
||||
|
||||
const cmpnArray = Array.from(
|
||||
new Set(userData.map(u => u.userCmpn).filter(Boolean))
|
||||
).sort((a, b) => a.localeCompare(b, "ko"));
|
||||
setUserCmpnArray(cmpnArray);
|
||||
}
|
||||
|
||||
// 등록 버튼 클릭
|
||||
|
||||
498
src/app/(pages)/(main)/project/assign/page.tsx
Normal file
498
src/app/(pages)/(main)/project/assign/page.tsx
Normal file
@@ -0,0 +1,498 @@
|
||||
'use client'
|
||||
|
||||
import {useCallback, useEffect, useMemo, useState} from 'react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
import { Input } from '@/components/ui/input'
|
||||
import { Checkbox } from '@/components/ui/checkbox'
|
||||
import { ChevronLeft, ChevronRight } from 'lucide-react'
|
||||
import { KriSingleSelect } from '@/components/common/KriAutoComplete'
|
||||
import {ProjectInfo} from "@/types/project";
|
||||
import {nextApi} from "@/lib/http-client";
|
||||
import {PROJECT_SEARCH_COUNT} from "@/const/projectConst";
|
||||
import {useDebouncedValue} from "@/hooks/useDebouncedValue";
|
||||
import {useMounted} from "@/hooks/useMounted";
|
||||
import {UserInfo} from "@/types/user";
|
||||
import {useSelectedProject} from "@/hooks/useSelectedProject";
|
||||
import {KriSelect, KriSelectItem} from "@/components/common/KriSelect";
|
||||
import {useAuth} from "@/hooks/useAuth";
|
||||
import {RoleInfo} from "@/types/role";
|
||||
import {CONTACT_USER_ROLE, FW_USER_ROLE} from "@/const/userConst";
|
||||
import {useLoading} from "@/hooks/useLoading";
|
||||
import _ from "lodash";
|
||||
|
||||
const ProjectAssignPage = () => {
|
||||
const mounted = useMounted();
|
||||
const { withLoadingAsync } = useLoading();
|
||||
const { auth } = useAuth();
|
||||
const { selectedProject } = useSelectedProject();
|
||||
|
||||
const [projectArray, setProjectArray] = useState<ProjectInfo[]>([]);
|
||||
const [searchKeyword, setSearchKeyword] = useState("");
|
||||
const debouncedKeyword = useDebouncedValue(searchKeyword, 500);
|
||||
const [sourceProject, setSourceProject] = useState<ProjectInfo>();
|
||||
|
||||
const [companyArray, setCompanyArray] = useState<string[]>([]);
|
||||
const [companyFilter, setCompanyFilter] = useState<string>('');
|
||||
const [roleArray, setRoleArray] = useState<KriSelectItem[]>([]);
|
||||
const [roleFilter, setRoleFilter] = useState<KriSelectItem>();
|
||||
const [fwUserArray, setFwUserArray] = useState<UserInfo[]>([]);
|
||||
|
||||
const [originAssign, setOriginAssign] = useState<UserInfo[]>([]);
|
||||
const [assignUserArray, setAssignUserArray] = useState<UserInfo[]>([]);
|
||||
const [selectedAssignUser, setSelectedAssignUser] = useState<string[]>([]);
|
||||
const [searchAssign, setSearchAssign] = useState('');
|
||||
const debouncedAssign = useDebouncedValue(searchAssign, 500);
|
||||
|
||||
const [assignInfoString, setAssignInfoString] = useState<string>('');
|
||||
|
||||
const [ableUserArray, setAbleUserArray] = useState<UserInfo[]>([]);
|
||||
const [selectedAbleUser, setSelectedAbleUser] = useState<string[]>([]);
|
||||
const [searchAble, setSearchAble] = useState('');
|
||||
const debouncedAble = useDebouncedValue(searchAble, 500);
|
||||
|
||||
const searchTopProject = async (keyword: string) => {
|
||||
const res = await nextApi.get<ProjectInfo[]>(
|
||||
`/project/top/${PROJECT_SEARCH_COUNT}`,
|
||||
{ query: { keyword } }
|
||||
);
|
||||
|
||||
setProjectArray(res);
|
||||
};
|
||||
|
||||
const handleSelectProject = (info:ProjectInfo|null) => {
|
||||
if(info === null){
|
||||
setSourceProject(undefined)
|
||||
}
|
||||
else{
|
||||
setSourceProject(info);
|
||||
}
|
||||
}
|
||||
|
||||
const handleSelectAllLeft = (checked: boolean) => {
|
||||
if (checked) {
|
||||
setSelectedAssignUser(assignUserArray.map(u => u.userId))
|
||||
} else {
|
||||
setSelectedAssignUser([])
|
||||
}
|
||||
}
|
||||
|
||||
const handleSelectAllRight = (checked: boolean) => {
|
||||
if (checked) {
|
||||
setSelectedAbleUser(ableUserArray.map(u => u.userId))
|
||||
} else {
|
||||
setSelectedAbleUser([])
|
||||
}
|
||||
}
|
||||
|
||||
const handleToggleUnassign = (id: string) => {
|
||||
setSelectedAssignUser(prev =>
|
||||
prev.includes(id)
|
||||
? prev.filter(x => x !== id)
|
||||
: [...prev, id]
|
||||
)
|
||||
}
|
||||
|
||||
const handleToggleAssign = (id: string) => {
|
||||
setSelectedAbleUser(prev =>
|
||||
prev.includes(id)
|
||||
? prev.filter(x => x !== id)
|
||||
: [...prev, id]
|
||||
)
|
||||
}
|
||||
|
||||
const appendUserInfo = (
|
||||
userIdArray:string[],
|
||||
sourceArray:UserInfo[]
|
||||
) => {
|
||||
return sourceArray.filter(user => userIdArray.includes(user.userId));
|
||||
}
|
||||
|
||||
const resetSelect = () => {
|
||||
setSelectedAssignUser([]);
|
||||
setSelectedAbleUser([]);
|
||||
|
||||
//검색도 초기화
|
||||
setSearchAssign('');
|
||||
setSearchAble('');
|
||||
}
|
||||
|
||||
const resetSelectAndAssign = () => {
|
||||
resetSelect();
|
||||
setAssignUserArray(_.cloneDeep(originAssign));
|
||||
};
|
||||
|
||||
const handleCompanyChange = (v: string) => {
|
||||
resetSelectAndAssign();
|
||||
setCompanyFilter(v);
|
||||
// 필요하면 데이터도 같이 재조회/재계산 트리거
|
||||
};
|
||||
|
||||
const handleRoleChange = (item: KriSelectItem) => {
|
||||
resetSelectAndAssign();
|
||||
setRoleFilter(item);
|
||||
};
|
||||
|
||||
const handleAssign = () => {
|
||||
const toAssign = ableUserArray.filter(u => selectedAbleUser.includes(u.userId));
|
||||
setAssignUserArray(prev => [...prev, ...toAssign]);
|
||||
|
||||
setSelectedAbleUser([]);
|
||||
}
|
||||
|
||||
const handleRemove = () => {
|
||||
const toRemove = assignUserArray.filter(u => selectedAssignUser.includes(u.userId));
|
||||
setAssignUserArray(prev => prev.filter(u => !selectedAssignUser.includes(u.userId)));
|
||||
|
||||
setSelectedAssignUser([]);
|
||||
}
|
||||
|
||||
const handleSave = async () => {
|
||||
if(selectedProject){
|
||||
await nextApi.put(
|
||||
`/assign/prjct-fieldwork/${selectedProject.prjctIdx}`,
|
||||
assignUserArray.map(u => u.userId)
|
||||
)
|
||||
|
||||
setOriginAssign(_.cloneDeep(assignUserArray));
|
||||
|
||||
alert("저장되었습니다.");
|
||||
}
|
||||
else{
|
||||
alert("옳지 않은 요청입니다.");
|
||||
}
|
||||
}
|
||||
|
||||
const baseFiltered = useCallback((users: UserInfo[]) => {
|
||||
return users.filter(
|
||||
(u) =>
|
||||
String(u.userRole) === roleFilter?.value &&
|
||||
u.userCmpn === companyFilter
|
||||
);
|
||||
}, [roleFilter, companyFilter]);
|
||||
|
||||
const withKeyword = useCallback((users: UserInfo[], keyword: string) => {
|
||||
const k = keyword.trim();
|
||||
if (!k) return users;
|
||||
|
||||
return users.filter(
|
||||
(u) => u.userId.includes(k) || u.userName.includes(k)
|
||||
);
|
||||
}, []);
|
||||
|
||||
const assignBase = useMemo(
|
||||
() => baseFiltered(assignUserArray),
|
||||
[assignUserArray, baseFiltered]
|
||||
);
|
||||
|
||||
const assignView = useMemo(
|
||||
() => withKeyword(assignBase, debouncedAssign),
|
||||
[assignBase, debouncedAssign, withKeyword]
|
||||
);
|
||||
|
||||
const assignedIdSet = useMemo(
|
||||
() => new Set(assignUserArray.map(u => u.userId)),
|
||||
[assignUserArray]
|
||||
);
|
||||
|
||||
const ableBase = useMemo(
|
||||
() => baseFiltered(ableUserArray)
|
||||
.filter((user) => !assignedIdSet.has(user.userId)),
|
||||
[ableUserArray, baseFiltered, assignedIdSet]
|
||||
);
|
||||
|
||||
const ableView = useMemo(
|
||||
() => withKeyword(ableBase, debouncedAble)
|
||||
.filter((user) => !assignedIdSet.has(user.userId)),
|
||||
[ableBase, debouncedAble, withKeyword, assignedIdSet]
|
||||
);
|
||||
|
||||
useEffect(() => {
|
||||
if(selectedProject){
|
||||
const keyword = debouncedKeyword.trim();
|
||||
searchTopProject(keyword);
|
||||
}
|
||||
}, [debouncedKeyword]);
|
||||
|
||||
useEffect(() => {
|
||||
withLoadingAsync(async () => {
|
||||
nextApi.get<UserInfo[]>("/user/fieldwork")
|
||||
.then(res => setFwUserArray(res));
|
||||
|
||||
nextApi.get<string[]>("/user/cmpn")
|
||||
.then((res) => setCompanyArray(res));
|
||||
|
||||
const roleList = await nextApi.get<RoleInfo[]>("/role")
|
||||
const roleOptionArray = roleList
|
||||
.filter(role => role.roleCd >= FW_USER_ROLE)
|
||||
.map((role) => ({
|
||||
value: String(role.roleCd),
|
||||
label: role.roleNm,
|
||||
}))
|
||||
setRoleArray(roleOptionArray);
|
||||
const contactRole = roleOptionArray.find((role) => role.value === CONTACT_USER_ROLE.toString());
|
||||
if(contactRole){
|
||||
setRoleFilter(contactRole);
|
||||
}
|
||||
})
|
||||
|
||||
}, []);
|
||||
|
||||
useEffect(() => {
|
||||
if(auth.user){
|
||||
setCompanyFilter(auth.user.userCmpn || "")
|
||||
}
|
||||
}, [auth.user]);
|
||||
|
||||
useEffect(() => {
|
||||
withLoadingAsync(async () => {
|
||||
if(selectedProject){
|
||||
const res = await nextApi.get<string[]>(`/assign/prjct-fieldwork/${selectedProject.prjctIdx}`);
|
||||
const assignUserInfoArray = appendUserInfo(res, fwUserArray);
|
||||
|
||||
setAssignUserArray(assignUserInfoArray);
|
||||
setOriginAssign(assignUserInfoArray);
|
||||
}else{
|
||||
setAssignUserArray([]);
|
||||
setOriginAssign([]);
|
||||
}
|
||||
resetSelect();
|
||||
});
|
||||
}, [fwUserArray, selectedProject, roleArray]);
|
||||
|
||||
useEffect(() => {
|
||||
const assignString = roleArray.map((role) => {
|
||||
const assignCount = originAssign.filter(user => user.userRole.toString() === role.value).length
|
||||
return `${role.label} : ${assignCount}`;
|
||||
}).join(' / ');
|
||||
|
||||
setAssignInfoString(assignString);
|
||||
}, [originAssign]);
|
||||
|
||||
useEffect(() => {
|
||||
withLoadingAsync(async () => {
|
||||
let ableUserList :UserInfo[] = [];
|
||||
|
||||
if(sourceProject){
|
||||
const res = await nextApi.get<string[]>(`/assign/prjct-fieldwork/${sourceProject.prjctIdx}`);
|
||||
ableUserList = appendUserInfo(res, fwUserArray);
|
||||
}
|
||||
else{
|
||||
ableUserList = _.cloneDeep(fwUserArray);
|
||||
}
|
||||
|
||||
setAbleUserArray(ableUserList);
|
||||
});
|
||||
}, [fwUserArray, sourceProject]);
|
||||
|
||||
if (!mounted || !selectedProject) return null
|
||||
|
||||
return (
|
||||
<div className="min-h-screen bg-gray-50 p-1">
|
||||
<div className="max-w-7xl mx-auto">
|
||||
{/* 공용 필터 바 (회사 / 대상) */}
|
||||
<div className="mb-6 rounded-lg border border-gray-200 bg-white p-4 shadow-sm">
|
||||
<div className="flex flex-col gap-3 sm:flex-row sm:items-end">
|
||||
<div className="w-full sm:w-auto flex items-center gap-3">
|
||||
<div className="w-14 content-text-lg font-medium text-gray-700 whitespace-nowrap text-right">
|
||||
회사
|
||||
</div>
|
||||
<KriSelect
|
||||
items={companyArray}
|
||||
value={companyFilter}
|
||||
onChange={handleCompanyChange}
|
||||
placeholder="회사 선택"
|
||||
className="w-56 h-9"
|
||||
useAll={false}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="w-full sm:w-auto flex items-center gap-3">
|
||||
<div className="w-14 content-text-lg font-medium text-gray-700 whitespace-nowrap text-right">
|
||||
대상
|
||||
</div>
|
||||
<KriSelect
|
||||
items={roleArray}
|
||||
value={roleFilter?.value || ""}
|
||||
onChangeOption={handleRoleChange}
|
||||
placeholder="대상 선택"
|
||||
className="w-56 h-9"
|
||||
useAll={false}
|
||||
getValue={(x) => x.value}
|
||||
getLabel={(x) => x.label}
|
||||
/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 메인 배정 영역 */}
|
||||
<div className="grid grid-cols-[minmax(0,1fr)_auto_minmax(0,1fr)] gap-6 mb-6">
|
||||
{/* 왼쪽: 배정된 면접원 */}
|
||||
<div className="min-w-0">
|
||||
<div className="p-3 bg-black text-white rounded-lg content-text-lg mb-2 h-15 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">
|
||||
<div className="bg-gray-50 p-3 border-b border-gray-200">
|
||||
<Input
|
||||
placeholder="면접원 ID Or 면접원 이름"
|
||||
value={searchAssign}
|
||||
onChange={(e) => setSearchAssign(e.target.value)}
|
||||
className="bg-white border-gray-300"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="h-[600px] overflow-y-auto">
|
||||
<table className="w-full">
|
||||
<thead className="bg-black text-white sticky top-0">
|
||||
<tr>
|
||||
<th className="p-3 text-left w-12">
|
||||
<Checkbox
|
||||
checked={selectedAssignUser.length === assignView.length && assignView.length > 0}
|
||||
onCheckedChange={handleSelectAllLeft}
|
||||
className="border-white"
|
||||
/>
|
||||
</th>
|
||||
<th className="p-3 text-left content-text-base font-medium">배정된 {roleFilter?.label} ( {assignBase.length}명 )</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{assignView
|
||||
.map((userInfo) => (
|
||||
<tr
|
||||
key={userInfo.userId}
|
||||
className={`border-b border-gray-100 cursor-pointer hover:bg-gray-50 ${
|
||||
selectedAssignUser.includes(userInfo.userId) ? 'bg-blue-50' : ''
|
||||
}`}
|
||||
onClick={() => handleToggleUnassign(userInfo.userId)}
|
||||
>
|
||||
<td className="p-3">
|
||||
<Checkbox
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
checked={selectedAssignUser.includes(userInfo.userId)}
|
||||
onCheckedChange={() => handleToggleUnassign(userInfo.userId)}
|
||||
/>
|
||||
</td>
|
||||
<td className="p-3 content-text-base">
|
||||
{userInfo.userName} ({userInfo.userId})
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 가운데: 배정/제외 버튼 */}
|
||||
<div className="flex flex-col justify-center gap-4">
|
||||
<Button
|
||||
onClick={handleAssign}
|
||||
disabled={selectedAbleUser.length === 0}
|
||||
className="bg-black hover:bg-gray-800 w-36 h-12 flex items-center justify-center content-text-base disabled:bg-gray-300"
|
||||
>
|
||||
<ChevronLeft className="w-5 h-5" />
|
||||
<span className="ml-2">배정 {selectedAbleUser.length}명</span>
|
||||
</Button>
|
||||
<Button
|
||||
onClick={handleRemove}
|
||||
disabled={selectedAssignUser.length === 0}
|
||||
className="bg-red-600 hover:bg-red-700 w-36 h-12 flex items-center justify-center content-text-base disabled:bg-gray-300"
|
||||
>
|
||||
<ChevronRight className="w-5 h-5" />
|
||||
<span className="ml-2">제외 {selectedAssignUser.length}명</span>
|
||||
</Button>
|
||||
</div>
|
||||
|
||||
{/* 오른쪽: 전체 면접원 풀 */}
|
||||
<div className="min-w-0">
|
||||
<div className="p-3 bg-black text-white rounded-lg content-text-lg mb-2 h-15">
|
||||
<KriSingleSelect
|
||||
<ProjectInfo>
|
||||
items={projectArray}
|
||||
value={String(sourceProject?.prjctIdx ?? "")}
|
||||
onChange={() => {}}
|
||||
withInfo
|
||||
onItemChange={handleSelectProject}
|
||||
searchMode="inputOnly"
|
||||
onSearchValueChange={setSearchKeyword}
|
||||
placeholder="프로젝트 검색..."
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
preventDeselect
|
||||
hideOptionCheck
|
||||
useClear
|
||||
getLabel={(item) => `${item.prjctCd}_${item.prjctName}`}
|
||||
getValue={(item) => String(item.prjctIdx)}
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="border border-gray-200 rounded-lg overflow-hidden bg-white shadow-sm">
|
||||
<div className="bg-gray-50 p-3 border-b border-gray-200">
|
||||
<Input
|
||||
placeholder="면접원 ID Or 면접원 이름"
|
||||
value={searchAble}
|
||||
onChange={(e) => setSearchAble(e.target.value)}
|
||||
className="bg-white border-gray-300"
|
||||
/>
|
||||
</div>
|
||||
|
||||
<div className="h-[600px] overflow-y-auto">
|
||||
<table className="w-full">
|
||||
<thead className="bg-black text-white sticky top-0">
|
||||
<tr>
|
||||
<th className="p-3 text-left w-12">
|
||||
<Checkbox
|
||||
checked={selectedAbleUser.length === ableView.length && ableView.length > 0}
|
||||
onCheckedChange={handleSelectAllRight}
|
||||
className="border-white"
|
||||
/>
|
||||
</th>
|
||||
<th className="p-3 text-left content-text-base font-medium">배정 가능 {roleFilter?.label} ({ableBase.length}명 )</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{ableView
|
||||
.map((user) => (
|
||||
<tr
|
||||
key={user.userId}
|
||||
className={`border-b border-gray-100 cursor-pointer hover:bg-gray-50 ${
|
||||
selectedAbleUser.includes(user.userId) ? 'bg-blue-50' : ''
|
||||
}`}
|
||||
onClick={() => handleToggleAssign(user.userId)}
|
||||
>
|
||||
<td className="p-3">
|
||||
<Checkbox
|
||||
onClick={(e) => e.stopPropagation()}
|
||||
checked={selectedAbleUser.includes(user.userId)}
|
||||
onCheckedChange={() => handleToggleAssign(user.userId)}
|
||||
/>
|
||||
</td>
|
||||
<td className="p-3 content-text-base">
|
||||
{user.userName} ({user.userId})
|
||||
</td>
|
||||
</tr>
|
||||
))}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{/* 하단 저장 버튼 */}
|
||||
<div className="flex justify-center">
|
||||
<Button
|
||||
onClick={handleSave}
|
||||
className="bg-black hover:bg-gray-800 px-12 h-11 content-text-base font-medium"
|
||||
>
|
||||
저장
|
||||
</Button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
export default ProjectAssignPage;
|
||||
@@ -147,7 +147,7 @@ const ProjectInfoPage = () => {
|
||||
resultCodeList: updateCodeArray,
|
||||
assignUserIdList: outsourceUserArray,
|
||||
}
|
||||
console.log(requestUpdateProject, projectInfo.prjctIdx)
|
||||
|
||||
await nextApi.patch(`/project/${projectInfo.prjctIdx}`, requestUpdateProject);
|
||||
|
||||
alert("저장되었습니다.");
|
||||
@@ -476,6 +476,7 @@ console.log(requestUpdateProject, projectInfo.prjctIdx)
|
||||
{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="컨택 시나리오를 작성해 주세요"
|
||||
|
||||
@@ -17,7 +17,7 @@ import {NONE_HTTP_ERROR} from "@/const/commonConst";
|
||||
|
||||
const LoginPage = () => {
|
||||
const searchParams = useSearchParams();
|
||||
const { setFromLoginResponse } = useAuth();
|
||||
const { auth, setFromLoginResponse } = useAuth();
|
||||
const { withLoadingAsync } = useLoading();
|
||||
const { get: getSeatNumberStorage, set: setSeatNumberStorage } = useStorage(StorageKeys.SeatNumber);
|
||||
const { get: getLoginTypeStorage, set: setLoginTypeStorage } = useStorage(StorageKeys.LoginType);
|
||||
@@ -61,8 +61,6 @@ const LoginPage = () => {
|
||||
// 저장 실패는 치명적이지 않으므로 콘솔 로깅만
|
||||
console.warn("Failed to persist SeatNumber to secure storage:", e);
|
||||
}
|
||||
// 메인 페이지로 이동 (보호 라우트 진입)
|
||||
window.location.replace("/");
|
||||
}).catch((e) => {
|
||||
const err = apiError(e);
|
||||
console.error(err.status, err.code, err.message);
|
||||
@@ -80,6 +78,12 @@ const LoginPage = () => {
|
||||
);
|
||||
}
|
||||
|
||||
useEffect(() => {
|
||||
if(auth.user){
|
||||
window.location.replace("/");
|
||||
}
|
||||
}, [auth]);
|
||||
|
||||
// URL 쿼리 파라미터에서 type 수신
|
||||
useEffect(() => {
|
||||
const typeParam = searchParams.get("type") ?? "";
|
||||
|
||||
@@ -10,11 +10,41 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
const [action] = slug;
|
||||
const contactApi = await createContactApi();
|
||||
|
||||
if (action === "prjct-outsource") {
|
||||
if (action === "prjct-outsource" && slug.length === 2) {
|
||||
const result = await contactApi.get<string[]>(`/assign/prjct-outsource/${slug[1]}`);
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (action === "prjct-fieldwork" && slug.length === 2) {
|
||||
const result = await contactApi.get<string[]>(`/assign/prjct-fieldwork/${slug[1]}`);
|
||||
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 === "prjct-fieldwork" && slug.length === 2) {
|
||||
const body = await req.json().catch(() => null);
|
||||
if (!body) {
|
||||
return NextResponse.json(
|
||||
{ message: "요청 바디가 없습니다." },
|
||||
{ status: 400 }
|
||||
);
|
||||
}
|
||||
|
||||
await contactApi.put(`/assign/prjct-fieldwork/${slug[1]}`, body);
|
||||
return new NextResponse(null, { status: 204 });
|
||||
}
|
||||
|
||||
return NextResponse.json({ message: "Not found" }, { status: 404 });
|
||||
} catch (error: unknown) {
|
||||
return errorToResponse(error);
|
||||
|
||||
@@ -35,6 +35,11 @@ export const GET = async (req: NextRequest, context: RouteContext) => {
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if(action === "fieldwork"){
|
||||
const result = await contactApi.get<UserInfo[]>("/user/fieldwork");
|
||||
return NextResponse.json(result, { status: 200 });
|
||||
}
|
||||
|
||||
if (slug.length === 1) {
|
||||
const userId = action;
|
||||
const result = await contactApi.get<UserInfo>(`/user/${encodeURIComponent(userId)}`);
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
|
||||
import * as React from 'react'
|
||||
import { cn } from '@/lib/utils'
|
||||
import { MultiSelect } from '@/components/ui/multi-select'
|
||||
import {MultiSelect, MultiSelectRef} from '@/components/ui/multi-select'
|
||||
import type { MultiSelectOption } from '@/components/ui/multi-select'
|
||||
|
||||
type BaseProps<T> = {
|
||||
@@ -14,6 +14,8 @@ type BaseProps<T> = {
|
||||
placeholder?: string
|
||||
widthClassName?: string
|
||||
heightClassName?: string
|
||||
spanClassName?: string
|
||||
badgeClassName?: string
|
||||
className?: string
|
||||
getValue?: (item: T) => string
|
||||
getLabel?: (item: T) => string
|
||||
@@ -48,6 +50,8 @@ export function KriMultiSelect<T = unknown>({
|
||||
placeholder = 'Select options',
|
||||
widthClassName,
|
||||
heightClassName,
|
||||
spanClassName = "content-text-lg",
|
||||
badgeClassName = "content-text-lg",
|
||||
className,
|
||||
getValue,
|
||||
getLabel,
|
||||
@@ -55,6 +59,8 @@ export function KriMultiSelect<T = unknown>({
|
||||
onItemsChange,
|
||||
onOptionsChange,
|
||||
}: KriMultiSelectProps<T>) {
|
||||
const msRef = React.useRef<MultiSelectRef>(null);
|
||||
|
||||
const extractValue = React.useCallback(
|
||||
(item: T) => (getValue ? getValue(item) : String(item)),
|
||||
[getValue]
|
||||
@@ -75,6 +81,7 @@ export function KriMultiSelect<T = unknown>({
|
||||
return (
|
||||
<div className={cn(widthClassName, heightClassName, "flex-none overflow-hidden")}>
|
||||
<MultiSelect<T>
|
||||
ref={msRef}
|
||||
options={options}
|
||||
defaultValue={value}
|
||||
onValueChange={onChange}
|
||||
@@ -83,6 +90,8 @@ export function KriMultiSelect<T = unknown>({
|
||||
maxSelected={maxSelected}
|
||||
placeholder={placeholder}
|
||||
className={cn("bg-white content-text-lg", className)}
|
||||
spanClassName={spanClassName}
|
||||
badgeClassName={badgeClassName}
|
||||
searchable={searchable}
|
||||
searchMode={searchMode}
|
||||
defaultSearchValue={defaultSearchValue}
|
||||
@@ -105,6 +114,12 @@ type KriSingleSelectProps<T = unknown> = BaseProps<T> & {
|
||||
onOptionChange?: (option: MultiSelectOption<T> | null) => void
|
||||
preventDeselect?: boolean;
|
||||
hideOptionCheck?: boolean;
|
||||
|
||||
useClear?: boolean
|
||||
clearLabel?: string
|
||||
clearValue?: string
|
||||
|
||||
showSelectedTooltip?: boolean
|
||||
}
|
||||
|
||||
export function KriSingleSelect<T = unknown>({
|
||||
@@ -118,6 +133,8 @@ export function KriSingleSelect<T = unknown>({
|
||||
placeholder = 'Select an option',
|
||||
heightClassName,
|
||||
widthClassName,
|
||||
spanClassName = "content-text-lg",
|
||||
badgeClassName = "content-text-lg",
|
||||
className,
|
||||
getValue,
|
||||
getLabel,
|
||||
@@ -126,7 +143,13 @@ export function KriSingleSelect<T = unknown>({
|
||||
onOptionChange,
|
||||
preventDeselect = false,
|
||||
hideOptionCheck = false,
|
||||
showSelectedTooltip = false,
|
||||
useClear = false,
|
||||
clearLabel = "선택 해제",
|
||||
clearValue = "__CLEAR__",
|
||||
}: KriSingleSelectProps<T>) {
|
||||
const msRef = React.useRef<MultiSelectRef>(null);
|
||||
|
||||
const extractValue = React.useCallback(
|
||||
(item: T) => (getValue ? getValue(item) : String(item)),
|
||||
[getValue]
|
||||
@@ -137,31 +160,65 @@ export function KriSingleSelect<T = unknown>({
|
||||
)
|
||||
|
||||
const options = React.useMemo<MultiSelectOption<T>[]>(() => {
|
||||
return items.map((item) => ({
|
||||
const special: MultiSelectOption<T>[] = [];
|
||||
|
||||
if (useClear) special.push({ value: clearValue, label: clearLabel });
|
||||
|
||||
const normal = items.map((item) => ({
|
||||
value: extractValue(item),
|
||||
label: extractLabel(item),
|
||||
...(withInfo ? { info: item } : {}),
|
||||
}))
|
||||
}, [items, extractValue, extractLabel, withInfo])
|
||||
}));
|
||||
|
||||
return [...special, ...normal]
|
||||
}, [items, extractValue, extractLabel, withInfo, useClear, clearLabel, clearValue])
|
||||
|
||||
const defaultValue = React.useMemo(() => (value ? [value] : []), [value])
|
||||
|
||||
const tooltipText = React.useMemo(() => {
|
||||
if (!showSelectedTooltip) return undefined;
|
||||
if (!value || !value) return undefined;
|
||||
if (useClear && value === clearValue) return undefined;
|
||||
|
||||
const label = options.find(o => o.value === value)?.label;
|
||||
return label ?? value; // options에 없으면 value라도 표시
|
||||
}, [showSelectedTooltip, value, options, useClear, clearValue]);
|
||||
|
||||
return (
|
||||
<div className={cn(widthClassName, heightClassName, "flex-none overflow-hidden")}>
|
||||
<MultiSelect<T>
|
||||
ref={msRef}
|
||||
options={options}
|
||||
defaultValue={defaultValue}
|
||||
onValueChange={(next) => onChange(next[0] ?? '')}
|
||||
onValueChange={(next) => {
|
||||
const v = next[0] ?? ""
|
||||
|
||||
if (v === clearValue) {
|
||||
msRef.current?.clear();
|
||||
|
||||
onChange("")
|
||||
onOptionChange?.(null)
|
||||
onItemChange?.(null)
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
onChange(v)
|
||||
}}
|
||||
onOptionChange={(opts) => {
|
||||
const opt = opts[0] ?? null
|
||||
const item = withInfo ? ((opt as any)?.info ?? null) : null
|
||||
|
||||
onOptionChange?.(opt)
|
||||
onItemChange?.((withInfo ? (opt?.info ?? null) : null))
|
||||
onItemChange?.(item)
|
||||
}}
|
||||
selectionMode="single"
|
||||
maxCount={1}
|
||||
maxSelected={1}
|
||||
placeholder={placeholder}
|
||||
className={cn("bg-white content-text-lg", className)}
|
||||
spanClassName={spanClassName}
|
||||
badgeClassName={badgeClassName}
|
||||
searchable={searchable}
|
||||
searchMode={searchMode}
|
||||
defaultSearchValue={defaultSearchValue}
|
||||
|
||||
@@ -14,7 +14,9 @@ type KriSelectProps<T> = {
|
||||
/** 현재 선택 값 */
|
||||
value: string
|
||||
/** 값 변경 시 호출 */
|
||||
onChange: (value: string) => void
|
||||
onChange?: (value: string) => void
|
||||
/** 옵션 변경시 호출 */
|
||||
onChangeOption?: (option: T) => void
|
||||
/** placeholder 텍스트 */
|
||||
placeholder?: string
|
||||
/** 기타 클래스 (예: 'w-40') */
|
||||
@@ -31,22 +33,31 @@ export function KriSelect<T>({
|
||||
items,
|
||||
value,
|
||||
onChange,
|
||||
onChangeOption,
|
||||
placeholder,
|
||||
className,
|
||||
getValue,
|
||||
getLabel,
|
||||
useAll = true,
|
||||
}: KriSelectProps<T>) {
|
||||
|
||||
const extractValue = (item: T) =>
|
||||
getValue ? getValue(item) : String(item)
|
||||
getValue ? getValue(item) : String(item);
|
||||
|
||||
const extractLabel = (item: T) =>
|
||||
getLabel ? getLabel(item) : String(item)
|
||||
getLabel ? getLabel(item) : String(item);
|
||||
|
||||
return (
|
||||
<Select
|
||||
value={value}
|
||||
onValueChange={onChange}
|
||||
onValueChange={(v) => {
|
||||
onChange?.(v);
|
||||
|
||||
const selected = items.find((item) => extractValue(item) === v);
|
||||
if(selected) {
|
||||
onChangeOption?.(selected);
|
||||
}
|
||||
}}
|
||||
>
|
||||
<SelectTrigger
|
||||
className={cn(
|
||||
@@ -60,8 +71,9 @@ export function KriSelect<T>({
|
||||
<SelectContent>
|
||||
{ useAll? <SelectItem key="ALL" value="ALL">전체</SelectItem> :null }
|
||||
{items.map((item, idx) => {
|
||||
const v = extractValue(item)
|
||||
const label = extractLabel(item)
|
||||
const v = extractValue(item);
|
||||
const label = extractLabel(item);
|
||||
|
||||
return (
|
||||
<SelectItem key={v ?? idx} value={v}>
|
||||
{label}
|
||||
|
||||
@@ -5,6 +5,9 @@ import { cn } from "@/lib/utils";
|
||||
import type { KriEditorProps } from "./types";
|
||||
import { useDebouncedChange } from "./hooks/useDebouncedChange";
|
||||
import { sanitizeHtmlForPreview } from "./utils/sanitizeHtml";
|
||||
import {useCallback} from "react";
|
||||
import {toast} from "sonner";
|
||||
import {compressImage} from "@/components/kri-editor/utils/imageCompression";
|
||||
|
||||
type HtmlOnlyProps = Omit<KriEditorProps, "mode"> & {
|
||||
mode: "html";
|
||||
@@ -20,18 +23,26 @@ export function KriEditorHtmlOnly(props: HtmlOnlyProps) {
|
||||
showPreview,
|
||||
previewClassName,
|
||||
rows = 14,
|
||||
debounceMs = 350,
|
||||
|
||||
onImageUpload,
|
||||
onImageUploadError,
|
||||
debounceMs = 350,
|
||||
maxImageBytes = 5 * 1024 * 1024,
|
||||
imageMaxWidth = 1600,
|
||||
imageMaxHeight = 1600,
|
||||
imageQuality = 0.82,
|
||||
imageMimeType = "image/webp",
|
||||
} = props;
|
||||
|
||||
const [html, setHtml] = React.useState<string>(value || "");
|
||||
const textareaRef = React.useRef<HTMLTextAreaElement | null>(null);
|
||||
const fileInputRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const fileRef = React.useRef<HTMLInputElement | null>(null);
|
||||
const latestHtmlRef = React.useRef(html);
|
||||
latestHtmlRef.current = html;
|
||||
|
||||
const flushChange = useDebouncedChange(onChange, debounceMs);
|
||||
const canImageUpload = Boolean(onImageUpload);
|
||||
|
||||
const { scheduleChange, flushChange } = useDebouncedChange(onChange, debounceMs);
|
||||
|
||||
// 외부 value 변경 시 동기화
|
||||
React.useEffect(() => {
|
||||
@@ -45,65 +56,100 @@ export function KriEditorHtmlOnly(props: HtmlOnlyProps) {
|
||||
const next = e.target.value;
|
||||
setHtml(next);
|
||||
latestHtmlRef.current = next;
|
||||
flushChange(next);
|
||||
scheduleChange(next);
|
||||
};
|
||||
|
||||
const handleBlur = () => {
|
||||
flushChange(latestHtmlRef.current);
|
||||
};
|
||||
|
||||
const handleClickImageButton = () => {
|
||||
if (!onImageUpload) return;
|
||||
fileInputRef.current?.click();
|
||||
};
|
||||
const handlePickImage = useCallback(() => {
|
||||
if (!canImageUpload) return;
|
||||
fileRef.current?.click();
|
||||
}, [canImageUpload]);
|
||||
|
||||
const handleFileChange = async (
|
||||
e: React.ChangeEvent<HTMLInputElement>,
|
||||
) => {
|
||||
const file = e.target.files?.[0];
|
||||
if (!file || !onImageUpload) return;
|
||||
const handleFile = useCallback(
|
||||
async (e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
try {
|
||||
const file = e.target.files?.[0];
|
||||
e.target.value = "";
|
||||
if (!file) return;
|
||||
|
||||
try {
|
||||
const url = await onImageUpload(file);
|
||||
if (!url) return;
|
||||
if (!canImageUpload || !onImageUpload) return;
|
||||
|
||||
setHtml((prev) => {
|
||||
const current = prev ?? "";
|
||||
const textarea = textareaRef.current;
|
||||
const imgTag = `<img src="${url}" alt="" />`;
|
||||
if (!file.type.startsWith("image/")) {
|
||||
toast.error("이미지 파일만 업로드할 수 있습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!textarea) {
|
||||
const next = current + imgTag;
|
||||
latestHtmlRef.current = next;
|
||||
flushChange(next);
|
||||
return next;
|
||||
const compressed = await compressImage(file, {
|
||||
maxBytes: maxImageBytes,
|
||||
maxWidth: imageMaxWidth,
|
||||
maxHeight: imageMaxHeight,
|
||||
mimeType: imageMimeType,
|
||||
quality: imageQuality,
|
||||
});
|
||||
|
||||
if (compressed.size > maxImageBytes) {
|
||||
toast.error("이미지 용량이 제한을 초과합니다.", {
|
||||
description: `최대 ${(maxImageBytes / (1024 * 1024)).toFixed(0)}MB`,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
const { url } = await onImageUpload(compressed);
|
||||
|
||||
if (!url || typeof url !== "string") {
|
||||
toast.error("이미지 업로드 응답이 올바르지 않습니다.");
|
||||
return;
|
||||
}
|
||||
|
||||
setHtml((prev) => {
|
||||
const current = prev ?? "";
|
||||
const textarea = textareaRef.current;
|
||||
const imgTag = `<img src="${url}" alt="" />`;
|
||||
|
||||
if (!textarea) {
|
||||
const next = current + imgTag;
|
||||
latestHtmlRef.current = next;
|
||||
scheduleChange(next);
|
||||
return next;
|
||||
}
|
||||
|
||||
const { selectionStart, selectionEnd } = textarea;
|
||||
const before = current.slice(0, selectionStart);
|
||||
const after = current.slice(selectionEnd);
|
||||
const next = before + imgTag + after;
|
||||
|
||||
latestHtmlRef.current = next;
|
||||
scheduleChange(next);
|
||||
|
||||
// 커서 위치를 이미지 태그 뒤로 이동
|
||||
window.requestAnimationFrame(() => {
|
||||
const pos = before.length + imgTag.length;
|
||||
textarea.focus();
|
||||
textarea.setSelectionRange(pos, pos);
|
||||
});
|
||||
|
||||
return next;
|
||||
});
|
||||
} catch (err) {
|
||||
toast.error("이미지 업로드에 실패했습니다.");
|
||||
console.error(err);
|
||||
}
|
||||
|
||||
const { selectionStart, selectionEnd } = textarea;
|
||||
const before = current.slice(0, selectionStart);
|
||||
const after = current.slice(selectionEnd);
|
||||
const next = before + imgTag + after;
|
||||
|
||||
latestHtmlRef.current = next;
|
||||
flushChange(next);
|
||||
|
||||
// 커서 위치를 이미지 태그 뒤로 이동
|
||||
window.requestAnimationFrame(() => {
|
||||
const pos = before.length + imgTag.length;
|
||||
textarea.focus();
|
||||
textarea.setSelectionRange(pos, pos);
|
||||
});
|
||||
|
||||
return next;
|
||||
});
|
||||
} catch (error) {
|
||||
onImageUploadError?.(error);
|
||||
} finally {
|
||||
if (fileInputRef.current) {
|
||||
fileInputRef.current.value = "";
|
||||
}
|
||||
}
|
||||
};
|
||||
},
|
||||
[
|
||||
scheduleChange,
|
||||
setHtml,
|
||||
canImageUpload,
|
||||
onImageUpload,
|
||||
maxImageBytes,
|
||||
imageMaxWidth,
|
||||
imageMaxHeight,
|
||||
imageMimeType,
|
||||
imageQuality,
|
||||
]
|
||||
);
|
||||
|
||||
const sanitizedHtml = React.useMemo(
|
||||
() => sanitizeHtmlForPreview(html || ""),
|
||||
@@ -124,7 +170,7 @@ export function KriEditorHtmlOnly(props: HtmlOnlyProps) {
|
||||
{onImageUpload && (
|
||||
<button
|
||||
type="button"
|
||||
onClick={handleClickImageButton}
|
||||
onClick={handlePickImage}
|
||||
className="rounded border px-2 py-1 text-xs hover:bg-gray-50"
|
||||
>
|
||||
이미지 업로드
|
||||
@@ -143,18 +189,17 @@ export function KriEditorHtmlOnly(props: HtmlOnlyProps) {
|
||||
/>
|
||||
|
||||
<input
|
||||
ref={fileInputRef}
|
||||
ref={fileRef}
|
||||
type="file"
|
||||
accept="image/*"
|
||||
className="hidden"
|
||||
onChange={handleFileChange}
|
||||
onChange={handleFile}
|
||||
/>
|
||||
</div>
|
||||
{showPreview ?? (
|
||||
{showPreview && (
|
||||
<div className={cn("border-t p-3", previewClassName)}>
|
||||
<div className="mb-2 text-sm font-semibold">미리보기</div>
|
||||
<div className="rounded-md border bg-gray-50 p-3 text-sm leading-relaxed">
|
||||
{/* eslint-disable-next-line react/no-danger */}
|
||||
<div dangerouslySetInnerHTML={{ __html: sanitizedHtml }} />
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -79,6 +79,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
debounceMs = 350,
|
||||
|
||||
onImageUpload,
|
||||
onImageUploadError,
|
||||
maxImageBytes = 5 * 1024 * 1024,
|
||||
imageMaxWidth = 1600,
|
||||
imageMaxHeight = 1600,
|
||||
@@ -93,6 +94,11 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
const isLmsMode = mode === "lms";
|
||||
const showHtmlToggle = mode === "both";
|
||||
|
||||
const LINK_HTML_ATTRS = {
|
||||
rel: "noopener noreferrer",
|
||||
target: "_blank",
|
||||
} as const;
|
||||
|
||||
const { scheduleChange, flushChange, optimisticHtmlRef } = useDebouncedChange(onChange, debounceMs);
|
||||
|
||||
const fileRef = useRef<HTMLInputElement | null>(null);
|
||||
@@ -156,13 +162,12 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
Div,
|
||||
|
||||
Link.configure({
|
||||
openOnClick: false,
|
||||
autolink: true,
|
||||
openOnClick: false,
|
||||
linkOnPaste: true,
|
||||
HTMLAttributes: {
|
||||
class: "text-blue-600 underline underline-offset-2",
|
||||
rel: "noopener noreferrer nofollow",
|
||||
target: "_blank",
|
||||
class: "cursor-pointer text-blue-600 underline underline-offset-2",
|
||||
...LINK_HTML_ATTRS,
|
||||
},
|
||||
}),
|
||||
|
||||
@@ -174,6 +179,7 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
TableCell,
|
||||
|
||||
TiptapImage.configure({
|
||||
inline: true,
|
||||
allowBase64,
|
||||
HTMLAttributes: {
|
||||
class: "max-w-full h-auto",
|
||||
@@ -206,6 +212,52 @@ export function KriEditorWysiwyg(props: KriEditorProps) {
|
||||
"[&_td]:border [&_td]:p-2 [&_td]:align-top [&_td]:min-w-[90px]"
|
||||
),
|
||||
},
|
||||
handleDOMEvents: {
|
||||
click: (view, event) => {
|
||||
const e = event as MouseEvent;
|
||||
|
||||
// Alt + 좌클릭만
|
||||
if (!e.altKey || e.button !== 0) return false;
|
||||
|
||||
// 이미지(또는 리사이즈 컨테이너) 클릭일 때만
|
||||
const target = e.target as HTMLElement | null;
|
||||
const isImageClick = !!target?.closest?.("img, [data-resize-container]");
|
||||
if (!isImageClick) return false;
|
||||
|
||||
// 1) 문서 상태에서 link mark의 href 찾기 (NodeView/리사이즈 DOM에서도 안전)
|
||||
const pos = view.posAtCoords({ left: e.clientX, top: e.clientY });
|
||||
const linkType = view.state.schema.marks.link;
|
||||
|
||||
let href: string | undefined;
|
||||
|
||||
if (pos && linkType) {
|
||||
const $pos = view.state.doc.resolve(pos.pos);
|
||||
|
||||
const pickHref = (marks: readonly any[] | null | undefined) =>
|
||||
marks?.find(m => m.type === linkType)?.attrs?.href as string | undefined;
|
||||
|
||||
href =
|
||||
pickHref($pos.marks()) ||
|
||||
pickHref($pos.nodeAfter?.marks) ||
|
||||
pickHref($pos.nodeBefore?.marks);
|
||||
}
|
||||
|
||||
// 2) DOM fallback (실제 <a>가 있는 경우)
|
||||
if (!href) {
|
||||
const a = target?.closest?.("a") as HTMLAnchorElement | null;
|
||||
if (a?.href) href = a.href;
|
||||
}
|
||||
|
||||
if (!href) return false;
|
||||
|
||||
// 링크 열기 + 에디터 클릭 처리(커서 이동 등) 막기
|
||||
e.preventDefault();
|
||||
e.stopPropagation();
|
||||
console.log(LINK_HTML_ATTRS.rel.replaceAll(" ",","))
|
||||
window.open(href, LINK_HTML_ATTRS.target, LINK_HTML_ATTRS.rel.replaceAll(" ",","));
|
||||
return true;
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
@@ -318,12 +370,14 @@ const normalizeLinkUrl = (raw: string): string => {
|
||||
if (!editor) return;
|
||||
restoreSelection();
|
||||
|
||||
const prev = (editor.getAttributes("link").href as string | undefined) ?? "";
|
||||
if (editor.isActive("link")) {
|
||||
editor.chain().focus().unsetLink().run();
|
||||
return;
|
||||
if(confirm(`링크를 해제 하시겠습니까?\r\nLink: ${prev}`)){
|
||||
editor.chain().focus().unsetLink().run();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const prev = (editor.getAttributes("link").href as string | undefined) ?? "";
|
||||
const url = window.prompt("링크 URL을 입력하세요", prev);
|
||||
if (url === null) return;
|
||||
|
||||
@@ -412,8 +466,12 @@ const normalizeLinkUrl = (raw: string): string => {
|
||||
restoreSelection();
|
||||
editor.chain().focus().setImage({ src: url }).run();
|
||||
} catch (err) {
|
||||
toast.error("이미지 업로드에 실패했습니다.");
|
||||
console.error(err);
|
||||
if(onImageUploadError){
|
||||
onImageUploadError(err);
|
||||
}else{
|
||||
toast.error("이미지 업로드에 실패했습니다.");
|
||||
console.error(err);
|
||||
}
|
||||
}
|
||||
},
|
||||
[
|
||||
|
||||
@@ -37,8 +37,7 @@ export const Header = ({
|
||||
setUserInfo(auth.user);
|
||||
}
|
||||
else{
|
||||
alert("Fix Me!!!! components/layout/Header.tsx")
|
||||
//window.location.replace("/logout");
|
||||
window.location.replace("/logout");
|
||||
}
|
||||
}, [auth])
|
||||
|
||||
|
||||
@@ -76,6 +76,7 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
useEffect(() => {
|
||||
if(!isMain && isProjectMenu && !selectedProject){
|
||||
alert("옳지 않은 접근입니다.");
|
||||
window.location.replace("/");
|
||||
}
|
||||
}, []);
|
||||
|
||||
@@ -83,7 +84,7 @@ const MainLayout = ({ children, initialFontSize }: MainLayoutProps) => {
|
||||
<div
|
||||
className={cn(
|
||||
"bg-gray-50 flex flex-col",
|
||||
isMain ? "min-h-screen" : "h-screen overflow-hidden" // ✅ 메인 제외: 바깥 스크롤 잠금
|
||||
isMain ? "min-h-screen" : "h-screen overflow-hidden"
|
||||
)}
|
||||
>
|
||||
{/* 헤더 - 고정 폰트 크기 */}
|
||||
|
||||
@@ -52,10 +52,12 @@ export const SidebarProjectSearch = () =>{
|
||||
searchMode="inputOnly"
|
||||
onSearchValueChange={setSearchKeyword}
|
||||
placeholder="프로젝트 검색..."
|
||||
spanClassName="content-text-sm"
|
||||
widthClassName="w-full"
|
||||
heightClassName="h-9"
|
||||
preventDeselect
|
||||
hideOptionCheck
|
||||
showSelectedTooltip
|
||||
getLabel={(item) => `${item.prjctCd}_${item.prjctName}`}
|
||||
getValue={(item) => String(item.prjctIdx)}
|
||||
/>
|
||||
|
||||
@@ -14,7 +14,7 @@ function Checkbox({
|
||||
<CheckboxPrimitive.Root
|
||||
data-slot="checkbox"
|
||||
className={cn(
|
||||
"peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
||||
"cursor-pointer peer border-input dark:bg-input/30 data-[state=checked]:bg-primary data-[state=checked]:text-primary-foreground dark:data-[state=checked]:bg-primary data-[state=checked]:border-primary focus-visible:border-ring focus-visible:ring-ring/50 aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive size-4 shrink-0 rounded-[4px] border shadow-xs transition-shadow outline-none focus-visible:ring-[3px] disabled:cursor-not-allowed disabled:opacity-50",
|
||||
className
|
||||
)}
|
||||
{...props}
|
||||
|
||||
@@ -216,6 +216,10 @@ export interface MultiSelectProps<T = unknown>
|
||||
*/
|
||||
className?: string;
|
||||
|
||||
spanClassName?: string;
|
||||
|
||||
badgeClassName?: string;
|
||||
|
||||
/**
|
||||
* If true, disables the select all functionality.
|
||||
* Optional, defaults to false.
|
||||
@@ -389,6 +393,8 @@ function MultiSelectInner(
|
||||
modalPopover = false,
|
||||
asChild = false,
|
||||
className,
|
||||
spanClassName,
|
||||
badgeClassName,
|
||||
hideSelectAll = false,
|
||||
searchable = true,
|
||||
searchMode = "filter",
|
||||
@@ -1115,7 +1121,7 @@ function MultiSelectInner(
|
||||
{selectedValues.length > 0 ? (
|
||||
<div className="flex justify-between items-center w-full">
|
||||
{isSingle ? (
|
||||
<span className="mx-3 flex-1 min-w-0 truncate text-left content-text-lg text-foreground">
|
||||
<span className={cn("mx-3 flex-1 min-w-0 truncate text-left text-foreground", spanClassName)}>
|
||||
{selectedValues[0]
|
||||
? (getOptionByValue(selectedValues[0])?.label ?? selectedValues[0])
|
||||
: ""}
|
||||
@@ -1156,14 +1162,14 @@ function MultiSelectInner(
|
||||
multiSelectVariants({ variant }),
|
||||
customStyle?.gradient &&
|
||||
"text-white border-transparent",
|
||||
"content-text-lg",
|
||||
responsiveSettings.compactMode &&
|
||||
"px-1.5 py-0.5",
|
||||
screenSize === "mobile" &&
|
||||
"max-w-[120px] truncate",
|
||||
singleLine &&
|
||||
"flex-shrink-0 whitespace-nowrap",
|
||||
"[&>svg]:pointer-events-auto"
|
||||
"[&>svg]:pointer-events-auto",
|
||||
badgeClassName
|
||||
)}
|
||||
style={{
|
||||
...badgeStyle,
|
||||
@@ -1238,12 +1244,12 @@ function MultiSelectInner(
|
||||
"bg-transparent text-foreground border-foreground/1 hover:bg-transparent",
|
||||
getBadgeAnimationClass(),
|
||||
multiSelectVariants({ variant }),
|
||||
"content-text-lg",
|
||||
responsiveSettings.compactMode &&
|
||||
"px-1.5 py-0.5",
|
||||
singleLine &&
|
||||
"flex-shrink-0 whitespace-nowrap",
|
||||
"[&>svg]:pointer-events-auto"
|
||||
"[&>svg]:pointer-events-auto",
|
||||
badgeClassName
|
||||
)}
|
||||
style={{
|
||||
animationDuration: `${
|
||||
@@ -1307,7 +1313,7 @@ function MultiSelectInner(
|
||||
</div>
|
||||
) : (
|
||||
<div className="flex items-center justify-between w-full mx-auto">
|
||||
<span className="mx-3 text-muted-foreground content-text-lg">
|
||||
<span className={cn("mx-3 text-muted-foreground", spanClassName)}>
|
||||
{placeholder}
|
||||
</span>
|
||||
<ChevronDown className="h-4 cursor-pointer text-muted-foreground mx-2" />
|
||||
|
||||
@@ -36,8 +36,8 @@ export const projectSideMenus: SideMenuItem[] = [
|
||||
label: "면접원 배정",
|
||||
icon: Users,
|
||||
children: [
|
||||
{ id: "assign-project", label: "프로젝트 배정", path: "/assign/project" },
|
||||
{ id: "assign-list", label: "리스트 배정", path: "/assign/list" },
|
||||
{ id: "assign-project", label: "프로젝트 배정", path: "/project/assign" },
|
||||
{ id: "assign-list", label: "리스트 배정", path: "/list/assign" },
|
||||
],
|
||||
},
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
export const EXTERNAL_USER_ROLE = 4000
|
||||
export const FW_USER_ROLE = 9000
|
||||
export const CONTACT_USER_ROLE = 9002
|
||||
|
||||
export const USER_NAME_REGEX = /^[가-힣A-Za-z][가-힣A-Za-z0-9_ ()]*$/
|
||||
export const DEFAULT_COMPANY_NAME = 'KRI'
|
||||
|
||||
Reference in New Issue
Block a user