import React, {useContext, useState} from 'react'; import {FontAwesomeIcon} from '@fortawesome/react-fontawesome'; import { faBars, faComments, faExchangeAlt, faLanguage, faLightbulb, faSpellCheck, IconDefinition } from '@fortawesome/free-solid-svg-icons'; import QuillSense, {QSView,} from "@/lib/models/QuillSense"; import QuillList from "@/components/quillsense/modes/QuillList"; import QuillConversation from "./modes/QuillConversation"; import Dictionary from "@/components/quillsense/modes/Dictionary"; import Synonyms from "@/components/quillsense/modes/Synonyms"; import InspireMe from "@/components/quillsense/modes/InspireMe"; import {SessionContext} from "@/context/SessionContext"; import {useTranslations} from "next-intl"; import Conjugator from "@/components/quillsense/modes/Conjugator"; interface QSOption { view: QSView; icon: IconDefinition; } export default function QuillSenseComponent() { const [view, setView] = useState('chat'); const t = useTranslations(); const [selectedConversation, setSelectedConversation] = useState(''); const {session} = useContext(SessionContext); const isBringYourKeys: boolean = QuillSense.isBringYourKeys(session); const subLevel: number = QuillSense.getSubLevel(session) const isGPTEnabled: boolean = QuillSense.isOpenAIEnabled(session); const isSubTierTwo: boolean = QuillSense.getSubLevel(session) >= 1; const hasAccess: boolean = isGPTEnabled || isSubTierTwo; const qsOptions: QSOption[] = [ {view: 'dictionary', icon: faSpellCheck}, {view: 'conjugator', icon: faLanguage}, {view: 'synonyms', icon: faExchangeAlt}, {view: 'inspiration', icon: faLightbulb}, {view: 'chat', icon: faComments}, ]; function handleSetView(view: QSView): void { setView(view); } function handleSelectConversation(conversationId: string) { setSelectedConversation(conversationId); setView('chat'); } return (
{ qsOptions.map((option: QSOption) => ( )) }
{ isBringYourKeys || subLevel >= 1 ? ( <> {view === 'list' ? ( ) : view === 'chat' ? ( ) : view === 'dictionary' ? ( ) : view === 'synonyms' ? ( ) : view === 'conjugator' ? ( ) : view === 'inspiration' ? ( ) : ( <> )} ) : (

{t('quillSense.needSubscription')}

{t('quillSense.subscriptionDescription')}

) }
); }