Skip to content

Commit

Permalink
Merge pull request #29 from yale-swe/michal-new-branch
Browse files Browse the repository at this point in the history
minor profile frontend changes
  • Loading branch information
MLewkowicz authored Apr 16, 2024
2 parents 09b28d1 + d421830 commit 436743b
Show file tree
Hide file tree
Showing 5 changed files with 64 additions and 22 deletions.
18 changes: 18 additions & 0 deletions backend/.elasticbeanstalk/config.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
branch-defaults:
default:
environment: null
group_suffix: null
global:
application_name: bluebook-ai-backend
branch: null
default_ec2_keyname: bluebookai-server-key
default_platform: Python 3.8 running on 64bit Amazon Linux 2
default_region: us-east-2
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: null
repository: null
sc: null
workspace_type: Application
5 changes: 5 additions & 0 deletions deploy_frontend.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
echo "Deploying Frontend..."
cd frontend
export REACT_APP_API_URL=/api
npm run build
aws s3 sync out/ s3://bluebook-ai-frontend --acl public-read
24 changes: 18 additions & 6 deletions frontend/src/app/page.module.css
Original file line number Diff line number Diff line change
Expand Up @@ -84,10 +84,8 @@
padding: 1rem;
margin-bottom: auto;
font-size: 13px;
padding-bottom: 100px;
}


.message {
display: inline;
flex-direction: column;
Expand Down Expand Up @@ -292,11 +290,24 @@
.floatingProfileButton {
position: fixed;
bottom: 20px;
right: 90px; /* Adjust based on chat button placement */
z-index: 1001;
/* additional styling */
right: 70px;
width: 50px;
height: 50px;
padding: 10px 15px;
border-radius: 50%;
background-color: #468ff2;
background-image: url('profile_icon.png');
background-repeat: no-repeat;
background-position: center;
background-size: 40%;
color: white;
border: none;
cursor: pointer;
box-shadow: 2px 2px 10px rgb(0 0 0 / 20%);
z-index: 1200;
}


.profileContainer {
position: fixed;
bottom: 70px; /* Adjust based on your design */
Expand All @@ -306,7 +317,8 @@
box-shadow: 0 4px 6px rgba(0,0,0,0.1);
transition: right 0.3s ease-in-out;
/* More styles */
}
}


.profileVisible {
right: 10px; /* Adjust to make visible */
Expand Down
Binary file added frontend/src/app/profile_icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
39 changes: 23 additions & 16 deletions frontend/src/app/profiles.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
"use client";

import React, { useState } from "react";
import styles from "./page.module.css"; // Use your specific styles directory
import styles from "./page.module.css";

const ProfilePopup = () => {
const [popupVisible, setPopupVisible] = useState(false);
const [chatHistoryVisible, setChatHistoryVisible] = useState(false);
const [username, setUsername] = useState("JohnDoe");
const [email, setEmail] = useState("[email protected]");
const [courses, setCourses] = useState<string[]>([]);
Expand All @@ -15,6 +16,10 @@ const ProfilePopup = () => {
setPopupVisible(!popupVisible);
};

const toggleChatHistory = () => {
setChatHistoryVisible(!chatHistoryVisible);
};

const handleSaveProfile = async () => {
const response = await fetch('/api/save_profile', {
method: 'POST',
Expand Down Expand Up @@ -43,12 +48,9 @@ const ProfilePopup = () => {

const reloadChat = async (chatId: number) => {
console.log(`Reloading chat with ID: ${chatId}`);
// Simulate fetching chat data from a backend
const response = await fetch(`/api/reload_chat/${chatId}`);
if (response.ok) {
const data = await response.json();
// Assuming you have a state for the current chat display:
// setCurrentChat(data.chatContent);
console.log("Chat reloaded:", data.chatContent);
} else {
console.error("Failed to reload chat");
Expand All @@ -63,11 +65,12 @@ const ProfilePopup = () => {
return (
<>
<button onClick={togglePopupVisibility} className={styles.floatingProfileButton}>
<img src="/path/to/profile-icon.png" alt="Profile Icon" />
</button>

{popupVisible && (
<div className={`${styles.profileContainer} ${popupVisible ? styles.profileVisible : ""}`}>
<button onClick={toggleChatHistory} className={styles.toggleChatHistoryButton}>Chat History</button>

<div className={styles.profileHeader}>User Profile</div>
<div className={styles.profileDetails}>
<input type="text" value={username} onChange={(e) => setUsername(e.target.value)} placeholder="Username" />
Expand All @@ -79,20 +82,24 @@ const ProfilePopup = () => {
<button onClick={handleAddCourse}>Add Course</button>
{courses.map(course => <div key={course}>{course}</div>)}
</div>
<div className={styles.chatHistory}>
<div className={styles.chatHistoryHeader}>Chat History</div>
<div className={styles.chatHistoryList}>
{chatHistories.map(history => (
<div key={history.id} className={styles.chatTile}>
<span>{history.summary}</span>
<button onClick={() => reloadChat(history.id)}>🔄</button>
</div>
))}
</div>
</div>
<button onClick={togglePopupVisibility} className={styles.closeButton}>Close</button>
</div>
)}

{chatHistoryVisible && (
<div className={`${styles.chatContainer} ${chatHistoryVisible ? styles.chatVisible : ""}`}>
<div className={styles.chatHeader}>Chat History</div>
<div className={styles.messages}>
{chatHistories.map(history => (
<div key={history.id} className={styles.message}>
<span>{history.summary}</span>
<button onClick={() => reloadChat(history.id)}>🔄</button>
</div>
))}
</div>
<button onClick={toggleChatHistory} className={styles.closeButton}>Close</button>
</div>
)}
</>
);
};
Expand Down

0 comments on commit 436743b

Please sign in to comment.