Add advanced generation options with Explicit and Smart modes

- Implemented `AdvancedGenerationOptions` component for toggling Explicit and Smart modes with confirmation dialogs.
- Integrated generation options into `GhostWriter`, `DraftCompanion`, and `ShortStoryGenerator`.
- Introduced `ToggleWithConfirmation` component for user interaction with alerts.
- Updated `InputField` to support centered alignment for better layout flexibility.
- Localized Explicit and Smart mode strings in English and French.
- Enhanced content preview logic to filter placeholder text before display.
- Added `autoUpdater` initialization checks and refactored updater setup for improved reliability.
This commit is contained in:
natreex
2026-01-17 23:26:22 -05:00
parent 0020b3abbd
commit c62a7eb0f7
11 changed files with 335 additions and 34 deletions

View File

@@ -0,0 +1,61 @@
'use client'
import React from "react";
import {faBrain, faTriangleExclamation} from "@fortawesome/free-solid-svg-icons";
import InputField from "@/components/form/InputField";
import ToggleWithConfirmation from "@/components/form/ToggleWithConfirmation";
import {useTranslations} from "next-intl";
interface AdvancedGenerationOptionsProps {
useExplicit: boolean;
setUseExplicit: (value: boolean) => void;
useSmart: boolean;
setUseSmart: (value: boolean) => void;
}
export default function AdvancedGenerationOptions({
useExplicit,
setUseExplicit,
useSmart,
setUseSmart
}: AdvancedGenerationOptionsProps) {
const t = useTranslations();
return (
<div className="bg-secondary/20 rounded-xl p-5 shadow-inner border border-secondary/30">
<div className="flex justify-evenly items-center">
<InputField
icon={faTriangleExclamation}
fieldName={t("generationOptions.explicit.label")}
centered
input={
<ToggleWithConfirmation
checked={useExplicit}
onChange={setUseExplicit}
alertTitle={t("generationOptions.explicit.alertTitle")}
alertMessage={t("generationOptions.explicit.alertMessage")}
alertType="alert"
confirmText={t("generationOptions.activate")}
cancelText={t("generationOptions.cancel")}
/>
}
/>
<InputField
icon={faBrain}
fieldName={t("generationOptions.smart.label")}
centered
input={
<ToggleWithConfirmation
checked={useSmart}
onChange={setUseSmart}
alertTitle={t("generationOptions.smart.alertTitle")}
alertMessage={t("generationOptions.smart.alertMessage")}
alertType="informatif"
confirmText={t("generationOptions.activate")}
cancelText={t("generationOptions.cancel")}
/>
}
/>
</div>
</div>
);
}

View File

@@ -14,6 +14,7 @@ interface InputFieldProps {
actionLabel?: string
actionIcon?: IconDefinition
hint?: string,
centered?: boolean,
}
export default function InputField(
@@ -27,11 +28,12 @@ export default function InputField(
action,
actionLabel,
actionIcon,
hint
hint,
centered = false
}: InputFieldProps) {
return (
<div className={'flex flex-col'}>
<div className={'flex justify-between items-center mb-2 lg:mb-3 flex-wrap gap-2'}>
<div className={`flex flex-col ${centered ? 'items-center' : ''}`}>
<div className={`flex items-center mb-2 lg:mb-3 flex-wrap gap-2 ${centered ? 'justify-center' : 'justify-between'}`}>
{
fieldName && (
<h3 className="text-text-primary text-xl font-[ADLaM Display] font-medium mb-2 flex items-center gap-2">
@@ -64,7 +66,7 @@ export default function InputField(
</span>
)}
</div>
<div className="flex justify-between items-center gap-2">
<div className={`flex items-center gap-2 ${centered ? 'justify-center' : 'justify-between'}`}>
{input}
{
addButtonCallBack && (

View File

@@ -0,0 +1,63 @@
'use client'
import React, {useState} from "react";
import ToggleSwitch from "@/components/form/ToggleSwitch";
import AlertBox, {AlertType} from "@/components/AlertBox";
interface ToggleWithConfirmationProps {
checked: boolean;
onChange: (checked: boolean) => void;
alertTitle: string;
alertMessage: string;
alertType: AlertType;
confirmText?: string;
cancelText?: string;
disabled?: boolean;
}
export default function ToggleWithConfirmation({
checked,
onChange,
alertTitle,
alertMessage,
alertType,
confirmText = "Activer",
cancelText = "Annuler",
disabled = false
}: ToggleWithConfirmationProps) {
const [showAlert, setShowAlert] = useState<boolean>(false);
function handleToggle(newChecked: boolean): void {
if (newChecked) {
setShowAlert(true);
} else {
onChange(false);
}
}
async function handleConfirm(): Promise<void> {
onChange(true);
setShowAlert(false);
}
function handleCancel(): void {
setShowAlert(false);
}
return (
<>
<ToggleSwitch checked={checked} onChange={handleToggle} disabled={disabled}/>
{showAlert && (
<AlertBox
title={alertTitle}
message={alertMessage}
type={alertType}
confirmText={confirmText}
cancelText={cancelText}
onConfirm={handleConfirm}
onCancel={handleCancel}
/>
)}
</>
);
}