Skip to content

Commit 7742b58

Browse files
committed
setting profile
1 parent 7af0764 commit 7742b58

File tree

14 files changed

+461
-307
lines changed

14 files changed

+461
-307
lines changed

client/package-lock.json

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

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"node-sass": "^7.0.1",
1919
"react": "^17.0.2",
2020
"react-dom": "^17.0.2",
21+
"react-router-dom": "^6.3.0",
2122
"react-scripts": "5.0.0",
2223
"typescript": "^4.4.2",
2324
"web-vitals": "^2.1.0"

client/src/App.tsx

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,23 @@ import CustomNavbar from './Common/CustomNavbar';
55
import ExistingUser from './Common/ExistingUser';
66
import LoadingScreen from './Common/LoadingScreen';
77
import NewUser from './Common/NewUser';
8+
import { BrowserRouter, Routes, Route } from 'react-router-dom';
89

910
function App() {
10-
const { isAuthenticated, isLoading } = useAuth0();
11+
const { isLoading } = useAuth0();
1112
return (
1213
<div className="App">
13-
<CustomNavbar />
14-
{isLoading ? (
15-
<LoadingScreen />
16-
) : isAuthenticated ? (
17-
<ExistingUser />
18-
) : (
19-
<NewUser />
20-
)}
14+
<BrowserRouter>
15+
<CustomNavbar />
16+
{isLoading ? (
17+
<LoadingScreen />
18+
) : (
19+
<Routes>
20+
<Route path="/" element={<NewUser />}></Route>
21+
<Route path="dashboard" element={<ExistingUser />}></Route>
22+
</Routes>
23+
)}
24+
</BrowserRouter>
2125
</div>
2226
);
2327
}

client/src/ClientServer.ts

Lines changed: 23 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,32 @@
1-
import requestWrapper from "./utils/requestWrapper";
2-
const baseUrl = "http://localhost:8080/api";
1+
import requestWrapper from './utils/requestWrapper';
2+
const baseUrl = 'http://localhost:8080/api';
33

44
export async function getProfile(data: { authId: string }) {
5-
const requestOptions = {
6-
url: `${baseUrl}/profile`,
7-
method: "POST",
8-
data,
9-
};
10-
return await requestWrapper(requestOptions);
5+
const requestOptions = {
6+
url: `${baseUrl}/profile`,
7+
method: 'POST',
8+
data,
9+
};
10+
return await requestWrapper(requestOptions);
1111
}
1212

1313
export async function createProfile(data: {
14-
authId: string;
15-
username: string;
14+
authId: string;
15+
username: string;
1616
}) {
17-
const requestOptions = {
18-
url: `${baseUrl}/create-profile`,
19-
method: "POST",
20-
data,
21-
};
22-
return await requestWrapper(requestOptions);
17+
const requestOptions = {
18+
url: `${baseUrl}/create-profile`,
19+
method: 'POST',
20+
data,
21+
};
22+
return await requestWrapper(requestOptions);
2323
}
2424

