make the apropriate changes. here are the script chatpage.js: import React, { useState,…
- User
make the apropriate changes.
here are the script chatpage.js: import React, { useState, useEffect, useContext, useRef } from 'react'; import { AuthContext } from '../AuthContext'; import { ref, get, update, push, set, remove } from 'firebase/database'; import { db } from '../firebase'; import { TextField, Button, Paper, Typography, List, ListItem, Divider, IconButton, Avatar, Menu, MenuItem, Badge, Switch } from '@mui/material'; import SendIcon from '@mui/icons-material/Send'; import EditIcon from '@mui/icons-material/Edit'; import SaveIcon from '@mui/icons-material/Save'; import DeleteIcon from '@mui/icons-material/Delete'; import LogoutIcon from '@mui/icons-material/Logout'; import Brightness4Icon from '@mui/icons-material/Brightness4'; import Brightness7Icon from '@mui/icons-material/Brightness7'; import { ThemeProvider, createTheme, CssBaseline } from '@mui/material'; import { styled } from '@mui/system';
const Root = styled('div')(({ theme }) => ({ height: '100vh', display: 'flex', flexDirection: 'column', }));
const Header = styled('div')(({ theme }) => ({ display: 'flex', justifyContent: 'space-between', alignItems: 'center', padding: theme.spacing(2), backgroundColor: theme.palette.primary.main, color: theme.palette.primary.contrastText, }));
const Sidebar = styled('div')(({ theme }) => ({ width: '250px', padding: theme.spacing(2), backgroundColor: theme.palette.background.paper, borderRight:
1px solid ${theme.palette.divider}, overflowY: 'auto', }));const ChatContainer = styled(Paper)(({ theme }) => ({ padding: theme.spacing(4), textAlign: 'left', width: '100%', height: '100%', display: 'flex', flexDirection: 'column', justifyContent: 'space-between', overflowY: 'auto', }));
const Title = styled(Typography)(({ theme }) => ({ marginBottom: theme.spacing(2), }));
const MessageContainer = styled('div')({ marginTop: 16, flexGrow: 1, display: 'flex', flexDirection: 'column', overflowY: 'auto', });
const Message = styled(Typography)(({ sender, theme }) => ({ alignSelf: sender === 'user' ? 'flex-end' : 'flex-start', backgroundColor: sender === 'user' ? theme.palette.primary.main : theme.palette.grey[200], color: sender === 'user' ? theme.palette.primary.contrastText : theme.palette.text.primary, padding: theme.spacing(1), borderRadius: theme.spacing(1), marginBottom: theme.spacing(1), maxWidth: '75%', }));
const InputContainer = styled('div')(({ theme }) => ({ display: 'flex', gap: theme.spacing(1), marginTop: theme.spacing(2), }));
const TextInput = styled(TextField)(({ theme }) => ({ flexGrow: 1, }));
const SendButton = styled(Button)(({ theme }) => ({ flexShrink: 0, }));
const UserAvatar = styled(Avatar)(({ theme }) => ({ marginRight: theme.spacing(2), }));
const UserStatus = styled('div')(({ theme }) => ({ display: 'flex', alignItems: 'center', }));
function ChatPage() { const [sessions, setSessions] = useState([]); const [currentSession, setCurrentSession] = useState(null); const [messages, setMessages] = useState([]); const [input, setInput] = useState(''); const [editingSession, setEditingSession] = useState(null); const [sessionName, setSessionName] = useState(''); const { currentUser, signOut } = useContext(AuthContext); const [isSending, setIsSending] = useState(false); const [isCreatingSession, setIsCreatingSession] = useState(false); const messagesEndRef = useRef(null); const [anchorEl, setAnchorEl] = useState(null); const [darkMode, setDarkMode] = useState(false); // Light/Dark mode state
- Assistant