fix(oa-board): align filter param parsing types
This commit is contained in:
parent
1cff836933
commit
1fad12d718
@ -9,9 +9,14 @@ export async function GET(request: NextRequest) {
|
||||
request,
|
||||
async (ctx) => {
|
||||
const searchParams = request.nextUrl.searchParams
|
||||
const readMultiParam = (value: string | null) =>
|
||||
String(value ?? '')
|
||||
.split(',')
|
||||
.map((entry) => entry.trim())
|
||||
.filter(Boolean)
|
||||
const keyword = searchParams.get('keyword') ?? ''
|
||||
const approvalNumber = searchParams.get('approvalNumber') ?? ''
|
||||
const overallStatus = searchParams.get('overallStatus') ?? ''
|
||||
const overallStatus = readMultiParam(searchParams.get('overallStatus'))
|
||||
const productType = searchParams.get('productType') ?? ''
|
||||
const approvalStage = searchParams.get('approvalStage') ?? ''
|
||||
const owner = searchParams.get('owner') ?? ''
|
||||
@ -22,7 +27,7 @@ export async function GET(request: NextRequest) {
|
||||
const dashboard = await oaBoardService.getDashboard({
|
||||
keyword: keyword || undefined,
|
||||
approvalNumber: approvalNumber || undefined,
|
||||
overallStatus: overallStatus || undefined,
|
||||
overallStatus: overallStatus.length > 0 ? overallStatus : undefined,
|
||||
productType: productType || undefined,
|
||||
approvalStage: approvalStage || undefined,
|
||||
owner: owner || undefined,
|
||||
|
||||
@ -363,6 +363,14 @@ function readFieldSnapshot(fieldSnapshots: NormalizedFieldSnapshot[], names: rea
|
||||
return null
|
||||
}
|
||||
|
||||
function matchesFieldName(
|
||||
fieldName: string | null | undefined,
|
||||
candidateNames: readonly string[],
|
||||
) {
|
||||
const normalizedFieldName = String(fieldName ?? '').trim()
|
||||
return candidateNames.some((candidateName) => candidateName === normalizedFieldName)
|
||||
}
|
||||
|
||||
function parseJsonArrayOfStrings(value: string | null | undefined): string[] {
|
||||
const text = normalizeText(value)
|
||||
if (!text) return []
|
||||
@ -1373,7 +1381,9 @@ async function fetchSourceData(limit?: number): Promise<NormalizedFlowRecord[]>
|
||||
const openingCodes = Array.from(
|
||||
new Set(
|
||||
reviewSchemeRows
|
||||
.filter((row) => OA_BOARD_JOIN_FIELD_NAMES.openingCode.includes(String(row.name ?? '').trim()))
|
||||
.filter((row) =>
|
||||
matchesFieldName(row.name, OA_BOARD_JOIN_FIELD_NAMES.openingCode),
|
||||
)
|
||||
.map((row) => normalizeText(row.value))
|
||||
.filter((value): value is string => Boolean(value)),
|
||||
),
|
||||
@ -1441,7 +1451,9 @@ async function fetchSourceData(limit?: number): Promise<NormalizedFlowRecord[]>
|
||||
const openingCodes = Array.from(
|
||||
new Set(
|
||||
reviewSchemeRows
|
||||
.filter((row) => OA_BOARD_JOIN_FIELD_NAMES.openingCode.includes(String(row.name ?? '').trim()))
|
||||
.filter((row) =>
|
||||
matchesFieldName(row.name, OA_BOARD_JOIN_FIELD_NAMES.openingCode),
|
||||
)
|
||||
.map((row) => normalizeText(row.value))
|
||||
.filter((value): value is string => Boolean(value)),
|
||||
),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user