Skip to content

Commit

Permalink
feat: add frontend closes #76
Browse files Browse the repository at this point in the history
  • Loading branch information
HunorTotBagi committed Sep 24, 2024
1 parent 2ba926e commit 78f8f35
Show file tree
Hide file tree
Showing 35 changed files with 22,811 additions and 0 deletions.
20,970 changes: 20,970 additions & 0 deletions frontend/package-lock.json

Large diffs are not rendered by default.

48 changes: 48 additions & 0 deletions frontend/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
{
"name": "school-management-system",
"version": "0.1.0",
"private": true,
"dependencies": {
"@testing-library/jest-dom": "^5.17.0",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"react": "^18.3.1",
"react-dom": "^18.3.1",
"react-scripts": "5.0.1",
"web-vitals": "^2.1.4",
"@auth-kit/react-router": "^3.1.3",
"@emotion/react": "^11.13.3",
"@emotion/styled": "^11.13.0",
"@fontsource/roboto": "^5.0.14",
"@mui/icons-material": "^6.0.1",
"@mui/material": "^6.0.1",
"axios": "^1.7.5",
"immer": "^10.1.1",
"react-router-dom": "^6.26.1",
"use-immer": "^0.10.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
Binary file added frontend/public/favicon.ico
Binary file not shown.
43 changes: 43 additions & 0 deletions frontend/public/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<link rel="icon" href="%PUBLIC_URL%/favicon.ico" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="theme-color" content="#000000" />
<meta
name="description"
content="Web site created using create-react-app"
/>
<link rel="apple-touch-icon" href="%PUBLIC_URL%/logo192.png" />
<!--
manifest.json provides metadata used when your web app is installed on a
user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" />
<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Only files inside the `public` folder can be referenced from the HTML.
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<title>School Management System</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
You can add webfonts, meta tags, or analytics to this file.
The build step will place the bundled scripts into the <body> tag.
To begin the development, run `npm start` or `yarn start`.
To create a production bundle, use `npm run build` or `yarn build`.
-->
</body>
</html>
Binary file added frontend/public/logo192.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added frontend/public/logo512.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
25 changes: 25 additions & 0 deletions frontend/public/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"short_name": "React App",
"name": "Create React App Sample",
"icons": [
{
"src": "logo192.png",
"sizes": "64x64 32x32 24x24 16x16",
"type": "image/x-icon"
},
{
"src": "logo192.png",
"type": "image/png",
"sizes": "192x192"
},
{
"src": "logo512.png",
"type": "image/png",
"sizes": "512x512"
}
],
"start_url": ".",
"display": "standalone",
"theme_color": "#000000",
"background_color": "#ffffff"
}
3 changes: 3 additions & 0 deletions frontend/public/robots.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# https://www.robotstxt.org/robotstxt.html
User-agent: *
Disallow:
137 changes: 137 additions & 0 deletions frontend/src/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
import { createBrowserRouter, RouterProvider } from 'react-router-dom';
import { getSubjects } from './HelperFunctions/SubjectEndpoints';
import { getParents} from './HelperFunctions/ParentEndpoints';
import { useState } from 'react';
import { createTheme, ThemeProvider } from '@mui/material';
import './Css/App.css';

import ErrorPage from './components/ErrorPage';
import MainPage from './components/MainPage';
import StartPage from './components/StartPage';

import EditSubject from './components/Subject/EditSubject';
import NewSubject from './components/Subject/NewSubject';
import Subjects from './components/Subject/Subjects';

import EditParent from './components/Parent/EditParent';
import NewParent from './components/Parent/NewParent';
import Parents from './components/Parent/Parents';

import Storage from './Store/Storage';

const loadData = async (request, item) => {
let url = new URL(request.url);
let q = url.searchParams.get('q');

let response;

const username = localStorage.getItem('username');
const password = localStorage.getItem('password');

if (item === 'subjects') {
response = await getSubjects(username, password);
}

if (item === 'parents') {
response = await getParents(username, password);
}

if (!q || q === '') {
return response.data;
} else {
return response.data.filter((v) => {
let w = q.toLowerCase();
let r;

if (item === 'subjects') {
r = v.name.toLowerCase().includes(w);
}

if (item === 'parents') {
r =
v.firstName.toLowerCase().includes(w) ||
v.lastName.toLowerCase().includes(w);
}

return r;
});
}
};

const router = createBrowserRouter([
{
path: '/',
element: <MainPage />,
errorElement: <ErrorPage />,

children: [
{
index: true,
element: <StartPage />,
},
{
path: 'subjects',
element: <Subjects />,
loader: ({ request }) => {
return loadData(request, 'subjects');
},
},
{
path: 'parents',
element: <Parents />,
loader: ({ request }) => {
return loadData(request, 'parents');
},
},
{
path: 'newsubject',
element: <NewSubject />,
},
{
path: 'newparent',
element: <NewParent />,
},
{
path: 'editsubject',
element: <EditSubject />,
},
{
path: 'editparent',
element: <EditParent />,
},
],
},
]);

function App() {
const [isLoggedIn, setIsLoggedIn] = useState(false);
const [isComicSans, setIsComicSans] = useState(false);
const [role, setRole] = useState('');

const theme = createTheme({
typography: {
fontFamily: isComicSans
? 'cursive'
: 'Verdana, Geneva, Tahoma, sans-serif',
},
});

return (
<ThemeProvider theme={theme}>
<Storage.Provider
value={{
isLoggedIn: isLoggedIn,
setIsLoggedIn: setIsLoggedIn,
role: role,
setRole: setRole,
isComicSans: isComicSans,
setIsComicSans: setIsComicSans,
}}
>
<RouterProvider router={router} />;
</Storage.Provider>
</ThemeProvider>
);
}

export default App;
8 changes: 8 additions & 0 deletions frontend/src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import { render, screen } from '@testing-library/react';
import App from './App';

test('renders learn react link', () => {
render(<App />);
const linkElement = screen.getByText(/learn react/i);
expect(linkElement).toBeInTheDocument();
});
33 changes: 33 additions & 0 deletions frontend/src/Css/App.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
.root-page {
display: flex;
flex-direction: column;
min-height: 90vh;
justify-content: flex-start;
}

.page-content {
display: flex;
gap: 20px;
margin-top: 20px;
}

.navigation {
width: 250px;
border-right: 1px solid #e0e0e0;
}

.outlet {
flex-grow: 1;
}

@media (max-width: 768px) {
.page-content {
flex-direction: column;
}

.navigation {
width: 100%;
border: none;
border-bottom: 1px solid #e0e0e0;
}
}
18 changes: 18 additions & 0 deletions frontend/src/Css/EditSubject.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.edit-subject-page {
display: flex;
flex-direction: column;
gap: 20px;
margin-top: 20px;
}

.form-container {
display: flex;
flex-direction: column;
gap: 20px;
}

@media (max-width: 768px) {
.edit-subject-page {
padding: 10px;
}
}
18 changes: 18 additions & 0 deletions frontend/src/Css/NewSubject.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
.new-subject-page {
display: flex;
flex-direction: column;
gap: 20px;
margin-top: 20px;
}

.form-container {
display: flex;
flex-direction: column;
gap: 20px;
}

@media (max-width: 768px) {
.new-subject-page {
padding: 10px;
}
}
29 changes: 29 additions & 0 deletions frontend/src/Css/Subject.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
.subject-page {
display: flex;
flex-direction: column;
gap: 20px;
padding: 20px;
border: 1px solid #e0e0e0;
border-radius: 8px;
background-color: #f9f9f9;
margin-top: 20px;
}

.subject-details {
margin-top: 20px;
}

.admin-actions {
display: flex;
gap: 10px;
}

@media (max-width: 768px) {
.subject-page {
padding: 10px;
}

.admin-actions {
flex-direction: column;
}
}
22 changes: 22 additions & 0 deletions frontend/src/Css/Subjects.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
.subjects-page {
display: flex;
flex-direction: column;
gap: 20px;
margin-top: 20px;
}

.subjects-container {
display: flex;
flex-direction: column;
gap: 20px;
}

.search-bar {
width: 100%;
}

@media (max-width: 768px) {
.subjects-page {
padding: 10px;
}
}
Loading

0 comments on commit 78f8f35

Please sign in to comment.