118 lines
4.7 KiB
TypeScript
118 lines
4.7 KiB
TypeScript
import BasicInformationSetting from "./BasicInformationSetting";
|
|
import GuideLineSetting from "./guide-line/GuideLineSetting";
|
|
import StorySetting from "./story/StorySetting";
|
|
import WorldSetting from "@/components/book/settings/world/WorldSetting";
|
|
import {faPen, faSave} from "@fortawesome/free-solid-svg-icons";
|
|
import {RefObject, useRef} from "react";
|
|
import PanelHeader from "@/components/PanelHeader";
|
|
import LocationComponent from "@/components/book/settings/locations/LocationComponent";
|
|
import CharacterComponent from "@/components/book/settings/characters/CharacterComponent";
|
|
import {useTranslations} from "next-intl"; // Ajouté pour la traduction
|
|
|
|
export default function BookSettingOption(
|
|
{
|
|
setting,
|
|
}: {
|
|
setting: string;
|
|
}) {
|
|
const t = useTranslations(); // Ajouté pour la traduction
|
|
|
|
const basicInfoRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
|
|
handleSave: () => Promise<void>
|
|
}>(null);
|
|
const guideLineRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
|
|
handleSave: () => Promise<void>
|
|
}>(null);
|
|
const storyRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
|
|
handleSave: () => Promise<void>
|
|
}>(null);
|
|
const worldRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
|
|
handleSave: () => Promise<void>
|
|
}>(null);
|
|
const locationRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
|
|
handleSave: () => Promise<void>
|
|
}>(null);
|
|
const characterRef: RefObject<{ handleSave: () => Promise<void> } | null> = useRef<{
|
|
handleSave: () => Promise<void>
|
|
}>(null);
|
|
|
|
function renderTitle(): string {
|
|
switch (setting) {
|
|
case 'basic-information':
|
|
return t("bookSettingOption.basicInformation");
|
|
case 'guide-line':
|
|
return t("bookSettingOption.guideLine");
|
|
case 'story':
|
|
return t("bookSettingOption.storyPlan");
|
|
case 'world':
|
|
return t("bookSettingOption.manageWorlds");
|
|
case 'locations':
|
|
return t("bookSettingOption.yourLocations");
|
|
case 'characters':
|
|
return t("bookSettingOption.characters");
|
|
case 'objects':
|
|
return t("bookSettingOption.objectsList");
|
|
case 'goals':
|
|
return t("bookSettingOption.bookGoals");
|
|
default:
|
|
return "";
|
|
}
|
|
}
|
|
|
|
async function handleSaveClick(): Promise<void> {
|
|
switch (setting) {
|
|
case 'basic-information':
|
|
basicInfoRef.current?.handleSave();
|
|
break;
|
|
case 'guide-line':
|
|
guideLineRef.current?.handleSave();
|
|
break;
|
|
case 'story':
|
|
storyRef.current?.handleSave();
|
|
break;
|
|
case 'world':
|
|
worldRef.current?.handleSave();
|
|
break;
|
|
case 'locations':
|
|
locationRef.current?.handleSave();
|
|
break;
|
|
case 'characters':
|
|
characterRef.current?.handleSave();
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
}
|
|
|
|
return (
|
|
<div className="space-y-5">
|
|
<PanelHeader
|
|
icon={faPen}
|
|
badge={`BI`}
|
|
title={renderTitle()}
|
|
description={``}
|
|
secondActionCallback={handleSaveClick}
|
|
callBackAction={handleSaveClick}
|
|
secondActionIcon={faSave}
|
|
/>
|
|
<div className="bg-secondary/10 rounded-xl overflow-auto max-h-[calc(100vh-250px)] p-1">
|
|
{
|
|
setting === 'basic-information' ? (
|
|
<BasicInformationSetting ref={basicInfoRef}/>
|
|
) : setting === 'guide-line' ? (
|
|
<GuideLineSetting ref={guideLineRef}/>
|
|
) : setting === 'story' ? (
|
|
<StorySetting ref={storyRef}/>
|
|
) : setting === 'world' ? (
|
|
<WorldSetting ref={worldRef}/>
|
|
) : setting === 'locations' ? (
|
|
<LocationComponent ref={locationRef}/>
|
|
) : setting === 'characters' ? (
|
|
<CharacterComponent ref={characterRef}/>
|
|
) : <div
|
|
className="text-text-secondary py-4 text-center">{t("bookSettingOption.notAvailable")}</div>
|
|
}
|
|
</div>
|
|
</div>
|
|
)
|
|
} |