fix: require explicit transport mode for applications
This commit is contained in:
@@ -400,6 +400,22 @@ function normalizeTransportModeOption(value, fallback = '') {
|
||||
return APPLICATION_TRANSPORT_MODE_OPTIONS.includes(text) ? text : fallback
|
||||
}
|
||||
|
||||
function resolveModelRefinedTransportMode(ontologyFields = {}, rawText = '', currentFields = {}) {
|
||||
const currentTransportMode = isApplicationPreviewValueProvided(currentFields.transportMode)
|
||||
? String(currentFields.transportMode).trim()
|
||||
: ''
|
||||
const explicitTransportMode = resolveApplicationTransportMode(rawText)
|
||||
if (!explicitTransportMode) {
|
||||
return currentTransportMode
|
||||
}
|
||||
|
||||
const ontologyTransportMode = normalizeTransportModeOption(ontologyFields.transportMode, '')
|
||||
if (ontologyTransportMode && ontologyTransportMode === explicitTransportMode) {
|
||||
return ontologyTransportMode
|
||||
}
|
||||
return currentTransportMode || explicitTransportMode
|
||||
}
|
||||
|
||||
function normalizeAmountFromOntology(fields = {}, fallback = '') {
|
||||
const numericAmount = Number(fields.amount || 0)
|
||||
if (Number.isFinite(numericAmount) && numericAmount > 0) {
|
||||
@@ -640,10 +656,7 @@ export function buildModelRefinedApplicationPreview(localPreview = {}, ontology
|
||||
location: resolveProvidedValue(ontologyFields.location, currentFields.location),
|
||||
reason: resolveProvidedValue(ontologyFields.reason, currentFields.reason),
|
||||
days: resolveProvidedValue(ontologyFields.days, currentFields.days),
|
||||
transportMode: normalizeTransportModeOption(
|
||||
ontologyFields.transportMode,
|
||||
currentFields.transportMode
|
||||
),
|
||||
transportMode: resolveModelRefinedTransportMode(ontologyFields, rawText, currentFields),
|
||||
amount: normalizeAmountFromOntology(ontologyFields, currentFields.amount),
|
||||
grade: resolveProvidedValue(currentFields.grade, resolveCurrentUserGrade(currentUser)),
|
||||
applicant: resolveProvidedValue(ontologyFields.applicant, currentFields.applicant),
|
||||
|
||||
Reference in New Issue
Block a user