Remove unused components and models for improved maintainability
- Deleted redundant components (`AddActionButton`, `AlertBox`, `AlertStack`, `BackButton`, `CancelButton`, and `CollapsableArea`) and related files. - Removed unused models (`Book`, `BookSerie`, `BookTables`, `Character`, and `Chapter`) to reduce codebase clutter. - Updated project structure and references to reflect these removals.
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
'use client'
|
||||
import React, {lazy, Suspense, useContext, useRef} from 'react';
|
||||
import {faPen, faSave} from '@fortawesome/free-solid-svg-icons';
|
||||
import {FontAwesomeIcon} from '@fortawesome/react-fontawesome';
|
||||
import {faSpinner} from '@fortawesome/free-solid-svg-icons';
|
||||
import {useTranslations} from 'next-intl';
|
||||
import PanelHeader from '@/components/PanelHeader';
|
||||
import {SeriesContext} from '@/context/SeriesContext';
|
||||
import {useTranslations} from '@/lib/i18n';
|
||||
import SectionHeader from "@/components/ui/SectionHeader";
|
||||
import IconButton from "@/components/ui/IconButton";
|
||||
import {Save} from 'lucide-react';
|
||||
import PulseLoader from '@/components/ui/PulseLoader';
|
||||
import {SeriesContext, SeriesContextProps} from '@/context/SeriesContext';
|
||||
import {SettingRef} from "@/lib/types/settings";
|
||||
|
||||
// Lazy loaded components - avec ref (anciens)
|
||||
const BasicSeriesInformation = lazy(function () {
|
||||
@@ -29,32 +30,20 @@ const SpellSettings = lazy(function () {
|
||||
return import('@/components/book/settings/spells/settings/SpellSettings');
|
||||
});
|
||||
|
||||
function LoadingSpinner(): React.JSX.Element {
|
||||
return (
|
||||
<div className="flex items-center justify-center py-12">
|
||||
<FontAwesomeIcon icon={faSpinner} className="w-8 h-8 text-primary animate-spin"/>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
interface SeriesSettingOptionProps {
|
||||
setting: string;
|
||||
}
|
||||
|
||||
interface SettingRef {
|
||||
handleSave: () => Promise<void>;
|
||||
}
|
||||
|
||||
// Settings qui gèrent leur propre save (pas de bouton save parent)
|
||||
const selfManagedSettings: string[] = ['characters', 'spells', 'worlds', 'locations'];
|
||||
|
||||
export default function SeriesSettingOption({setting}: SeriesSettingOptionProps): React.JSX.Element {
|
||||
const t = useTranslations();
|
||||
const {seriesId} = useContext(SeriesContext);
|
||||
const settingRef = useRef<SettingRef>(null);
|
||||
|
||||
const {seriesId}: SeriesContextProps = useContext<SeriesContextProps>(SeriesContext);
|
||||
const settingRef: React.RefObject<SettingRef | null> = useRef<SettingRef>(null);
|
||||
|
||||
const showSaveButton: boolean = !selfManagedSettings.includes(setting);
|
||||
|
||||
|
||||
function renderTitle(): string {
|
||||
switch (setting) {
|
||||
case 'basic-information':
|
||||
@@ -73,41 +62,38 @@ export default function SeriesSettingOption({setting}: SeriesSettingOptionProps)
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function handleSaveClick(): Promise<void> {
|
||||
if (settingRef.current?.handleSave) {
|
||||
await settingRef.current.handleSave();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return (
|
||||
<div className="px-6">
|
||||
<div className="sticky top-0 z-10 bg-tertiary pt-6 pb-4">
|
||||
<PanelHeader
|
||||
icon={faPen}
|
||||
badge="SE"
|
||||
<div className="sticky top-0 z-10 bg-darkest-background pt-6 pb-4">
|
||||
<SectionHeader
|
||||
title={renderTitle()}
|
||||
description=""
|
||||
secondActionCallback={showSaveButton ? handleSaveClick : undefined}
|
||||
callBackAction={showSaveButton ? handleSaveClick : undefined}
|
||||
secondActionIcon={showSaveButton ? faSave : undefined}
|
||||
actions={showSaveButton ? (
|
||||
<IconButton icon={Save} variant="primary" onClick={handleSaveClick}/>
|
||||
) : undefined}
|
||||
/>
|
||||
</div>
|
||||
<div className="bg-secondary/10 rounded-xl p-1 mb-6">
|
||||
<Suspense fallback={<LoadingSpinner/>}>
|
||||
<div className="mb-6">
|
||||
<Suspense fallback={<PulseLoader/>}>
|
||||
{setting === 'basic-information' && <BasicSeriesInformation ref={settingRef}/>}
|
||||
{setting === 'books' && <SeriesBooksManager ref={settingRef}/>}
|
||||
{setting === 'worlds' && (
|
||||
<WorldSettings entityType="series" entityId={seriesId} showToggle={false}/>
|
||||
<WorldSettings entityType="series" entityId={seriesId}/>
|
||||
)}
|
||||
{setting === 'locations' && (
|
||||
<LocationSettings entityType="series" entityId={seriesId} showToggle={false}/>
|
||||
<LocationSettings entityType="series" entityId={seriesId}/>
|
||||
)}
|
||||
{setting === 'characters' && (
|
||||
<CharacterSettings entityType="series" entityId={seriesId} showToggle={false}/>
|
||||
<CharacterSettings entityType="series" entityId={seriesId}/>
|
||||
)}
|
||||
{setting === 'spells' && (
|
||||
<SpellSettings entityType="series" entityId={seriesId} showToggle={false}/>
|
||||
<SpellSettings entityType="series" entityId={seriesId}/>
|
||||
)}
|
||||
{!['basic-information', 'books', 'worlds', 'locations', 'characters', 'spells'].includes(setting) && (
|
||||
<div className="text-text-secondary py-4 text-center">
|
||||
|
||||
Reference in New Issue
Block a user