start chatHistory
This commit is contained in:
parent
a60cc7e941
commit
76da6aed0e
8 changed files with 89 additions and 38 deletions
|
@ -2,10 +2,14 @@
|
|||
import React from 'react';
|
||||
import InputOutputBackend from '../backend/InputOutputHandler';
|
||||
|
||||
const AI: React.FC = () => {
|
||||
interface AIProps{
|
||||
selectedIndex:number
|
||||
}
|
||||
|
||||
const AI: React.FC<AIProps> = ({selectedIndex}) => {
|
||||
return (
|
||||
<div className="ai-container">
|
||||
<InputOutputBackend />
|
||||
<InputOutputBackend selectedIndex={selectedIndex}/>
|
||||
</div>
|
||||
);
|
||||
};
|
||||
|
|
|
@ -1,6 +1,16 @@
|
|||
import React from 'react';
|
||||
import React, { useState } from 'react';
|
||||
|
||||
interface HistoryProps{
|
||||
selectedIndex: number;
|
||||
setSelectedIndex: (index: number) => void;
|
||||
}
|
||||
|
||||
const History: React.FC<HistoryProps> = ({selectedIndex, setSelectedIndex}) => {
|
||||
|
||||
const handleHistoryClick = (index: number) => {
|
||||
setSelectedIndex(index)
|
||||
}
|
||||
|
||||
const History: React.FC = () => {
|
||||
return (
|
||||
<div className="history-background">
|
||||
<div className="history">
|
||||
|
@ -8,7 +18,7 @@ const History: React.FC = () => {
|
|||
{/* Populate with history items */}
|
||||
{Array.from({ length: 20 }, (_, index) => (
|
||||
<li key={index}>
|
||||
<a href="#">history{index + 1}</a>
|
||||
<a href="#" onClick={()=>handleHistoryClick(index)}>history{index + 1}</a>
|
||||
</li>
|
||||
))}
|
||||
</ul>
|
||||
|
|
|
@ -2,7 +2,7 @@ import React, { useState, useEffect } from 'react';
|
|||
import {
|
||||
createAccount,
|
||||
checkCredentials,
|
||||
getData
|
||||
getSettings
|
||||
} from '../backend/database';
|
||||
import Settings from './settings/Settings'; // Import the Settings component
|
||||
|
||||
|
@ -62,7 +62,7 @@ const Login: React.FC = () => {
|
|||
const success = await checkCredentials(accountName, password);
|
||||
if (success) {
|
||||
setIsLoggedIn(true); // Successful login
|
||||
const data = await getData(accountName, password)
|
||||
const data = await getSettings(accountName, password)
|
||||
if (data) {
|
||||
if (typeof localStorage !== 'undefined') {
|
||||
localStorage.setItem("dataFromServer", data)
|
||||
|
|
|
@ -11,7 +11,7 @@ import PrivacySettings from './PrivacySettings';
|
|||
import FontSizeSetting from './FontSize';
|
||||
import OpenSourceModeToggle from './OpenSourceToggle';
|
||||
import {
|
||||
changeData,
|
||||
changeSettings,
|
||||
createAccount,
|
||||
deleteAccount,
|
||||
} from '../../backend/database';
|
||||
|
@ -351,7 +351,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
}
|
||||
|
||||
if (await createAccount(useName, useEmail, usePassword)) {
|
||||
if (await changeData(useName, usePassword, settings)) {
|
||||
if (await changeSettings(useName, usePassword, settings)) {
|
||||
localStorage.setItem("currentName", useName)
|
||||
localStorage.setItem("currentPassword", usePassword)
|
||||
localStorage.setItem("currentEmail", useEmail)
|
||||
|
@ -729,7 +729,7 @@ const Settings: React.FC<{ closeSettings: () => void; accountName: string }> = (
|
|||
<button className="apply" onClick={async () => {
|
||||
getAllLocalStorageItems();
|
||||
closeSettings();
|
||||
await changeData(localStorage.getItem('accountName') ?? "hello", localStorage.getItem('accountPassword') ?? "hello", settings) // ????
|
||||
await changeSettings(localStorage.getItem('accountName') ?? "hello", localStorage.getItem('accountPassword') ?? "hello", settings) // ????
|
||||
window.location.reload();
|
||||
}}>
|
||||
Apply
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue