Skip to content

Commit

Permalink
update for sprint
Browse files Browse the repository at this point in the history
  • Loading branch information
JannisSideras committed Oct 22, 2024
1 parent fe47e52 commit c1cc1ce
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 6 deletions.
16 changes: 16 additions & 0 deletions logic/frontend/web/src/app/logout/page.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"use client"

import {useUser} from "@/provider/UserProvider";
import {useEffect} from "react";

export default function Page() {
const {logout} = useUser();

useEffect(() => {
logout();
}, []);

return (
<></>
);
}
5 changes: 3 additions & 2 deletions logic/frontend/web/src/app/profile/[slug]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default function Page({ params }: { params: { slug: string } }) {
display: "flex",
flexDirection: "column",
alignItems: "center",
overflowY: "scroll",
}}
>
<Grid container spacing={2} justifyContent="center" alignItems="center" sx={{mb: 4, width: '100%'}}>
Expand Down Expand Up @@ -123,13 +124,13 @@ export default function Page({ params }: { params: { slug: string } }) {
) : (
posts.map((post, index) => (
<Grid item xs={12} key={index}>
<Card sx={{bgcolor: "#2E2F55"}}>
<Card sx={{bgcolor: "#2E2F55", color: "#fff"}}>
<CardContent>
<Typography variant="h6">{post.title}</Typography>
<Typography variant="body2">{post.definition}</Typography>
<Box display="flex" justifyContent="space-between" alignItems="center" mt={2}>
<Typography variant="caption" sx={{color: "#C0C0C0"}}>
{new Date(post.createdOn).toLocaleDateString()}
{post.createdOn}
</Typography>
<Button
variant="outlined"
Expand Down
8 changes: 5 additions & 3 deletions logic/frontend/web/src/app/profile/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ export default function Page() {
axios.get(`https://www.boast.social/api/posts/${postId}`)
));

console.log(postResponses)

setPosts(postResponses.map(res => res.data));
} catch (error) {
console.error("Error fetching profile or posts:", error);
Expand Down Expand Up @@ -64,10 +66,10 @@ export default function Page() {
bgcolor="#1A1C40"
color="white"
sx={{
minHeight: "100vh",
display: "flex",
flexDirection: "column",
alignItems: "center",
overflowY: "scroll",
}}
>
<Grid container spacing={2} justifyContent="center" alignItems="center" sx={{mb: 4, width: '100%'}}>
Expand Down Expand Up @@ -116,13 +118,13 @@ export default function Page() {
) : (
posts.map((post, index) => (
<Grid item xs={12} key={index}>
<Card sx={{bgcolor: "#2E2F55"}}>
<Card sx={{bgcolor: "#2E2F55", color: "#fff"}}>
<CardContent>
<Typography variant="h6">{post.title}</Typography>
<Typography variant="body2">{post.definition}</Typography>
<Box display="flex" justifyContent="space-between" alignItems="center" mt={2}>
<Typography variant="caption" sx={{color: "#C0C0C0"}}>
{new Date(post.createdOn).toLocaleString()}
{post.createdOn}
</Typography>
<Button
variant="outlined"
Expand Down
2 changes: 1 addition & 1 deletion logic/frontend/web/src/component/SideBarComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export default function SideBarComponent() {


{/* Logout Section */}
<Link href="/" style={{ textDecoration: 'none', marginTop: "auto", marginLeft: "2rem" }}>
<Link href="/logout" style={{ textDecoration: 'none', marginTop: "auto", marginLeft: "2rem" }}>
<List>
<ListItem>
<ListItemIcon sx={{ color: "#8691C3" }}>
Expand Down
1 change: 1 addition & 0 deletions logic/frontend/web/src/provider/UserProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ export const UserProvider = ({ children }: UserProviderProps) => {
};

const logout = () => {
console.log("logout")
setUser(null);
localStorage.removeItem('user');
router.push('/login');
Expand Down

0 comments on commit c1cc1ce

Please sign in to comment.