Skip to content

Commit

Permalink
add real friend count to Account page
Browse files Browse the repository at this point in the history
  • Loading branch information
annacai44 committed Jan 21, 2025
1 parent 304cad5 commit 8d2584c
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
4 changes: 3 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ function App() {
const [user, setUser] = useState(null);
const [userEmail, setUserEmail] = useState(null);
const [profilePic, setProfilePic] = useState(null);
const [friends, setFriends] = useState([]);

const isAuthenticated = DEV_MODE || user;

Expand Down Expand Up @@ -73,6 +74,7 @@ function App() {
userName={user}
userEmail={userEmail}
profilePic={profilePic}
friends={friends}
/>
: <Navigate to="/" />
}
Expand All @@ -89,7 +91,7 @@ function App() {
path="/my-friends"
element={
isAuthenticated
? <MyFriends user={user} />
? <MyFriends user={user} friends={friends} setFriends={setFriends} />
: <Navigate to="/" />
}
/>
Expand Down
4 changes: 2 additions & 2 deletions src/components/Account/Account.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { useNavigate } from 'react-router-dom';
import Avatar from '@mui/material/Avatar';
import "./Account.css";

function Account({ userName, userEmail, profilePic }) {
function Account({ userName, userEmail, profilePic, friends }) {
const navigate = useNavigate();

const signOut = () => {
Expand Down Expand Up @@ -80,7 +80,7 @@ function Account({ userName, userEmail, profilePic }) {
>
<CardContent>
<Typography variant="subtitle1">Friends:</Typography>
<Typography variant="h5" style={{ fontWeight: 'bold' }}>87</Typography>
<Typography variant="h5" style={{ fontWeight: 'bold' }}>{friends.length}</Typography>
</CardContent>
</Card>
</Box>
Expand Down
3 changes: 1 addition & 2 deletions src/components/Account/Friends/MyFriends.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import AppBar from '../../AppBar/AppBar';
import NavigationBar from '../../NavigationBar/NavigationBar';
import "./Friends.css";

function MyFriends({ user }) {
const [friends, setFriends] = useState([]);
function MyFriends({ user, friends, setFriends }) {

useEffect(() => {
if (!user) return;
Expand Down

0 comments on commit 8d2584c

Please sign in to comment.