Skip to content

Commit

Permalink
Merge pull request #71 from JimTheCat/CU-8696ybq3g_Integrate-Frontend…
Browse files Browse the repository at this point in the history
…-with-Backend_Patryk-Kosiski

feature: Integrate FE with BE
  • Loading branch information
JimTheCat authored Dec 11, 2024
2 parents bef37de + 12c2855 commit d94d510
Show file tree
Hide file tree
Showing 24 changed files with 437 additions and 138 deletions.
2 changes: 2 additions & 0 deletions frontend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# .env.development
VITE_API_URL=http://localhost:8080
88 changes: 80 additions & 8 deletions frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,18 @@
"@tiptap/pm": "^2.10.0",
"@tiptap/react": "^2.10.0",
"@tiptap/starter-kit": "^2.10.0",
"axios": "^1.7.9",
"dayjs": "^1.11.13",
"i18next": "^23.16.1",
"jwt-decode": "^4.0.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-i18next": "^15.0.3",
"react-router": "^6.27.0",
"react-router-dom": "^6.27.0",
"react-tsparticles": "^2.12.2",
"tsparticles": "^2.12.0"
"tsparticles": "^2.12.0",
"zustand": "^5.0.2"
},
"devDependencies": {
"@eslint/js": "^9.11.1",
Expand Down
File renamed without changes
28 changes: 28 additions & 0 deletions frontend/src/Components/Buttons/LogOut/LogOut.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import {Button} from "@mantine/core";
import {IconLogout} from "@tabler/icons-react";
import {useAuthStore} from "../../../Services/authStore.ts";
import {useNavigate} from "react-router-dom";

export const LogOut = () => {

const auth = useAuthStore();
const navigate = useNavigate();

return (
<Button
variant={"subtle"}
size={"md"}
leftSection={<IconLogout/>}
autoContrast
fullWidth
justify={"flex-start"}
color={"gray"}
onClick={() => {
auth.logout();
navigate('/login');
}}
>
Wyloguj się
</Button>
);
}
Empty file.
16 changes: 16 additions & 0 deletions frontend/src/Components/CenterContainer/CenterContainer.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import {Center, Flex} from "@mantine/core";
import React from "react";

type ICenterContainer = {
children: React.ReactNode;
}

export const CenterContainer = (props: ICenterContainer) => {
return (
<Center h={'100vh'}>
<Flex direction={'column'} align={'center'} justify={'center'}>
{props.children}
</Flex>
</Center>
);
}
1 change: 1 addition & 0 deletions frontend/src/Components/CenterContainer/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './CenterContainer';
4 changes: 4 additions & 0 deletions frontend/src/Components/ContainerVhVw/ContainerVhVw.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ interface IContainerVhVw {
children: ReactNode;
}

/**
* @deprecated ContainerVhVw is deprecated due to bugs with displaying children nodes with raw html components and Mantine dependency.
* Use CenterContainer instead which is more stable and is fully based on Mantine.
*/
export const ContainerVhVw = (props: IContainerVhVw) => {
return (
<div style={{width: props.vw + 'vw', height: props.vh + 'vh'}}>
Expand Down
1 change: 1 addition & 0 deletions frontend/src/Components/InnerHtmlHandler/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './InnerHtmlHandler';
21 changes: 15 additions & 6 deletions frontend/src/Components/Navbar/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import {AppShell, Avatar, Box, Card, Group, Image, Stack, Text} from "@mantine/core";
import MeowHubLogo from "../../../public/mh_logo.svg";
import MeowHubLogo from "../../Assets/mh_logo.svg";
import {MenuButton} from "../Buttons/Menu";
import {
IconHome,
IconLogout,
IconMail,
IconPencil,
IconSettings,
Expand All @@ -13,17 +12,27 @@ import {
IconUsersGroup,
IconZoom
} from "@tabler/icons-react";
import {LogOut} from "../Buttons/LogOut/LogOut.tsx";
import {useAuthStore} from "../../Services/authStore.ts";
import {useNavigate} from "react-router-dom";

export const Navbar = () => {

const nickname = "Placeholder name";
const auth = useAuthStore();
const nickname = auth.user?.login;
const navigate = useNavigate();

const handleProfileClick = () => {
navigate(`/profile/${auth.user?.tag}`);
}

return (
<>

{/*Logo*/}
<AppShell.Section>
<Card p={"xs"} mb={"lg"} withBorder radius={"md"}>
<Card p={"xs"} mb={"lg"} withBorder radius={"md"} style={{cursor: "pointer"}}
onClick={() => navigate("/mainpage")}>
<Image
src={MeowHubLogo}
alt="MeowHub Logo"
Expand All @@ -35,7 +44,7 @@ export const Navbar = () => {

{/*Profile*/}
<AppShell.Section>
<Card p={"xs"} withBorder>
<Card p={"xs"} withBorder style={{cursor: "pointer"}} onClick={handleProfileClick}>
<Group>
<Avatar radius={180} size={"xl"}/>
<Stack justify={"center"} gap={0}>
Expand Down Expand Up @@ -69,7 +78,7 @@ export const Navbar = () => {
</Box>
<Box>
<MenuButton icon={<IconSettings/>} text={"Ustawienia"} href={"/settings"}/>
<MenuButton icon={<IconLogout/>} text={"Wyloguj się"}/>
<LogOut/>
</Box>
</Stack>
</Card>
Expand Down
8 changes: 8 additions & 0 deletions frontend/src/Components/ProtectedRoute/ProtectedRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import React from 'react';
import {Navigate, Outlet} from 'react-router-dom';
import {useAuthStore} from "../../Services/authStore.ts";

export const ProtectedRoute: React.FC = () => {
const {token} = useAuthStore();
return token ? <Outlet/> : <Navigate to="/login"/>;
};
1 change: 1 addition & 0 deletions frontend/src/Components/ProtectedRoute/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './ProtectedRoute';
14 changes: 14 additions & 0 deletions frontend/src/Components/PublicRoute/PublicRoute.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import React from "react";
import {Navigate, Outlet} from "react-router-dom";

interface PublicRouteProps {
isAuthenticated: boolean;
redirectPath?: string;
}

export const PublicRoute: React.FC<PublicRouteProps> = ({isAuthenticated, redirectPath = "/mainpage",}) => {
if (isAuthenticated) {
return <Navigate to={redirectPath} replace/>;
}
return <Outlet/>;
};
1 change: 1 addition & 0 deletions frontend/src/Components/PublicRoute/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './PublicRoute';
1 change: 1 addition & 0 deletions frontend/src/Components/RichEditor/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './RichEditor';
Loading

0 comments on commit d94d510

Please sign in to comment.