feat(web-admin): add document reminder jump path resolver
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ed5784d1f7
commit
c0fa3ccfd9
2 files changed
+75
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import assert from 'node:assert/strict'
|
||||
import { describe, it } from 'node:test'
|
||||
import {
|
||||
resolveDocumentReminderEditPath,
|
||||
DOCUMENT_REMINDER_JUMP_UNSUPPORTED
|
||||
} from './pl-document-reminder-jump'
|
||||
|
||||
describe('证件提醒跳转路径', () => {
|
||||
it('车辆按 vehicleType 分流自有与三方', () => {
|
||||
assert.equal(
|
||||
resolveDocumentReminderEditPath({ ownerType: 'vehicle', vehicleType: 'self' }),
|
||||
'/vehicle-mgmt/base-info/self-vehicle'
|
||||
)
|
||||
assert.equal(
|
||||
resolveDocumentReminderEditPath({ ownerType: 'vehicle', vehicleType: 'carrier' }),
|
||||
'/vehicle-mgmt/base-info/vehicle'
|
||||
)
|
||||
assert.equal(
|
||||
resolveDocumentReminderEditPath({ ownerType: 'vehicle', vehicleType: '' }),
|
||||
'/vehicle-mgmt/base-info/vehicle'
|
||||
)
|
||||
})
|
||||
|
||||
it('人员按 personnelAffiliation 分流', () => {
|
||||
assert.equal(
|
||||
resolveDocumentReminderEditPath({
|
||||
ownerType: 'personnel',
|
||||
personnelAffiliation: 'self'
|
||||
}),
|
||||
'/vehicle-mgmt/base-info/personnel'
|
||||
)
|
||||
assert.equal(
|
||||
resolveDocumentReminderEditPath({
|
||||
ownerType: 'personnel',
|
||||
personnelAffiliation: 'carrier'
|
||||
}),
|
||||
'/vehicle-mgmt/base-info/personnel-carrier'
|
||||
)
|
||||
assert.equal(
|
||||
resolveDocumentReminderEditPath({
|
||||
ownerType: 'personnel',
|
||||
personnelAffiliation: ''
|
||||
}),
|
||||
'/vehicle-mgmt/base-info/personnel'
|
||||
)
|
||||
})
|
||||
|
||||
it('不支持的主体返回 null', () => {
|
||||
assert.equal(resolveDocumentReminderEditPath({ ownerType: 'carrier' }), null)
|
||||
assert.equal(resolveDocumentReminderEditPath({ ownerType: '' }), null)
|
||||
assert.equal(DOCUMENT_REMINDER_JUMP_UNSUPPORTED, '暂不支持该主体类型的证件维护跳转')
|
||||
})
|
||||
})
|
||||
@@ -0,0 +1,22 @@
|
||||
export const DOCUMENT_REMINDER_JUMP_UNSUPPORTED = '暂不支持该主体类型的证件维护跳转'
|
||||
|
||||
export type ReminderJumpInput = {
|
||||
ownerType?: string | null
|
||||
vehicleType?: string | null
|
||||
personnelAffiliation?: string | null
|
||||
}
|
||||
|
||||
export function resolveDocumentReminderEditPath(input: ReminderJumpInput): string | null {
|
||||
const ownerType = String(input.ownerType || '').trim()
|
||||
if (ownerType === 'vehicle') {
|
||||
return String(input.vehicleType || '').trim() === 'self'
|
||||
? '/vehicle-mgmt/base-info/self-vehicle'
|
||||
: '/vehicle-mgmt/base-info/vehicle'
|
||||
}
|
||||
if (ownerType === 'personnel') {
|
||||
return String(input.personnelAffiliation || '').trim() === 'carrier'
|
||||
? '/vehicle-mgmt/base-info/personnel-carrier'
|
||||
: '/vehicle-mgmt/base-info/personnel'
|
||||
}
|
||||
return null
|
||||
}
|
||||
Reference in new issue
Block a user