Refactor NobilityView: Remove debug logs and improve conditional rendering for advance section. Add cooldown message styling for better user feedback when advancement is not possible.
This commit is contained in:
@@ -23,30 +23,21 @@
|
||||
{{ $t('falukant.nobility.nextTitle') }}:
|
||||
<strong>{{ $t(`falukant.titles.${gender}.${next.labelTr}`) }}</strong>
|
||||
</p>
|
||||
<p v-if="nextAdvanceAt && !canAdvance">
|
||||
{{ $t('falukant.nobility.cooldown', { date: formatDate(nextAdvanceAt) }) }}
|
||||
</p>
|
||||
<ul class="prerequisites" v-if="next.requirements && next.requirements.length > 0">
|
||||
<li v-for="req in next.requirements" :key="req.titleId">
|
||||
{{ $t(`falukant.nobility.requirement.${req.requirementType}`, { amount: formatCost(req.requirementValue) }) }}
|
||||
</li>
|
||||
</ul>
|
||||
<button @click="applyAdvance" class="button" :disabled="!canAdvance || isAdvancing">
|
||||
<button v-if="canAdvance" @click="applyAdvance" class="button" :disabled="isAdvancing">
|
||||
<span v-if="!isAdvancing">{{ $t('falukant.nobility.advance.confirm') }}</span>
|
||||
<span v-else>{{ $t('falukant.nobility.advance.processing') }}</span>
|
||||
</button>
|
||||
<div style="margin-top: 10px; font-size: 12px; color: #666;">
|
||||
Debug: canAdvance={{ canAdvance }}, isAdvancing={{ isAdvancing }}, next={{ next ? 'exists' : 'null' }}, nextAdvanceAt={{ nextAdvanceAt }}
|
||||
</div>
|
||||
<div v-if="!canAdvance" style="color: red; margin-top: 10px;">
|
||||
Debug: canAdvance = false (next: {{ next ? 'exists' : 'null' }}, nextAdvanceAt: {{ nextAdvanceAt }})
|
||||
</div>
|
||||
<p v-else-if="nextAdvanceAt" class="cooldown-message">
|
||||
{{ $t('falukant.nobility.cooldown', { date: formatDate(nextAdvanceAt) }) }}
|
||||
</p>
|
||||
</div>
|
||||
<div v-else class="advance-section">
|
||||
<p style="color: red;">Fehler: Keine nächste Titel-Information verfügbar. Bitte Seite neu laden.</p>
|
||||
<div style="margin-top: 10px; font-size: 12px; color: #666;">
|
||||
Debug: next={{ next }}, next.labelTr={{ next ? next.labelTr : 'N/A' }}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@@ -117,41 +108,19 @@
|
||||
},
|
||||
async loadNobility() {
|
||||
try {
|
||||
console.log('[NobilityView] Loading nobility data...');
|
||||
const { data } = await apiClient.get('/api/falukant/nobility');
|
||||
console.log('[NobilityView] Received data:', data);
|
||||
this.current = data.current || { labelTr: '', requirements: [], charactersWithNobleTitle: [] };
|
||||
this.next = data.next || { labelTr: '', requirements: [] };
|
||||
this.nextAdvanceAt = data.nextAdvanceAt || null;
|
||||
console.log('[NobilityView] Updated state:', {
|
||||
current: this.current,
|
||||
next: this.next,
|
||||
nextAdvanceAt: this.nextAdvanceAt,
|
||||
canAdvance: this.canAdvance
|
||||
});
|
||||
} catch (err) {
|
||||
console.error('[NobilityView] Error loading nobility:', err);
|
||||
console.error('Error loading nobility:', err);
|
||||
}
|
||||
},
|
||||
async applyAdvance() {
|
||||
console.log('[NobilityView] applyAdvance called', {
|
||||
canAdvance: this.canAdvance,
|
||||
isAdvancing: this.isAdvancing,
|
||||
next: this.next,
|
||||
nextAdvanceAt: this.nextAdvanceAt
|
||||
});
|
||||
if (!this.canAdvance || this.isAdvancing) {
|
||||
console.log('[NobilityView] applyAdvance blocked:', {
|
||||
canAdvance: this.canAdvance,
|
||||
isAdvancing: this.isAdvancing
|
||||
});
|
||||
return;
|
||||
}
|
||||
if (!this.canAdvance || this.isAdvancing) return;
|
||||
this.isAdvancing = true;
|
||||
try {
|
||||
console.log('[NobilityView] Sending POST request to /api/falukant/nobility');
|
||||
await apiClient.post('/api/falukant/nobility');
|
||||
console.log('[NobilityView] POST request successful, reloading nobility data');
|
||||
await this.loadNobility();
|
||||
} catch (err) {
|
||||
console.error('Error advancing nobility:', err);
|
||||
@@ -188,4 +157,9 @@
|
||||
list-style: disc inside;
|
||||
margin-bottom: 1rem;
|
||||
}
|
||||
.cooldown-message {
|
||||
color: #666;
|
||||
font-style: italic;
|
||||
margin-top: 1rem;
|
||||
}
|
||||
</style>
|
||||
Reference in New Issue
Block a user