Skip to content

Commit be4e476

Browse files
committed
Created Header
1 parent 8ae7fe8 commit be4e476

File tree

13 files changed

+576
-20
lines changed

13 files changed

+576
-20
lines changed

package-lock.json

Lines changed: 363 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,11 @@
1313
"@types/react": "^17.0.41",
1414
"@types/react-dom": "^17.0.14",
1515
"axios": "^0.26.1",
16+
"bootstrap": "^5.1.3",
1617
"i": "^0.3.7",
1718
"npm": "^8.5.5",
1819
"react": "^17.0.2",
20+
"react-bootstrap": "^2.2.1",
1921
"react-dom": "^17.0.2",
2022
"react-redux": "^7.2.6",
2123
"react-router-dom": "^6.2.2",

src/App.css

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
color: #61dafb;
2929
}
3030

31+
3132
@keyframes App-logo-spin {
3233
from {
3334
transform: rotate(0deg);
@@ -36,3 +37,4 @@
3637
transform: rotate(360deg);
3738
}
3839
}
40+

src/App.tsx

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,41 @@
11
import React from 'react';
2-
import {BrowserRouter as Router} from 'react-router-dom';
3-
import {MsalAuthenticationTemplate} from '@azure/msal-react';
4-
import {InteractionType} from "@azure/msal-browser";
5-
import {authRequest} from "./config/msalConfig";
2+
import { MsalAuthenticationTemplate, useMsal } from '@azure/msal-react';
3+
import { InteractionType } from "@azure/msal-browser";
4+
import { authRequest } from "./config/msalConfig";
5+
import Header from './component/Header';
6+
import { BrowserRouter, Link, Route, Routes } from "react-router-dom";
7+
import headerLogo from './pictures/logo-dialogdata.png'
8+
import { Button, Container, Nav, Navbar, NavbarBrand, NavDropdown } from 'react-bootstrap';
9+
import 'bootstrap/dist/css/bootstrap.min.css';
10+
import { useSelector } from 'react-redux';
11+
import { selectLoggedInUser } from './store/employee/employeeSelectors';
12+
import Input from './component/projects/input';
13+
import ProjectList from './component/projects/list';
14+
import Page from './component/page';
15+
616

717
const App = () => {
818

9-
// @ts-ignore
10-
const ErrorComponent = ({error}) => {
11-
return <p>An Error Occurred: {error}</p>;
12-
}
13-
14-
return (
15-
<MsalAuthenticationTemplate
16-
interactionType={InteractionType.Redirect}
17-
authenticationRequest={authRequest}
18-
errorComponent={ErrorComponent}>
19-
<h1>Test</h1>
20-
</MsalAuthenticationTemplate>
21-
);
19+
20+
// @ts-ignore
21+
const ErrorComponent = (error:any) => {
22+
return <p>An Error Occurred: {error.error}</p>;
23+
}
24+
25+
26+
27+
28+
29+
30+
31+
return (
32+
<MsalAuthenticationTemplate
33+
interactionType={InteractionType.Redirect}
34+
authenticationRequest={authRequest}
35+
errorComponent={ErrorComponent}>
36+
<Page/>
37+
</MsalAuthenticationTemplate>
38+
);
2239
};
2340

2441
export default App;

src/component/Header.tsx

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import React from "react";
2+
import { useSelector } from "react-redux";
3+
import { useMsal } from "@azure/msal-react";
4+
import { selectLoggedInUser } from "../store/employee/employeeSelectors";
5+
import headerLogo from '../pictures/logo-dialogdata.png'
6+
import { msalConfiguration } from "../config/msalConfig";
7+
8+
const Header = () => {
9+
10+
const msal = useMsal()
11+
12+
return (
13+
<h1>Welcome back {msal.accounts[0].name}</h1>
14+
)
15+
};
16+
17+
export default Header;

src/component/SignInButton.jsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React from "react";
2+
import { useMsal } from "@azure/msal-react";
3+
import Button from "react-bootstrap/Button";
4+
import { loginRequest } from "../config/msalConfig";
5+
6+
function handleLogin(instance) {
7+
instance.loginPopup(loginRequest).catch(e => {
8+
console.error(e);
9+
});
10+
}
11+
12+
export const SignInButton = () => {
13+
const { instance } = useMsal();
14+
15+
return (
16+
<Button variant="secondary" className="ml-auto" onClick={() => handleLogin(instance)}>Sign In</Button>
17+
)
18+
19+
}

