fixes
Some checks failed
Build And Push Image / docker (push) Failing after 1m9s

This commit is contained in:
2025-08-14 10:43:21 +02:00
parent 2ff0c31bbd
commit 503d10f0ab
3 changed files with 37 additions and 55 deletions

View File

@@ -102,59 +102,33 @@ export const formatNationalitiesAsString = (nationalities: string[]): string =>
export const normalizeFieldsFromNocoDB = (data: any): Member => {
console.log('[normalizeFieldsFromNocoDB] Input data keys:', Object.keys(data));
// Since NocoDB schema uses snake_case directly, no complex mapping needed
const normalized: any = { ...data };
// Field mapping for display names to snake_case (READ operations)
const readFieldMap: Record<string, string> = {
'First Name': 'first_name',
'Last Name': 'last_name',
'Email': 'email',
'Email Address': 'email',
'Phone': 'phone',
'Phone Number': 'phone',
'Date of Birth': 'date_of_birth',
'Nationality': 'nationality',
'Address': 'address',
'Membership Status': 'membership_status',
'Member Since': 'member_since',
'Member ID': 'member_id', // Added field mapping for member_id
'Current Year Dues Paid': 'current_year_dues_paid',
'Membership Date Paid': 'membership_date_paid',
'Payment Due Date': 'payment_due_date',
'Keycloak ID': 'keycloak_id',
'keycloak_id': 'keycloak_id',
// Also handle reverse mapping in case data comes in snake_case already
'first_name': 'first_name',
'last_name': 'last_name',
'email': 'email',
'phone': 'phone',
'date_of_birth': 'date_of_birth',
'nationality': 'nationality',
'address': 'address',
'membership_status': 'membership_status',
'member_since': 'member_since',
'member_id': 'member_id',
'current_year_dues_paid': 'current_year_dues_paid',
'membership_date_paid': 'membership_date_paid',
'payment_due_date': 'payment_due_date'
};
// Ensure all expected fields exist with proper fallbacks
const requiredFields = [
'first_name', 'last_name', 'email', 'phone', 'nationality',
'address', 'date_of_birth', 'membership_status', 'member_since',
'member_id', 'current_year_dues_paid', 'membership_date_paid',
'payment_due_date', 'keycloak_id'
];
// Apply field mapping
for (const [sourceKey, targetKey] of Object.entries(readFieldMap)) {
if (sourceKey in data && data[sourceKey] !== undefined && data[sourceKey] !== null) {
normalized[targetKey] = data[sourceKey];
console.log(`[normalizeFieldsFromNocoDB] Mapped "${sourceKey}" -> "${targetKey}":`, data[sourceKey]);
// Initialize missing fields as empty strings (except booleans)
requiredFields.forEach(field => {
if (!(field in normalized) || normalized[field] === null || normalized[field] === undefined) {
if (field === 'current_year_dues_paid') {
normalized[field] = 'false'; // Boolean field default
} else if (field === 'membership_status') {
normalized[field] = 'Pending'; // Enum field default
} else {
normalized[field] = ''; // String field default
}
}
}
// Ensure required fields exist with fallbacks
normalized.first_name = normalized.first_name || normalized['First Name'] || '';
normalized.last_name = normalized.last_name || normalized['Last Name'] || '';
normalized.email = normalized.email || normalized['Email'] || normalized['Email Address'] || '';
});
console.log('[normalizeFieldsFromNocoDB] Normalized member fields:', Object.keys(normalized));
console.log('[normalizeFieldsFromNocoDB] Final first_name:', normalized.first_name);
console.log('[normalizeFieldsFromNocoDB] Final last_name:', normalized.last_name);
console.log('[normalizeFieldsFromNocoDB] Final first_name:', `"${normalized.first_name}"`);
console.log('[normalizeFieldsFromNocoDB] Final last_name:', `"${normalized.last_name}"`);
return normalized as Member;
};