Skip to content

Commit

Permalink
Merge pull request #218 from Arquisoft/vira-statistics
Browse files Browse the repository at this point in the history
Changing user photo
  • Loading branch information
ritacatuxo authored Apr 24, 2024
2 parents 519177b + 3298539 commit 0a27c78
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
9 changes: 4 additions & 5 deletions webapp/src/components/general/SimpleNav.tsx
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@

import { Avatar, AvatarFallback, AvatarImage } from "../ui/avatar";
import React, { useState, useRef } from 'react';
import { useUserStore } from "../../stores/user-store";
import { Link } from "react-router-dom";
import { useUserStore } from '../../stores/user-store';


export const SimpleNav = () => {
let username : string = useUserStore(state => state.user?.username!);
let user = useUserStore(state => state.user!);

const getLinkStyle = ():string => {
return "text-text text-sm font-bold hover:text-primary transition-colors duration-300 ease-in-out"
Expand Down Expand Up @@ -38,11 +38,10 @@ export const SimpleNav = () => {
<div className="aspect-square h-12 px-5 py-3 flex items-center w-full justify-between border-b ">
<div className="flex items-center gap-5 ">
<Avatar className="w-9 h-9 rounded-full">
<AvatarImage src="https://pbs.twimg.com/media/Frq7CQ-WwAEnXzh?format=jpg&name=large" />
<AvatarFallback>CN</AvatarFallback>
<AvatarFallback className="AvatarFallback">{user.username.toUpperCase().charAt(0)}{user.username.toUpperCase().charAt(1)} </AvatarFallback>
</Avatar>
<div className="flex items-center gap-2 text-text text-sm font-thin ">
<h2 className="font-bold">{username}</h2>
<h2 className="font-bold">{user.username}</h2>

</div>
</div>
Expand Down
13 changes: 4 additions & 9 deletions webapp/src/components/stats/StatsTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,18 @@ import { getUser } from "../../services/auth-service";
import { useUserStore } from '../../stores/user-store';

export default function StatsTable() {


const [questionsAnswered ,setQuestionAnswered ] = useState<number>(0);
const [questionsCorrect, setQuestionCorrect] = useState<number>(0);
const [username, setUsername] = useState<string>();

useEffect(() => {
let username = useUserStore.getState().user?.username!;
console.log('username: ', username);
getUser(username).then((user) => {
console.log('LDKFLKDJF: ', user);
let user = useUserStore.getState().user;

if(user != null){
setQuestionAnswered(user.questions_answered);
setQuestionCorrect(user.correctly_answered_questions);
setUsername(user.username);
}).catch((error) => {
console.error('Error during retrieving the user', error);
});
}
} , []);


Expand Down

0 comments on commit 0a27c78

Please sign in to comment.