Skip to content

Commit

Permalink
Fixed Login Modals for both desktop and Mobile + added link to work s…
Browse files Browse the repository at this point in the history
…ignup for logged in users (#198)

* Have started to work on a new documents-page. I will have to figure out how to import the module to the app

* tmp

* centered the Login modal and added a link to work signup (temporarily)

* Fixed the LoginModal on mobile, ready for deploy

* Bumped version number

Co-authored-by: Sebbe <[email protected]>
  • Loading branch information
Sebbedi and Sebbe authored Jan 23, 2023
1 parent 63bf4c5 commit 444db28
Show file tree
Hide file tree
Showing 10 changed files with 126 additions and 24 deletions.
2 changes: 1 addition & 1 deletion back/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "tmeit_backend"
version = "1.0.4"
version = "1.0.5"
description = "Python backend for the TMEIT website"
authors = ["TraditionsMEsterIT"]
license = "AGPL-3.0"
Expand Down
2 changes: 1 addition & 1 deletion deploy/kubernetes/tmeit-se/postgres/set_image_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/jobTemplate/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/db-backup-agent:1.0.4"
"value": "ghcr.io/tmeit/db-backup-agent:1.0.5"
}
]
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/tmeit-run-migrations:1.0.4"
"value": "ghcr.io/tmeit/tmeit-run-migrations:1.0.5"
}
]
2 changes: 1 addition & 1 deletion deploy/kubernetes/tmeit-se/tmeit-app/set_image_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/tmeit-app:1.0.4"
"value": "ghcr.io/tmeit/tmeit-app:1.0.5"
}
]
2 changes: 1 addition & 1 deletion deploy/kubernetes/tmeit-se/tmeit-worker/set_image_tag.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
{
"op": "replace",
"path": "/spec/template/spec/containers/0/image",
"value": "ghcr.io/tmeit/tmeit-worker:1.0.4"
"value": "ghcr.io/tmeit/tmeit-worker:1.0.5"
}
]
2 changes: 1 addition & 1 deletion front/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"sideEffects": [
"*.css"
],
"version": "1.0.4",
"version": "1.0.5",
"description": "Front-end for the TMEIT website.",
"main": "index.js",
"scripts": {
Expand Down
7 changes: 5 additions & 2 deletions front/src/app/components/HeaderFooter/MobileHeaderMenu.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import {DropdownMenu} from "../DropdownMenu.js";
import {getApiFetcher} from "../../api";
import logOut from "../../login_cookie/logOut";
import MenuItem from "@mui/material/MenuItem";
import hasLoginCookie from "../../hasLoginCookie.js";


const StyledMobileHeaderMenu = styled(MobileHeaderMenu)({});

function MobileHeaderMenu({className}) {
function MobileHeaderMenu({className, loggedIn, setLoginModalOpen}) {
let navigate = useNavigate();

const [meData, setMeData] = useState(null); // Yarr, set me data (Logged-in user's member data)
Expand All @@ -28,7 +29,9 @@ function MobileHeaderMenu({className}) {
[true, (<Link to={"/events"}><MenuItem>Events</MenuItem></Link>)],
[true, (<Link to={"/team"}><MenuItem>Team</MenuItem></Link>)],
[true, (<Link to={"/about"}><MenuItem>About TMEIT</MenuItem></Link>)],
[true, (<MenuItem onClick={() => logOut(navigate)}>Log Out</MenuItem>)],
[true, (<Link to={"/join_tmeit"}><MenuItem>Join</MenuItem></Link>)],
[!loggedIn, (<MenuItem onClick={() => {setLoginModalOpen(true)}}>Log in</MenuItem>)],
[loggedIn, (<MenuItem onClick={() => logOut(navigate)}>Log Out</MenuItem>)],
]

return (
Expand Down
121 changes: 105 additions & 16 deletions front/src/app/components/LoginModal.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useState, useEffect } from "react";
import { useNavigate } from "react-router-dom";
import styled from "@emotion/styled";
import {getApiFetcher} from "../api";
import useIsScreenWide from "../useIsScreenWide";

const StyledLoginModal = styled(LoginModal)({

Expand All @@ -14,16 +15,18 @@ const StyledLoginModal = styled(LoginModal)({
left: 0,
zIndex: 10,

//Desktop/widescreen-headers
dialog: {
position: "fixed",
position: "relative",
zIndex: 20,
background: "#fff",
width: "500px",
marginTop: "10%",

/* Center the modal */
top: "50%",
left: "50%",
transform: "translateX(-50%) translateY(-50%)",
display: "flex",
flexDirection: "column",
justifyContent: "space-around",
},

".modalHeader": {
Expand All @@ -37,11 +40,6 @@ const StyledLoginModal = styled(LoginModal)({
padding: "20px",
},

form: {
display: "flex",
flexDirection: "column",
},

".closeButton": {
border: "none",
background: "transparent",
Expand All @@ -54,6 +52,46 @@ const StyledLoginModal = styled(LoginModal)({
".closeButton:hover": {
color: "yellow",
},

//Mobile/thinscreen-headers
dialogMobile: {
position: "relative",
zIndex: 20,
background: "#fff",
width: "250px",
marginTop: "10%",
marginLeft: "auto",
marginRight: "auto",

display: "flex",
flexDirection: "column",
justifyContent: "space-around",
},

".modalHeaderMobile": {
background:" #44687d",
padding: "5px 10px",
display: "flex",
justifyContent: "space-between",
},

".modalMainMobile": {
padding: "10px",
},

".closeButtonMobile": {
border: "none",
background: "transparent",
padding: "5px",
color: "#fff",
fontsize: "18px",
},

//header used on both desktop and mobil
form: {
display: "flex",
flexDirection: "column",
},
});

function LoginModal({className, loggedIn, setLoggedIn, setLoginModalOpen}) {
Expand Down Expand Up @@ -81,6 +119,7 @@ function LoginModal({className, loggedIn, setLoggedIn, setLoginModalOpen}) {
// Error message for logins
const [errorMessage, setError] = useState(0);

const ScreenIsWide = useIsScreenWide(950);

function handleLogin(e) {
e.preventDefault();
Expand Down Expand Up @@ -112,19 +151,69 @@ function LoginModal({className, loggedIn, setLoggedIn, setLoginModalOpen}) {
};
}

return (
if(ScreenIsWide) //Make a big LoginModal for desktops/wider screens
{ return (
<div className={className}>
<dialog open>
<header className="modalHeader">
<h2>Login</h2>
<button
onClick={() => setLoginModalOpen(false)}
className="closeButton"
>
&times;
</button>
</header>
<div className="modalMain">
<form onSubmit={handleLogin}>
<label htmlFor="email">Email</label>
<input
type="text"
id="email"
name="email"
value={email}
onChange={(e) => setEmail(e.target.value)}
></input>
<label htmlFor="pswrd">Password</label>
<input
type="password"
id="pswrd"
name="password"
value={pswrd}
onChange={(e) => setPswrd(e.target.value)}
></input>
<input type="submit" value="login"></input>
</form>
<div className="errorMessage">
{(() => {
switch (errorMessage) {
case 0:
return <></>;
case 1:
return <>Incorrect email or password</>;
case 2:
return <>Validation error</>;
}
})()}
</div>
</div>
</dialog>
</div>
)}
else //Make a small LoginModal for mobiles/thinner screens
{return (
<div className={className}>
<dialog open>
<header className="modalHeader">
<dialogMobile open>
<header className="modalHeaderMobile">
<h2>Login</h2>
<button
onClick={() => setLoginModalOpen(false)}
className="closeButton"
className="closeButtonMobile"
>
&times;
</button>
</header>
<div className="modalMain">
<div className="modalMainMobile">
<form onSubmit={handleLogin}>
<label htmlFor="email">Email</label>
<input
Expand Down Expand Up @@ -157,9 +246,9 @@ function LoginModal({className, loggedIn, setLoggedIn, setLoginModalOpen}) {
})()}
</div>
</div>
</dialog>
</dialogMobile>
</div>
)
)}
}

export default StyledLoginModal;
1 change: 1 addition & 0 deletions front/src/app/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ const router = createBrowserRouter([{
return await getApiFetcher().get("/members/").json();
}
},
{ path: "/documents", element: <routes.Documents.component />, loader: routes.Documents.loader},
{ path: "/join_tmeit", element: <routes.Join.component />, loader: routes.Join.loader },
{ path: "/profile/:shortUuid", element: <routes.Profile.component />, loader: routes.Profile.loader },
{ path: "/profile/:shortUuid/:name", element: <routes.Profile.component />, loader: routes.Profile.loader },
Expand Down
9 changes: 9 additions & 0 deletions front/src/app/layouts/Events.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import styled from "@emotion/styled";

import Centered from "../components/Centered.js";
import TextSummary from "../components/TextSummary.js";
import hasLoginCookie from "../hasLoginCookie.js";

const StyledEvents = styled(Events)({
[TextSummary]: {
Expand All @@ -19,6 +20,14 @@ function Events({className}) {
<p>TMEIT.SE GEN 3 is very new and we're still re-implementing the event pages.</p>
<p>Check out our <a href="https://www.facebook.com/TMEIT/events" target="_blank">Facebook events</a> in the meantime!</p>
</TextSummary>
<>{hasLoginCookie()?
<TextSummary>
<h1>Work signup</h1><p>Meanwhile the development of the events page is underway,</p>
<p>you can sign up to work on an event here: </p>
<a href="https://docs.google.com/spreadsheets/d/1XxQQKn0U0aYRtVvEvowolVkEkQn55XNmB1my1TOB3cc/edit?usp=sharing" target="_blank">Work sign-up</a>
</TextSummary>
: <></>}
</>
</Centered>
);
}
Expand Down

0 comments on commit 444db28

Please sign in to comment.