src/component/page.tsx

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
import React from "react";
2+
import { Button, Container, Nav, Navbar, NavbarBrand, NavDropdown } from 'react-bootstrap';
3+
import { useSelector } from 'react-redux';
4+
import { selectLoggedInUser } from '../store/employee/employeeSelectors';
5+
import { MsalAuthenticationTemplate, useMsal } from '@azure/msal-react';
6+
import { BrowserRouter, Link, Route, Routes } from "react-router-dom";
7+
import Header from "./Header";
8+
import ProjectList from "./projects/list";
9+
10+
const Page = () => {
11+
const msal = useMsal()
12+
console.log(msal)
13+
// @ts-ignore
14+
const ErrorComponent = ({ error }) => {
15+
return <p>An Error Occurred: {error}</p>;
16+
}
17+
18+
const employee = useSelector(selectLoggedInUser)
19+
const {instance, accounts} = useMsal();
20+
21+
const logOutHandler = () => {
22+
const logOutRequest = {
23+
account: accounts[0],
24+
postLogoutRedirectUri: "/projects"
25+
}
26+
instance.logoutRedirect(logOutRequest)
27+
28+
};
29+
30+
return (
31+
<div>
32+
<Button onClick={logOutHandler}>Log out</Button>
33+
<Navbar bg="light" expand="lg">
34+
<Container>
35+
<Navbar.Brand href="#home">
36+
</Navbar.Brand>
37+
<Navbar.Toggle aria-controls="basic-navbar-nav" />
38+
<Navbar.Collapse id="basic-navbar-nav">
39+
<Nav className="me-auto">
40+
<Nav.Link href="">Home</Nav.Link>
41+
<Nav.Link href="projects">Projects</Nav.Link>
42+
<Nav.Link href="mission-assignments">Mission assignments</Nav.Link>
43+
<Nav.Link href="business-domains">Business Domains</Nav.Link>
44+
<NavDropdown title="Dropdown" id="basic-nav-dropdown">
45+
<NavDropdown.Item href="#action/3.1">Action</NavDropdown.Item>
46+
<NavDropdown.Item href="#action/3.2">Another action</NavDropdown.Item>
47+
<NavDropdown.Item href="#action/3.3">Something</NavDropdown.Item>
48+
<NavDropdown.Divider />
49+
</NavDropdown>
50+
</Nav>
51+
</Navbar.Collapse>
52+
</Container>
53+
</Navbar>
54+
55+
56+
<Routes>
57+
<Route path="" element={<Header />} />
58+
<Route path="/projects" element={<ProjectList/>} />
59+
<Route path="/mission-assignments" />
60+
<Route path="/business-domains" />
61+
</Routes>
62+
</div>
63+
)
64+
65+
}
66+
67+
export default Page;

src/component/projects/input.tsx

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import React, { useState } from "react";
2+
3+
const Input = (props:any) => {
4+
const [userInput, setUserInput] = useState('');
5+
6+
function removeUserInput() {
7+
setUserInput('')
8+
}
9+
10+
return (
11+
<div>
12+
<input type="text" placeholder="New Project" value={props.userInput} onChange={ (event) => setUserInput(event.target.value)} />
13+
<span onClick={ () => {props.addToDo(userInput); removeUserInput()} }/>Add Project
14+
15+
</div>
16+
)
17+
}
18+
19+
export default Input;

src/component/projects/list.tsx

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import React, { useState } from "react";
2+
import { Button } from "react-bootstrap";
3+
import Input from "./input";
4+
5+
const ProjectList = () => {
6+
7+
/* const testObject = {
8+
text: "Hallo"
9+
10+
}
11+
12+
const [projectListArray, setprojectListArry] = useState([testObject]) */
13+
14+
15+
return (
16+
17+
18+
<div>
19+
<h2>Test</h2>
20+
<Button>Test</Button>
21+
</div>
22+
23+
24+
)
25+
26+
27+
}
28+
29+
export default ProjectList;

src/component/projects/listItem.tsx

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import React, { useState } from "react";
2+
3+
function projectListItem(props:any) {
4+
5+
const [isEditModeOn, setEditModeOn] = useState(false);
6+
7+
return (
8+
<li>
9+
10+
</li>
11+
)
12+
13+
14+
}

src/config/msalConfig.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@ import {Configuration} from '@azure/msal-browser';
22

33
export const msalConfiguration: Configuration = {
44
auth: {
5-
clientId: '',
6-
authority: ''
5+
clientId: 'c30dc17f-54f5-4c59-98c3-83a254a5264a',
6+
authority: 'https://login.microsoftonline.com/3bed001c-7aa5-43a6-becc-1fc2f7c94a75'
77
}
88
};
99

1010
export const authRequest = {
1111
scopes: ['openid', 'profile']
12+
};
13+
14+
export const loginRequest = {
15+
scopes: ["User.Read"]
1216
};

src/index.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,17 @@ import App from "./App";
66
import React from "react";
77
import {MsalProvider} from "@azure/msal-react";
88
import ReactDOM from "react-dom";
9+
import { BrowserRouter } from "react-router-dom";
910

1011
const pca = new PublicClientApplication(msalConfiguration);
1112

1213
const ProjectsApp = () => (
1314
<React.StrictMode>
1415
<Provider store={store}>
1516
<MsalProvider instance={pca}>
16-
<App/>
17+
<BrowserRouter>
18+
<App/>
19+
</BrowserRouter>
1720
</MsalProvider>
1821
</Provider>
1922
</React.StrictMode>

src/pictures/logo-dialogdata.png

3.62 KB
Loading

0 commit comments

Comments
 (0)