2024-09-19 12:18:04 +02:00
|
|
|
"use client";
|
2024-09-18 09:47:23 +02:00
|
|
|
import React, { useState, useEffect, useRef } from 'react';
|
2024-09-20 10:34:16 +02:00
|
|
|
import Header from './components/Header';
|
|
|
|
import AI from './components/AI';
|
|
|
|
import FAQ from './components/Faq'; // Ensure the import path is correct
|
|
|
|
import Documentation from './components/Documentation'; // Ensure the import path is correct
|
|
|
|
import History from './components/History';
|
|
|
|
import Models from './components/Models';
|
2024-09-18 11:17:34 +02:00
|
|
|
import './styles/master.css';
|
2024-09-18 09:47:23 +02:00
|
|
|
|
2024-09-18 10:03:36 +02:00
|
|
|
const LandingPage: React.FC = () => {
|
|
|
|
const [showDivs, setShowDivs] = useState(true);
|
2024-09-19 09:54:00 +02:00
|
|
|
const [view, setView] = useState<'AI' | 'FAQ' | 'Documentation'>('AI');
|
2024-09-18 09:47:23 +02:00
|
|
|
const conversationRef = useRef<HTMLDivElement>(null);
|
|
|
|
|
|
|
|
useEffect(() => {
|
|
|
|
const scrollToBottom = () => {
|
|
|
|
const conversation = conversationRef.current;
|
|
|
|
if (conversation) {
|
|
|
|
conversation.scrollTop = conversation.scrollHeight;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-09-18 10:03:36 +02:00
|
|
|
scrollToBottom();
|
2024-09-18 09:47:23 +02:00
|
|
|
|
|
|
|
const observer = new MutationObserver(scrollToBottom);
|
|
|
|
if (conversationRef.current) {
|
|
|
|
observer.observe(conversationRef.current, {
|
|
|
|
childList: true,
|
|
|
|
subtree: true,
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
return () => {
|
|
|
|
if (conversationRef.current) {
|
|
|
|
observer.disconnect();
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}, []);
|
|
|
|
|
|
|
|
const toggleDivs = () => {
|
|
|
|
setShowDivs(prevState => !prevState);
|
|
|
|
};
|
|
|
|
|
2024-09-19 09:54:00 +02:00
|
|
|
const handleViewChange = (view: 'AI' | 'FAQ' | 'Documentation') => {
|
|
|
|
setView(view);
|
|
|
|
if (view !== 'AI') {
|
|
|
|
setShowDivs(false);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2024-09-18 09:47:23 +02:00
|
|
|
return (
|
2024-09-19 12:18:04 +02:00
|
|
|
<div className="container">
|
2024-09-19 09:54:00 +02:00
|
|
|
<Header
|
|
|
|
toggleDivs={toggleDivs}
|
|
|
|
showDivs={showDivs}
|
|
|
|
onViewChange={handleViewChange}
|
2024-09-19 12:18:04 +02:00
|
|
|
showHistoryModelsToggle={true}
|
|
|
|
showToggle={view === 'AI'} // Pass the condition here
|
2024-09-19 09:54:00 +02:00
|
|
|
/>
|
2024-09-19 12:18:04 +02:00
|
|
|
<div className={`left-panel ${showDivs ? 'visible' : 'hidden'}`}>
|
|
|
|
{showDivs && (
|
|
|
|
<div className="history-models">
|
2024-09-19 09:54:00 +02:00
|
|
|
<History />
|
|
|
|
<Models />
|
|
|
|
</div>
|
|
|
|
)}
|
2024-09-19 12:18:04 +02:00
|
|
|
</div>
|
|
|
|
<div className={`conversation-container ${showDivs ? 'collapsed' : 'expanded'}`} ref={conversationRef}>
|
|
|
|
{view === 'AI' && <AI />}
|
|
|
|
{view === 'FAQ' && <FAQ />}
|
|
|
|
{view === 'Documentation' && <Documentation />}
|
2024-09-18 09:47:23 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
);
|
|
|
|
};
|
|
|
|
|
2024-09-18 10:03:36 +02:00
|
|
|
export default LandingPage;
|