Compare commits
No commits in common. "73b04e3e4af402efcc8db422c89abf08482038a3" and "6baa3d5fdbb743990d9d366f835f1407465247c2" have entirely different histories.
73b04e3e4a
...
6baa3d5fdb
2 changed files with 1 additions and 36 deletions
|
@ -3,30 +3,11 @@ import { useChatHistory } from '../hooks/useChatHistory';
|
||||||
|
|
||||||
const History: React.FC = () => {
|
const History: React.FC = () => {
|
||||||
const [chatHistory, setChatHistory, setSelectedIndex] = useChatHistory()
|
const [chatHistory, setChatHistory, setSelectedIndex] = useChatHistory()
|
||||||
const [isEditing, setIsEditing] = useState(false);
|
|
||||||
const [inputValue, setInputValue] = useState<string>('');
|
|
||||||
|
|
||||||
const handleEditButtonClick = () => {
|
|
||||||
setIsEditing(true);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleInputChange = (e: React.ChangeEvent<HTMLInputElement>) => {
|
|
||||||
setInputValue(e.target.value);
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSaveButtonClick = () => {
|
|
||||||
setIsEditing(false);
|
|
||||||
chatHistory.chats.push({ name: inputValue, messages: [], timestamp: 5 })
|
|
||||||
setInputValue("")
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleHistoryClick = (index: number) => {
|
const handleHistoryClick = (index: number) => {
|
||||||
setSelectedIndex(index)
|
setSelectedIndex(index)
|
||||||
console.log("index",index);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<div className="history-background">
|
<div className="history-background">
|
||||||
<div className="history">
|
<div className="history">
|
||||||
|
@ -37,21 +18,6 @@ const History: React.FC = () => {
|
||||||
<a href="#" onClick={() => handleHistoryClick(index)}>{chatHistory.chats[index].name}</a>
|
<a href="#" onClick={() => handleHistoryClick(index)}>{chatHistory.chats[index].name}</a>
|
||||||
</li>
|
</li>
|
||||||
))}
|
))}
|
||||||
<li>
|
|
||||||
{isEditing ? (
|
|
||||||
<div>
|
|
||||||
<input
|
|
||||||
type="text"
|
|
||||||
value={inputValue}
|
|
||||||
onChange={handleInputChange}
|
|
||||||
placeholder="Enter text"
|
|
||||||
/>
|
|
||||||
<button onClick={handleSaveButtonClick}>Save</button>
|
|
||||||
</div>
|
|
||||||
) : (
|
|
||||||
<button onClick={handleEditButtonClick}>{'New Chat'}</button>
|
|
||||||
)}
|
|
||||||
</li>
|
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -19,8 +19,7 @@ interface GlobalChatHistory {
|
||||||
|
|
||||||
let globalChatHistory: GlobalChatHistory = {
|
let globalChatHistory: GlobalChatHistory = {
|
||||||
chats: [
|
chats: [
|
||||||
{ name: "Chat 1", messages: [{role:"system",content:"you are a helpful assistant"},{role:"assistant",content:"how can i help you"}], timestamp: 4 },
|
{ name: "Chat 1", messages: [], timestamp: 4 }
|
||||||
{ name: "Chat 2", messages: [{role:"system",content:"you are a helpful assistant"},{role:"assistant",content:"how can i help you"}], timestamp: 4 },
|
|
||||||
],
|
],
|
||||||
selectedIndex:0
|
selectedIndex:0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue