260810_01_ENH: sid 필터 복붙, 리스트 배정 화면에서 대상 선택시 필터 자동적용, pw 제한, timepicker 수정
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useEffect, useMemo, useState } from 'react'
|
||||
import { useMemo, useState } from 'react'
|
||||
import { useMounted } from '@kri/common/hooks'
|
||||
import { LoadingOverlayAdapter } from '@/components/app-shell/LoadingOverlayAdapter'
|
||||
import { useAuth } from '@/hooks/useAuth'
|
||||
@@ -19,9 +19,9 @@ import { createEmptyListFilter, type ListFilter, type ListHeaderAssignType, type
|
||||
import type { ResultCode } from '@/types/project'
|
||||
|
||||
const ASSIGN_TAB_TYPES: ListHeaderAssignType[] = [
|
||||
ListHeaderAssignConst.OUTSOURCE,
|
||||
ListHeaderAssignConst.CONTACT_INTERVIEWER,
|
||||
ListHeaderAssignConst.FIELD_INTERVIEWER,
|
||||
ListHeaderAssignConst.OUTSOURCE,
|
||||
]
|
||||
|
||||
const ASSIGNED_SENTINEL = '__ASSIGNED__'
|
||||
@@ -37,7 +37,7 @@ const ListAssignPage = () => {
|
||||
const enabled = mounted && prjctIdx > 0
|
||||
const userRole = auth?.user?.userRole ?? 0
|
||||
|
||||
const [assignType, setAssignType] = useState<ListHeaderAssignType>(ListHeaderAssignConst.OUTSOURCE)
|
||||
const [assignType, setAssignType] = useState<ListHeaderAssignType>(ListHeaderAssignConst.CONTACT_INTERVIEWER)
|
||||
const [selectedAssignId, setSelectedAssignId] = useState<string | undefined>(undefined)
|
||||
const [assignFilterIds, setAssignFilterIds] = useState<string[]>([])
|
||||
const [transferResve, setTransferResve] = useState(false)
|
||||
@@ -60,11 +60,6 @@ const ListAssignPage = () => {
|
||||
setSelectedAssignId(undefined)
|
||||
}
|
||||
|
||||
// 좌측 테이블 선택값이 바뀌면 결과 필터 multiselect도 그 값으로 맞춘다.
|
||||
useEffect(() => {
|
||||
setAssignFilterIds(selectedAssignId ? [selectedAssignId] : [])
|
||||
}, [selectedAssignId])
|
||||
|
||||
// "배정됨"/"배정되지 않음"은 실제 대상 선택과 동시에 선택될 수 없다: 새로 클릭된 쪽만 남긴다.
|
||||
const handleAssignFilterChange = (next: string[]) => {
|
||||
const addedSentinel = next.find((value) => isAssignFilterSentinel(value) && !assignFilterIds.includes(value))
|
||||
|
||||
@@ -61,7 +61,13 @@ export function useAssignTargetRows({ prjctIdx, enabled, assignType }: UseAssign
|
||||
])
|
||||
}
|
||||
|
||||
export function AssignTargetList({ prjctIdx, enabled, assignType, selectedId, onSelect }: AssignTargetListProps) {
|
||||
export function AssignTargetList({
|
||||
prjctIdx,
|
||||
enabled,
|
||||
assignType,
|
||||
selectedId,
|
||||
onSelect
|
||||
}: AssignTargetListProps) {
|
||||
const rows = useAssignTargetRows({ prjctIdx, enabled, assignType })
|
||||
|
||||
return (
|
||||
|
||||
@@ -17,6 +17,11 @@ export type KriDateTimePickerProps = {
|
||||
contentClassName?: string
|
||||
disabled?: boolean
|
||||
modalPopover?: boolean
|
||||
startHour?: number
|
||||
endHour?: number
|
||||
minuteStep?: number
|
||||
hourLabel?: string
|
||||
minuteLabel?: string
|
||||
}
|
||||
|
||||
const parseDateTime = (value: string): { date: Date | undefined; time: string } => {
|
||||
@@ -59,15 +64,20 @@ const toDisplayText = (date: Date | undefined, time: string, placeholder: string
|
||||
}
|
||||
|
||||
export function KriDateTimePicker({
|
||||
value,
|
||||
onChange,
|
||||
placeholder = '날짜/시간 선택',
|
||||
className,
|
||||
triggerClassName,
|
||||
contentClassName,
|
||||
disabled = false,
|
||||
modalPopover = true,
|
||||
}: KriDateTimePickerProps) {
|
||||
value,
|
||||
onChange,
|
||||
placeholder = '날짜/시간 선택',
|
||||
className,
|
||||
triggerClassName,
|
||||
contentClassName,
|
||||
disabled = false,
|
||||
modalPopover = true,
|
||||
startHour,
|
||||
endHour,
|
||||
minuteStep,
|
||||
hourLabel,
|
||||
minuteLabel,
|
||||
}: KriDateTimePickerProps) {
|
||||
const [open, setOpen] = React.useState(false)
|
||||
const { date, time } = parseDateTime(value)
|
||||
const hasValue = date !== undefined
|
||||
@@ -83,53 +93,59 @@ export function KriDateTimePicker({
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cn('relative', className)}>
|
||||
<Popover open={open} onOpenChange={setOpen} modal={modalPopover}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
'h-9 w-full justify-start bg-white pr-8 text-left font-normal',
|
||||
!hasValue && 'text-muted-foreground',
|
||||
triggerClassName,
|
||||
)}
|
||||
>
|
||||
<CalendarIcon className="mr-2 h-4 w-4" />
|
||||
<span className="truncate">{toDisplayText(date, time, placeholder)}</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className={cn('w-auto p-0', contentClassName)} align="start">
|
||||
<div className="sm:flex">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={date}
|
||||
onSelect={handleDateSelect}
|
||||
/>
|
||||
<KriTimePicker
|
||||
value={time || '00:00'}
|
||||
onChange={handleTimeChange}
|
||||
disabled={!date}
|
||||
/>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
<div className={cn('relative', className)}>
|
||||
<Popover open={open} onOpenChange={setOpen} modal={modalPopover}>
|
||||
<PopoverTrigger asChild>
|
||||
<Button
|
||||
type="button"
|
||||
variant="outline"
|
||||
disabled={disabled}
|
||||
className={cn(
|
||||
'h-9 w-full justify-start bg-white pr-8 text-left font-normal',
|
||||
!hasValue && 'text-muted-foreground',
|
||||
triggerClassName,
|
||||
)}
|
||||
>
|
||||
<CalendarIcon className="mr-2 h-4 w-4" />
|
||||
<span className="truncate">{toDisplayText(date, time, placeholder)}</span>
|
||||
</Button>
|
||||
</PopoverTrigger>
|
||||
<PopoverContent className={cn('w-auto p-0', contentClassName)} align="start">
|
||||
<div className="sm:flex">
|
||||
<Calendar
|
||||
mode="single"
|
||||
selected={date}
|
||||
onSelect={handleDateSelect}
|
||||
initialFocus
|
||||
/>
|
||||
<KriTimePicker
|
||||
value={time || '00:00'}
|
||||
onChange={handleTimeChange}
|
||||
disabled={!date}
|
||||
startHour={startHour}
|
||||
endHour={endHour}
|
||||
minuteStep={minuteStep}
|
||||
hourLabel={hourLabel}
|
||||
minuteLabel={minuteLabel}
|
||||
/>
|
||||
</div>
|
||||
</PopoverContent>
|
||||
</Popover>
|
||||
|
||||
{hasValue && !disabled ? (
|
||||
<button
|
||||
type="button"
|
||||
className="absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
onChange('')
|
||||
}}
|
||||
aria-label="날짜/시간 초기화"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
{hasValue && !disabled ? (
|
||||
<button
|
||||
type="button"
|
||||
className="absolute right-2 top-1/2 inline-flex h-5 w-5 -translate-y-1/2 items-center justify-center rounded-full text-muted-foreground hover:bg-muted hover:text-foreground"
|
||||
onClick={(event) => {
|
||||
event.stopPropagation()
|
||||
onChange('')
|
||||
}}
|
||||
aria-label="날짜/시간 초기화"
|
||||
>
|
||||
<X className="h-3.5 w-3.5" />
|
||||
</button>
|
||||
) : null}
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -9,10 +9,10 @@ import { cn } from '@/lib/utils'
|
||||
import { KRI_PW_REGEX, ONLY_ALLOWED_PW_REGEX } from '@/const/validationConst'
|
||||
|
||||
const requirements = [
|
||||
{ test: (value: string) => /[A-Za-z]/.test(value), text: '영문 1개 이상' },
|
||||
{ test: (value: string) => /\d/.test(value), text: '숫자 1개 이상' },
|
||||
{ test: (value: string) => value.length >= 8 && value.length <= 20, text: '8~20자' },
|
||||
{ test: (value: string) => !value || ONLY_ALLOWED_PW_REGEX.test(value), text: '허용 문자만 사용' },
|
||||
//{ test: (value: string) => /[A-Za-z]/.test(value), text: '영문 1개 이상' },
|
||||
//{ test: (value: string) => /\d/.test(value), text: '숫자 1개 이상' },
|
||||
//{ test: (value: string) => value.length >= 1 && value.length <= 20, text: '1~20자' },
|
||||
{ test: (value: string) => !value || KRI_PW_REGEX.test(value), text: '영문, 숫자, 허용된 특수문자를 사용하여 1~20자로 입력해야 합니다.' },
|
||||
]
|
||||
|
||||
export type KriPasswordRef = {
|
||||
@@ -55,12 +55,13 @@ export const KriPassword = forwardRef<KriPasswordRef, KriPasswordProps>(function
|
||||
const score = checks.filter((item) => item.met).length
|
||||
|
||||
const statusText = useMemo(() => {
|
||||
if (!value) return '비밀번호를 입력하세요'
|
||||
if (!hasOnlyAllowedChars) return '허용되지 않는 문자가 포함되어 있어요'
|
||||
return isValid ? '사용 가능한 비밀번호입니다' : '영문과 숫자를 포함한 8~20자로 입력하세요'
|
||||
if (!value) return '비밀번호를 입력하세요.'
|
||||
if (!hasOnlyAllowedChars) return '허용되지 않는 문자가 포함되어 있습니다.'
|
||||
return isValid ? '사용 가능한 비밀번호입니다' : '영문, 숫자, 허용된 특수문자를 사용하여 1~20자로 입력해야 합니다.'
|
||||
}, [hasOnlyAllowedChars, isValid, value])
|
||||
|
||||
const barClass = score <= 1 ? 'bg-destructive' : score === 2 ? 'bg-orange-500' : score === 3 ? 'bg-yellow-400' : 'bg-green-500'
|
||||
//const barClass = score <= 1 ? 'bg-destructive' : score === 2 ? 'bg-orange-500' : score === 3 ? 'bg-yellow-400' : 'bg-green-500'
|
||||
const barClass = 'bg-green-500'
|
||||
|
||||
return (
|
||||
<div className={cn('w-full space-y-2', className)}>
|
||||
|
||||
@@ -9,6 +9,10 @@ export type KriTimePickerProps = {
|
||||
onChange: (value: string) => void
|
||||
disabled?: boolean
|
||||
minuteStep?: number
|
||||
startHour?: number
|
||||
endHour?: number
|
||||
hourLabel?: string
|
||||
minuteLabel?: string
|
||||
className?: string
|
||||
}
|
||||
|
||||
@@ -27,72 +31,97 @@ const formatTime = (hour: number, minute: number) => {
|
||||
return `${String(hour).padStart(2, '0')}:${String(minute).padStart(2, '0')}`
|
||||
}
|
||||
|
||||
const normalizeHour = (hour: number, fallback: number) => {
|
||||
return Number.isFinite(hour) ? Math.min(23, Math.max(0, Math.trunc(hour))) : fallback
|
||||
}
|
||||
|
||||
export function KriTimePicker({
|
||||
value,
|
||||
onChange,
|
||||
disabled = false,
|
||||
minuteStep = 5,
|
||||
className,
|
||||
}: KriTimePickerProps) {
|
||||
value,
|
||||
onChange,
|
||||
disabled = false,
|
||||
minuteStep = 5,
|
||||
startHour = 0,
|
||||
endHour = 23,
|
||||
hourLabel = '시',
|
||||
minuteLabel = '분',
|
||||
className,
|
||||
}: KriTimePickerProps) {
|
||||
const { hour: selectedHour, minute: selectedMinute } = parseTime(value)
|
||||
const normalizedMinuteStep = Number.isFinite(minuteStep) && minuteStep > 0
|
||||
? Math.min(Math.floor(minuteStep), 60)
|
||||
: 5
|
||||
const hours = Array.from({ length: 24 }, (_, index) => index)
|
||||
? Math.min(Math.floor(minuteStep), 60)
|
||||
: 5
|
||||
|
||||
const clampedStartHour = normalizeHour(startHour, 0)
|
||||
const clampedEndHour = normalizeHour(endHour, 23)
|
||||
// startHour > endHour로 잘못 지정된 경우, 두 값을 뒤바꿔 유효한 범위로 되돌린다.
|
||||
const [normalizedStartHour, normalizedEndHour] = clampedStartHour > clampedEndHour
|
||||
? [clampedEndHour, clampedStartHour]
|
||||
: [clampedStartHour, clampedEndHour]
|
||||
|
||||
const hours = Array.from(
|
||||
{ length: normalizedEndHour - normalizedStartHour + 1 },
|
||||
(_, index) => normalizedStartHour + index,
|
||||
)
|
||||
const minutes = Array.from(
|
||||
{ length: Math.ceil(60 / normalizedMinuteStep) },
|
||||
(_, index) => index * normalizedMinuteStep,
|
||||
{ length: Math.ceil(60 / normalizedMinuteStep) },
|
||||
(_, index) => index * normalizedMinuteStep,
|
||||
).filter((minute) => minute < 60)
|
||||
|
||||
const handleTimeChange = (type: 'hour' | 'minute', nextValue: number) => {
|
||||
if (disabled) return
|
||||
|
||||
const nextHour = type === 'hour' ? nextValue : selectedHour ?? 0
|
||||
const nextHour = type === 'hour' ? nextValue : selectedHour ?? normalizedStartHour
|
||||
const nextMinute = type === 'minute' ? nextValue : selectedMinute ?? 0
|
||||
|
||||
onChange(formatTime(nextHour, nextMinute))
|
||||
}
|
||||
|
||||
return (
|
||||
<div className={cn('flex flex-col divide-y sm:h-[300px] sm:flex-row sm:divide-x sm:divide-y-0', className)}>
|
||||
<ScrollArea className="w-64 sm:w-auto">
|
||||
<div className={cn('flex flex-col divide-y sm:h-[300px] sm:flex-row sm:divide-x sm:divide-y-0', className)}>
|
||||
<div className="flex flex-col">
|
||||
<div className="mt-1 p-1 align-middle text-center text-base border-b">{hourLabel}</div>
|
||||
<ScrollArea className="w-64 sm:w-auto sm:min-h-0 sm:flex-1">
|
||||
<div className="flex p-2 sm:flex-col">
|
||||
{hours.map((hour) => (
|
||||
<Button
|
||||
key={hour}
|
||||
type="button"
|
||||
size="icon"
|
||||
variant={selectedHour === hour ? 'default' : 'ghost'}
|
||||
className="aspect-square shrink-0 sm:w-full"
|
||||
disabled={disabled}
|
||||
onClick={() => handleTimeChange('hour', hour)}
|
||||
>
|
||||
{hour}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<ScrollBar orientation="horizontal" className="sm:hidden" />
|
||||
</ScrollArea>
|
||||
|
||||
<ScrollArea className="w-64 sm:w-auto">
|
||||
<div className="flex p-2 sm:flex-col">
|
||||
{minutes.map((minute) => (
|
||||
<Button
|
||||
key={minute}
|
||||
type="button"
|
||||
size="icon"
|
||||
variant={selectedMinute === minute ? 'default' : 'ghost'}
|
||||
className="aspect-square shrink-0 sm:w-full"
|
||||
disabled={disabled}
|
||||
onClick={() => handleTimeChange('minute', minute)}
|
||||
>
|
||||
{String(minute).padStart(2, '0')}
|
||||
</Button>
|
||||
<Button
|
||||
key={hour}
|
||||
type="button"
|
||||
size="icon"
|
||||
variant={selectedHour === hour ? 'default' : 'ghost'}
|
||||
className="aspect-square shrink-0 sm:w-full"
|
||||
disabled={disabled}
|
||||
onClick={() => handleTimeChange('hour', hour)}
|
||||
>
|
||||
{hour}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<ScrollBar orientation="horizontal" className="sm:hidden" />
|
||||
</ScrollArea>
|
||||
</div>
|
||||
|
||||
<div className="flex flex-col">
|
||||
<div className="mt-1 p-1 align-middle text-center text-base border-b">{minuteLabel}</div>
|
||||
<ScrollArea className="w-64 sm:w-auto sm:min-h-0 sm:flex-1">
|
||||
<div className="flex p-2 sm:flex-col">
|
||||
{minutes.map((minute) => (
|
||||
<Button
|
||||
key={minute}
|
||||
type="button"
|
||||
size="icon"
|
||||
variant={selectedMinute === minute ? 'default' : 'ghost'}
|
||||
className="aspect-square shrink-0 sm:w-full"
|
||||
disabled={disabled}
|
||||
onClick={() => handleTimeChange('minute', minute)}
|
||||
>
|
||||
{String(minute).padStart(2, '0')}
|
||||
</Button>
|
||||
))}
|
||||
</div>
|
||||
<ScrollBar orientation="horizontal" className="sm:hidden" />
|
||||
</ScrollArea>
|
||||
</div>
|
||||
</div>
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -375,7 +375,7 @@ const ListContactEventPanel = ({
|
||||
|
||||
{useFF &&
|
||||
<ContactEventSection
|
||||
title="인터뷰 요원 확인사항"
|
||||
title="면접 확인사항"
|
||||
prjctIdx={prjctIdx}
|
||||
sid={sid}
|
||||
resultCodeType={ResultCodeType.INTERVIEW}
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
'use client'
|
||||
|
||||
import { useCallback, useEffect, useMemo, useState, type ReactNode } from 'react'
|
||||
import { useCallback, useEffect, useMemo, 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'
|
||||
@@ -77,6 +77,8 @@ const toSidSet = (value: string) =>
|
||||
.map((item) => item.trim())
|
||||
.filter((item) => item.length > 0)
|
||||
|
||||
const deduplicateSidInput = (value: string) => [...new Set(toSidSet(value))].join(',')
|
||||
|
||||
const sanitizeSidInput = (value: string) => {
|
||||
let result = ''
|
||||
let lastChar: 'digit' | 'comma' | 'tilde' | null = null
|
||||
@@ -485,6 +487,17 @@ export function ListSearchTable({
|
||||
setPagination((prev) => ({ ...prev, pageIndex: 0 }))
|
||||
}
|
||||
|
||||
const handleSidPaste = (e: ClipboardEvent<HTMLInputElement>) => {
|
||||
const pastedText = e.clipboardData.getData('text')
|
||||
const normalizedText = pastedText.replace(/\t|\r\n|\r|\n/g, ',')
|
||||
|
||||
e.preventDefault()
|
||||
const selectionStart = e.currentTarget.selectionStart ?? searchText.length
|
||||
const selectionEnd = e.currentTarget.selectionEnd ?? selectionStart
|
||||
const nextValue = `${searchText.slice(0, selectionStart)}${normalizedText}${searchText.slice(selectionEnd)}`
|
||||
setSearchText(deduplicateSidInput(sanitizeSidInput(nextValue)))
|
||||
}
|
||||
|
||||
const handleFilterConfirm = async (rows: FilterRow[]) => {
|
||||
setFilterRows(rows)
|
||||
setPagination((prev) => ({ ...prev, pageIndex: 0 }))
|
||||
@@ -565,6 +578,7 @@ export function ListSearchTable({
|
||||
className="h-9 bg-white flex-1 min-w-0 max-w-xs"
|
||||
value={searchText}
|
||||
onChange={(e) => setSearchText(sanitizeSidInput(e.target.value))}
|
||||
onPaste={handleSidPaste}
|
||||
/>
|
||||
<div className="flex-1 min-w-0 max-w-xs">
|
||||
<KriMultiSelect
|
||||
|
||||
@@ -14,4 +14,5 @@ export const ALLOWED_PW_SPECIALS_TEXT = `~ ! @ # $ % ^ & * ( ) _ + - = { } [ ] :
|
||||
// 비밀번호에 허용된 문자만 사용했는지
|
||||
export const ONLY_ALLOWED_PW_REGEX = /^[A-Za-z\d~!@#$%^&*()_+\-={}\[\]:;"'<>,.?/]+$/
|
||||
// 영문 1개 이상 + 숫자 1개 이상 포함, 8~20자, 허용된 문자만 사용
|
||||
export const KRI_PW_REGEX = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_+\-={}\[\]:;"'<>,.?/]{8,20}$/
|
||||
//export const KRI_PW_REGEX = /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d!@#$%^&*()_+\-={}\[\]:;"'<>,.?/]{1,20}$/
|
||||
export const KRI_PW_REGEX = /^[A-Za-z\d!@#$%^&*()_+\-={}\[\]:;"'<>,.?/]{1,20}$/
|
||||
|
||||
Reference in New Issue
Block a user