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,20 +1,24 @@
|
||||
import {faRobot} from '@fortawesome/free-solid-svg-icons';
|
||||
import {useContext, useEffect, useState} from 'react';
|
||||
import {SessionContext} from "@/context/SessionContext";
|
||||
import {ConversationProps} from "@/lib/models/QuillSense";
|
||||
import System from "@/lib/models/System";
|
||||
import {FontAwesomeIcon} from "@fortawesome/react-fontawesome";
|
||||
import {Bot} from 'lucide-react';
|
||||
import React, {useContext, useEffect, useState} from 'react';
|
||||
import {SessionContext, SessionContextProps} from "@/context/SessionContext";
|
||||
import {ConversationProps} from "@/lib/types/quillsense";
|
||||
import {apiGet} from '@/lib/api/client';
|
||||
import {BookContext, BookContextProps} from "@/context/BookContext";
|
||||
import {LangContext} from "@/context/LangContext";
|
||||
import {LangContext, LangContextProps} from "@/context/LangContext";
|
||||
import {AlertContext, AlertContextProps} from "@/context/AlertContext";
|
||||
import {useTranslations} from '@/lib/i18n';
|
||||
import Badge from "@/components/ui/Badge";
|
||||
|
||||
interface QuillListProps {
|
||||
handleSelectConversation: (itemId: string) => void;
|
||||
}
|
||||
|
||||
export default function QuillList({handleSelectConversation}: QuillListProps) {
|
||||
const {session} = useContext(SessionContext);
|
||||
const {book} = useContext<BookContextProps>(BookContext);
|
||||
const {lang} = useContext(LangContext);
|
||||
export default function QuillList({handleSelectConversation}: QuillListProps): React.JSX.Element {
|
||||
const t = useTranslations();
|
||||
const {session}: SessionContextProps = useContext<SessionContextProps>(SessionContext);
|
||||
const {book}: BookContextProps = useContext<BookContextProps>(BookContext);
|
||||
const {lang}: LangContextProps = useContext<LangContextProps>(LangContext);
|
||||
const {errorMessage}: AlertContextProps = useContext<AlertContextProps>(AlertContext);
|
||||
|
||||
const [conversations, setConversations] = useState<ConversationProps[]>([]);
|
||||
|
||||
@@ -24,7 +28,7 @@ export default function QuillList({handleSelectConversation}: QuillListProps) {
|
||||
|
||||
async function getConversations(): Promise<void> {
|
||||
try {
|
||||
const response: ConversationProps[] = await System.authGetQueryToServer<ConversationProps[]>(
|
||||
const response: ConversationProps[] = await apiGet<ConversationProps[]>(
|
||||
`quillsense/conversations`,
|
||||
session.accessToken,
|
||||
lang,
|
||||
@@ -35,8 +39,12 @@ export default function QuillList({handleSelectConversation}: QuillListProps) {
|
||||
if (response.length > 0) {
|
||||
setConversations(response);
|
||||
}
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
} catch (e: unknown) {
|
||||
if (e instanceof Error) {
|
||||
errorMessage(e.message);
|
||||
} else {
|
||||
errorMessage(t('quillList.error.unknown'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -45,7 +53,7 @@ export default function QuillList({handleSelectConversation}: QuillListProps) {
|
||||
case 1:
|
||||
return 'bg-muted';
|
||||
case 2:
|
||||
return 'bg-blue-500';
|
||||
return 'bg-accent-blue';
|
||||
case 3:
|
||||
return 'bg-primary';
|
||||
case 4:
|
||||
@@ -57,25 +65,25 @@ export default function QuillList({handleSelectConversation}: QuillListProps) {
|
||||
|
||||
return (
|
||||
<div className="flex-1 overflow-y-auto p-2">
|
||||
{conversations.map((conversation: ConversationProps) => (
|
||||
{conversations.map((conversation: ConversationProps): React.JSX.Element => (
|
||||
<div key={conversation.id}
|
||||
className="flex items-center justify-between p-3 mb-2 rounded-xl bg-secondary/30 hover:bg-secondary hover:shadow-md cursor-pointer transition-all duration-200 border border-secondary/50 hover:border-secondary hover:scale-102"
|
||||
className="flex items-center justify-between p-3 mb-2 rounded-xl bg-tertiary hover:bg-secondary cursor-pointer transition-colors duration-150"
|
||||
onClick={(): void => handleSelectConversation(conversation.id)}
|
||||
>
|
||||
<div className="flex items-center gap-3">
|
||||
<div
|
||||
className={`w-2.5 h-2.5 rounded-full ${getStatusColorClass(conversation.status)} shadow-sm`}></div>
|
||||
<FontAwesomeIcon icon={faRobot} className="text-primary w-5 h-5"/>
|
||||
className={`w-2.5 h-2.5 rounded-full ${getStatusColorClass(conversation.status)}`}></div>
|
||||
<Bot className="text-primary w-5 h-5" strokeWidth={1.75}/>
|
||||
<div>
|
||||
<span className="text-text-primary font-medium">{conversation.title || "Sans titre"}</span>
|
||||
<span
|
||||
className="text-text-primary font-medium">{conversation.title || t('quillList.untitled')}</span>
|
||||
{conversation.startDate && (
|
||||
<p className="text-xs text-muted mt-0.5">{conversation.startDate}</p>
|
||||
)}
|
||||
</div>
|
||||
</div>
|
||||
{conversation.mode && (
|
||||
<span
|
||||
className="text-xs bg-primary/20 text-primary px-2.5 py-1 rounded-lg font-medium border border-primary/30">{conversation.mode}</span>
|
||||
<Badge size="sm">{conversation.mode}</Badge>
|
||||
)}
|
||||
</div>
|
||||
))}
|
||||
|
||||
Reference in New Issue
Block a user