come on mannnnnn

This commit is contained in:
YasinOnm08 2024-10-08 15:33:21 +02:00
parent 1f12a1d708
commit 9350a41197
4 changed files with 104 additions and 39 deletions

View file

@ -1,11 +1,8 @@
import React, { useState } from 'react';
import { useChatHistory } from '../hooks/useChatHistory';
interface HistoryProps{
selectedIndex: number;
setSelectedIndex: (index: number) => void;
}
const History: React.FC<HistoryProps> = ({selectedIndex, setSelectedIndex}) => {
const History: React.FC = () => {
const [chatHistory, setChatHistory, setSelectedIndex] = useChatHistory()
const handleHistoryClick = (index: number) => {
setSelectedIndex(index)
@ -16,9 +13,9 @@ const History: React.FC<HistoryProps> = ({selectedIndex, setSelectedIndex}) => {
<div className="history">
<ul>
{/* Populate with history items */}
{Array.from({ length: 20 }, (_, index) => (
{chatHistory.chats.map((chats, index) => (
<li key={index}>
<a href="#" onClick={()=>handleHistoryClick(index)}>history{index + 1}</a>
<a href="#" onClick={() => handleHistoryClick(index)}>{chatHistory.chats[index].name}</a>
</li>
))}
</ul>