Add character deletion functionality with confirmation workflow

- Added `handleDeleteCharacter` method to handle character deletion with confirmation prompts.
- Updated `CharacterComponent` and `CharacterDetail` to include delete button and related logic.
- Localized new strings for character deletion (e.g., confirmation prompts, success/error messages).
- Enhanced database repository methods (`deleteCharacter`) to handle character deletion securely.
- Improved synchronization workflows to accommodate character deletion.
This commit is contained in:
natreex
2026-01-22 15:09:04 -05:00
parent 9461eb6120
commit 4e462670a9
16 changed files with 383 additions and 59 deletions

View File

@@ -28,6 +28,8 @@ import GuidelineRepo, {
BookGuideLineTable
} from "../repositories/guideline.repository.js";
import IssueRepository, {BookIssuesTable} from "../repositories/issue.repository.js";
import SpellRepo, {BookSpellsTable} from "../repositories/spell.repo.js";
import SpellTagRepo, {BookSpellTagsTable} from "../repositories/spelltag.repo.js";
export default class Download {
/**
@@ -198,8 +200,54 @@ export default class Download {
});
if (!issuesInserted) return false;
return data.bookTools.every((bookTool: BookToolsTable): boolean => {
return BookRepo.insertSyncBookTools(bookTool.book_id, userId, bookTool.characters_enabled, bookTool.worlds_enabled, bookTool.locations_enabled, bookTool.last_update, lang);
const bookToolsInserted: boolean = data.bookTools.every((bookTool: BookToolsTable): boolean => {
return BookRepo.insertSyncBookTools(bookTool.book_id, userId, bookTool.characters_enabled, bookTool.worlds_enabled, bookTool.locations_enabled, bookTool.spells_enabled, bookTool.last_update, lang);
});
if (!bookToolsInserted) return false;
const spellTagsInserted: boolean = data.spellTags.every((spellTag: BookSpellTagsTable): boolean => {
const encryptedTagName: string = System.encryptDataWithUserKey(spellTag.name, userEncryptionKey);
return SpellTagRepo.insertSyncSpellTag(
spellTag.tag_id,
spellTag.book_id,
userId,
encryptedTagName,
spellTag.name_hash,
spellTag.color,
spellTag.last_update,
lang
);
});
if (!spellTagsInserted) return false;
const spellsInserted: boolean = data.spells.every((spell: BookSpellsTable): boolean => {
const encryptedName: string = System.encryptDataWithUserKey(spell.name, userEncryptionKey);
const encryptedDescription: string = System.encryptDataWithUserKey(spell.description, userEncryptionKey);
const encryptedAppearance: string = System.encryptDataWithUserKey(spell.appearance, userEncryptionKey);
const encryptedTags: string = System.encryptDataWithUserKey(spell.tags, userEncryptionKey);
const encryptedPowerLevel: string | null = spell.power_level ? System.encryptDataWithUserKey(spell.power_level, userEncryptionKey) : null;
const encryptedComponents: string | null = spell.components ? System.encryptDataWithUserKey(spell.components, userEncryptionKey) : null;
const encryptedLimitations: string | null = spell.limitations ? System.encryptDataWithUserKey(spell.limitations, userEncryptionKey) : null;
const encryptedNotes: string | null = spell.notes ? System.encryptDataWithUserKey(spell.notes, userEncryptionKey) : null;
return SpellRepo.insertSyncSpell(
spell.spell_id,
spell.book_id,
userId,
encryptedName,
spell.name_hash,
encryptedDescription,
encryptedAppearance,
encryptedTags,
encryptedPowerLevel,
encryptedComponents,
encryptedLimitations,
encryptedNotes,
spell.last_update,
lang
);
});
if (!spellsInserted) return false;
return true;
}
}