Fix(Core): Restore system lookups and enhance reference data view
- API: Correctly exported 'get_ae_obj_li_for_lu' and reverted to stable V2 endpoints (/v2/crud/lu/.../list) to resolve V3 500 errors. - Auth: Injected 'x-no-account-id' bypass header for unauthenticated global lookup access. - UI: Updated lookups page to support 'english_short_name' fallback for countries and added Country Subdivisions card. - Debug: Added transient console logging for verification.
This commit is contained in:
@@ -14,15 +14,20 @@
|
||||
|
||||
async function load_lookups() {
|
||||
loading = true;
|
||||
// Using existing generic lookup loaders if available, or raw API calls
|
||||
try {
|
||||
const [countries, time_zones] = await Promise.all([
|
||||
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'country', log_lvl: 0 }),
|
||||
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'time_zone', log_lvl: 0 })
|
||||
const [countries, time_zones, subdivisions] = await Promise.all([
|
||||
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'country', log_lvl: 1 }),
|
||||
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'time_zone', log_lvl: 1 }),
|
||||
api.get_ae_obj_li_for_lu({ api_cfg: $ae_api, for_lu_type: 'country_subdivision', log_lvl: 1 })
|
||||
]);
|
||||
|
||||
console.log('Lookup Results - Countries:', countries);
|
||||
console.log('Lookup Results - Time Zones:', time_zones);
|
||||
console.log('Lookup Results - Subdivisions:', subdivisions);
|
||||
|
||||
lookups.countries = countries || [];
|
||||
lookups.time_zones = time_zones || [];
|
||||
lookups.subdivisions = subdivisions || [];
|
||||
} catch (error) {
|
||||
console.error('Failed to load lookups:', error);
|
||||
} finally {
|
||||
@@ -86,7 +91,7 @@
|
||||
<tbody>
|
||||
{#each lookups.countries as c}
|
||||
<tr class="transition-colors">
|
||||
<td class="font-bold">{c.name}</td>
|
||||
<td class="font-bold">{c.name || c.english_short_name}</td>
|
||||
<td class="text-center"><span class="badge variant-soft-surface font-mono text-primary-500">{c.alpha_2_code}</span></td>
|
||||
</tr>
|
||||
{/each}
|
||||
@@ -124,6 +129,36 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Subdivisions (Full Width) -->
|
||||
<div class="card p-6 shadow-xl variant-glass-surface border border-surface-500/10 space-y-6 animate-fade-in" style="animation-delay: 100ms;">
|
||||
<h3 class="h4 font-bold border-b border-surface-500/30 pb-2 flex items-center gap-2">
|
||||
<MapPin size={20} class="text-primary-500" />
|
||||
Country Subdivisions (States/Provinces)
|
||||
<span class="badge variant-soft-secondary ml-auto text-[10px] uppercase font-bold">{lookups.subdivisions.length} Records</span>
|
||||
</h3>
|
||||
|
||||
<div class="table-container max-h-[600px] overflow-auto border border-surface-500/10 rounded-lg">
|
||||
<table class="table table-hover table-compact">
|
||||
<thead>
|
||||
<tr class="uppercase text-[10px] tracking-widest opacity-60">
|
||||
<th>Country</th>
|
||||
<th>Name</th>
|
||||
<th class="text-center">Code</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{#each lookups.subdivisions as s}
|
||||
<tr class="transition-colors">
|
||||
<td class="opacity-60">{s.country_alpha_2_code}</td>
|
||||
<td class="font-bold">{s.name}</td>
|
||||
<td class="text-center"><span class="badge variant-soft-surface font-mono">{s.code}</span></td>
|
||||
</tr>
|
||||
{/each}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="card p-4 variant-soft-surface border border-surface-500/10 flex items-center gap-3">
|
||||
<Info size={16} class="text-primary-500" />
|
||||
<p class="text-xs opacity-70">Lookup data is synchronized with the global system database and used for addresses, event scheduling, and localized displays.</p>
|
||||
|
||||
Reference in New Issue
Block a user