Skip to content

Commit

Permalink
Merge branch 'initial-modifications' into feat/spring-api
Browse files Browse the repository at this point in the history
  • Loading branch information
Toto-hitori authored Feb 7, 2024
2 parents c3947c7 + 7390b7b commit d31584e
Show file tree
Hide file tree
Showing 17 changed files with 187 additions and 23 deletions.
3 changes: 3 additions & 0 deletions .idea/.gitignore

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

6 changes: 6 additions & 0 deletions .idea/misc.xml

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

8 changes: 8 additions & 0 deletions .idea/modules.xml

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

6 changes: 6 additions & 0 deletions .idea/vcs.xml

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

9 changes: 9 additions & 0 deletions .idea/wiq_en2b.iml

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

2 changes: 1 addition & 1 deletion sonar-project.properties
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ sonar.host.url=https://sonarcloud.io
sonar.language=js
sonar.projectName=wiq_en2b

sonar.coverage.exclusions=**/*.test.js
sonar.coverage.exclusions=**/*.test.js,**/*.test.jsx
sonar.sources=webapp/src/components,users/authservice,users/userservice,gatewayservice
sonar.sourceEncoding=UTF-8
sonar.exclusions=node_modules/**
Expand Down
7 changes: 7 additions & 0 deletions webapp/jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"compilerOptions": {
"baseUrl": "./src",
"checkJs": true,
"jsx": "react"
}
}
110 changes: 99 additions & 11 deletions webapp/package-lock.json

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

6 changes: 6 additions & 0 deletions webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@
"@testing-library/react": "^14.1.2",
"@testing-library/user-event": "^14.5.2",
"axios": "^1.6.5",
"dotenv": "^16.4.1",
"i18next": "^23.8.2",
"i18next-browser-languagedetector": "^7.2.0",
"i18next-http-backend": "^2.4.3",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-router": "^6.21.3",
"react-router-dom": "^6.21.3",
"react-scripts": "5.0.1",
"web-vitals": "^3.5.1"
},
Expand Down
4 changes: 2 additions & 2 deletions webapp/src/App.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React, { useState } from 'react';
import AddUser from './components/AddUser';
import Login from './components/Login';
import AddUser from './pages/Register';
import Login from './pages/Login';
import CssBaseline from '@mui/material/CssBaseline';
import Container from '@mui/material/Container';
import Typography from '@mui/material/Typography';
Expand Down
24 changes: 24 additions & 0 deletions webapp/src/components/Router.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import React from "react";
import {
createBrowserRouter
} from "react-router-dom";
import Root from "../pages/Root";
import Login from "../pages/Login";
import Register from "../pages/Register";

const router = createBrowserRouter([
{
path: "/",
element: <Root />,
},
{
path: "/login",
element: <Login />
},
{
path: "/register",
element: <Register />
}
]);

export default router;
4 changes: 3 additions & 1 deletion webapp/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,13 @@ import ReactDOM from 'react-dom/client';
import './index.css';
import App from './App';
import reportWebVitals from './reportWebVitals';
import { RouterProvider } from 'react-router-dom';
import router from 'components/Router';

const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(
<React.StrictMode>
<App />
<RouterProvider router={router} />
</React.StrictMode>
);

Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { Container, Typography, TextField, Button, Snackbar } from '@mui/materia

const apiEndpoint = process.env.REACT_APP_API_ENDPOINT || 'http://localhost:8000';

const AddUser = () => {
const Register = () => {
const [username, setUsername] = useState('');
const [password, setPassword] = useState('');
const [error, setError] = useState('');
Expand All @@ -27,7 +27,7 @@ const AddUser = () => {
return (
<Container component="main" maxWidth="xs" sx={{ marginTop: 4 }}>
<Typography component="h1" variant="h5">
Add User
Register
</Typography>
<TextField
name="username"
Expand All @@ -47,7 +47,7 @@ const AddUser = () => {
onChange={(e) => setPassword(e.target.value)}
/>
<Button variant="contained" color="primary" onClick={addUser}>
Add User
Register
</Button>
<Snackbar open={openSnackbar} autoHideDuration={6000} onClose={handleCloseSnackbar} message="User added successfully" />
{error && (
Expand All @@ -57,4 +57,4 @@ const AddUser = () => {
);
};

export default AddUser;
export default Register;
5 changes: 5 additions & 0 deletions webapp/src/pages/Root.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export default function Root() {
return <p>Proof of concept</p>
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render, fireEvent, screen, waitFor, act } from '@testing-library/react';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import Login from './Login';
import Login from '../pages/Login';

const mockAxios = new MockAdapter(axios);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import { render, fireEvent, screen, waitFor } from '@testing-library/react';
import axios from 'axios';
import MockAdapter from 'axios-mock-adapter';
import AddUser from './AddUser';
import AddUser from '../pages/Register';

const mockAxios = new MockAdapter(axios);

Expand All @@ -16,7 +16,7 @@ describe('AddUser component', () => {

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const addUserButton = screen.getByRole('button', { name: /Add User/i });
const addUserButton = screen.getByRole('button', { name: /Register/i });

// Mock the axios.post request to simulate a successful response
mockAxios.onPost('http://localhost:8000/adduser').reply(200);
Expand All @@ -39,7 +39,7 @@ describe('AddUser component', () => {

const usernameInput = screen.getByLabelText(/Username/i);
const passwordInput = screen.getByLabelText(/Password/i);
const addUserButton = screen.getByRole('button', { name: /Add User/i });
const addUserButton = screen.getByRole('button', { name: /Register/i });

// Mock the axios.post request to simulate an error response
mockAxios.onPost('http://localhost:8000/adduser').reply(500, { error: 'Internal Server Error' });
Expand Down

0 comments on commit d31584e

Please sign in to comment.