Skip to content

Commit

Permalink
Merge pull request #56 from hcp-uw/register-loading
Browse files Browse the repository at this point in the history
logout css + loading screen for registering
  • Loading branch information
s-fristrom authored Oct 11, 2024
2 parents 190b243 + ed68ceb commit 506f768
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 4 deletions.
5 changes: 4 additions & 1 deletion starter-backend/src/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -634,4 +634,7 @@ export async function getBio(req: SafeRequest, res: SafeResponse) {
return;
}
}


export async function isUp(req: SafeRequest, res: SafeResponse) {
res.send("we're up");
}
5 changes: 4 additions & 1 deletion starter-backend/src/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ import { unknownEndpoint } from "./middleware.js";
import { getNote, getFolderContents, createAccount,
createNote, createFolder, saveDoc, saveDetails, shareDoc,
deleteDoc, getShared, deleteFolder, getFolders,
updateBio, getBio} from "./routes.js";
updateBio, getBio,
isUp} from "./routes.js";

const app = express();

Expand Down Expand Up @@ -66,6 +67,8 @@ app.put("/updateBio", updateBio);

app.get("/getBio", getBio);

app.get("/isUp", isUp);

// error handling
app.use(unknownEndpoint);

Expand Down
7 changes: 5 additions & 2 deletions starter-frontend/src/components/auth/Logout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ export default function Logout({ isModal, setIsModal }: LogoutParams) {
<div>
<div className="centText logout-popup">
<h2>Are you sure you want to log out?</h2>
<button onClick={handleLogout}>Logout</button>
<button onClick={() => setIsModal(false)}>Cancel</button>
<button className="logout-exit" onClick={() => setIsModal(false)}>X</button>
<div className="modaltxt-wrap modal-centered">
<button className="input-button" onClick={handleLogout}>Logout</button>
<button className="input-button" onClick={() => setIsModal(false)}>Cancel</button>
</div>
</div>
</div>
);
Expand Down
18 changes: 18 additions & 0 deletions starter-frontend/src/pages/auth-pages/auth.css
Original file line number Diff line number Diff line change
Expand Up @@ -116,4 +116,22 @@
top: 50%;
transform: translate(-50%, -50%);
border-radius: 10px;
}


.logout-exit {
top: 0;
right: 0;
position: absolute;
margin: 10px;
cursor: pointer;
border: 2px solid red;
background-color: var(--green);
color: red;
font-size: 20px;
}

.logout-exit:hover {
background-color: red;
color: white;
}
57 changes: 57 additions & 0 deletions starter-frontend/src/pages/auth-pages/register.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,66 @@
import React from 'react'
import RegisterForm from '../../components/auth/Register'
import { Link } from 'react-router-dom';
import { useState, useEffect } from 'react';
import { auth } from '../../config/firebase';
import { FetchRoute } from '../../components/file-navigation/routes';

/** Register page */
export default function Register(): JSX.Element {

const [isLoading, setIsLoading] = useState<boolean>(true);

useEffect(() => {
const checkServer = async(): Promise<void> => {
try {
const user = auth.currentUser;
const token = user && (await user.getIdToken());

const payloadHeader = {
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${token}`,
},
method: "GET"
};

fetch(FetchRoute+"/isUp", payloadHeader)
.then((res) => {
if (res.status === 200) {

res.json().then((val) => fetchResponse(val))
.catch(() => console.error("Error fetching /isUp: 200 response is not JSON"))
} else {
console.error(`Error fetching /isUp: bad status code ${res.status}`)
}
})
.catch(() => console.error("Error fetching /isUp: Failed to connect to server"));


} catch (e) {
console.log(e);
}
}

const fetchResponse = (val: unknown): void => {
setIsLoading(false);
}

checkServer();

}, [])

if (isLoading) {
return (
<div className="page flex green-background">
<div className="centText">
<h2 className="placeholder for title text">Register your account</h2>
<h1>Loading...</h1>
<Link to={'../login'} className="authlink">Already have an account? Login</Link>
</div>
</div>
)
}
return (
<div className="page flex green-background">
<div className="centText">
Expand Down

0 comments on commit 506f768

Please sign in to comment.