Bump app version to 0.2.1 and add Spell and DeleteButton components

- Introduced comprehensive `Spell` models with tagging and state management capabilities.
- Added reusable `DeleteButton` component with confirmation workflow for destructive actions.
This commit is contained in:
natreex
2026-01-26 14:24:22 -05:00
parent 512955d10a
commit 2359638cb0
3 changed files with 176 additions and 1 deletions

109
lib/models/Spell.ts Normal file
View File

@@ -0,0 +1,109 @@
import {SelectBoxProps} from "@/shared/interface";
// ==================== SPELL TAG INTERFACES ====================
export interface SpellTagProps {
id: string;
name: string;
color: string | null;
}
// ==================== SPELL INTERFACES ====================
// Réponse de GET /spell/detail et POST /spell/add
export interface SpellProps {
id: string;
name: string;
description: string;
appearance: string;
tags: string[]; // IDs des tags
powerLevel: string | null;
components: string | null;
limitations: string | null;
notes: string | null;
}
// Pour POST /spell/add et PUT /spell/update
export interface SpellPropsPost {
id?: string;
name: string;
description: string;
appearance: string;
tags: string[];
powerLevel?: string | null;
components?: string | null;
limitations?: string | null;
notes?: string | null;
}
// Item dans la liste (GET /spell/list)
export interface SpellListItem {
id: string;
name: string;
description: string;
tags: SpellTagProps[]; // Tags résolus (pas les IDs)
}
// Réponse de GET /spell/list
export interface SpellListResponse {
enabled: boolean;
spells: SpellListItem[];
tags: SpellTagProps[];
}
// État local pour l'édition (avec id nullable pour création)
export interface SpellEditState {
id: string | null;
name: string;
description: string;
appearance: string;
tags: string[];
powerLevel: string | null;
components: string | null;
limitations: string | null;
notes: string | null;
}
export const initialSpellState: SpellEditState = {
id: null,
name: '',
description: '',
appearance: '',
tags: [],
powerLevel: null,
components: null,
limitations: null,
notes: null,
};
export const spellPowerLevels: SelectBoxProps[] = [
{value: 'none', label: 'spellPowerLevels.none'},
{value: 'cantrip', label: 'spellPowerLevels.cantrip'},
{value: 'novice', label: 'spellPowerLevels.novice'},
{value: 'apprentice', label: 'spellPowerLevels.apprentice'},
{value: 'journeyman', label: 'spellPowerLevels.journeyman'},
{value: 'expert', label: 'spellPowerLevels.expert'},
{value: 'master', label: 'spellPowerLevels.master'},
{value: 'grandmaster', label: 'spellPowerLevels.grandmaster'},
{value: 'legendary', label: 'spellPowerLevels.legendary'},
{value: 'divine', label: 'spellPowerLevels.divine'},
];
export const defaultTagColors: string[] = [
'#51AE84',
'#3A8B69',
'#2196F3',
'#1976D2',
'#FFA726',
'#FF9800',
'#EF5350',
'#E53935',
'#AB47BC',
'#9C27B0',
'#26A69A',
'#00897B',
'#5C6BC0',
'#3F51B5',
'#EC407A',
'#D81B60',
];