Merge pull request '260910_02_ENH: 검색 시 1페이지로' (#34) from develop into master
Reviewed-on: #34
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState, type ClipboardEvent, type ReactNode } from 'react'
|
||||
import { useCallback, useEffect, useMemo, useRef, useState, type ClipboardEvent, type ReactNode } from 'react'
|
||||
import type { PaginationState, SortingState } from '@tanstack/react-table'
|
||||
import { Funnel, PencilLine } from 'lucide-react'
|
||||
import { Button } from '@/components/ui/button'
|
||||
@@ -200,6 +200,8 @@ export function ListSearchTable({
|
||||
const [batchResultCodes, setBatchResultCodes] = useState<BatchEditResultCodes>({})
|
||||
const [batchSurveyResultCodes, setBatchSurveyResultCodes] = useState<BatchEditSurveyResultCodes>({})
|
||||
const [selectedRows, setSelectedRows] = useState<ListTableRow[]>([])
|
||||
const handledRefreshKeyRef = useRef(refreshKey)
|
||||
const previousExternalAssignFilterRef = useRef(externalAssignFilter)
|
||||
const selectedSids = useMemo(
|
||||
() => selectedRows.map((row) => String(row.sid ?? '')).filter((sid) => sid.length > 0),
|
||||
[selectedRows],
|
||||
@@ -533,8 +535,28 @@ export function ListSearchTable({
|
||||
[accessibleFilterHeaders, getValueOptionsForHeader, lockedListFilterHeaderTypes],
|
||||
)
|
||||
|
||||
const handleSearchClick = () => {
|
||||
setPagination((prev) => ({ ...prev, pageIndex: 0 }))
|
||||
const resetToFirstPage = () => {
|
||||
setPagination((prev) => (prev.pageIndex === 0 ? prev : { ...prev, pageIndex: 0 }))
|
||||
}
|
||||
|
||||
const handleSearchTextChange = (value: string) => {
|
||||
setSearchText(sanitizeSidInput(value))
|
||||
resetToFirstPage()
|
||||
}
|
||||
|
||||
const handleContactResultChange = (value: string[]) => {
|
||||
setSearchContactResult(value)
|
||||
resetToFirstPage()
|
||||
}
|
||||
|
||||
const handleInterviewResultChange = (value: string[]) => {
|
||||
setSearchInterviewResult(value)
|
||||
resetToFirstPage()
|
||||
}
|
||||
|
||||
const handleSortingChange = (value: SortingState) => {
|
||||
setSorting(value)
|
||||
resetToFirstPage()
|
||||
}
|
||||
|
||||
const handleSidPaste = (e: ClipboardEvent<HTMLInputElement>) => {
|
||||
@@ -546,6 +568,7 @@ export function ListSearchTable({
|
||||
const selectionEnd = e.currentTarget.selectionEnd ?? selectionStart
|
||||
const nextValue = `${searchText.slice(0, selectionStart)}${normalizedText}${searchText.slice(selectionEnd)}`
|
||||
setSearchText(deduplicateSidInput(sanitizeSidInput(nextValue)))
|
||||
resetToFirstPage()
|
||||
}
|
||||
|
||||
const handleFilterConfirm = async (rows: FilterRow[]) => {
|
||||
@@ -555,6 +578,7 @@ export function ListSearchTable({
|
||||
|
||||
const handleChangeSurveyResult = (prjctSurveyIdx: number, codes: string[]) => {
|
||||
setSurveyResultSelections((prev) => ({ ...prev, [prjctSurveyIdx]: codes }))
|
||||
resetToFirstPage()
|
||||
}
|
||||
|
||||
const surveyResultCodeOptions = resultCodes.filter((item) => item.resultCdTy === ResultCodeType.SURVEY)
|
||||
@@ -617,9 +641,22 @@ export function ListSearchTable({
|
||||
}, [accessibleFilterHeaderById, lockedListFilterHeaderTypes])
|
||||
|
||||
useEffect(() => {
|
||||
if (!refreshKey) return
|
||||
refetch()
|
||||
}, [refetch, refreshKey])
|
||||
if (!refreshKey || handledRefreshKeyRef.current === refreshKey) return
|
||||
handledRefreshKeyRef.current = refreshKey
|
||||
|
||||
if (pagination.pageIndex === 0) {
|
||||
refetch()
|
||||
return
|
||||
}
|
||||
|
||||
resetToFirstPage()
|
||||
}, [pagination.pageIndex, refetch, refreshKey])
|
||||
|
||||
useEffect(() => {
|
||||
if (previousExternalAssignFilterRef.current === externalAssignFilter) return
|
||||
previousExternalAssignFilterRef.current = externalAssignFilter
|
||||
resetToFirstPage()
|
||||
}, [externalAssignFilter])
|
||||
|
||||
return (
|
||||
<div className="space-y-2">
|
||||
@@ -629,14 +666,14 @@ export function ListSearchTable({
|
||||
placeholder="SID 검색"
|
||||
className="h-9 bg-white flex-1 min-w-0 max-w-xs"
|
||||
value={searchText}
|
||||
onChange={(e) => setSearchText(sanitizeSidInput(e.target.value))}
|
||||
onChange={(e) => handleSearchTextChange(e.target.value)}
|
||||
onPaste={handleSidPaste}
|
||||
/>
|
||||
<div className="flex-1 min-w-0 max-w-xs">
|
||||
<KriMultiSelect
|
||||
items={resultCodes.filter((item) => item.resultCdTy === ResultCodeType.CONTACT)}
|
||||
value={searchContactResult}
|
||||
onChange={setSearchContactResult}
|
||||
onChange={handleContactResultChange}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="컨택 결과"
|
||||
@@ -658,7 +695,7 @@ export function ListSearchTable({
|
||||
<KriMultiSelect
|
||||
items={resultCodes.filter((item) => item.resultCdTy === ResultCodeType.INTERVIEW)}
|
||||
value={searchInterviewResult}
|
||||
onChange={setSearchInterviewResult}
|
||||
onChange={handleInterviewResultChange}
|
||||
getValue={(item) => String(item.resultCd)}
|
||||
getLabel={(item) => item.resultCdLbl}
|
||||
placeholder="면접 결과"
|
||||
@@ -719,7 +756,7 @@ export function ListSearchTable({
|
||||
totalCount={totalCount}
|
||||
pagination={pagination}
|
||||
onPaginationChange={setPagination}
|
||||
onSortingChange={setSorting}
|
||||
onSortingChange={handleSortingChange}
|
||||
selectMode={selectMode}
|
||||
onRowSelectionChange={handleRowSelectionChange}
|
||||
onRowClick={onRowClick}
|
||||
|
||||
Reference in New Issue
Block a user