diff --git a/frontend/src/components/widgets/FalukantWidget.vue b/frontend/src/components/widgets/FalukantWidget.vue index 41a28a6..22df3ce 100644 --- a/frontend/src/components/widgets/FalukantWidget.vue +++ b/frontend/src/components/widgets/FalukantWidget.vue @@ -24,8 +24,31 @@ export default { }, computed: { falukantData() { - const d = this.data; - if (d && typeof d === 'object' && 'characterName' in d && 'money' in d) return d; + // normalize incoming API payload: accept both camelCase and snake_case + const raw = this.data; + if (!raw || typeof raw !== 'object') return null; + + const pick = (obj, camel, snake) => { + if (camel in obj && obj[camel] !== undefined) return obj[camel]; + if (snake in obj && obj[snake] !== undefined) return obj[snake]; + return undefined; + }; + + const normalized = { + characterName: pick(raw, 'characterName', 'character_name') ?? pick(raw, 'nameWithoutTitle', 'name_without_title'), + nameWithoutTitle: pick(raw, 'nameWithoutTitle', 'name_without_title'), + titleLabelTr: pick(raw, 'titleLabelTr', 'title_label_tr'), + gender: pick(raw, 'gender', 'gender'), + age: pick(raw, 'age', 'age'), + money: pick(raw, 'money', 'money'), + unreadNotificationsCount: pick(raw, 'unreadNotificationsCount', 'unread_notifications_count'), + childrenCount: pick(raw, 'childrenCount', 'children_count'), + // keep all original keys as fallback for any other usage + ...raw + }; + + // sanity: require at least a name and money + if ((normalized.characterName || normalized.nameWithoutTitle) && (normalized.money !== undefined)) return normalized; return null; }, falukantDisplayName() {