25 lines
701 B
TypeScript
25 lines
701 B
TypeScript
type PerformanceSurveyTargetPolicyInput = {
|
|
requestedEmployeeIds: unknown
|
|
currentEmployeeId?: string | null
|
|
surveyKind: string
|
|
}
|
|
|
|
function normalizeEmployeeIds(value: unknown): string[] {
|
|
if (!Array.isArray(value)) return []
|
|
return Array.from(new Set(
|
|
value
|
|
.map((item) => String(item || '').trim())
|
|
.filter(Boolean),
|
|
))
|
|
}
|
|
|
|
export function getPerformanceSurveyTargetEmployeeIds({
|
|
requestedEmployeeIds,
|
|
currentEmployeeId,
|
|
surveyKind,
|
|
}: PerformanceSurveyTargetPolicyInput): string[] {
|
|
const requested = normalizeEmployeeIds(requestedEmployeeIds)
|
|
if (surveyKind === 'item_course') return requested
|
|
return normalizeEmployeeIds([currentEmployeeId, ...requested])
|
|
}
|