Added sorting to Trips and Dashboard tables; chenged Follow-up values to snapmed and ctm
This commit is contained in:
@@ -133,6 +133,16 @@ export async function updateVaccineRecord(id, data) {
|
||||
}
|
||||
|
||||
|
||||
const VALID_FOLLOW_UP_STATUSES = ['snapmed', 'ctm']
|
||||
|
||||
function sanitizeFollowUpStatus(val) {
|
||||
if (!val) return []
|
||||
const list = Array.isArray(val) ? val : [val]
|
||||
return list
|
||||
.map((s) => (typeof s === 'string' ? s.trim().toLowerCase() : ''))
|
||||
.filter((s) => VALID_FOLLOW_UP_STATUSES.includes(s))
|
||||
}
|
||||
|
||||
function parseEntry(r) {
|
||||
const traveller = r.expand?.traveller_id
|
||||
? (Array.isArray(r.expand.traveller_id) ? r.expand.traveller_id[0] : r.expand.traveller_id)
|
||||
@@ -153,7 +163,7 @@ function parseEntry(r) {
|
||||
locations: r.locations ?? r.location ?? '',
|
||||
countryISO: r.country_iso ?? '',
|
||||
countriesISO: r.countries_iso ?? [],
|
||||
followUpStatus: r.follow_up_status ?? [],
|
||||
followUpStatus: sanitizeFollowUpStatus(r.follow_up_status),
|
||||
isAtRisk: r.is_at_risk ?? false,
|
||||
archived: r.archived ?? false,
|
||||
departure: r.departure ?? '',
|
||||
@@ -255,7 +265,7 @@ export async function createEntry(trip) {
|
||||
countries_iso: trip.countriesISO ?? trip.countries_iso ?? [],
|
||||
departure: trip.departure ?? '',
|
||||
arrival: trip.arrival ?? '',
|
||||
follow_up_status: trip.followUpStatus ?? trip.follow_up_status ?? [],
|
||||
follow_up_status: sanitizeFollowUpStatus(trip.followUpStatus ?? trip.follow_up_status),
|
||||
is_at_risk: trip.isAtRisk ?? trip.is_at_risk ?? false,
|
||||
}
|
||||
|
||||
@@ -300,7 +310,7 @@ export async function updateEntry(id, trip) {
|
||||
tripPayload.arrival = trip.arrival
|
||||
}
|
||||
if (trip.followUpStatus !== undefined || trip.follow_up_status !== undefined) {
|
||||
tripPayload.follow_up_status = trip.followUpStatus ?? trip.follow_up_status ?? []
|
||||
tripPayload.follow_up_status = sanitizeFollowUpStatus(trip.followUpStatus ?? trip.follow_up_status)
|
||||
}
|
||||
if (trip.isAtRisk !== undefined || trip.is_at_risk !== undefined) {
|
||||
tripPayload.is_at_risk = trip.isAtRisk ?? trip.is_at_risk ?? false
|
||||
|
||||
Reference in New Issue
Block a user