fix: TypeScript errors and add clickable class actions
- Fix isEquipped -> equipped property name in export-character-html.ts - Remove unused imports in character-sheet-page.tsx - Remove unused variable in alchemy-tab.tsx - Add on-demand German translation for feats in feats.service.ts - Make class actions clickable in actions-tab with FeatDetailModal - Add (Englisch) hint for untranslated feat descriptions Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@@ -110,9 +110,18 @@ export class FeatsService {
|
||||
}
|
||||
|
||||
async findById(id: string) {
|
||||
return this.prisma.feat.findUnique({
|
||||
const feat = await this.prisma.feat.findUnique({
|
||||
where: { id },
|
||||
});
|
||||
|
||||
if (!feat) return null;
|
||||
|
||||
// Generate translation on-demand if missing
|
||||
if (!feat.nameGerman || !feat.summaryGerman) {
|
||||
return this.ensureTranslation(feat);
|
||||
}
|
||||
|
||||
return feat;
|
||||
}
|
||||
|
||||
async findByName(name: string) {
|
||||
@@ -133,6 +142,13 @@ export class FeatsService {
|
||||
});
|
||||
}
|
||||
|
||||
if (!feat) return null;
|
||||
|
||||
// Generate translation on-demand if missing
|
||||
if (!feat.nameGerman || !feat.summaryGerman) {
|
||||
return this.ensureTranslation(feat);
|
||||
}
|
||||
|
||||
return feat;
|
||||
}
|
||||
|
||||
@@ -179,6 +195,38 @@ export class FeatsService {
|
||||
return Array.from(traitsSet).sort();
|
||||
}
|
||||
|
||||
// Ensure a feat has German translations, generating them if needed
|
||||
private async ensureTranslation(feat: {
|
||||
id: string;
|
||||
name: string;
|
||||
summary?: string | null;
|
||||
nameGerman?: string | null;
|
||||
summaryGerman?: string | null;
|
||||
}) {
|
||||
try {
|
||||
const translation = await this.translationsService.getTranslation(
|
||||
TranslationType.FEAT,
|
||||
feat.name,
|
||||
feat.summary || undefined,
|
||||
);
|
||||
|
||||
// Update the database with the translation
|
||||
const updated = await this.prisma.feat.update({
|
||||
where: { id: feat.id },
|
||||
data: {
|
||||
nameGerman: translation.germanName,
|
||||
summaryGerman: translation.germanDescription,
|
||||
},
|
||||
});
|
||||
|
||||
return updated;
|
||||
} catch (error) {
|
||||
// If translation fails, return the original feat
|
||||
console.error(`Failed to translate feat ${feat.name}:`, error);
|
||||
return feat;
|
||||
}
|
||||
}
|
||||
|
||||
// Get translation for a feat (with caching)
|
||||
async getTranslatedFeat(feat: { name: string; summary?: string | null }) {
|
||||
const translation = await this.translationsService.getTranslation(
|
||||
|
||||
Reference in New Issue
Block a user