From bfbf4635b3829e669a8e230be8da185f2f5ac6b5 Mon Sep 17 00:00:00 2001 From: kric_jspark Date: Tue, 16 Dec 2025 16:57:03 +0900 Subject: [PATCH] =?UTF-8?q?251216=5F01=5FENH=20:=20=ED=94=84=EB=A1=9C?= =?UTF-8?q?=EC=A0=9D=ED=8A=B8=EC=97=90=20FW=20User=20=EB=B0=B0=EC=A0=95=20?= =?UTF-8?q?=EA=B5=AC=ED=98=84=20=EB=B0=8F=20=ED=85=8C=EC=8A=A4=ED=8A=B8=20?= =?UTF-8?q?=EC=99=84=EB=A3=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../(pages)/(main)/assign/project/page.tsx | 8 - .../{assign/list => list/assign}/page.tsx | 0 src/app/(pages)/(main)/manage/user/page.tsx | 5 - .../(pages)/(main)/project/assign/page.tsx | 498 ++++++++++++++++++ src/app/(pages)/(main)/project/info/page.tsx | 3 +- src/app/(pages)/login/page.tsx | 10 +- src/app/api/assign/[[...slug]]/route.ts | 32 +- src/app/api/user/[[...slug]]/route.ts | 5 + src/components/common/KriAutoComplete.tsx | 69 ++- src/components/common/KriSelect.tsx | 24 +- .../kri-editor/KriEditorHtmlOnly.tsx | 157 ++++-- .../kri-editor/KriEditorWysiwyg.tsx | 76 ++- src/components/layout/Header.tsx | 3 +- src/components/layout/MainLayout.tsx | 3 +- .../layout/SidebarProjectSearch .tsx | 2 + src/components/ui/checkbox.tsx | 2 +- src/components/ui/multi-select.tsx | 18 +- src/config/menu.data.ts | 4 +- src/const/userConst.ts | 1 + 19 files changed, 813 insertions(+), 107 deletions(-) delete mode 100644 src/app/(pages)/(main)/assign/project/page.tsx rename src/app/(pages)/(main)/{assign/list => list/assign}/page.tsx (100%) create mode 100644 src/app/(pages)/(main)/project/assign/page.tsx diff --git a/src/app/(pages)/(main)/assign/project/page.tsx b/src/app/(pages)/(main)/assign/project/page.tsx deleted file mode 100644 index b404abc..0000000 --- a/src/app/(pages)/(main)/assign/project/page.tsx +++ /dev/null @@ -1,8 +0,0 @@ -const ProjectAssignPage = () => { - //const url = buildUrlWithParams("/login", searchParams, { ref: "root" }); - //redirect(url); - - return (
This is Project Assign Page
) -} - -export default ProjectAssignPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/assign/list/page.tsx b/src/app/(pages)/(main)/list/assign/page.tsx similarity index 100% rename from src/app/(pages)/(main)/assign/list/page.tsx rename to src/app/(pages)/(main)/list/assign/page.tsx diff --git a/src/app/(pages)/(main)/manage/user/page.tsx b/src/app/(pages)/(main)/manage/user/page.tsx index f38684c..338863f 100644 --- a/src/app/(pages)/(main)/manage/user/page.tsx +++ b/src/app/(pages)/(main)/manage/user/page.tsx @@ -57,11 +57,6 @@ const UserManagePage = () => { const userData = await nextApi.get("/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); } // 등록 버튼 클릭 diff --git a/src/app/(pages)/(main)/project/assign/page.tsx b/src/app/(pages)/(main)/project/assign/page.tsx new file mode 100644 index 0000000..02da7bd --- /dev/null +++ b/src/app/(pages)/(main)/project/assign/page.tsx @@ -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([]); + const [searchKeyword, setSearchKeyword] = useState(""); + const debouncedKeyword = useDebouncedValue(searchKeyword, 500); + const [sourceProject, setSourceProject] = useState(); + + const [companyArray, setCompanyArray] = useState([]); + const [companyFilter, setCompanyFilter] = useState(''); + const [roleArray, setRoleArray] = useState([]); + const [roleFilter, setRoleFilter] = useState(); + const [fwUserArray, setFwUserArray] = useState([]); + + const [originAssign, setOriginAssign] = useState([]); + const [assignUserArray, setAssignUserArray] = useState([]); + const [selectedAssignUser, setSelectedAssignUser] = useState([]); + const [searchAssign, setSearchAssign] = useState(''); + const debouncedAssign = useDebouncedValue(searchAssign, 500); + + const [assignInfoString, setAssignInfoString] = useState(''); + + const [ableUserArray, setAbleUserArray] = useState([]); + const [selectedAbleUser, setSelectedAbleUser] = useState([]); + const [searchAble, setSearchAble] = useState(''); + const debouncedAble = useDebouncedValue(searchAble, 500); + + const searchTopProject = async (keyword: string) => { + const res = await nextApi.get( + `/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("/user/fieldwork") + .then(res => setFwUserArray(res)); + + nextApi.get("/user/cmpn") + .then((res) => setCompanyArray(res)); + + const roleList = await nextApi.get("/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(`/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(`/assign/prjct-fieldwork/${sourceProject.prjctIdx}`); + ableUserList = appendUserInfo(res, fwUserArray); + } + else{ + ableUserList = _.cloneDeep(fwUserArray); + } + + setAbleUserArray(ableUserList); + }); + }, [fwUserArray, sourceProject]); + + if (!mounted || !selectedProject) return null + + return ( +
+
+ {/* 공용 필터 바 (회사 / 대상) */} +
+
+
+
+ 회사 +
+ +
+ +
+
+ 대상 +
+ x.value} + getLabel={(x) => x.label} + /> +
+
+
+ + {/* 메인 배정 영역 */} +
+ {/* 왼쪽: 배정된 면접원 */} +
+
+ + {assignInfoString} + +
+
+
+ setSearchAssign(e.target.value)} + className="bg-white border-gray-300" + /> +
+ +
+ + + + + + + + + {assignView + .map((userInfo) => ( + handleToggleUnassign(userInfo.userId)} + > + + + + ))} + +
+ 0} + onCheckedChange={handleSelectAllLeft} + className="border-white" + /> + 배정된 {roleFilter?.label} ( {assignBase.length}명 )
+ e.stopPropagation()} + checked={selectedAssignUser.includes(userInfo.userId)} + onCheckedChange={() => handleToggleUnassign(userInfo.userId)} + /> + + {userInfo.userName} ({userInfo.userId}) +
+
+
+
+ + {/* 가운데: 배정/제외 버튼 */} +
+ + +
+ + {/* 오른쪽: 전체 면접원 풀 */} +
+
+ + 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)} + /> +
+ +
+
+ setSearchAble(e.target.value)} + className="bg-white border-gray-300" + /> +
+ +
+ + + + + + + + + {ableView + .map((user) => ( + handleToggleAssign(user.userId)} + > + + + + ))} + +
+ 0} + onCheckedChange={handleSelectAllRight} + className="border-white" + /> + 배정 가능 {roleFilter?.label} ({ableBase.length}명 )
+ e.stopPropagation()} + checked={selectedAbleUser.includes(user.userId)} + onCheckedChange={() => handleToggleAssign(user.userId)} + /> + + {user.userName} ({user.userId}) +
+
+
+
+
+ + {/* 하단 저장 버튼 */} +
+ +
+
+
+ ) +} + +export default ProjectAssignPage; \ No newline at end of file diff --git a/src/app/(pages)/(main)/project/info/page.tsx b/src/app/(pages)/(main)/project/info/page.tsx index 8ab18f3..bef9771 100644 --- a/src/app/(pages)/(main)/project/info/page.tsx +++ b/src/app/(pages)/(main)/project/info/page.tsx @@ -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 && (

"} onChange={(html: string) => handleChange("contactSenario", html)} placeholder="컨택 시나리오를 작성해 주세요" diff --git a/src/app/(pages)/login/page.tsx b/src/app/(pages)/login/page.tsx index b67f820..e6c2ebb 100644 --- a/src/app/(pages)/login/page.tsx +++ b/src/app/(pages)/login/page.tsx @@ -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") ?? ""; diff --git a/src/app/api/assign/[[...slug]]/route.ts b/src/app/api/assign/[[...slug]]/route.ts index ae76317..dedf102 100644 --- a/src/app/api/assign/[[...slug]]/route.ts +++ b/src/app/api/assign/[[...slug]]/route.ts @@ -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(`/assign/prjct-outsource/${slug[1]}`); return NextResponse.json(result, { status: 200 }); } + if (action === "prjct-fieldwork" && slug.length === 2) { + const result = await contactApi.get(`/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); diff --git a/src/app/api/user/[[...slug]]/route.ts b/src/app/api/user/[[...slug]]/route.ts index 23fa83f..8def304 100644 --- a/src/app/api/user/[[...slug]]/route.ts +++ b/src/app/api/user/[[...slug]]/route.ts @@ -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("/user/fieldwork"); + return NextResponse.json(result, { status: 200 }); + } + if (slug.length === 1) { const userId = action; const result = await contactApi.get(`/user/${encodeURIComponent(userId)}`); diff --git a/src/components/common/KriAutoComplete.tsx b/src/components/common/KriAutoComplete.tsx index 3a50e51..1b285fb 100644 --- a/src/components/common/KriAutoComplete.tsx +++ b/src/components/common/KriAutoComplete.tsx @@ -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 = { @@ -14,6 +14,8 @@ type BaseProps = { 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({ placeholder = 'Select options', widthClassName, heightClassName, + spanClassName = "content-text-lg", + badgeClassName = "content-text-lg", className, getValue, getLabel, @@ -55,6 +59,8 @@ export function KriMultiSelect({ onItemsChange, onOptionsChange, }: KriMultiSelectProps) { + const msRef = React.useRef(null); + const extractValue = React.useCallback( (item: T) => (getValue ? getValue(item) : String(item)), [getValue] @@ -75,6 +81,7 @@ export function KriMultiSelect({ return (
+ ref={msRef} options={options} defaultValue={value} onValueChange={onChange} @@ -83,6 +90,8 @@ export function KriMultiSelect({ 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 = BaseProps & { onOptionChange?: (option: MultiSelectOption | null) => void preventDeselect?: boolean; hideOptionCheck?: boolean; + + useClear?: boolean + clearLabel?: string + clearValue?: string + + showSelectedTooltip?: boolean } export function KriSingleSelect({ @@ -118,6 +133,8 @@ export function KriSingleSelect({ placeholder = 'Select an option', heightClassName, widthClassName, + spanClassName = "content-text-lg", + badgeClassName = "content-text-lg", className, getValue, getLabel, @@ -126,7 +143,13 @@ export function KriSingleSelect({ onOptionChange, preventDeselect = false, hideOptionCheck = false, + showSelectedTooltip = false, + useClear = false, + clearLabel = "선택 해제", + clearValue = "__CLEAR__", }: KriSingleSelectProps) { + const msRef = React.useRef(null); + const extractValue = React.useCallback( (item: T) => (getValue ? getValue(item) : String(item)), [getValue] @@ -137,31 +160,65 @@ export function KriSingleSelect({ ) const options = React.useMemo[]>(() => { - return items.map((item) => ({ + const special: MultiSelectOption[] = []; + + 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 (
+ 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} diff --git a/src/components/common/KriSelect.tsx b/src/components/common/KriSelect.tsx index dc36e59..5c1c8d5 100644 --- a/src/components/common/KriSelect.tsx +++ b/src/components/common/KriSelect.tsx @@ -14,7 +14,9 @@ type KriSelectProps = { /** 현재 선택 값 */ 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({ items, value, onChange, + onChangeOption, placeholder, className, getValue, getLabel, useAll = true, }: KriSelectProps) { + 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 (
- {showPreview ?? ( + {showPreview && (
미리보기
- {/* eslint-disable-next-line react/no-danger */}
diff --git a/src/components/kri-editor/KriEditorWysiwyg.tsx b/src/components/kri-editor/KriEditorWysiwyg.tsx index 9017793..4183ffb 100644 --- a/src/components/kri-editor/KriEditorWysiwyg.tsx +++ b/src/components/kri-editor/KriEditorWysiwyg.tsx @@ -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(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 (실제 가 있는 경우) + 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); + } } }, [ diff --git a/src/components/layout/Header.tsx b/src/components/layout/Header.tsx index 96a7052..8060930 100644 --- a/src/components/layout/Header.tsx +++ b/src/components/layout/Header.tsx @@ -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]) diff --git a/src/components/layout/MainLayout.tsx b/src/components/layout/MainLayout.tsx index c486a41..e3bb9e0 100644 --- a/src/components/layout/MainLayout.tsx +++ b/src/components/layout/MainLayout.tsx @@ -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) => {
{/* 헤더 - 고정 폰트 크기 */} diff --git a/src/components/layout/SidebarProjectSearch .tsx b/src/components/layout/SidebarProjectSearch .tsx index 01fd932..abf1baf 100644 --- a/src/components/layout/SidebarProjectSearch .tsx +++ b/src/components/layout/SidebarProjectSearch .tsx @@ -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)} /> diff --git a/src/components/ui/checkbox.tsx b/src/components/ui/checkbox.tsx index cb0b07b..4a2e07e 100644 --- a/src/components/ui/checkbox.tsx +++ b/src/components/ui/checkbox.tsx @@ -14,7 +14,7 @@ function Checkbox({ */ 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 ? (
{isSingle ? ( - + {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(
) : (
- + {placeholder} diff --git a/src/config/menu.data.ts b/src/config/menu.data.ts index 9d5897b..e92b7a9 100644 --- a/src/config/menu.data.ts +++ b/src/config/menu.data.ts @@ -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" }, ], }, { diff --git a/src/const/userConst.ts b/src/const/userConst.ts index fe9c953..0db7507 100644 --- a/src/const/userConst.ts +++ b/src/const/userConst.ts @@ -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'