25-
export async function generateWorkflow(data?: number) {
26-
const requestOptions = {
27-
url: `${baseUrl}/workflows/generate`,
28-
method: "POST",
29-
data,
30-
};
31-
return await requestWrapper(requestOptions);
25+
export async function generateWorkflow(data: { authId: string }) {
26+
const requestOptions = {
27+
url: `${baseUrl}/workflows/generate`,
28+
method: 'POST',
29+
data,
30+
};
31+
return await requestWrapper(requestOptions);
3232
}

client/src/Common/Common.scss

Lines changed: 51 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -3,42 +3,58 @@ $textBlack: #272727;
33
$errorRed: #d32f2f;
44

55
.toolbar {
6-
display: flex;
7-
justify-content: space-between;
8-
background-color: $lightBlue;
9-
color: $textBlack;
10-
height: 3rem;
11-
.logo {
12-
max-height: 3rem;
13-
padding-right: 1rem;
14-
}
15-
.circle {
16-
height: 3rem;
17-
width: 3rem;
18-
border-radius: 50%;
19-
}
6+
display: flex;
7+
justify-content: space-between;
8+
background-color: $lightBlue;
9+
color: $textBlack;
10+
height: 3rem;
11+
.home {
12+
cursor: pointer;
13+
14+
.logo {
15+
max-height: 3rem;
16+
padding-right: 1rem;
17+
}
18+
}
19+
.circle {
20+
height: 3rem;
21+
width: 3rem;
22+
border-radius: 50%;
23+
}
24+
.link {
25+
margin-left: 1rem;
26+
}
2027
}
21-
.loading-screen {
22-
height: 70vh;
23-
width: 100vw;
28+
.loading-screen,
29+
.error-screen {
30+
height: 70vh;
31+
width: 100vw;
32+
33+
a {
34+
color: $lightBlue;
35+
text-decoration: underline;
36+
padding-top: 1rem;
37+
font-size: 1.2rem;
38+
}
2439
}
2540
.container--signup {
26-
padding: 2rem;
27-
div {
28-
width: 90vw;
29-
max-width: 20rem;
30-
.username {
31-
margin-top: 1rem;
32-
*:not(.Mui-error) {
33-
color: white;
34-
fieldset:not(.Mui-error) {
35-
border-color: white !important;
36-
}
37-
}
38-
}
39-
.error {
40-
margin-top: 0.5rem;
41-
color: $errorRed;
42-
}
43-
}
41+
padding: 2rem;
42+
.container--input {
43+
width: 90vw;
44+
max-width: 20rem;
45+
height: 15rem;
46+
.username {
47+
margin-top: 1rem;
48+
*:not(.Mui-error) {
49+
color: white;
50+
fieldset:not(.Mui-error) {
51+
border-color: white !important;
52+
}
53+
}
54+
}
55+
.error {
56+
margin-top: 0.5rem;
57+
color: $errorRed;
58+
}
59+
}
4460
}

client/src/Common/CustomNavbar.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,27 @@ import AppBar from '@mui/material/AppBar';
33
import Toolbar from '@mui/material/Toolbar';
44
import Button from '@mui/material/Button';
55
import Logo from '../Assets/images/logo.png';
6+
import { useNavigate } from 'react-router-dom';
67
export default function CustomNavbar() {
78
const { loginWithRedirect, isAuthenticated, logout, user } = useAuth0();
9+
let navigate = useNavigate();
810
return (
911
<AppBar position="static">
1012
<Toolbar className="toolbar">
1113
<div className="d-flex ai-center">
12-
<img src={Logo} alt="CodeyBot" className="logo" />
13-
<h1>Codey</h1>
14+
<div className="d-flex ai-center home" onClick={() => navigate('/')}>
15+
<img src={Logo} alt="CodeyBot" className="logo" />
16+
<h1>Codey</h1>
17+
</div>
18+
{isAuthenticated && (
19+
<Button
20+
className="link"
21+
variant="contained"
22+
onClick={() => navigate('dashboard')}
23+
>
24+
Dashboard
25+
</Button>
26+
)}
1427
</div>
1528
{isAuthenticated ? (
1629
<div className="d-flex">
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
import { Profile } from '../../utils/constants';
2+
import { useAuth0 } from '@auth0/auth0-react';
3+
import Button from '@mui/material/Button';
4+
import { generateWorkflow } from '../../ClientServer';
5+
6+
type Props = {
7+
profile: Profile;
8+
};
9+
10+
export default function Dashboard({ profile }: Props) {
11+
const { user } = useAuth0();
12+
13+
const handleGenerate = () => {
14+
generateWorkflow({ authId: user?.sub ?? '' }).then(({ data }) => {
15+
console.log(data);
16+
});
17+
};
18+
19+
return (
20+
<div className="d-flex flex-column ai-center jc-center">
21+
<h2>Hey, {profile.username}!</h2>
22+
<Button variant="contained" onClick={() => handleGenerate()}>
23+
Generate
24+
</Button>
25+
</div>
26+
);
27+
}

client/src/Common/ErrorScreen.tsx

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
export default function ErrorScreen() {
2+
return (
3+
<div className="error-screen d-flex flex-column ai-center jc-center">
4+
<h1>Oh no!</h1>
5+
<div>
6+
Looks like we messed up. If a refresh doesn't work, let us know on one
7+
of these platforms:
8+
</div>
9+
<a href="https://twitter.com/matthughes2112">Twitter</a>
10+
<a href="https://discord.gg/ugtxfRYbDf">Discord</a>
11+
</div>
12+
);
13+
}

0 commit comments

Comments
 (0)