Skip to content
Snippets Groups Projects
Commit 125bb28a authored by Leander Tolksdorf's avatar Leander Tolksdorf
Browse files

Pretty big commit. What I've done:

- Split server and client into two separate packages.
- Update README with info on how to start dev server locally
- Client
	- Update react-router-dom to v6
	- Separate page components from UI components
	- Add "proxy" field to package.json for proxying api requests to the backend server
- Server
	- Update path of static file serving to new client directory
	- Update scripts
parent 77d11f52
No related branches found
No related tags found
No related merge requests found
Showing
with 42895 additions and 16686 deletions
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
# dependencies
/node_modules
/.pnp
.pnp.js
# testing
/coverage
# production
/build
# misc
.DS_Store
.env.local
.env.development.local
.env.test.local
.env.production.local
npm-debug.log*
yarn-debug.log*
yarn-error.log*
# Getting Started with Create React App
This project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).
## Available Scripts
In the project directory, you can run:
### `npm start`
Runs the app in the development mode.\
Open [http://localhost:3000](http://localhost:3000) to view it in the browser.
The page will reload if you make edits.\
You will also see any lint errors in the console.
### `npm test`
Launches the test runner in the interactive watch mode.\
See the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.
### `npm run build`
Builds the app for production to the `build` folder.\
It correctly bundles React in production mode and optimizes the build for the best performance.
The build is minified and the filenames include the hashes.\
Your app is ready to be deployed!
See the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.
### `npm run eject`
**Note: this is a one-way operation. Once you `eject`, you can’t go back!**
If you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.
Instead, it will copy all the configuration files and the transitive dependencies (webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.
You don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.
## Learn More
You can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).
To learn React, check out the [React documentation](https://reactjs.org/).
This diff is collapsed.
{
"name": "client",
"version": "0.1.0",
"private": true,
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.16",
"@testing-library/jest-dom": "^5.15.0",
"@testing-library/react": "^11.2.7",
"@testing-library/user-event": "^12.8.3",
"@types/jest": "^26.0.24",
"@types/node": "^12.20.36",
"@types/react": "^17.0.34",
"@types/react-dom": "^17.0.11",
"bootstrap": "^5.1.3",
"formik": "^2.2.9",
"react": "^17.0.2",
"react-bootstrap": "^2.0.2",
"react-dom": "^17.0.2",
"react-router-dom": "^6.0.1",
"react-scripts": "4.0.3",
"sass": "^1.43.4",
"typescript": "^4.4.4",
"web-vitals": "^1.1.2",
"yup": "^0.32.11"
},
"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"
]
}
}
<!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>React App</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>
\ No newline at end of file
import React from "react";
import { BrowserRouter, Routes, Route } from "react-router-dom";
import Header from "./components/Header";
import Home from "./pages/Home";
import VehicleTypes from "./pages/VehicleTypes";
import CreateLogEntry from "./pages/CreateLogEntry";
function Router() {
return (
<BrowserRouter>
<Header />
<div className="mainView">
<Routes>
<Route path="/">
<Route index element={<Home />} />
<Route path="qr">
<Route path=":vehicleId" element={<CreateLogEntry />} />
</Route>
<Route path="vehicleTypes" element={<VehicleTypes />} />
<Route path="login" element={null} />
</Route>
</Routes>
</div>
</BrowserRouter>
);
}
export default Router;
import React from "react"; import React from "react";
import Navbar from "react-bootstrap/Navbar"; import { Navbar, Container, Nav } from "react-bootstrap";
import Container from "react-bootstrap/Container";
import Nav from "react-bootstrap/Nav";
import { Link } from "react-router-dom"; import { Link } from "react-router-dom";
function Header() { function Header() {
......
import React from "react";
import ReactDOM from "react-dom";
import Router from "./Router";
import "./styles/app.scss";
ReactDOM.render(
<React.StrictMode>
<Router />
</React.StrictMode>,
document.getElementById("root")
);
import React from "react"; import React from "react";
import Form from "react-bootstrap/Form"; import { useParams } from "react-router-dom";
import Row from "react-bootstrap/Row";
import Col from "react-bootstrap/Col";
import Button from "react-bootstrap/Button";
import { useFormik } from "formik"; import { useFormik } from "formik";
import * as Yup from "yup"; import * as Yup from "yup";
import { useParams } from "react-router-dom"; import { Col, Form, Row, Button } from "react-bootstrap";
function VehicleInfo() { function VehicleInfo() {
const { vehicleId } = useParams<{ vehicleId: string }>(); const { vehicleId } = useParams();
return ( return (
<div> <div>
<h3>ID: {vehicleId}</h3> <h3>ID: {vehicleId}</h3>
......
import React from "react";
function Home() {
return <div>Home</div>;
}
export default Home;
...@@ -10,7 +10,7 @@ function VehicleTypes() { ...@@ -10,7 +10,7 @@ function VehicleTypes() {
{ id: number; name: string; seats: number; image: string }[] { id: number; name: string; seats: number; image: string }[]
>([]); >([]);
const [add, setAdd] = useState(false); const [add, setAdd] = useState(false);
const [removeId, setRemoveId] = useState<number>(null); const [removeId, setRemoveId] = useState<number | null>(null);
useEffect(() => { useEffect(() => {
reloadData(); reloadData();
...@@ -65,7 +65,7 @@ function VehicleTypes() { ...@@ -65,7 +65,7 @@ function VehicleTypes() {
<Modal.Body> <Modal.Body>
<p> <p>
Remove VehicleType " Remove VehicleType "
{vehicleTypes.find((x) => x.id == removeId).name}"? {/* {vehicleTypes.find((x) => x.id == removeId).name}"? */}
</p> </p>
</Modal.Body> </Modal.Body>
<Modal.Footer> <Modal.Footer>
...@@ -161,7 +161,7 @@ function VehicleTypes() { ...@@ -161,7 +161,7 @@ function VehicleTypes() {
<FontAwesomeIcon <FontAwesomeIcon
className={"text-danger text-center iconHover"} className={"text-danger text-center iconHover"}
onClick={() => { onClick={() => {
this.setState({ removeId: t.id }); setRemoveId(t.id);
}} }}
title="Remove" title="Remove"
icon={faTrash} icon={faTrash}
......
/// <reference types="react-scripts" />
...@@ -31,4 +31,4 @@ $theme-colors: ( ...@@ -31,4 +31,4 @@ $theme-colors: (
} }
} }
@import '../../../node_modules/bootstrap/dist/css/bootstrap.css'; @import 'bootstrap/dist/css/bootstrap.css';
{
"compilerOptions": {
"target": "es5",
"lib": [
"dom",
"dom.iterable",
"esnext"
],
"allowJs": true,
"skipLibCheck": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"strict": true,
"forceConsistentCasingInFileNames": true,
"noFallthroughCasesInSwitch": true,
"module": "esnext",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"noEmit": true,
"jsx": "react-jsx"
},
"include": [
"src"
]
}
This diff is collapsed.
{
"name": "swp-einhorn",
"version": "1.0.0",
"description": "",
"main": "dist/server.js",
"scripts": {
"build": "webpack",
"watch:build": "webpack -w",
"watch:server": "nodemon -r dotenv/config dist/server.js",
"dev": "npm-run-all --parallel watch:*",
"start": "node dist/server.js",
"test": "jest"
},
"author": "",
"license": "ISC",
"dependencies": {
"@fortawesome/fontawesome-svg-core": "^1.2.36",
"@fortawesome/free-solid-svg-icons": "^5.15.4",
"@fortawesome/react-fontawesome": "^0.1.16",
"bootstrap": "^5.1.3",
"dotenv": "^10.0.0",
"express": "^4.17.1",
"formik": "^2.2.9",
"pg": "^8.7.1",
"react": "^17.0.2",
"react-bootstrap": "^2.0.0",
"react-dom": "^17.0.2",
"react-router-dom": "^5.3.0",
"sass": "^1.43.4",
"sequelize": "^6.8.0",
"yup": "^0.32.11"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/jquery": "^3.5.8",
"@types/node": "^16.11.6",
"@types/react": "^17.0.33",
"@types/react-dom": "^17.0.10",
"@types/react-router-dom": "^5.3.2",
"concurrently": "^6.3.0",
"css-loader": "^6.5.0",
"eslint": "^8.1.0",
"eslint-webpack-plugin": "^3.1.0",
"jest": "^27.3.1",
"mocha": "^9.1.3",
"nodemon": "^2.0.14",
"npm-run-all": "^4.1.5",
"sass-loader": "^12.3.0",
"style-loader": "^3.3.1",
"supertest": "^6.1.6",
"ts-loader": "^9.2.6",
"webpack": "^5.60.0",
"webpack-cli": "^4.9.1",
"webpack-node-externals": "^3.0.0"
}
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>EFB - Einhorn</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
</head>
<body>
<div id="app"></div>
<script src="/js/app.js"></script>
</body>
</html>
File moved
This diff is collapsed.
{
"name": "server",
"version": "1.0.0",
"description": "",
"main": "./src/server.ts",
"scripts": {
"dev": "nodemon",
"build": "tsc",
"start": "node .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "ISC",
"dependencies": {
"dotenv": "^10.0.0",
"express": "^4.17.1",
"pg": "^8.7.1",
"sequelize": "^6.9.0"
},
"devDependencies": {
"@types/express": "^4.17.13",
"@types/node": "^16.11.6",
"@types/validator": "^13.6.6",
"nodemon": "^2.0.14",
"ts-node": "^10.4.0",
"typescript": "^4.4.4"
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment