fix(frontend): normalize org_type names to letter codes in DuckLake hook
DuckLake stores full names like 'MUSEUM' but map expects single-letter codes like 'M' for color styling. Also includes CSS fixes for Database page.
This commit is contained in:
parent
18874e6070
commit
1981dc28ed
3 changed files with 173 additions and 2 deletions
|
|
@ -1,5 +1,5 @@
|
|||
{
|
||||
"generated": "2025-12-07T18:19:27.338Z",
|
||||
"generated": "2025-12-07T18:21:53.617Z",
|
||||
"version": "1.0.0",
|
||||
"categories": [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -35,6 +35,54 @@ const TYPE_COLORS: Record<string, string> = {
|
|||
'T': '#ff5722', // Taste/smell - deep orange
|
||||
};
|
||||
|
||||
// Map full type names to single-letter codes
|
||||
// DuckLake stores full names like "MUSEUM", but frontend expects "M"
|
||||
const TYPE_NAME_TO_CODE: Record<string, string> = {
|
||||
'GALLERY': 'G',
|
||||
'LIBRARY': 'L',
|
||||
'ARCHIVE': 'A',
|
||||
'MUSEUM': 'M',
|
||||
'OFFICIAL': 'O',
|
||||
'OFFICIAL_INSTITUTION': 'O',
|
||||
'RESEARCH': 'R',
|
||||
'RESEARCH_CENTER': 'R',
|
||||
'CORPORATION': 'C',
|
||||
'UNKNOWN': 'U',
|
||||
'BOTANICAL': 'B',
|
||||
'BOTANICAL_ZOO': 'B',
|
||||
'EDUCATION': 'E',
|
||||
'EDUCATION_PROVIDER': 'E',
|
||||
'SOCIETY': 'S',
|
||||
'COLLECTING_SOCIETY': 'S',
|
||||
'FEATURES': 'F',
|
||||
'INTANGIBLE': 'I',
|
||||
'INTANGIBLE_HERITAGE_GROUP': 'I',
|
||||
'MIXED': 'X',
|
||||
'PERSONAL': 'P',
|
||||
'PERSONAL_COLLECTION': 'P',
|
||||
'HOLY_SITES': 'H',
|
||||
'DIGITAL': 'D',
|
||||
'DIGITAL_PLATFORM': 'D',
|
||||
'NGO': 'N',
|
||||
'TASTE_SMELL': 'T',
|
||||
};
|
||||
|
||||
// Convert org_type from DuckLake to single-letter code
|
||||
function normalizeTypeCode(orgType: string): string {
|
||||
if (!orgType) return 'U';
|
||||
|
||||
// If already a single letter code, return it
|
||||
if (orgType.length === 1 && TYPE_COLORS[orgType]) {
|
||||
return orgType;
|
||||
}
|
||||
|
||||
// Handle compound types like "MUSEUM,FEATURES" - take first type
|
||||
const firstType = orgType.split(',')[0].trim().toUpperCase();
|
||||
|
||||
// Look up the mapping
|
||||
return TYPE_NAME_TO_CODE[firstType] || 'U';
|
||||
}
|
||||
|
||||
// Institution type code to name mapping
|
||||
const TYPE_NAMES: Record<string, string> = {
|
||||
'G': 'Gallery',
|
||||
|
|
@ -259,7 +307,8 @@ export function useDuckLakeInstitutions(): UseDuckLakeInstitutionsReturn {
|
|||
const name = String(row[2] || '');
|
||||
const city = String(row[3] || '');
|
||||
const ghcidCurrent = row[4] ? String(row[4]) : undefined;
|
||||
const typeCode = String(row[5] || 'U');
|
||||
const rawOrgType = String(row[5] || 'U');
|
||||
const typeCode = normalizeTypeCode(rawOrgType); // Convert "MUSEUM" -> "M"
|
||||
const wikidataId = row[6] ? String(row[6]) : '';
|
||||
const rating = row[7] ? Number(row[7]) : undefined;
|
||||
const totalRatings = row[8] ? Number(row[8]) : undefined;
|
||||
|
|
|
|||
|
|
@ -3540,3 +3540,125 @@ body.resizing-row * {
|
|||
color: #777;
|
||||
}
|
||||
}
|
||||
|
||||
/* ==========================================================================
|
||||
Table Search Bar
|
||||
========================================================================== */
|
||||
|
||||
.table-search-bar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 1rem;
|
||||
padding: 0.75rem 1rem;
|
||||
background: #f8f9fa;
|
||||
border-bottom: 1px solid #e0e0e0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.search-input-wrapper {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
flex: 1;
|
||||
max-width: 400px;
|
||||
position: relative;
|
||||
background: white;
|
||||
border: 1px solid #ddd;
|
||||
border-radius: 8px;
|
||||
padding: 0.5rem 0.75rem;
|
||||
transition: all 0.2s ease;
|
||||
}
|
||||
|
||||
.search-input-wrapper:focus-within {
|
||||
border-color: #FFC107;
|
||||
box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.2);
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
font-size: 0.9rem;
|
||||
margin-right: 0.5rem;
|
||||
color: #888;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
flex: 1;
|
||||
border: none;
|
||||
outline: none;
|
||||
font-size: 0.9rem;
|
||||
background: transparent;
|
||||
padding: 0;
|
||||
}
|
||||
|
||||
.search-input::placeholder {
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.clear-search-btn {
|
||||
background: #e9ecef;
|
||||
border: none;
|
||||
border-radius: 50%;
|
||||
width: 20px;
|
||||
height: 20px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
cursor: pointer;
|
||||
font-size: 0.7rem;
|
||||
color: #666;
|
||||
transition: all 0.15s;
|
||||
margin-left: 0.5rem;
|
||||
}
|
||||
|
||||
.clear-search-btn:hover {
|
||||
background: #FFC107;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.search-results-count {
|
||||
font-size: 0.8rem;
|
||||
color: #666;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
/* Dark mode for search bar */
|
||||
@media (prefers-color-scheme: dark) {
|
||||
.table-search-bar {
|
||||
background: #1a1a2e;
|
||||
border-color: #333;
|
||||
}
|
||||
|
||||
.search-input-wrapper {
|
||||
background: #252538;
|
||||
border-color: #404050;
|
||||
}
|
||||
|
||||
.search-input-wrapper:focus-within {
|
||||
border-color: #FFC107;
|
||||
box-shadow: 0 0 0 2px rgba(255, 193, 7, 0.15);
|
||||
}
|
||||
|
||||
.search-icon {
|
||||
color: #777;
|
||||
}
|
||||
|
||||
.search-input {
|
||||
color: #e0e0e0;
|
||||
}
|
||||
|
||||
.search-input::placeholder {
|
||||
color: #666;
|
||||
}
|
||||
|
||||
.clear-search-btn {
|
||||
background: #3a3a4e;
|
||||
color: #aaa;
|
||||
}
|
||||
|
||||
.clear-search-btn:hover {
|
||||
background: #FFC107;
|
||||
color: #000;
|
||||
}
|
||||
|
||||
.search-results-count {
|
||||
color: #888;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue